diff options
author | crupest <crupest@outlook.com> | 2021-11-20 21:25:29 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-11-20 21:25:29 +0800 |
commit | 1a53ed0791d9793ed8030d3a44e833e5e7c4542b (patch) | |
tree | 28aedaabee675b192e414489122349ad4985a31b /include/cru/ui/components | |
parent | a9da4c10459e3c45115c8a42e771b00cb1caeab7 (diff) | |
download | cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.tar.gz cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.tar.bz2 cru-1a53ed0791d9793ed8030d3a44e833e5e7c4542b.zip |
...
Diffstat (limited to 'include/cru/ui/components')
-rw-r--r-- | include/cru/ui/components/Menu.hpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/include/cru/ui/components/Menu.hpp b/include/cru/ui/components/Menu.hpp index d60d38eb..96b21173 100644 --- a/include/cru/ui/components/Menu.hpp +++ b/include/cru/ui/components/Menu.hpp @@ -4,9 +4,9 @@ #include "cru/ui/controls/Button.hpp" #include "cru/ui/controls/Control.hpp" #include "cru/ui/controls/FlexLayout.hpp" +#include "cru/ui/controls/Popup.hpp" #include "cru/ui/controls/TextBlock.hpp" -#include <string> #include <vector> namespace cru::ui::components { @@ -40,6 +40,8 @@ class Menu : public Component { ~Menu(); public: + controls::Control* GetRootControl() override { return container_; } + gsl::index GetItemCount() const { return static_cast<gsl::index>(items_.size()); } @@ -57,4 +59,29 @@ class Menu : public Component { controls::FlexLayout* container_; std::vector<Component*> items_; }; + +class PopupMenu : public Component { + public: + explicit PopupMenu(controls::Control* attached_control = nullptr); + + CRU_DELETE_COPY(PopupMenu) + CRU_DELETE_MOVE(PopupMenu) + + ~PopupMenu(); + + public: + controls::Control* GetRootControl() override; + + controls::Popup* GetPopup() { return popup_; } + Menu* GetMenu() { return menu_; } + + void SetPosition(const Point& position); + void Show(); + + private: + controls::Control* attached_control_; + + controls::Popup* popup_; + Menu* menu_; +}; } // namespace cru::ui::components |