From 34a64e6ffefaab007578932ddbab931a25f1d56e Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 15 May 2022 14:15:31 +0800 Subject: ... --- .../components/properties/PointPropertyEditor.cpp | 38 ---------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/theme_builder/components/properties/PointPropertyEditor.cpp (limited to 'src/theme_builder/components/properties/PointPropertyEditor.cpp') diff --git a/src/theme_builder/components/properties/PointPropertyEditor.cpp b/src/theme_builder/components/properties/PointPropertyEditor.cpp deleted file mode 100644 index 6d4277aa..00000000 --- a/src/theme_builder/components/properties/PointPropertyEditor.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "PointPropertyEditor.h" -#include "cru/common/Format.h" -#include "cru/ui/mapper/MapperRegistry.h" -#include "cru/ui/mapper/PointMapper.h" - -namespace cru::theme_builder::components::properties { -PointPropertyEditor::PointPropertyEditor() { - container_.AddChild(&label_); - container_.AddChild(&text_); - - text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) { - auto text = text_.GetTextView(); - auto point_mapper = - ui::mapper::MapperRegistry::GetInstance()->GetMapper(); - try { - auto point = point_mapper->MapFromString(text.ToString()); - point_ = point; - is_text_valid_ = true; - RaiseChangeEvent(); - } catch (const Exception&) { - is_text_valid_ = false; - // TODO: Show error! - } - }); -} - -PointPropertyEditor::~PointPropertyEditor() {} - -void PointPropertyEditor::SetValue(const ui::Point& point, - bool trigger_change) { - if (!trigger_change) SuppressNextChangeEvent(); - text_.SetText(ConvertPointToString(point)); -} - -String PointPropertyEditor::ConvertPointToString(const ui::Point& point) { - return Format(u"{} {}", point.x, point.y); -} -} // namespace cru::theme_builder::components::properties -- cgit v1.2.3