aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-03 22:51:04 +0800
committercrupest <crupest@outlook.com>2020-12-03 22:51:04 +0800
commit02ce593a7397f49d763c2c410a67bad46b9876a9 (patch)
tree406c0737d4f7e3367dd548fe190cb8f147ed4550 /src
parent51cc89106193cc4695507d678adab7388d940577 (diff)
downloadcru-02ce593a7397f49d763c2c410a67bad46b9876a9.tar.gz
cru-02ce593a7397f49d763c2c410a67bad46b9876a9.tar.bz2
cru-02ce593a7397f49d763c2c410a67bad46b9876a9.zip
...
Diffstat (limited to 'src')
-rw-r--r--src/ui/helper/ClickDetector.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/ui/helper/ClickDetector.cpp b/src/ui/helper/ClickDetector.cpp
index 4059f890..309685d3 100644
--- a/src/ui/helper/ClickDetector.cpp
+++ b/src/ui/helper/ClickDetector.cpp
@@ -1,6 +1,7 @@
#include "cru/ui/helper/ClickDetector.hpp"
#include "cru/common/Logger.hpp"
+#include "cru/ui/DebugFlags.hpp"
#include <optional>
@@ -44,8 +45,10 @@ ClickDetector::ClickDetector(controls::Control* control) {
if (this->enable_ && (button & this->trigger_button_) &&
this->state_ == ClickState::Hover) {
if (!this->control_->CaptureMouse()) {
- log::TagDebug(log_tag,
- u"Failed to capture mouse when begin click.");
+ if constexpr (debug_flags::click_detector) {
+ log::TagDebug(log_tag,
+ u"Failed to capture mouse when begin click.");
+ }
return;
}
this->down_point_ = args.GetPoint();
@@ -106,24 +109,24 @@ void ClickDetector::SetTriggerButton(MouseButton trigger_button) {
}
void ClickDetector::SetState(ClickState state) {
-#ifdef CRU_DEBUG
- auto to_string = [](ClickState state) -> std::u16string_view {
- switch (state) {
- case ClickState::None:
- return u"None";
- case ClickState::Hover:
- return u"Hover";
- case ClickState::Press:
- return u"Press";
- case ClickState::PressInactive:
- return u"PressInvactive";
- default:
- UnreachableCode();
- }
- };
- log::TagDebug(log_tag, u"Click state changed, new state: {}.",
- to_string(state));
-#endif
+ if constexpr (debug_flags::click_detector) {
+ auto to_string = [](ClickState state) -> std::u16string_view {
+ switch (state) {
+ case ClickState::None:
+ return u"None";
+ case ClickState::Hover:
+ return u"Hover";
+ case ClickState::Press:
+ return u"Press";
+ case ClickState::PressInactive:
+ return u"PressInvactive";
+ default:
+ UnreachableCode();
+ }
+ };
+ log::TagDebug(log_tag, u"Click state changed, new state: {}.",
+ to_string(state));
+ }
state_ = state;
state_change_event_.Raise(state);