From 32aa6f116acc6e3e20a1ec76cef45b29f7005ad7 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 17 Oct 2025 12:06:14 +0800 Subject: Remove String stage 1. --- include/cru/ui/components/Input.h | 14 +++++++------- include/cru/ui/components/Menu.h | 8 ++++---- include/cru/ui/components/PopupButton.h | 8 ++++---- include/cru/ui/components/Select.h | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) (limited to 'include/cru/ui/components') diff --git a/include/cru/ui/components/Input.h b/include/cru/ui/components/Input.h index e808afd7..0f077983 100644 --- a/include/cru/ui/components/Input.h +++ b/include/cru/ui/components/Input.h @@ -5,17 +5,17 @@ namespace cru::ui::components { struct CRU_UI_API InputValidateResult { bool valid; - String message; + std::string message; }; struct CRU_UI_API IInputValidator : public virtual Interface { - virtual InputValidateResult Validate(StringView text) const = 0; + virtual InputValidateResult Validate(std::string_view text) const = 0; }; struct CRU_UI_API InputChangeEventArgs { - String text; + std::string text; bool valid; - String message; + std::string message; }; class CRU_UI_API Input : public Component { @@ -26,8 +26,8 @@ class CRU_UI_API Input : public Component { public: controls::Control* GetRootControl() override; - String GetText() const; - void SetText(String text); + std::string GetText() const; + void SetText(std::string text); IInputValidator* GetValidator() const; void SetValidator(IInputValidator* validator); @@ -48,7 +48,7 @@ class CRU_UI_API Input : public Component { class CRU_UI_API FloatInputValidator : public Object, public virtual IInputValidator { public: - InputValidateResult Validate(StringView text) const override; + InputValidateResult Validate(std::string_view text) const override; std::optional min; std::optional max; diff --git a/include/cru/ui/components/Menu.h b/include/cru/ui/components/Menu.h index 913f5c92..554a8898 100644 --- a/include/cru/ui/components/Menu.h +++ b/include/cru/ui/components/Menu.h @@ -14,7 +14,7 @@ namespace cru::ui::components { class CRU_UI_API MenuItem : public Component { public: MenuItem(); - explicit MenuItem(String text); + explicit MenuItem(std::string text); CRU_DELETE_COPY(MenuItem) CRU_DELETE_MOVE(MenuItem) @@ -24,7 +24,7 @@ class CRU_UI_API MenuItem : public Component { public: controls::Control* GetRootControl() override { return &container_; } - void SetText(String text); + void SetText(std::string text); void SetOnClick(std::function on_click) { on_click_ = std::move(on_click); @@ -55,10 +55,10 @@ class CRU_UI_API Menu : public Component { Component* RemoveItemAt(Index index); void ClearItems(); - void AddTextItem(String text, std::function on_click) { + void AddTextItem(std::string text, std::function on_click) { AddTextItemAt(std::move(text), GetItemCount(), std::move(on_click)); } - void AddTextItemAt(String text, Index index, std::function on_click); + void AddTextItemAt(std::string text, Index index, std::function on_click); void SetOnItemClick(std::function on_item_click) { on_item_click_ = std::move(on_item_click); diff --git a/include/cru/ui/components/PopupButton.h b/include/cru/ui/components/PopupButton.h index c8ef9c50..5fa69044 100644 --- a/include/cru/ui/components/PopupButton.h +++ b/include/cru/ui/components/PopupButton.h @@ -18,14 +18,14 @@ class CRU_UI_API PopupMenuTextButton : public Component { ui::controls::Button* GetButton() { return &button_; } - String GetButtonText() { return button_text_.GetText(); } - void SetButtonText(String text) { button_text_.SetText(std::move(text)); } + std::string GetButtonText() { return button_text_.GetText(); } + void SetButtonText(std::string text) { button_text_.SetText(std::move(text)); } void SetButtonTextColor(const Color& color) { button_text_.SetTextColor(color); } - void SetMenuItems(std::vector items); + void SetMenuItems(std::vector items); IEvent* MenuItemSelectedEvent() { return &menu_item_selected_event_; } @@ -47,7 +47,7 @@ class CRU_UI_API PopupMenuIconButton : public Component { ui::controls::IconButton* GetButton() { return &button_; } - void SetMenuItems(std::vector items); + void SetMenuItems(std::vector items); IEvent* MenuItemSelectedEvent() { return &menu_item_selected_event_; } diff --git a/include/cru/ui/components/Select.h b/include/cru/ui/components/Select.h index d5ff0b43..9efe9a04 100644 --- a/include/cru/ui/components/Select.h +++ b/include/cru/ui/components/Select.h @@ -13,8 +13,8 @@ class CRU_UI_API Select : public Component { public: ui::controls::Control* GetRootControl() override { return &button_; } - std::vector GetItems() const { return items_; } - void SetItems(std::vector items); + std::vector GetItems() const { return items_; } + void SetItems(std::vector items); Index GetSelectedIndex() const { return selected_index_; } void SetSelectedIndex(Index index); @@ -23,7 +23,7 @@ class CRU_UI_API Select : public Component { private: Index selected_index_; - std::vector items_; + std::vector items_; ui::controls::Button button_; ui::controls::TextBlock button_text_; -- cgit v1.2.3