载入中...
搜索中...
未找到
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) {
14 if (!UIHost::resolve(h)) h = UIHost::createHost(hostName);
15 attach(h);
16 rebuild(true);
17}
18
19void Component::rebuild(bool forceFull) {
20 auto host = UIHost::resolve(host_);
21 if (!host) return;
22 WidgetDesc tree = build();
23 if (forceFull)
24 host->get().setTree(std::move(tree));
25 else
26 host->get().setTreeReconcile(std::move(tree));
27 dirty_ = false;
28}
29
31 if (!dirty_ || !UIHost::resolve(host_)) return false;
32 rebuild(false);
33 return true;
34}
35
36} // namespace eve::ui
int h
UIHostHandle host
virtual WidgetDesc build()=0
Builds .
void rebuild(bool forceFull=false)
Rebuild tree onto host (reconcile by key when possible).
Definition Component.cpp:19
void mountAs(const std::string &hostName)
Mounts as.
Definition Component.cpp:12
bool updateIfDirty()
If dirty, rebuild and clear flag. Returns true if rebuilt.
Definition Component.cpp:30
void attach(UIHostHandle host)
Attaches .
Definition Component.cpp:7
UIHostHandle host() const noexcept
Returns the attached host handle, or an empty handle before attach.
Definition Component.h:30
static UIHostHandle createHost(const std::string &name="")
Creates an ECS-owned UI host.
Definition UIHost.cpp:48
static eve::OptionalRef< UIHost > resolve(UIHostHandle handle) noexcept
Resolves a UI host handle with ECS generation checking.
Definition UIHost.cpp:61
static UIHostHandle findHost(const std::string &name)
Lookup by Meta.name across the UIHost View.
ecs::EntityHandle UIHostHandle
Definition UIHost.h:16
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:15