diff options
author | crupest <crupest@outlook.com> | 2022-02-15 21:34:21 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-15 21:34:21 +0800 |
commit | 24aaa8fbc5da8370506402facdb8ccaf563454e5 (patch) | |
tree | 0075bfbee729b1ccc57966bef97bda4be09cbde9 /include/cru/ui | |
parent | fa6e9a419f688df12a57199aa3b4dce10cc6fd49 (diff) | |
download | cru-24aaa8fbc5da8370506402facdb8ccaf563454e5.tar.gz cru-24aaa8fbc5da8370506402facdb8ccaf563454e5.tar.bz2 cru-24aaa8fbc5da8370506402facdb8ccaf563454e5.zip |
...
Diffstat (limited to 'include/cru/ui')
-rw-r--r-- | include/cru/ui/components/PopupButton.h | 3 | ||||
-rw-r--r-- | include/cru/ui/components/Select.h | 34 | ||||
-rw-r--r-- | include/cru/ui/helper/ClickDetector.h | 3 | ||||
-rw-r--r-- | include/cru/ui/render/LayoutRenderObject.h | 2 |
4 files changed, 40 insertions, 2 deletions
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<String> GetItems() { return items_; } + void SetItems(std::vector<String> items); + + Index GetSelectedIndex() { return selected_index_; } + void SetSelectedIndex(Index index); + + IEvent<Index>* ItemSelectedEvent() { return &item_selected_event_; } + + private: + Index selected_index_; + std::vector<String> items_; + + ui::controls::Button button_; + ui::controls::TextBlock button_text_; + PopupMenu popup_menu_; + + Event<Index> item_selected_event_; +}; +} // namespace cru::ui::components diff --git a/include/cru/ui/helper/ClickDetector.h b/include/cru/ui/helper/ClickDetector.h index 1cfb26bc..0d74b9c0 100644 --- a/include/cru/ui/helper/ClickDetector.h +++ b/include/cru/ui/helper/ClickDetector.h @@ -4,6 +4,8 @@ #include "cru/common/Event.h" namespace cru::ui::helper { +class ClickDetector; + class CRU_UI_API ClickEventArgs : Object { public: ClickEventArgs(controls::Control* sender, const Point& down_point, @@ -20,6 +22,7 @@ class CRU_UI_API ClickEventArgs : Object { controls::Control* GetSender() const { return sender_; } Point GetDownPoint() const { return down_point_; } + Point GetDownPointOfScreen() const; Point GetUpPoint() const { return up_point_; } MouseButton GetButton() const { return button_; } diff --git a/include/cru/ui/render/LayoutRenderObject.h b/include/cru/ui/render/LayoutRenderObject.h index 8fec3ada..11df0449 100644 --- a/include/cru/ui/render/LayoutRenderObject.h +++ b/include/cru/ui/render/LayoutRenderObject.h @@ -39,7 +39,7 @@ class LayoutRenderObject : public RenderObject { } void RemoveChild(Index position) { - Expects(position > 0 && position < GetChildCount()); + Expects(position >= 0 && position < GetChildCount()); children_[position].render_object->SetParent(nullptr); children_.erase(children_.begin() + position); InvalidateLayout(); |