aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/components/Menu.cpp5
-rw-r--r--src/ui/controls/Control.cpp4
-rw-r--r--src/ui/helper/ClickDetector.cpp4
-rw-r--r--src/ui/host/RoutedEventDispatch.h20
4 files changed, 9 insertions, 24 deletions
diff --git a/src/ui/components/Menu.cpp b/src/ui/components/Menu.cpp
index fa594399..65c1e810 100644
--- a/src/ui/components/Menu.cpp
+++ b/src/ui/components/Menu.cpp
@@ -79,10 +79,7 @@ void Menu::AddTextItemAt(std::string text, Index index,
PopupMenu::PopupMenu(controls::Control* attached_control)
: attached_control_(attached_control), popup_(attached_control) {
- menu_.SetOnItemClick([resolver = CreateResolver()](Index) {
- auto t = static_cast<PopupMenu*>(resolver.Resolve());
- if (t) t->popup_.GetNativeWindow()->Close();
- });
+ menu_.SetOnItemClick([this](Index) { popup_.GetNativeWindow()->Close(); });
popup_.AddChildAt(menu_.GetRootControl(), 0);
}
diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp
index 14397fa7..cf0cc11f 100644
--- a/src/ui/controls/Control.cpp
+++ b/src/ui/controls/Control.cpp
@@ -27,10 +27,6 @@ Control::Control() {
}
Control::~Control() {
- if (host::WindowHost::IsInEventHandling()) {
- std::terminate();
- }
-
in_destruction_ = true;
RemoveFromParent();
}
diff --git a/src/ui/helper/ClickDetector.cpp b/src/ui/helper/ClickDetector.cpp
index cf219db0..796c3ad4 100644
--- a/src/ui/helper/ClickDetector.cpp
+++ b/src/ui/helper/ClickDetector.cpp
@@ -77,12 +77,10 @@ ClickDetector::ClickDetector(controls::Control* control) {
button == button_) {
if (this->state_ == ClickState::Press) {
this->SetState(ClickState::Hover);
- auto resolver = this->control_->CreateResolver();
this->event_.Raise(ClickEventArgs{this->control_,
this->down_point_,
args.GetPoint(), button});
- auto c = resolver.Resolve();
- if (c) c->ReleaseMouse();
+ this->control_->ReleaseMouse();
} else if (this->state_ == ClickState::PressInactive) {
this->SetState(ClickState::None);
this->control_->ReleaseMouse();
diff --git a/src/ui/host/RoutedEventDispatch.h b/src/ui/host/RoutedEventDispatch.h
index 0729d176..6e8b4af1 100644
--- a/src/ui/host/RoutedEventDispatch.h
+++ b/src/ui/host/RoutedEventDispatch.h
@@ -1,5 +1,4 @@
#pragma once
-#include "cru/base/SelfResolvable.h"
#include "cru/base/log/Logger.h"
#include "cru/ui/DebugFlags.h"
#include "cru/ui/controls/Control.h"
@@ -43,11 +42,11 @@ void DispatchEvent(
WindowHost::EnterEventHandling();
- std::vector<ObjectResolver<controls::Control>> receive_list;
+ std::vector<controls::Control*> receive_list;
auto parent = original_sender;
while (parent != last_receiver) {
- receive_list.push_back(parent->CreateResolver());
+ receive_list.push_back(parent);
auto p = parent->GetParent();
assert(!(p == nullptr && last_receiver != nullptr));
parent = p;
@@ -60,10 +59,10 @@ void DispatchEvent(
auto i = receive_list.crbegin();
const auto end = --receive_list.crend();
for (; i != end; ++i) {
- log += i->Resolve()->GetControlType();
+ log += (*i)->GetControlType();
log += " -> ";
}
- log += i->Resolve()->GetControlType();
+ log += (*i)->GetControlType();
CRU_LOG_TAG_DEBUG("{}", log);
}
@@ -74,8 +73,7 @@ void DispatchEvent(
// tunnel
for (auto i = receive_list.crbegin(); i != receive_list.crend(); ++i) {
count++;
- auto control = i->Resolve();
- if (!control) continue;
+ auto control = *i;
EventArgs event_args(control, original_sender, std::forward<Args>(args)...);
static_cast<Event<EventArgs&>*>((control->*event_ptr)()->Tunnel())
->Raise(event_args);
@@ -92,10 +90,8 @@ void DispatchEvent(
// bubble
if (!handled) {
- for (const auto& resolver : receive_list) {
+ for (auto control : receive_list) {
count--;
- auto control = resolver.Resolve();
- if (!control) continue;
EventArgs event_args(control, original_sender,
std::forward<Args>(args)...);
static_cast<Event<EventArgs&>*>((control->*event_ptr)()->Bubble())
@@ -112,9 +108,7 @@ void DispatchEvent(
}
// direct
- for (auto resolver : receive_list) {
- auto control = resolver.Resolve();
- if (!control) continue;
+ for (auto control : receive_list) {
EventArgs event_args(control, original_sender, std::forward<Args>(args)...);
static_cast<Event<EventArgs&>*>((control->*event_ptr)()->Direct())
->Raise(event_args);