载入中...
搜索中...
未找到
Inspector.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4#include "common/Runtime.h"
6#include "ui/PropertyView.h"
7#include "ui/Widget.h"
8
9#include <simplesquirrel/simplesquirrel.hpp>
10
11#include <functional>
12#include <memory>
13#include <string>
14#include <vector>
15
16namespace eve::ui {
17
18class UIHost;
19
44public:
46 Inspector() = default;
48 ~Inspector();
49 Inspector(const Inspector&) = delete;
50 Inspector& operator=(const Inspector&) = delete;
51
53 void refresh();
55 void open();
57 void close();
59 bool isOpen() const;
61 [[nodiscard]] UIHostHandle host() const noexcept { return host_; }
62
64 bool selectClass(const std::string& name);
71 bool inspectObject(const ssq::Object& object);
73 const std::string& selectedClass() const { return selectedClass_; }
75 bool addInstance();
81 void setPickScene(std::function<ssq::Object()> pickScene);
83 bool selectInstance(int index);
85 void openNested(const std::string& className, const ssq::Object& object);
87 void back();
89 int instanceCount() const { return int(instances_.size()); }
91 int selectedIndex() const { return selectedInstance_; }
93 ssq::Object selectedInstance() const {
94 return (selectedInstance_ >= 0 &&
96 size_t(selectedInstance_) < instances_.size())
97 ? instances_[size_t(selectedInstance_)].object
99 : ssq::Object();
100 }
101
103 void sync();
105 WidgetDesc build();
106
107private:
108 struct InstanceEntry {
109 std::string label;
110 ssq::Object object;
111 };
112 struct NestedEntry {
113 std::string className;
114 ssq::Object object;
115 };
116
125 Runtime* runtime() const;
134 const ssq::Object* currentInstance() const;
135 int currentClassIndex() const;
136 void rebuildPropertyModel();
137 void rebuildHost();
138 PropertyViewOptions propertyViewOptions();
139 WidgetDesc propertyWidget(const std::string& ownerClass,
140 const ReflectedMember& member,
141 const ReflectedValue& value,
142 const ssq::Object& instance);
143
144 std::vector<std::string> classNames_;
145 std::string selectedClass_;
146 std::vector<InstanceEntry> instances_;
147 std::vector<NestedEntry> navStack_;
148 std::function<ssq::Object()> pickScene_;
149 int selectedInstance_ = -1;
150 UIHostHandle host_{};
151 std::unique_ptr<property_access::ReflectedPropertyModel> propertyModel_;
152};
153
154} // namespace eve::ui
double value
std::string label
#define EVENGINE_API_WORLD
Definition Export.h:109
std::string name
Json object
float(ui::Theme::* member)[4]
uint32_t index
Reflection-driven property inspector (DevTools phase C, MVVM).
Definition Inspector.h:43
Inspector()=default
Inspector.
Inspector & operator=(const Inspector &)=delete
UIHostHandle host() const noexcept
Returns the mounted inspector host handle, or an empty handle until open().
Definition Inspector.h:61
int selectedIndex() const
Index of the selected instance; -1 when none.
Definition Inspector.h:91
ssq::Object selectedInstance() const
Live script object of the selected instance (empty when none).
Definition Inspector.h:93
Inspector(const Inspector &)=delete
const std::string & selectedClass() const
Name of the currently selected class ("" when none).
Definition Inspector.h:73
int instanceCount() const
Number of live instances of the selected class.
Definition Inspector.h:89
ecs::EntityHandle UIHostHandle
Definition UIHost.h:16
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:15