载入中...
搜索中...
未找到
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 {
12namespace detail {
13struct ComponentSchedule;
19} // namespace detail
20
26public:
28 Component();
29 Component(const Component &) = delete;
30 Component &operator=(const Component &) = delete;
31 Component(Component &&) = delete;
34 virtual ~Component();
35
37 virtual WidgetDesc build() = 0;
38
40 void attach(UIHostHandle host);
42 void mountAs(const std::string &hostName);
44 [[nodiscard]] UIHostHandle host() const noexcept { return host_; }
45
49 void rebuild(bool forceFull = false);
50
54 void markDirty();
56 bool isDirty() const { return dirty_; }
57
61 bool updateIfDirty();
62
63protected:
65 void setState() { markDirty(); }
66
67private:
68 UIHostHandle host_{};
69 bool dirty_ = true;
70 bool building_ = false;
71 std::shared_ptr<detail::ComponentSchedule> schedule_;
72};
73
74} // namespace eve::ui
#define EVENGINE_API_WORLD
Definition Export.h:109
int detail
UIHostHandle host
React-style UI component: implement build(); setState / markDirty schedules one update before UI rend...
Definition Component.h:25
bool isDirty() const
True when dirty.
Definition Component.h:56
virtual WidgetDesc build()=0
Builds .
void setState()
Subclasses call after mutating local state that affects build().
Definition Component.h:65
Component & operator=(const Component &)=delete
Component & operator=(Component &&)=delete
Component(Component &&)=delete
Component(const Component &)=delete
UIHostHandle host() const noexcept
Returns the attached host handle, or an empty handle before attach.
Definition Component.h:44
void flushPendingComponents()
Flush one batch of live dirty components before host traversal. @thread Owner thread; newly queued ed...
Definition Component.cpp:18
ecs::EntityHandle UIHostHandle
Definition UIHost.h:20
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:15