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
fix: Improve TreeView column options and Label clipping
esenginea504ec5af515
diff --git a/src/esengine/editor/EditorApplication.cpp b/src/esengine/editor/EditorApplication.cppindex 4d5f6da4d..e44c14aa2 100644--- a/src/esengine/editor/EditorApplication.cpp+++ b/src/esengine/editor/EditorApplication.cpp@@ -370,8 +370,8 @@ void EditorApplication::setupEditorLayout() {ES_LOG_INFO("setupEditorLayout: Creating HierarchyPanel...");auto hierarchyPanel = makeUnique<HierarchyPanel>(registry_, selection_);- hierarchyPanel->setMinSize(glm::vec2(200.0f, 200.0f));- dockArea_->addPanel(std::move(hierarchyPanel), ui::DockDropZone::Left, nullptr, 0.2f);+ hierarchyPanel->setMinSize(glm::vec2(280.0f, 200.0f));+ dockArea_->addPanel(std::move(hierarchyPanel), ui::DockDropZone::Left, nullptr, 0.22f);ES_LOG_INFO("setupEditorLayout: Creating InspectorPanel...");auto inspectorPanel = makeUnique<InspectorPanel>(registry_, selection_, commandHistory_);diff --git a/src/esengine/editor/panels/AssetBrowserPanel.cpp b/src/esengine/editor/panels/AssetBrowserPanel.cppindex 4440a9dc8..17e976e80 100644--- a/src/esengine/editor/panels/AssetBrowserPanel.cpp+++ b/src/esengine/editor/panels/AssetBrowserPanel.cpp@@ -143,6 +143,8 @@ void AssetBrowserPanel::buildUI() {folderTree->setMultiSelect(false);folderTree->setRowHeight(24.0f);folderTree->setIndentSize(16.0f);+ folderTree->setShowVisibilityColumn(false);+ folderTree->setShowTypeColumn(false);folderTree->setWidth(ui::SizeValue::flex(1.0f));folderTree->setHeight(ui::SizeValue::autoSize());folderTree_ = folderTree.get();diff --git a/src/esengine/editor/panels/HierarchyPanel.cpp b/src/esengine/editor/panels/HierarchyPanel.cppindex 42e1d95fa..76111ee56 100644--- a/src/esengine/editor/panels/HierarchyPanel.cpp+++ b/src/esengine/editor/panels/HierarchyPanel.cpp@@ -39,7 +39,7 @@ HierarchyPanel::HierarchyPanel(ecs::Registry& registry, EntitySelection& selectisetPanelType("Hierarchy");setClosable(false);- setMinSize(glm::vec2(200.0f, 200.0f));+ setMinSize(glm::vec2(280.0f, 200.0f));buildUI();@@ -206,6 +206,7 @@ void HierarchyPanel::buildUI() {itemLabelHeader->setFontSize(11.0f);itemLabelHeader->setColor(headerTextColor);itemLabelHeader->setWidth(ui::SizeValue::flex(1.0f));+ itemLabelHeader->setClipContent(true);columnHeader->addChild(std::move(itemLabelHeader));auto typeHeader = makeUnique<ui::Label>(ui::WidgetId(getId().path + "_type_header"), "Type");diff --git a/src/esengine/ui/widgets/Label.cpp b/src/esengine/ui/widgets/Label.cppindex 4dc26c47a..be044a1ca 100644--- a/src/esengine/ui/widgets/Label.cpp+++ b/src/esengine/ui/widgets/Label.cpp@@ -109,7 +109,9 @@ void Label::render(UIBatchRenderer& renderer) {glm::vec4 textColor = customColor_ ? color_ : style.getTextColor(getState());Rect contentBounds = getContentBounds();- renderer.pushClipRect(contentBounds);+ if (clipContent_) {+ renderer.pushClipRect(contentBounds);+ }#if ES_FEATURE_SDF_FONTMSDFFont* font = nullptr;@@ -128,7 +130,9 @@ void Label::render(UIBatchRenderer& renderer) {}#endif- renderer.popClipRect();+ if (clipContent_) {+ renderer.popClipRect();+ }}} // namespace esengine::uidiff --git a/src/esengine/ui/widgets/Label.hpp b/src/esengine/ui/widgets/Label.hppindex 348d4e153..376c14016 100644--- a/src/esengine/ui/widgets/Label.hpp+++ b/src/esengine/ui/widgets/Label.hpp@@ -105,6 +105,12 @@ public:/** @brief Gets vertical text alignment */VAlign getVAlign() const { return vAlign_; }+ /** @brief Sets whether to clip text to bounds */+ void setClipContent(bool clip) { clipContent_ = clip; }++ /** @brief Returns true if content is clipped */+ bool getClipContent() const { return clipContent_; }+// =========================================================================// Widget Overrides// =========================================================================@@ -123,6 +129,7 @@ private:HAlign hAlign_ = HAlign::Left;VAlign vAlign_ = VAlign::Center;+ bool clipContent_ = false;glm::vec2 cachedTextSize_{0.0f};bool textSizeDirty_ = true;diff --git a/src/esengine/ui/widgets/TreeView.cpp b/src/esengine/ui/widgets/TreeView.cppindex 6bffd9062..927c2d30f 100644--- a/src/esengine/ui/widgets/TreeView.cpp+++ b/src/esengine/ui/widgets/TreeView.cpp@@ -328,15 +328,16 @@ void TreeView::renderNode(UIBatchRenderer& renderer, const TreeNode& node, f32 yf32 x = bounds.x + padding.left + ROW_PADDING_X;- // Visibility icon- if (iconFont) {- Rect eyeBounds{x, y + (rowHeight_ - ICON_SIZE) * 0.5f, ICON_SIZE, ICON_SIZE};- const char* eyeIcon = node.visible ? icons::Eye : icons::EyeOff;- glm::vec4 eyeColor = node.visible ? visibleIconColor : hiddenIconColor;- renderer.drawTextInBounds(eyeIcon, eyeBounds, *iconFont, 12.0f, eyeColor,- HAlign::Center, VAlign::Center);+ if (showVisibilityColumn_) {+ if (iconFont) {+ Rect eyeBounds{x, y + (rowHeight_ - ICON_SIZE) * 0.5f, ICON_SIZE, ICON_SIZE};+ const char* eyeIcon = node.visible ? icons::Eye : icons::EyeOff;+ glm::vec4 eyeColor = node.visible ? visibleIconColor : hiddenIconColor;+ renderer.drawTextInBounds(eyeIcon, eyeBounds, *iconFont, 12.0f, eyeColor,+ HAlign::Center, VAlign::Center);+ }+ x += VISIBILITY_COLUMN_WIDTH;}- x += VISIBILITY_COLUMN_WIDTH;// Indent + expand arrowx += static_cast<f32>(node.depth) * indentSize_;@@ -367,7 +368,8 @@ void TreeView::renderNode(UIBatchRenderer& renderer, const TreeNode& node, f32 yx += ICON_SIZE + 6.0f;// Label- f32 labelMaxWidth = bounds.x + bounds.width - padding.right - TYPE_COLUMN_WIDTH - x;+ f32 typeColumnSpace = showTypeColumn_ ? TYPE_COLUMN_WIDTH : 0.0f;+ f32 labelMaxWidth = bounds.x + bounds.width - padding.right - typeColumnSpace - x;f32 textY = y + (rowHeight_ - FONT_SIZE) * 0.5f;if (textFont && labelMaxWidth > 0) {@@ -377,8 +379,7 @@ void TreeView::renderNode(UIBatchRenderer& renderer, const TreeNode& node, f32 yrenderer.popClipRect();}- // Type column (right-aligned)- if (textFont && !node.type.empty()) {+ if (showTypeColumn_ && textFont && !node.type.empty()) {f32 typeX = bounds.x + bounds.width - padding.right - TYPE_COLUMN_WIDTH;renderer.drawText(node.type, glm::vec2(typeX, textY), *textFont, 11.0f, dimTextColor);}diff --git a/src/esengine/ui/widgets/TreeView.hpp b/src/esengine/ui/widgets/TreeView.hppindex a70bed7a3..06ae4d2fa 100644--- a/src/esengine/ui/widgets/TreeView.hpp+++ b/src/esengine/ui/widgets/TreeView.hpp@@ -147,6 +147,18 @@ public:*/f32 getIconSize() const { return iconSize_; }+ /** @brief Sets whether to show the visibility column */+ void setShowVisibilityColumn(bool show) { showVisibilityColumn_ = show; }++ /** @brief Returns true if the visibility column is shown */+ bool getShowVisibilityColumn() const { return showVisibilityColumn_; }++ /** @brief Sets whether to show the type column */+ void setShowTypeColumn(bool show) { showTypeColumn_ = show; }++ /** @brief Returns true if the type column is shown */+ bool getShowTypeColumn() const { return showTypeColumn_; }+// =========================================================================// Node Management// =========================================================================@@ -371,6 +383,8 @@ private:f32 indentSize_ = 20.0f;f32 rowHeight_ = 24.0f;f32 iconSize_ = 12.0f;+ bool showVisibilityColumn_ = true;+ bool showTypeColumn_ = true;// ID generationTreeNodeId nextNodeId_ = 1;