blob: d44e67281a5755db0b0f5e6debab96ce781f591f (
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
|
#pragma once
#include "../Base.h"
#include "../DeleteLater.h"
#include "cru/base/SelfResolvable.h"
namespace cru::ui::components {
/**
* \brief A component is a composition of controls.
* \remarks Component should respect children's Component::IsDeleteByParent
* value and decide whether to delete it.
*/
class CRU_UI_API Component : public Object,
public SelfResolvable<Component>,
public DeleteLaterImpl {
public:
Component() = default;
~Component() = default;
virtual controls::Control* GetRootControl() = 0;
bool IsDeleteByParent() const { return delete_by_parent_; }
void SetDeleteByParent(bool delete_by_parent) {
delete_by_parent_ = delete_by_parent;
}
void DeleteIfDeleteByParent() const {
if (delete_by_parent_) delete this;
}
protected:
void OnPrepareDelete() override;
private:
bool delete_by_parent_ = false;
};
} // namespace cru::ui::components
|