diff options
Diffstat (limited to 'include/cru/ui')
-rw-r--r-- | include/cru/ui/components/Component.h | 11 | ||||
-rw-r--r-- | include/cru/ui/components/Menu.h | 10 |
2 files changed, 16 insertions, 5 deletions
diff --git a/include/cru/ui/components/Component.h b/include/cru/ui/components/Component.h index e889ae97..8861f30b 100644 --- a/include/cru/ui/components/Component.h +++ b/include/cru/ui/components/Component.h @@ -17,5 +17,16 @@ class CRU_UI_API Component : public Object { ~Component() = default; virtual controls::Control* GetRootControl() = 0; + + bool IsDeleteByParent() const { return delete_by_parent_; } + void SetDeleteByParent(bool delete_by_parent) { + delete_by_parent_ = delete_by_parent; + } + void DeleteIfDeleteByParent() const { + if (delete_by_parent_) delete this; + } + + private: + bool delete_by_parent_; }; } // namespace cru::ui::components diff --git a/include/cru/ui/components/Menu.h b/include/cru/ui/components/Menu.h index 99668f62..f4e54c9f 100644 --- a/include/cru/ui/components/Menu.h +++ b/include/cru/ui/components/Menu.h @@ -52,15 +52,15 @@ class CRU_UI_API Menu : public Component { return static_cast<gsl::index>(items_.size()); } - void AddItem(Component* component) { AddItem(component, GetItemCount()); } - void AddItem(Component* component, gsl::index index); - Component* RemoveItem(gsl::index index); + void AddItem(Component* component) { AddItemAt(component, GetItemCount()); } + void AddItemAt(Component* component, gsl::index index); + Component* RemoveItemAt(gsl::index index); void ClearItems(); void AddTextItem(String text, std::function<void()> on_click) { - AddTextItem(std::move(text), GetItemCount(), std::move(on_click)); + AddTextItemAt(std::move(text), GetItemCount(), std::move(on_click)); } - void AddTextItem(String text, Index index, std::function<void()> on_click); + void AddTextItemAt(String text, Index index, std::function<void()> on_click); void SetOnItemClick(std::function<void(Index)> on_item_click) { on_item_click_ = std::move(on_item_click); |