aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Format.cpp19
-rw-r--r--src/theme_builder/components/properties/ColorPropertyEditor.cpp2
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();