Skip to content
Snippets Groups Projects
Unverified Commit c2f7f771 authored by Leon Dietrich's avatar Leon Dietrich
Browse files

add: Event structure for UI

parent a9cfa782
No related branches found
No related tags found
No related merge requests found
Pipeline #
#include "event.hpp"
namespace rmrf::ui {
event::event(std::shared_ptr<ui_context> sender) {
this->event_sender = sender;
}
event::~event() {
this->event_sender = nullptr;
this->handled = false;
}
std::shared_ptr<ui_context> event::get_sender() {
return this->event_sender;
}
bool event::has_been_handled() {
return this->handled;
}
void event::set_handled() {
this->handled = true;
}
}
#pragma once
#include <memory>
#include <string>
#include "ui_context.hpp"
namespace rmrf::ui {
/**
* This class is used to share publish event updates.
*/
class event {
private:
std::shared_ptr<ui_context> event_sender;
bool handled;
public:
/**
* In order to construct an event one needs at least to specify
* the sender.
*
* @param sender The source of the event.
*/
event(std::shared_ptr<ui_context> sender);
/**
* A class implementing an event also needs to make sure that
* the special payload of the event is beeing taken care of.
*/
~event();
/**
* Use this methos in order to obtain the sender of this event.
*
* @return The sender
*/
std::shared_ptr<ui_context> get_sender();
/**
* Use this function in order to get a human readable description
* of the event.
*
* This does not need to be translated due to its purpose beeing
* debugging.
*
* @return A pointer to the description string
*/
std::shared_ptr<std::string> get_event_description();
/**
* Use this function in order to check if the event has been handled yet.
*
* @return true if the event was already dealt with or otherwise false.
*/
bool has_been_handled();
/**
* Call this function once the purpose of the event has been taken care of.
*/
void set_handled();
};
}
#pragma once
#include <memory>
#include <string>
namespace rmrf::ui {
/**
* This class is used to provide some basic infomation of
* an UI object.
*/
class ui_context {
public:
virtual ~ui_context();
/**
* Use this method in order to get a fully qualified debug name
* of the context.
*/
virtual std::shared_ptr<std::string> get_name();
};
}
......@@ -5,6 +5,8 @@
#include <shared_mutex>
#include "progress_indicator.hpp"
#include "ui_context.hpp"
#include "event.hpp"
namespace rmrf::ui {
......@@ -40,9 +42,33 @@ public:
/**
* This abstract class implements a view page.
*/
class view {
class view : ui_context {
public:
virtual void set_progress_indicator(std::shared_ptr<progress_indicator>);
/**
* This method will be called when an operation is taking place. It may add
* more indicators even when there are others still running due to multi tasking.
*
* @param progress The progress_indicator from the new running task to add
*/
virtual void add_progress_indicator(std::shared_ptr<progress_indicator> progress);
/**
* This method will be called on a regular basis when the view needs to be updated
* due to certain events.
*
* A view is required to also invoke the update methos on its clients.
*
* @param display The display to update the view on.
* @param event The event that caused the update.
* @return True if rerendering is required or otherwise false.
*/
virtual bool update(std::shared_ptr<display> display, std::shared_ptr<event> event);
/**
* This constructor shall be capable of creating the view.
*
* @param parent The parent view of this view. This may be null if there is none.
*/
virtual view(std::shared_ptr<view> parent);
virtual ~view();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment