载入中...
搜索中...
未找到
Component.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "ui/UIHost.h"
6#include "ui/Widget.h"
7
8#include <memory>
9#include <string>
10
11namespace eve::ui {
12
18public:
20 virtual ~Component() = default;
21
23 virtual WidgetDesc build() = 0;
24
26 void attach(UIHostHandle host);
28 void mountAs(const std::string &hostName);
30 [[nodiscard]] UIHostHandle host() const noexcept { return host_; }
31
33 void rebuild(bool forceFull = false);
34
36 void markDirty() { dirty_ = true; }
38 bool isDirty() const { return dirty_; }
39
41 bool updateIfDirty();
42
43protected:
45 void setState() { dirty_ = true; }
46
47private:
48 UIHostHandle host_{};
49 bool dirty_ = true;
50};
51
52} // namespace eve::ui
#define EVENGINE_API_WORLD
Definition Export.h:109
UIHostHandle host
React-style UI component: implement build(), call setState / markDirty, then rebuild()....
Definition Component.h:17
bool isDirty() const
True when dirty.
Definition Component.h:38
virtual WidgetDesc build()=0
Builds .
virtual ~Component()=default
Component.
void setState()
Subclasses call after mutating local state that affects build().
Definition Component.h:45
void markDirty()
Mark dirty.
Definition Component.h:36
UIHostHandle host() const noexcept
Returns the attached host handle, or an empty handle before attach.
Definition Component.h:30
ecs::EntityHandle UIHostHandle
Definition UIHost.h:16
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:15