A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
style: Update HierarchyPanel and InspectorPanel to VS Code dark theme
esengined2cdc6873e12
diff --git a/src/esengine/editor/panels/HierarchyPanel.cpp b/src/esengine/editor/panels/HierarchyPanel.cppindex cad1f4d6f..c335c9d82 100644--- a/src/esengine/editor/panels/HierarchyPanel.cpp+++ b/src/esengine/editor/panels/HierarchyPanel.cpp@@ -14,7 +14,10 @@#include "../../ecs/components/Hierarchy.hpp"#include "../../core/Log.hpp"#include "../../events/Sink.hpp"+#include "../../ui/layout/StackLayout.hpp"+#include <algorithm>+#include <cctype>#include <sstream>namespace esengine::editor {@@ -32,14 +35,7 @@ HierarchyPanel::HierarchyPanel(ecs::Registry& registry, EntitySelection& selectisetClosable(false);setMinSize(glm::vec2(200.0f, 200.0f));- // Create tree view- auto treeView = makeUnique<ui::TreeView>(ui::WidgetId("hierarchy_tree"));- treeView->setMultiSelect(false);- treeView->setRowHeight(22.0f);- treeView->setIndentSize(16.0f);-- treeView_ = treeView.get();- setContent(std::move(treeView));+ buildUI();// Connect tree view signals using sink helpernodeSelectedConnection_ = sink(treeView_->onNodeSelected).connect(@@ -50,6 +46,10 @@ HierarchyPanel::HierarchyPanel(ecs::Registry& registry, EntitySelection& selecti[this](ui::TreeNodeId nodeId) { onNodeDoubleClicked(nodeId); });+ searchChangedConnection_ = sink(searchField_->onTextChanged).connect(+ [this](const std::string& text) { onSearchTextChanged(text); }+ );+// Connect selection change eventsu32 listenerId = selection_.addListener([this](const std::vector<Entity>& prev, const std::vector<Entity>& curr) {@@ -68,6 +68,66 @@ HierarchyPanel::~HierarchyPanel() {// Connections are automatically cleaned up by Connection RAII}+// =============================================================================+// UI Building+// =============================================================================++void HierarchyPanel::buildUI() {+ constexpr glm::vec4 panelBg{0.145f, 0.145f, 0.149f, 1.0f}; // #252526+ constexpr glm::vec4 toolbarBg{0.176f, 0.176f, 0.188f, 1.0f}; // #2d2d30+ constexpr glm::vec4 mainBg{0.118f, 0.118f, 0.118f, 1.0f}; // #1e1e1e+ constexpr glm::vec4 borderColor{0.235f, 0.235f, 0.235f, 1.0f}; // #3c3c3c++ auto rootPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + "_root"));+ rootPanel->setLayout(makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 0.0f));+ rootPanel->setDrawBackground(true);+ rootPanel->setBackgroundColor(mainBg);++ auto toolbar = makeUnique<ui::Panel>(ui::WidgetId(getId().path + "_toolbar"));+ toolbar->setHeight(ui::SizeValue::px(38.0f));+ toolbar->setWidth(ui::SizeValue::flex(1.0f));+ toolbar->setPadding(ui::Insets(6.0f, 12.0f, 6.0f, 12.0f));+ toolbar->setDrawBackground(true);+ toolbar->setBackgroundColor(toolbarBg);+ toolbar->setBorderColor(borderColor);+ toolbar->setBorderWidth(ui::BorderWidth(0.0f, 0.0f, 1.0f, 0.0f));++ auto searchField = makeUnique<ui::TextField>(ui::WidgetId(getId().path + "_search"));+ searchField->setPlaceholder("Search...");+ searchField->setWidth(ui::SizeValue::flex(1.0f));+ searchField->setHeight(ui::SizeValue::px(26.0f));+ searchField_ = searchField.get();+ toolbar->addChild(std::move(searchField));++ toolbar_ = toolbar.get();+ rootPanel->addChild(std::move(toolbar));++ auto scrollView = makeUnique<ui::ScrollView>(ui::WidgetId(getId().path + "_scroll"));+ scrollView->setScrollDirection(ui::ScrollDirection::Vertical);+ scrollView->setWidth(ui::SizeValue::flex(1.0f));+ scrollView->setHeight(ui::SizeValue::flex(1.0f));++ auto treeView = makeUnique<ui::TreeView>(ui::WidgetId(getId().path + "_tree"));+ treeView->setMultiSelect(false);+ treeView->setRowHeight(22.0f);+ treeView->setIndentSize(16.0f);+ treeView->setWidth(ui::SizeValue::flex(1.0f));+ treeView->setHeight(ui::SizeValue::autoSize());+ treeView_ = treeView.get();++ scrollView->setContent(std::move(treeView));+ scrollView_ = scrollView.get();+ rootPanel->addChild(std::move(scrollView));++ rootPanel_ = rootPanel.get();+ setContent(std::move(rootPanel));+}++void HierarchyPanel::onSearchTextChanged(const std::string& text) {+ searchFilter_ = text;+ rebuildTree();+}+// =============================================================================// Public Methods// =============================================================================@@ -120,6 +180,11 @@ void HierarchyPanel::rebuildTree() {ES_LOG_DEBUG("HierarchyPanel::rebuildTree: Found {} entities", allEntities.size());+ // Convert search filter to lowercase for case-insensitive search+ std::string lowerFilter = searchFilter_;+ std::transform(lowerFilter.begin(), lowerFilter.end(), lowerFilter.begin(),+ [](unsigned char c) { return static_cast<char>(std::tolower(c)); });+// Build tree starting from root entities (entities without Parent component)usize rootCount = 0;for (Entity entity : allEntities) {@@ -128,6 +193,19 @@ void HierarchyPanel::rebuildTree() {continue;}+ // If we have a search filter, check if entity or any descendant matches+ if (!searchFilter_.empty()) {+ bool matches = false;+ std::string displayName = getEntityDisplayName(entity);+ std::string lowerName = displayName;+ std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(),+ [](unsigned char c) { return static_cast<char>(std::tolower(c)); });+ if (lowerName.find(lowerFilter) != std::string::npos) {+ matches = true;+ }+ if (!matches) continue;+ }+// Add as root nodeaddEntityToTree(entity, ui::INVALID_TREE_NODE);rootCount++;diff --git a/src/esengine/editor/panels/HierarchyPanel.hpp b/src/esengine/editor/panels/HierarchyPanel.hppindex abda407c2..3739436db 100644--- a/src/esengine/editor/panels/HierarchyPanel.hpp+++ b/src/esengine/editor/panels/HierarchyPanel.hpp@@ -18,6 +18,9 @@#include "../../ui/docking/DockPanel.hpp"#include "../../ui/widgets/TreeView.hpp"+#include "../../ui/widgets/ScrollView.hpp"+#include "../../ui/widgets/Panel.hpp"+#include "../../ui/widgets/TextField.hpp"#include "../../ecs/Registry.hpp"#include "../core/Selection.hpp"#include "../../events/Connection.hpp"@@ -148,6 +151,9 @@ private:*/ui::TreeNodeId getNodeForEntity(Entity entity) const;+ void buildUI();+ void onSearchTextChanged(const std::string& text);+// =========================================================================// Member Variables// =========================================================================@@ -155,12 +161,18 @@ private:ecs::Registry& registry_;EntitySelection& selection_;+ ui::Panel* rootPanel_ = nullptr;+ ui::Panel* toolbar_ = nullptr;+ ui::TextField* searchField_ = nullptr;+ ui::ScrollView* scrollView_ = nullptr;ui::TreeView* treeView_ = nullptr;// Bidirectional mapping between entities and tree nodesstd::unordered_map<ui::TreeNodeId, Entity> nodeToEntity_;std::unordered_map<Entity, ui::TreeNodeId> entityToNode_;+ std::string searchFilter_;+// Settingsbool showOrphans_ = true;bool needsRebuild_ = false;@@ -169,6 +181,7 @@ private:Connection selectionChangedConnection_;Connection nodeSelectedConnection_;Connection nodeDoubleClickedConnection_;+ Connection searchChangedConnection_;};} // namespace esengine::editordiff --git a/src/esengine/editor/panels/InspectorPanel.cpp b/src/esengine/editor/panels/InspectorPanel.cppindex aa7718a65..a5f331296 100644--- a/src/esengine/editor/panels/InspectorPanel.cpp+++ b/src/esengine/editor/panels/InspectorPanel.cpp@@ -15,7 +15,14 @@#include "../../math/Math.hpp"#include "../../events/Sink.hpp"#include "../../core/Log.hpp"+#include "../../ui/UIContext.hpp"#include "../../ui/layout/StackLayout.hpp"+#include "../../ui/icons/Icons.hpp"+#include "../../ui/rendering/UIBatchRenderer.hpp"++#if ES_FEATURE_SDF_FONT+#include "../../ui/font/MSDFFont.hpp"+#endifnamespace esengine::editor {@@ -31,15 +38,11 @@ InspectorPanel::InspectorPanel(ecs::Registry& registry,selection_(selection),history_(history) {- auto scrollView = makeUnique<ui::ScrollView>(ui::WidgetId(getId().path + "_scroll"));- scrollView_ = scrollView.get();- addChild(std::move(scrollView));+ setPanelType("Inspector");+ setClosable(false);+ setMinSize(glm::vec2(250.0f, 200.0f));- auto content = makeUnique<ui::Panel>(ui::WidgetId(getId().path + "_content"));- content->setLayout(makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 8.0f));- content->setPadding(ui::Insets::all(8.0f));- contentPanel_ = content.get();- scrollView_->setContent(std::move(content));+ buildUI();selectionListenerId_ = selection_.addListener([this](const std::vector<Entity>&, const std::vector<Entity>&) {@@ -55,6 +58,105 @@ InspectorPanel::~InspectorPanel() {}}+// =============================================================================+// UI Building+// =============================================================================++void InspectorPanel::buildUI() {+ constexpr glm::vec4 panelBg{0.145f, 0.145f, 0.149f, 1.0f}; // #252526+ constexpr glm::vec4 headerBg{0.176f, 0.176f, 0.188f, 1.0f}; // #2d2d30+ constexpr glm::vec4 mainBg{0.118f, 0.118f, 0.118f, 1.0f}; // #1e1e1e+ constexpr glm::vec4 borderColor{0.235f, 0.235f, 0.235f, 1.0f}; // #3c3c3c+ constexpr glm::vec4 textColor{0.878f, 0.878f, 0.878f, 1.0f}; // #e0e0e0++ auto rootPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + "_root"));+ rootPanel->setLayout(makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 0.0f));+ rootPanel->setDrawBackground(true);+ rootPanel->setBackgroundColor(mainBg);++ auto headerPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + "_header"));+ headerPanel->setHeight(ui::SizeValue::px(38.0f));+ headerPanel->setWidth(ui::SizeValue::flex(1.0f));+ headerPanel->setPadding(ui::Insets(8.0f, 12.0f, 8.0f, 12.0f));+ headerPanel->setDrawBackground(true);+ headerPanel->setBackgroundColor(headerBg);+ headerPanel->setBorderColor(borderColor);+ headerPanel->setBorderWidth(ui::BorderWidth(0.0f, 0.0f, 1.0f, 0.0f));++ auto entityNameLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + "_entity_name"));+ entityNameLabel->setText("No Selection");+ entityNameLabel->setFontSize(14.0f);+ entityNameLabel->setColor(textColor);+ entityNameLabel_ = entityNameLabel.get();+ headerPanel->addChild(std::move(entityNameLabel));++ headerPanel_ = headerPanel.get();+ rootPanel->addChild(std::move(headerPanel));++ auto scrollView = makeUnique<ui::ScrollView>(ui::WidgetId(getId().path + "_scroll"));+ scrollView->setScrollDirection(ui::ScrollDirection::Vertical);+ scrollView->setWidth(ui::SizeValue::flex(1.0f));+ scrollView->setHeight(ui::SizeValue::flex(1.0f));+ scrollView_ = scrollView.get();++ auto contentPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + "_content"));+ contentPanel->setLayout(makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 0.0f));+ contentPanel->setWidth(ui::SizeValue::flex(1.0f));+ contentPanel->setHeight(ui::SizeValue::autoSize());+ contentPanel->setPadding(ui::Insets(8.0f, 0.0f, 8.0f, 0.0f));+ contentPanel_ = contentPanel.get();++ scrollView->setContent(std::move(contentPanel));+ rootPanel->addChild(std::move(scrollView));++ rootPanel_ = rootPanel.get();+ setContent(std::move(rootPanel));+}++ui::Panel* InspectorPanel::createComponentSection(const std::string& name, const std::string& icon) {+ constexpr glm::vec4 sectionHeaderBg{0.176f, 0.176f, 0.188f, 1.0f}; // #2d2d30+ constexpr glm::vec4 sectionBg{0.145f, 0.145f, 0.149f, 1.0f}; // #252526+ constexpr glm::vec4 borderColor{0.235f, 0.235f, 0.235f, 1.0f}; // #3c3c3c+ constexpr glm::vec4 textColor{0.878f, 0.878f, 0.878f, 1.0f}; // #e0e0e0++ auto section = makeUnique<ui::Panel>(ui::WidgetId(contentPanel_->getId().path + "_" + name));+ section->setLayout(makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 0.0f));+ section->setWidth(ui::SizeValue::flex(1.0f));+ section->setHeight(ui::SizeValue::autoSize());+ section->setDrawBackground(true);+ section->setBackgroundColor(sectionBg);+ section->setBorderColor(borderColor);+ section->setBorderWidth(ui::BorderWidth(0.0f, 0.0f, 1.0f, 0.0f));++ auto header = makeUnique<ui::Panel>(ui::WidgetId(section->getId().path + "_header"));+ header->setHeight(ui::SizeValue::px(28.0f));+ header->setWidth(ui::SizeValue::flex(1.0f));+ header->setPadding(ui::Insets(4.0f, 8.0f, 4.0f, 8.0f));+ header->setDrawBackground(true);+ header->setBackgroundColor(sectionHeaderBg);++ auto headerLabel = makeUnique<ui::Label>(ui::WidgetId(header->getId().path + "_label"));+ headerLabel->setText(name);+ headerLabel->setFontSize(12.0f);+ headerLabel->setColor(textColor);+ header->addChild(std::move(headerLabel));++ section->addChild(std::move(header));++ ui::Panel* sectionPtr = section.get();+ contentPanel_->addChild(std::move(section));+ return sectionPtr;+}++void InspectorPanel::toggleSection(const std::string& name) {+ if (collapsedSections_.count(name) > 0) {+ collapsedSections_.erase(name);+ } else {+ collapsedSections_.insert(name);+ }+ rebuildInspector();+}+// =============================================================================// Public Interface// =============================================================================@@ -73,12 +175,12 @@ void InspectorPanel::refresh() {// =============================================================================void InspectorPanel::render(ui::UIBatchRenderer& renderer) {- if (scrollView_) {- if (scrollView_->getContext() != getContext()) {- scrollView_->setContext(getContext());+ if (rootPanel_) {+ if (rootPanel_->getContext() != getContext()) {+ rootPanel_->setContext(getContext());}- scrollView_->layout(getBounds());- scrollView_->renderTree(renderer);+ rootPanel_->layout(getBounds());+ rootPanel_->renderTree(renderer);}}@@ -89,14 +191,33 @@ void InspectorPanel::render(ui::UIBatchRenderer& renderer) {void InspectorPanel::rebuildInspector() {clearInspector();+ constexpr glm::vec4 dimTextColor{0.533f, 0.533f, 0.533f, 1.0f}; // #888+if (currentEntity_ == INVALID_ENTITY || !registry_.valid(currentEntity_)) {+ if (entityNameLabel_) {+ entityNameLabel_->setText("No Selection");+ entityNameLabel_->setColor(dimTextColor);+ }+auto noSelectionLabel = makeUnique<ui::Label>(ui::WidgetId(contentPanel_->getId().path + "_no_selection"));- noSelectionLabel->setText("No entity selected");+ noSelectionLabel->setText("Select an entity to view properties");+ noSelectionLabel->setFontSize(12.0f);+ noSelectionLabel->setColor(dimTextColor);contentPanel_->addChild(std::move(noSelectionLabel));return;}+ constexpr glm::vec4 textColor{0.878f, 0.878f, 0.878f, 1.0f}; // #e0e0e0+ if (entityNameLabel_) {+ std::string displayName = "Entity " + std::to_string(currentEntity_);+ if (registry_.has<ecs::Name>(currentEntity_)) {+ displayName = registry_.get<ecs::Name>(currentEntity_).value;+ }+ entityNameLabel_->setText(displayName);+ entityNameLabel_->setColor(textColor);+ }+if (registry_.has<ecs::Name>(currentEntity_)) {addNameEditor(currentEntity_);}@@ -110,38 +231,49 @@ void InspectorPanel::clearInspector() {if (contentPanel_) {contentPanel_->clearChildren();}+ editorConnections_.disconnectAll();}void InspectorPanel::addNameEditor(Entity entity) {+ constexpr glm::vec4 sectionBg{0.145f, 0.145f, 0.149f, 1.0f};+ constexpr glm::vec4 labelColor{0.686f, 0.686f, 0.686f, 1.0f}; // #afafaf+ constexpr glm::vec4 valueColor{0.878f, 0.878f, 0.878f, 1.0f}; // #e0e0e0++ auto section = createComponentSection("Name", ui::icons::User);auto& name = registry_.get<ecs::Name>(entity);- auto headerLabel = makeUnique<ui::Label>(- ui::WidgetId(contentPanel_->getId().path + "_name_header"));- headerLabel->setText("Name");- contentPanel_->addChild(std::move(headerLabel));+ auto row = makeUnique<ui::Panel>(ui::WidgetId(section->getId().path + "_row"));+ row->setHeight(ui::SizeValue::px(26.0f));+ row->setWidth(ui::SizeValue::flex(1.0f));+ row->setPadding(ui::Insets(4.0f, 12.0f, 4.0f, 12.0f));- auto valueLabel = makeUnique<ui::Label>(- ui::WidgetId(contentPanel_->getId().path + "_name_value"));+ auto valueLabel = makeUnique<ui::Label>(ui::WidgetId(row->getId().path + "_value"));valueLabel->setText(name.value);- contentPanel_->addChild(std::move(valueLabel));+ valueLabel->setFontSize(12.0f);+ valueLabel->setColor(valueColor);+ row->addChild(std::move(valueLabel));++ section->addChild(std::move(row));}void InspectorPanel::addLocalTransformEditor(Entity entity) {+ auto section = createComponentSection("Transform", ui::icons::Move3d);auto& transform = registry_.get<ecs::LocalTransform>(entity);- auto headerLabel = makeUnique<ui::Label>(- ui::WidgetId(contentPanel_->getId().path + "_transform_header"));- headerLabel->setText("Local Transform");- contentPanel_->addChild(std::move(headerLabel));+ auto content = makeUnique<ui::Panel>(ui::WidgetId(section->getId().path + "_content"));+ content->setLayout(makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 4.0f));+ content->setWidth(ui::SizeValue::flex(1.0f));+ content->setHeight(ui::SizeValue::autoSize());+ content->setPadding(ui::Insets(8.0f, 12.0f, 8.0f, 12.0f));auto positionEditor = makeUnique<Vector3Editor>(- ui::WidgetId(contentPanel_->getId().path + "_position"),+ ui::WidgetId(content->getId().path + "_position"),"position");positionEditor->setLabel("Position");positionEditor->setValue(transform.position);positionEditor->setCommandHistory(&history_);- sink(positionEditor->onValueChanged).connect(+ editorConnections_.add(sink(positionEditor->onValueChanged).connect([this, entity](const std::any& value) {if (registry_.valid(entity) && registry_.has<ecs::LocalTransform>(entity)) {auto& t = registry_.get<ecs::LocalTransform>(entity);@@ -152,20 +284,20 @@ void InspectorPanel::addLocalTransformEditor(Entity entity) {}}}- );+ ));- contentPanel_->addChild(std::move(positionEditor));+ content->addChild(std::move(positionEditor));glm::vec3 eulerAngles = math::quatToEulerDegrees(transform.rotation);auto rotationEditor = makeUnique<Vector3Editor>(- ui::WidgetId(contentPanel_->getId().path + "_rotation"),+ ui::WidgetId(content->getId().path + "_rotation"),"rotation");rotationEditor->setLabel("Rotation");rotationEditor->setValue(eulerAngles);rotationEditor->setCommandHistory(&history_);- sink(rotationEditor->onValueChanged).connect(+ editorConnections_.add(sink(rotationEditor->onValueChanged).connect([this, entity](const std::any& value) {if (registry_.valid(entity) && registry_.has<ecs::LocalTransform>(entity)) {auto& t = registry_.get<ecs::LocalTransform>(entity);@@ -177,18 +309,18 @@ void InspectorPanel::addLocalTransformEditor(Entity entity) {}}}- );+ ));- contentPanel_->addChild(std::move(rotationEditor));+ content->addChild(std::move(rotationEditor));auto scaleEditor = makeUnique<Vector3Editor>(- ui::WidgetId(contentPanel_->getId().path + "_scale"),+ ui::WidgetId(content->getId().path + "_scale"),"scale");scaleEditor->setLabel("Scale");scaleEditor->setValue(transform.scale);scaleEditor->setCommandHistory(&history_);- sink(scaleEditor->onValueChanged).connect(+ editorConnections_.add(sink(scaleEditor->onValueChanged).connect([this, entity](const std::any& value) {if (registry_.valid(entity) && registry_.has<ecs::LocalTransform>(entity)) {auto& t = registry_.get<ecs::LocalTransform>(entity);@@ -199,9 +331,11 @@ void InspectorPanel::addLocalTransformEditor(Entity entity) {}}}- );+ ));++ content->addChild(std::move(scaleEditor));- contentPanel_->addChild(std::move(scaleEditor));+ section->addChild(std::move(content));}} // namespace esengine::editordiff --git a/src/esengine/editor/panels/InspectorPanel.hpp b/src/esengine/editor/panels/InspectorPanel.hppindex bdd05cfd6..b6d8df3e6 100644--- a/src/esengine/editor/panels/InspectorPanel.hpp+++ b/src/esengine/editor/panels/InspectorPanel.hpp@@ -19,6 +19,7 @@#include "../../ui/widgets/ScrollView.hpp"#include "../../ui/widgets/Label.hpp"#include "../../ui/widgets/Panel.hpp"+#include "../../ui/widgets/TextField.hpp"#include "../../ecs/Registry.hpp"#include "../../ecs/Entity.hpp"#include "../core/Selection.hpp"@@ -26,6 +27,8 @@#include "../property/editors/Vector3Editor.hpp"#include "../../events/Connection.hpp"+#include <unordered_set>+namespace esengine::editor {// =============================================================================@@ -71,9 +74,13 @@ public:void render(ui::UIBatchRenderer& renderer) override;private:+ void buildUI();void rebuildInspector();void clearInspector();+ ui::Panel* createComponentSection(const std::string& name, const std::string& icon);+ void toggleSection(const std::string& name);+// Component editorsvoid addLocalTransformEditor(Entity entity);void addNameEditor(Entity entity);@@ -82,11 +89,18 @@ private:EntitySelection& selection_;CommandHistory& history_;+ ui::Panel* rootPanel_ = nullptr;+ ui::Panel* headerPanel_ = nullptr;+ ui::Label* entityNameLabel_ = nullptr;ui::ScrollView* scrollView_ = nullptr;ui::Panel* contentPanel_ = nullptr;+ std::unordered_set<std::string> collapsedSections_;+Entity currentEntity_ = INVALID_ENTITY;u32 selectionListenerId_ = 0;++ ConnectionHolder editorConnections_;};} // namespace esengine::editor