aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/components/Menu.cpp19
-rw-r--r--src/ui/components/Select.cpp2
-rw-r--r--src/ui/render/FlexLayoutRenderObject.cpp7
3 files changed, 16 insertions, 12 deletions
diff --git a/src/ui/components/Menu.cpp b/src/ui/components/Menu.cpp
index ea1afc07..9170c6d2 100644
--- a/src/ui/components/Menu.cpp
+++ b/src/ui/components/Menu.cpp
@@ -8,22 +8,22 @@
#include "cru/ui/controls/TextBlock.h"
#include "cru/ui/controls/Window.h"
#include "cru/ui/helper/ClickDetector.h"
-#include "cru/ui/style/StyleRuleSet.h"
namespace cru::ui::components {
MenuItem::MenuItem() {
container_.SetChild(&text_);
container_.GetStyleRuleSet()->SetParent(
ThemeManager::GetInstance()->GetResourceStyleRuleSet("menuitem.style"));
- container_.ClickEvent()->AddHandler([this](const helper::ClickEventArgs&) {
- if (this->on_click_) this->on_click_();
- });
}
MenuItem::MenuItem(std::string text) : MenuItem() { SetText(std::move(text)); }
void MenuItem::SetText(std::string text) { text_.SetText(std::move(text)); }
+IEvent<const helper::ClickEventArgs&>* MenuItem::ClickEvent() {
+ return container_.ClickEvent();
+}
+
Menu::Menu() {
container_.SetFlexDirection(controls::FlexDirection::Vertical);
container_.SetItemCrossAlign(controls::FlexCrossAlignment::Stretch);
@@ -66,11 +66,12 @@ void Menu::ClearItems() {
void Menu::AddTextItemAt(std::string text, Index index,
std::function<void()> on_click) {
MenuItem* item = new MenuItem(std::move(text));
- item->SetOnClick([this, index, on_click = std::move(on_click)] {
- auto on_item_click = on_item_click_;
- on_click();
- if (on_item_click) on_item_click(index);
- });
+ item->ClickEvent()->AddSpyOnlyHandler(
+ [this, index, on_click = std::move(on_click)] {
+ auto on_item_click = on_item_click_;
+ on_click();
+ if (on_item_click) on_item_click(index);
+ });
item->SetDeleteByParent(true);
AddItemAt(item, index);
}
diff --git a/src/ui/components/Select.cpp b/src/ui/components/Select.cpp
index 5dbb727c..da81017f 100644
--- a/src/ui/components/Select.cpp
+++ b/src/ui/components/Select.cpp
@@ -11,6 +11,8 @@ Select::Select() {
left_bottom);
popup_menu_.Show();
});
+
+ popup_menu_.GetPopup()->SetAttachedControl(&button_);
}
Select::~Select() {}
diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp
index 4c7762e3..f4936f15 100644
--- a/src/ui/render/FlexLayoutRenderObject.cpp
+++ b/src/ui/render/FlexLayoutRenderObject.cpp
@@ -299,9 +299,10 @@ Size FlexLayoutMeasureContentImpl(
if (max_main_length.IsSpecified() &&
total_length > max_main_length.GetLengthOrUndefined()) {
- CruLogWarn(
- kLogTag,
- "(Measure) Children's main axis length exceeds required max length.");
+ CruLogWarn(kLogTag,
+ "(Measure) Children's main axis length {} exceeds required max "
+ "length {}.",
+ total_length, max_main_length.GetLengthOrUndefined());
total_length = max_main_length.GetLengthOrUndefined();
} else if (min_main_length.IsSpecified() &&
total_length < min_main_length.GetLengthOrUndefined()) {