blob: 866a8c037c4a25fa50c36246c3a605b283ef10e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#pragma once
#include "Control.h"
namespace cru::ui::controls {
template <typename TRenderObject>
class LayoutControl : public Control {
protected:
LayoutControl(std::string name) : Control(std::move(name)) {
container_render_object_.SetAttachedControl(this);
}
public:
using Control::AddChild;
using Control::InsertChildAt;
using Control::RemoveChildAt;
render::RenderObject* GetRenderObject() override {
return &container_render_object_;
}
TRenderObject* GetContainerRenderObject() {
return &container_render_object_;
}
const typename TRenderObject::ChildLayoutData& GetChildLayoutData(
Index position) {
return container_render_object_.GetChildLayoutDataAt(position);
}
void SetChildLayoutData(Index position,
typename TRenderObject::ChildLayoutData data) {
container_render_object_.SetChildLayoutDataAt(position, data);
}
protected:
void OnChildInserted(Control* control, Index index) override {
container_render_object_.AddChild(control->GetRenderObject(), index);
}
void OnChildRemoved([[maybe_unused]] Control* control, Index index) override {
container_render_object_.RemoveChild(index);
}
private:
TRenderObject container_render_object_;
};
} // namespace cru::ui::controls
|