diff options
author | crupest <crupest@outlook.com> | 2022-02-26 20:33:02 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-26 20:33:02 +0800 |
commit | 8da596f7b5fdbcf11fbda4aa66efc87a219f58ae (patch) | |
tree | d229a293f4cc424f23648c1f22de2cf268814870 /src | |
parent | 673f1939beb1b477a23d9641a07a2e05fff903b4 (diff) | |
download | cru-8da596f7b5fdbcf11fbda4aa66efc87a219f58ae.tar.gz cru-8da596f7b5fdbcf11fbda4aa66efc87a219f58ae.tar.bz2 cru-8da596f7b5fdbcf11fbda4aa66efc87a219f58ae.zip |
...
Diffstat (limited to 'src')
-rw-r--r-- | src/common/Format.cpp | 19 | ||||
-rw-r--r-- | src/theme_builder/components/properties/ColorPropertyEditor.cpp | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/common/Format.cpp b/src/common/Format.cpp index d58c90b7..0ae744fc 100644 --- a/src/common/Format.cpp +++ b/src/common/Format.cpp @@ -1,6 +1,25 @@ #include "cru/common/Format.h" +#include <double-conversion/utils.h> namespace cru { + +double_conversion::DoubleToStringConverter kDefaultDoubleToStringConverter( + 0, "infinity", "nan", 'e', -6, 21, 6, 1); + +String ToString(float value, StringView option) { + char buffer[50]; + double_conversion::StringBuilder string_builder(buffer, sizeof(buffer)); + kDefaultDoubleToStringConverter.ToShortestSingle(value, &string_builder); + return String::FromUtf8(std::string_view(buffer, string_builder.position())); +} + +String ToString(double value, StringView option) { + char buffer[50]; + double_conversion::StringBuilder string_builder(buffer, sizeof(buffer)); + kDefaultDoubleToStringConverter.ToShortestSingle(value, &string_builder); + return String::FromUtf8(std::string_view(buffer, string_builder.position())); +} + namespace details { FormatToken ParsePlaceHolder(String place_holder_string) { if (place_holder_string.empty()) { diff --git a/src/theme_builder/components/properties/ColorPropertyEditor.cpp b/src/theme_builder/components/properties/ColorPropertyEditor.cpp index 89b145a7..e9e486ac 100644 --- a/src/theme_builder/components/properties/ColorPropertyEditor.cpp +++ b/src/theme_builder/components/properties/ColorPropertyEditor.cpp @@ -19,7 +19,9 @@ ColorPropertyEditor::ColorPropertyEditor() { ->CreateSolidColorBrush(color_); color_cube_.SetForegroundBrush(color_cube_brush_); + color_text_.SetText(color_.ToString()); + color_text_.SetMargin(ui::Thickness(10, 0, 0, 0)); color_text_.TextChangeEvent()->AddHandler([this](std::nullptr_t) { auto text = color_text_.GetTextView(); |