From 24aaa8fbc5da8370506402facdb8ccaf563454e5 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 15 Feb 2022 21:34:21 +0800 Subject: ... --- include/cru/ui/components/PopupButton.h | 3 ++- include/cru/ui/components/Select.h | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 include/cru/ui/components/Select.h (limited to 'include/cru/ui/components') diff --git a/include/cru/ui/components/PopupButton.h b/include/cru/ui/components/PopupButton.h index f8c545bf..38109fbe 100644 --- a/include/cru/ui/components/PopupButton.h +++ b/include/cru/ui/components/PopupButton.h @@ -1,12 +1,13 @@ #pragma once #include "Component.h" +#include "cru/ui/Base.h" #include "cru/ui/components/Menu.h" #include "cru/ui/controls/Button.h" #include "cru/ui/controls/Popup.h" #include "cru/ui/controls/TextBlock.h" namespace cru::ui::components { -class PopupMenuTextButton : public Component { +class CRU_UI_API PopupMenuTextButton : public Component { public: PopupMenuTextButton(); ~PopupMenuTextButton() override; diff --git a/include/cru/ui/components/Select.h b/include/cru/ui/components/Select.h new file mode 100644 index 00000000..cc658092 --- /dev/null +++ b/include/cru/ui/components/Select.h @@ -0,0 +1,34 @@ +#pragma once +#include "Component.h" +#include "Menu.h" +#include "cru/ui/controls/Button.h" +#include "cru/ui/controls/TextBlock.h" + +namespace cru::ui::components { +class CRU_UI_API Select : public Component { + public: + Select(); + ~Select() override; + + public: + ui::controls::Control* GetRootControl() override { return &button_; } + + std::vector GetItems() { return items_; } + void SetItems(std::vector items); + + Index GetSelectedIndex() { return selected_index_; } + void SetSelectedIndex(Index index); + + IEvent* ItemSelectedEvent() { return &item_selected_event_; } + + private: + Index selected_index_; + std::vector items_; + + ui::controls::Button button_; + ui::controls::TextBlock button_text_; + PopupMenu popup_menu_; + + Event item_selected_event_; +}; +} // namespace cru::ui::components -- cgit v1.2.3