载入中...
搜索中...
未找到
Component.cpp
浏览该文件的文档.
1#include "ui/Component.h"
2
3#include "ui/UISystem.h"
4
5namespace eve::ui {
6
8 host_ = host;
9 dirty_ = true;
10}
11
12void Component::mountAs(const std::string &hostName) {
13 UIHost *h = UISystem::findHost(hostName);
14 if (!h) h = UIHost::createHost(hostName);
15 attach(h);
16 rebuild(true);
17}
18
19void Component::rebuild(bool forceFull) {
20 if (!host_) return;
21 WidgetDesc tree = build();
22 if (forceFull) host_->setTree(std::move(tree));
23 else host_->setTreeReconcile(std::move(tree));
24 dirty_ = false;
25}
26
28 if (!dirty_ || !host_) return false;
29 rebuild(false);
30 return true;
31}
32
33} // namespace eve::ui
int h
UIHost * host() const
Definition Component.h:23
virtual WidgetDesc build()=0
void rebuild(bool forceFull=false)
Rebuild tree onto host (reconcile by key when possible).
Definition Component.cpp:19
void attach(UIHost *host)
Definition Component.cpp:7
void mountAs(const std::string &hostName)
Definition Component.cpp:12
bool updateIfDirty()
If dirty, rebuild and clear flag. Returns true if rebuilt.
Definition Component.cpp:27
ECS mount point for one UI panel/screen. Subclass to attach UI to game entities, e....
Definition UIHost.h:130
bool setTreeReconcile(WidgetDesc root)
Key-aware patch when structure matches; else full replace.
Definition UIHost.cpp:28
static UIHost * createHost(const std::string &name="")
Definition UIHost.cpp:11
void setTree(WidgetDesc root)
Full replace.
Definition UIHost.cpp:26
static UIHost * findHost(const std::string &name)
Lookup by Meta.name across the UIHost View.
Definition UISystem.cpp:561
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:13