aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/ContentControl.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-11-08 17:45:41 +0800
committercrupest <crupest@outlook.com>2020-11-08 17:45:41 +0800
commit2188845a7acffa653015a1000139ec0a9a3984bc (patch)
tree7e8ed6eca5868a0943af6fcad6467115f369987c /src/ui/controls/ContentControl.cpp
parent93265251d56c91b05f160423077ce95339786f87 (diff)
downloadcru-2188845a7acffa653015a1000139ec0a9a3984bc.tar.gz
cru-2188845a7acffa653015a1000139ec0a9a3984bc.tar.bz2
cru-2188845a7acffa653015a1000139ec0a9a3984bc.zip
...
Diffstat (limited to 'src/ui/controls/ContentControl.cpp')
-rw-r--r--src/ui/controls/ContentControl.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ui/controls/ContentControl.cpp b/src/ui/controls/ContentControl.cpp
new file mode 100644
index 00000000..653882c0
--- /dev/null
+++ b/src/ui/controls/ContentControl.cpp
@@ -0,0 +1,25 @@
+#include "cru/ui/controls/ContentControl.hpp"
+
+namespace cru::ui::controls {
+Control* ContentControl::GetChild() const {
+ if (GetChildren().empty()) return nullptr;
+ return GetChildren()[0];
+}
+
+void ContentControl::SetChild(Control* child) {
+ Control* old_child = nullptr;
+ if (!GetChildren().empty()) {
+ old_child = GetChildren()[0];
+ this->RemoveChild(0);
+ }
+ if (child) {
+ this->AddChild(child, 0);
+ }
+ OnChildChanged(old_child, child);
+}
+
+void ContentControl::OnChildChanged(Control* old_child, Control* new_child) {
+ CRU_UNUSED(old_child)
+ CRU_UNUSED(new_child)
+}
+} // namespace cru::ui::controls