forked from Dynamitos/Seele
Editor: headless Vulkan graphics + entity/component InspectorView + --headless CLI
Engine (headless construction, no display / no WSI):
- Graphics/Vulkan/Graphics.{h,cpp} + Graphics/Initializer.h: a 'headless' flag
skips surface/swapchain extension negotiation and the window path so a VkDevice
can be created with a driver present but no display.
- Scene/Scene.{h,cpp}: null-guards + PScene circular-include decoupling.
- Actor/Entity.{h,cpp}: hasComponent fix (handle-space component query).
Editor:
- Editor/Window/InspectorView.{h,cpp}: Unity-style entity/component inspector on a
fixed widget pool (no runtime tree mutation) driven by a UIPass in the render
graph; owns its UI::System via UI::OSystem.
- Editor/ComponentRegistry.{h,cpp}: type-erased component catalog (handle-space only,
no entt in the editor API) that drives the inspector's component pane.
- Editor/main.cpp: --headless / --dump-entities path (headless device + scene dump,
no window) and InspectorView wiring with a live PScene on the windowed path.
Compile-verified (-fsyntax-only, -std=c++23) across all touched TUs.
This commit is contained in:
1 parent
499407d366
commit
c5c66f8cf3
12 files changed
+830
-46
No files matched your search
@@ -1,37 +1,78 @@
|
||||
#pragma once
|
||||
#include "Graphics/RenderPass/RenderGraph.h"
|
||||
#include "Graphics/RenderPass/UIPass.h"
|
||||
#include "Window/View.h"
|
||||
#include "UI/System.h"
|
||||
#include "UI/Style/Fonts.h"
|
||||
#include "Graphics/RenderPass/UIPass.h"
|
||||
#include "UI/Element.h" // UI::PElement / UI::OElement (complete, for the fixed widget pool)
|
||||
#include "Scene/Scene.h" // PScene
|
||||
|
||||
namespace Seele {
|
||||
DECLARE_REF(Actor)
|
||||
namespace Editor {
|
||||
// The editor's component inspector. Left pane lists the scene's live entities
|
||||
// (from the ComponentRegistry via Scene::getEntities); right pane shows the selected
|
||||
// entity's components as Unity-style "field: value" text, refreshed every frame.
|
||||
//
|
||||
// The UI tree is a FIXED widget pool: it is built once in the constructor and never
|
||||
// adds/removes children at runtime. Per-frame the only mutation is UI::Text::setText
|
||||
// on the pre-built widgets (the "children fixed at construction" constraint). Selection
|
||||
// state is changed exclusively through UI::Button onClick handlers (the sanctioned
|
||||
// click path) and read back in update().
|
||||
//
|
||||
// Pool handles are UI::PElement (the Element base ref). Text/Button/Div are class
|
||||
// templates (UI::Text<...>, UI::Button<...>) so they can't be named as member types;
|
||||
// we hold the base and dynamic_cast to the concrete type at the use site in refresh().
|
||||
class InspectorView : public View {
|
||||
public:
|
||||
InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo& createInfo);
|
||||
virtual ~InspectorView();
|
||||
// `scene` is the scene to inspect (non-owning; the editor owns its lifetime).
|
||||
// The roster + component data are read from it each frame via the ComponentRegistry.
|
||||
InspectorView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo& createInfo, PScene scene);
|
||||
virtual ~InspectorView() override;
|
||||
|
||||
virtual void beginUpdate() override;
|
||||
virtual void update() override;
|
||||
virtual void commitUpdate() override;
|
||||
|
||||
virtual void prepareRender() override;
|
||||
virtual void render() override;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void applyArea(URect area) override;
|
||||
UI::PSystem uiSystem;
|
||||
RenderGraph renderGraph;
|
||||
Component::Camera cam;
|
||||
|
||||
virtual void keyCallback(KeyCode code, InputAction action, KeyModifierFlags modifier) override;
|
||||
virtual void keyCallback(KeyCode code, InputAction action, uint32_t modifier) override;
|
||||
virtual void mouseMoveCallback(double xPos, double yPos) override;
|
||||
virtual void mouseButtonCallback(MouseButton button, InputAction action, KeyModifierFlags modifier) override;
|
||||
virtual void mouseButtonCallback(MouseButton button, InputAction action, uint32_t modifier) override;
|
||||
virtual void scrollCallback(double xOffset, double yOffset) override;
|
||||
virtual void fileCallback(int count, const char** paths) override;
|
||||
|
||||
private:
|
||||
// Fixed widget pools. Handles are UI::PElement (base) because Text/Button are class
|
||||
// templates. Each is safe for the life of the view: the constructed element is stored
|
||||
// in a parent Div's children array (Array<OElement>) which holds an OWNING ref; the
|
||||
// PElement here is a second (shared) ref to the same object. refresh() dynamic_casts
|
||||
// to the concrete UI::Text<Font_Arial>/UI::Button<> to call setText()/attr.
|
||||
static constexpr int kMaxEntities = 8; // entity-list rows
|
||||
static constexpr int kMaxComponentLines = 16; // component-inspector text lines
|
||||
|
||||
PScene scene;
|
||||
// The UI::System is a long-lived object with no other owner, so the view OWNS it
|
||||
// (OwningPtr, via the OSystem typedef from DEFINE_REF(System)). UIPass takes a
|
||||
// non-owning PSystem, which OSystem converts to implicitly.
|
||||
UI::OSystem uiSystem;
|
||||
RenderGraph renderGraph;
|
||||
// Direct handle to the UI render pass so the window input callbacks can be
|
||||
// forwarded to the UI system (RenderGraph exposes only resources, not passes).
|
||||
UIPass* uiPass = nullptr;
|
||||
|
||||
// Selection state: written by button onClick, read in refresh().
|
||||
int selectedEntity = -1;
|
||||
|
||||
struct EntityRow {
|
||||
UI::PElement label = nullptr; // UI::Text<Font_Arial> (cast in refresh())
|
||||
UI::PElement button = nullptr; // UI::Button<> (cast in refresh())
|
||||
};
|
||||
EntityRow entityPool[kMaxEntities];
|
||||
|
||||
UI::PElement componentHeader = nullptr;
|
||||
UI::PElement componentLines[kMaxComponentLines];
|
||||
|
||||
// Rebuild the pool text from the current scene state (called from update()).
|
||||
void refresh();
|
||||
};
|
||||
DEFINE_REF(InspectorView)
|
||||
} // namespace Editor
|
||||
|
||||
Reference in new issue
Block a user