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

add: new child event

parent bb810b18
No related branches found
No related tags found
No related merge requests found
Pipeline #
#pragma once
#include <memory>
#include <string>
#include "ui/event.hpp"
namespace rmrf::ui {
class new_child_event : event {
};
}
#include <memory>
#include "ui/view.hpp" #include "ui/view.hpp"
#include "ui/new_child_event.hpp"
namespace rmrf::ui { namespace rmrf::ui {
view::view(std::shared_ptr<view> parent) { view::view(std::shared_ptr<view> parent) : parent_view{parent} {
this->parent = parent; if(this->parent_view != nullptr) {
std::shared_ptr<new_child_event> child_event(new new_child_event(this));
this->parent_view->schedule_update(child_event);
delete child_event;
}
} }
std::shared_ptr<view> view::get_parent() { std::shared_ptr<view> view::get_parent() {
return this->parent; return this->parent_view;
} }
} }
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
*/ */
class view : ui_context { class view : ui_context {
private: private:
std::shared_ptr<view> parent; std::shared_ptr<view> parent_view;
public: public:
/** /**
* This method will be called when an operation is taking place. It may add * This method will be called when an operation is taking place. It may add
...@@ -65,6 +65,13 @@ public: ...@@ -65,6 +65,13 @@ public:
* @return True if rerendering is required or otherwise false. * @return True if rerendering is required or otherwise false.
*/ */
virtual bool update(std::shared_ptr<display> display, std::shared_ptr<event> event); virtual bool update(std::shared_ptr<display> display, std::shared_ptr<event> event);
/**
* This method gets called when events need to be processed that do not
* necessarily come from the UI thread.
*
* @param event The event that caused the update.
*/
virtual void schedule_update(std::shared_ptr<event> event);
/** /**
* Use this method in order to retrieve the parent of this view. * Use this method in order to retrieve the parent of this view.
* @warn Keep in mind that this might be null. * @warn Keep in mind that this might be null.
......
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