diff options
author | crupest <crupest@outlook.com> | 2022-03-09 23:18:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-03-09 23:18:31 +0800 |
commit | 268bec4cd0d562394c2c27d10a26be1264bc8648 (patch) | |
tree | b8398c35e3b51aa3b91c75612bb46da0a0f2845f /src/theme_builder/components/properties/FontPropertyEditor.cpp | |
parent | dceef749139061fdac4946df77219f1cc8aa6483 (diff) | |
download | cru-268bec4cd0d562394c2c27d10a26be1264bc8648.tar.gz cru-268bec4cd0d562394c2c27d10a26be1264bc8648.tar.bz2 cru-268bec4cd0d562394c2c27d10a26be1264bc8648.zip |
...
Diffstat (limited to 'src/theme_builder/components/properties/FontPropertyEditor.cpp')
-rw-r--r-- | src/theme_builder/components/properties/FontPropertyEditor.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/theme_builder/components/properties/FontPropertyEditor.cpp b/src/theme_builder/components/properties/FontPropertyEditor.cpp new file mode 100644 index 00000000..b4f5fa06 --- /dev/null +++ b/src/theme_builder/components/properties/FontPropertyEditor.cpp @@ -0,0 +1,49 @@ +#include "FontPropertyEditor.h" +#include "cru/platform/graphics/Factory.h" +#include "cru/platform/graphics/Font.h" +#include "cru/platform/gui/UiApplication.h" +#include "cru/ui/controls/FlexLayout.h" +#include "cru/ui/render/FlexLayoutRenderObject.h" + +namespace cru::theme_builder::components::properties { +using namespace cru::ui::controls; + +FontPropertyEditor::FontPropertyEditor() { + main_container_.SetFlexDirection(FlexDirection::Horizontal); + main_container_.AddChild(&label_); + main_container_.AddChild(&right_container_); + + right_container_.SetFlexDirection(FlexDirection::Vertical); + right_container_.AddChild(&font_family_container_); + right_container_.AddChild(&font_size_container_); + + font_family_container_.SetFlexDirection(FlexDirection::Horizontal); + font_family_container_.AddChild(&font_family_label_); + font_family_container_.AddChild(&font_family_text_); + font_family_label_.SetText(u"Font Family"); + + font_size_container_.SetFlexDirection(FlexDirection::Horizontal); + font_size_container_.AddChild(&font_size_label_); + font_size_container_.AddChild(&font_size_text_); + font_size_label_.SetText(u"Font Size"); + + font_family_text_.TextChangeEvent()->AddSpyOnlyHandler( + [this] { RaiseChangeEvent(); }); + + font_size_text_.TextChangeEvent()->AddSpyOnlyHandler( + [this] { RaiseChangeEvent(); }); +} + +FontPropertyEditor::~FontPropertyEditor() {} + +Control* FontPropertyEditor::GetRootControl() { return &main_container_; } + +std::shared_ptr<platform::graphics::IFont> FontPropertyEditor::GetValue() + const { + return platform::gui::IUiApplication::GetInstance() + ->GetGraphicsFactory() + ->CreateFont(font_family_text_.GetText(), + font_size_text_.GetText().ParseToFloat()); +} + +} // namespace cru::theme_builder::components::properties |