aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/components
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-17 12:54:55 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-17 12:54:55 +0800
commit0f8f98b9005803ab154b43dcad0db1f292072a4d (patch)
tree0a43d5a9c4e3b747ad955fc30a143aa07ab5888d /include/cru/ui/components
parentb68f9f52a3ecdd8e379dd60ac1c1366e76695464 (diff)
downloadcru-0f8f98b9005803ab154b43dcad0db1f292072a4d.tar.gz
cru-0f8f98b9005803ab154b43dcad0db1f292072a4d.tar.bz2
cru-0f8f98b9005803ab154b43dcad0db1f292072a4d.zip
Refactor window host.
Diffstat (limited to 'include/cru/ui/components')
-rw-r--r--include/cru/ui/components/Component.h6
-rw-r--r--include/cru/ui/components/Menu.h31
-rw-r--r--include/cru/ui/components/PopupButton.h1
3 files changed, 9 insertions, 29 deletions
diff --git a/include/cru/ui/components/Component.h b/include/cru/ui/components/Component.h
index 6d31ae79..d8966a89 100644
--- a/include/cru/ui/components/Component.h
+++ b/include/cru/ui/components/Component.h
@@ -10,9 +10,6 @@ namespace cru::ui::components {
*/
class CRU_UI_API Component : public Object, public DeleteLaterImpl {
public:
- Component() = default;
- ~Component() = default;
-
virtual controls::Control* GetRootControl() = 0;
bool IsDeleteByParent() const { return delete_by_parent_; }
@@ -21,9 +18,6 @@ class CRU_UI_API Component : public Object, public DeleteLaterImpl {
}
void DeleteIfDeleteByParent(bool delete_later = true);
- protected:
- void OnPrepareDelete() override;
-
private:
bool delete_by_parent_ = false;
};
diff --git a/include/cru/ui/components/Menu.h b/include/cru/ui/components/Menu.h
index 554a8898..92731f2e 100644
--- a/include/cru/ui/components/Menu.h
+++ b/include/cru/ui/components/Menu.h
@@ -1,11 +1,10 @@
#pragma once
+#include "../controls/Button.h"
+#include "../controls/Control.h"
+#include "../controls/FlexLayout.h"
+#include "../controls/TextBlock.h"
+#include "../controls/Window.h"
#include "Component.h"
-#include "cru/base/Base.h"
-#include "cru/ui/controls/Button.h"
-#include "cru/ui/controls/Control.h"
-#include "cru/ui/controls/FlexLayout.h"
-#include "cru/ui/controls/Popup.h"
-#include "cru/ui/controls/TextBlock.h"
#include <functional>
#include <vector>
@@ -16,11 +15,6 @@ class CRU_UI_API MenuItem : public Component {
MenuItem();
explicit MenuItem(std::string text);
- CRU_DELETE_COPY(MenuItem)
- CRU_DELETE_MOVE(MenuItem)
-
- ~MenuItem();
-
public:
controls::Control* GetRootControl() override { return &container_; }
@@ -39,10 +33,6 @@ class CRU_UI_API MenuItem : public Component {
class CRU_UI_API Menu : public Component {
public:
Menu();
-
- CRU_DELETE_COPY(Menu)
- CRU_DELETE_MOVE(Menu)
-
~Menu();
public:
@@ -58,7 +48,8 @@ class CRU_UI_API Menu : public Component {
void AddTextItem(std::string text, std::function<void()> on_click) {
AddTextItemAt(std::move(text), GetItemCount(), std::move(on_click));
}
- void AddTextItemAt(std::string text, Index index, std::function<void()> on_click);
+ void AddTextItemAt(std::string text, Index index,
+ std::function<void()> on_click);
void SetOnItemClick(std::function<void(Index)> on_item_click) {
on_item_click_ = std::move(on_item_click);
@@ -74,16 +65,12 @@ class CRU_UI_API Menu : public Component {
class CRU_UI_API PopupMenu : public Component {
public:
explicit PopupMenu(controls::Control* attached_control = nullptr);
-
- CRU_DELETE_COPY(PopupMenu)
- CRU_DELETE_MOVE(PopupMenu)
-
~PopupMenu();
public:
controls::Control* GetRootControl() override;
- controls::Popup* GetPopup() { return &popup_; }
+ controls::Window* GetPopup() { return popup_; }
Menu* GetMenu() { return &menu_; }
// position relative to screen left top.
@@ -99,7 +86,7 @@ class CRU_UI_API PopupMenu : public Component {
private:
controls::Control* attached_control_;
- controls::Popup popup_;
+ controls::Window* popup_;
Menu menu_;
};
} // namespace cru::ui::components
diff --git a/include/cru/ui/components/PopupButton.h b/include/cru/ui/components/PopupButton.h
index 5fa69044..0e3d5314 100644
--- a/include/cru/ui/components/PopupButton.h
+++ b/include/cru/ui/components/PopupButton.h
@@ -4,7 +4,6 @@
#include "cru/ui/components/Menu.h"
#include "cru/ui/controls/Button.h"
#include "cru/ui/controls/IconButton.h"
-#include "cru/ui/controls/Popup.h"
#include "cru/ui/controls/TextBlock.h"
namespace cru::ui::components {