diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/base/String.h | 13 | ||||
-rw-r--r-- | include/cru/platform/GraphicsBase.h | 4 | ||||
-rw-r--r-- | include/cru/platform/gui/UiApplication.h | 5 | ||||
-rw-r--r-- | include/cru/ui/controls/TextBlock.h | 13 |
4 files changed, 16 insertions, 19 deletions
diff --git a/include/cru/base/String.h b/include/cru/base/String.h index e58f21d3..7d462a6e 100644 --- a/include/cru/base/String.h +++ b/include/cru/base/String.h @@ -65,7 +65,7 @@ class CRU_BASE_API String { #endif public: - String() = default; + String(); String(const_pointer str); String(const_pointer str, size_type size); @@ -75,7 +75,7 @@ class CRU_BASE_API String { : String(reinterpret_cast<const_pointer>(str), size - 1) {} template <typename Iter> - String(Iter start, Iter end) { + String(Iter start, Iter end): String() { for (; start != end; start++) { append(*start); } @@ -250,12 +250,9 @@ class CRU_BASE_API String { } private: - static char16_t kEmptyBuffer[1]; - - private: - char16_t* buffer_ = kEmptyBuffer; - Index size_ = 0; // not including trailing '\0' - Index capacity_ = 0; // always 1 smaller than real buffer size + char16_t* buffer_; + Index size_; // not including trailing '\0' + Index capacity_; // always 1 smaller than real buffer size }; CRU_BASE_API std::ostream& operator<<(std::ostream& os, const String& value); diff --git a/include/cru/platform/GraphicsBase.h b/include/cru/platform/GraphicsBase.h index c9f7626c..b0f653ef 100644 --- a/include/cru/platform/GraphicsBase.h +++ b/include/cru/platform/GraphicsBase.h @@ -53,8 +53,8 @@ inline String ToString(const Point& point) { } struct Size final { - static const Size kMax; - static const Size kZero; + static CRU_PLATFORM_API const Size kMax; + static CRU_PLATFORM_API const Size kZero; constexpr Size() = default; constexpr Size(const float width, const float height) diff --git a/include/cru/platform/gui/UiApplication.h b/include/cru/platform/gui/UiApplication.h index 3f36c26c..b44a450f 100644 --- a/include/cru/platform/gui/UiApplication.h +++ b/include/cru/platform/gui/UiApplication.h @@ -15,10 +15,7 @@ namespace cru::platform::gui { // The entry point of a ui application. struct CRU_PLATFORM_GUI_API IUiApplication : public virtual IPlatformResource { public: - static IUiApplication* GetInstance() { return instance; } - - private: - static IUiApplication* instance; + static IUiApplication* GetInstance(); protected: IUiApplication(); diff --git a/include/cru/ui/controls/TextBlock.h b/include/cru/ui/controls/TextBlock.h index ad44ad2d..52e227eb 100644 --- a/include/cru/ui/controls/TextBlock.h +++ b/include/cru/ui/controls/TextBlock.h @@ -16,6 +16,14 @@ class CRU_UI_API TextBlock : public NoChildControl, public: static constexpr StringView kControlType = u"TextBlock"; + static std::unique_ptr<TextBlock> Create(String text, + bool selectable = false) { + auto c = std::make_unique<TextBlock>(); + c->SetText(std::move(text)); + c->SetSelectable(selectable); + return std::move(c); + } + public: TextBlock(); TextBlock(const TextBlock& other) = delete; @@ -24,11 +32,6 @@ class CRU_UI_API TextBlock : public NoChildControl, TextBlock& operator=(TextBlock&& other) = delete; ~TextBlock() override; - TextBlock(String text, bool selectable = false) : TextBlock() { - SetText(std::move(text)); - SetSelectable(selectable); - } - String GetControlType() const final { return kControlType.ToString(); } render::RenderObject* GetRenderObject() const override; |