Skip to content

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.

fix: Add Doxygen headers and ScrollView wrapper for folder tree

esengine35556242b382
diff --git a/src/esengine/editor/panels/AssetBrowserPanel.cpp b/src/esengine/editor/panels/AssetBrowserPanel.cpp
index d2b1c813f..c109a1049 100644
--- a/src/esengine/editor/panels/AssetBrowserPanel.cpp
+++ b/src/esengine/editor/panels/AssetBrowserPanel.cpp
@@ -1,9 +1,21 @@
+/**
+ * @file AssetBrowserPanel.cpp
+ * @brief Asset browser panel implementation
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
+
#include "AssetBrowserPanel.hpp"
#include "AssetGridItem.hpp"
#include "../AssetDatabase.hpp"
#include "../ThumbnailGenerator.hpp"
#include "../../ui/UIContext.hpp"
#include "../../ui/layout/StackLayout.hpp"
+#include "../../ui/layout/WrapLayout.hpp"
#include "../../ui/widgets/Label.hpp"
#include "../../platform/FileSystem.hpp"
#include "../../core/Log.hpp"
@@ -14,6 +26,10 @@
namespace esengine::editor {
+// =============================================================================
+// Constructor / Destructor
+// =============================================================================
+
AssetBrowserPanel::AssetBrowserPanel(AssetDatabase& assetDB, ThumbnailGenerator& thumbnailGen)
: DockPanel(ui::WidgetId("asset_browser_panel"), "Assets"),
assetDB_(assetDB),
@@ -29,6 +45,9 @@ AssetBrowserPanel::AssetBrowserPanel(AssetDatabase& assetDB, ThumbnailGenerator&
}
currentPath_ = rootPath_;
+ ES_LOG_INFO("AssetBrowserPanel: rootPath = {}", rootPath_);
+ ES_LOG_INFO("AssetBrowserPanel: directoryExists = {}", FileSystem::directoryExists(rootPath_));
+
buildUI();
#ifndef ES_PLATFORM_WEB
@@ -39,6 +58,10 @@ AssetBrowserPanel::AssetBrowserPanel(AssetDatabase& assetDB, ThumbnailGenerator&
AssetBrowserPanel::~AssetBrowserPanel() = default;
+// =============================================================================
+// Public Methods
+// =============================================================================
+
void AssetBrowserPanel::refresh() {
needsRebuild_ = true;
}
@@ -67,6 +90,10 @@ void AssetBrowserPanel::onActivated() {
}
}
+// =============================================================================
+// UI Building
+// =============================================================================
+
void AssetBrowserPanel::buildUI() {
auto rootPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + "_root"));
rootPanel->setLayout(makeUnique<ui::StackLayout>(ui::StackDirection::Horizontal, 4.0f));
@@ -76,16 +103,22 @@ void AssetBrowserPanel::buildUI() {
leftPanel->setWidth(ui::SizeValue::px(200.0f));
leftPanel->setHeight(ui::SizeValue::flex(1.0f));
leftPanel->setDrawBackground(true);
- leftPanel->setPadding(ui::Insets::all(4.0f));
+
+ auto leftScrollView = makeUnique<ui::ScrollView>(ui::WidgetId(getId().path + "_left_scroll"));
+ leftScrollView->setScrollDirection(ui::ScrollDirection::Vertical);
+ leftScrollView->setWidth(ui::SizeValue::flex(1.0f));
+ leftScrollView->setHeight(ui::SizeValue::flex(1.0f));
auto folderTree = makeUnique<ui::TreeView>(ui::WidgetId(getId().path + "_folder_tree"));
folderTree->setMultiSelect(false);
folderTree->setRowHeight(22.0f);
folderTree->setIndentSize(16.0f);
folderTree->setWidth(ui::SizeValue::flex(1.0f));
- folderTree->setHeight(ui::SizeValue::flex(1.0f));
+ folderTree->setHeight(ui::SizeValue::autoSize());
folderTree_ = folderTree.get();
- leftPanel->addChild(std::move(folderTree));
+
+ leftScrollView->setContent(std::move(folderTree));
+ leftPanel->addChild(std::move(leftScrollView));
leftPanel_ = leftPanel.get();
rootPanel->addChild(std::move(leftPanel));
@@ -120,6 +153,7 @@ void AssetBrowserPanel::buildUI() {
gridPanel->setDrawBackground(false);
gridPanel->setWidth(ui::SizeValue::flex(1.0f));
gridPanel->setHeight(ui::SizeValue::autoSize());
+ gridPanel->setLayout(makeUnique<ui::WrapLayout>(8.0f, 8.0f));
assetGridPanel_ = gridPanel.get();
scrollView->setContent(std::move(gridPanel));
@@ -140,6 +174,10 @@ void AssetBrowserPanel::buildUI() {
);
}
+// =============================================================================
+// Directory Scanning
+// =============================================================================
+
void AssetBrowserPanel::rebuildFolderTree() {
#ifdef ES_PLATFORM_WEB
auto label = makeUnique<ui::Label>(ui::WidgetId(getId().path + "_web_msg"), "N/A on Web");
@@ -174,10 +212,12 @@ void AssetBrowserPanel::addFolderNodes(const std::string& path, ui::TreeNodeId p
#endif
std::vector<std::string> entries = FileSystem::listDirectory(path, false);
+ ES_LOG_INFO("AssetBrowserPanel::addFolderNodes: {} has {} entries", path, entries.size());
for (const auto& entry : entries) {
if (FileSystem::directoryExists(entry)) {
std::string folderName = getFileName(entry);
+ ES_LOG_DEBUG(" Found folder: {}", folderName);
ui::TreeNodeId nodeId = folderTree_->addNode(parentNode, folderName);
nodeToPath_[nodeId] = entry;
@@ -197,10 +237,12 @@ void AssetBrowserPanel::refreshAssetList() {
assetGridPanel_->clearChildren();
if (!FileSystem::directoryExists(currentPath_)) {
+ ES_LOG_WARN("AssetBrowserPanel::refreshAssetList: directory not found: {}", currentPath_);
return;
}
std::vector<std::string> files = FileSystem::listDirectory(currentPath_, false);
+ ES_LOG_INFO("AssetBrowserPanel::refreshAssetList: {} has {} items", currentPath_, files.size());
for (const auto& filePath : files) {
AssetEntry entry;
@@ -254,8 +296,14 @@ void AssetBrowserPanel::refreshAssetList() {
assetGridPanel_->addChild(std::move(item));
}
+
+ ES_LOG_INFO("AssetBrowserPanel::refreshAssetList: added {} items to grid", currentAssets_.size());
}
+// =============================================================================
+// Event Handlers
+// =============================================================================
+
void AssetBrowserPanel::onFolderSelected(ui::TreeNodeId nodeId) {
auto it = nodeToPath_.find(nodeId);
if (it != nodeToPath_.end()) {
@@ -299,6 +347,10 @@ void AssetBrowserPanel::onAssetItemDoubleClicked(const std::string& path) {
}
}
+// =============================================================================
+// Utility Methods
+// =============================================================================
+
std::string AssetBrowserPanel::getFileName(const std::string& path) const {
usize pos = path.find_last_of("/\\");
if (pos != std::string::npos) {
diff --git a/src/esengine/editor/panels/AssetBrowserPanel.hpp b/src/esengine/editor/panels/AssetBrowserPanel.hpp
index 1cf688e6e..198fdf750 100644
--- a/src/esengine/editor/panels/AssetBrowserPanel.hpp
+++ b/src/esengine/editor/panels/AssetBrowserPanel.hpp
@@ -1,5 +1,21 @@
+/**
+ * @file AssetBrowserPanel.hpp
+ * @brief Asset browser panel for the editor
+ * @details Provides a file browser interface for navigating and managing
+ * project assets with folder tree and grid view.
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
#pragma once
+// =============================================================================
+// Includes
+// =============================================================================
+
#include "../../ui/docking/DockPanel.hpp"
#include "../../ui/widgets/TreeView.hpp"
#include "../../ui/widgets/ScrollView.hpp"
@@ -13,9 +29,17 @@
namespace esengine::editor {
+// =============================================================================
+// Forward Declarations
+// =============================================================================
+
class AssetDatabase;
class ThumbnailGenerator;
+// =============================================================================
+// AssetBrowserPanel Class
+// =============================================================================
+
class AssetBrowserPanel : public ui::DockPanel {
public:
AssetBrowserPanel(AssetDatabase& assetDB, ThumbnailGenerator& thumbnailGen);
diff --git a/src/esengine/editor/panels/AssetBrowserTypes.hpp b/src/esengine/editor/panels/AssetBrowserTypes.hpp
index 49bcdca72..bcc5615e8 100644
--- a/src/esengine/editor/panels/AssetBrowserTypes.hpp
+++ b/src/esengine/editor/panels/AssetBrowserTypes.hpp
@@ -1,5 +1,19 @@
+/**
+ * @file AssetBrowserTypes.hpp
+ * @brief Type definitions for the asset browser
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
#pragma once
+// =============================================================================
+// Includes
+// =============================================================================
+
#include "../../core/Types.hpp"
#include <glm/glm.hpp>
@@ -8,6 +22,10 @@
namespace esengine::editor {
+// =============================================================================
+// Enumerations
+// =============================================================================
+
enum class AssetType : u8 {
Unknown,
Folder,
@@ -25,6 +43,10 @@ enum class AssetViewMode : u8 {
List
};
+// =============================================================================
+// Data Structures
+// =============================================================================
+
struct AssetEntry {
std::string name;
std::string path;
@@ -35,6 +57,10 @@ struct AssetEntry {
bool isDirectory = false;
};
+// =============================================================================
+// Utility Functions
+// =============================================================================
+
inline AssetType getAssetTypeFromExtension(const std::string& ext) {
if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".tga") {
return AssetType::Texture;
diff --git a/src/esengine/editor/panels/AssetGridItem.cpp b/src/esengine/editor/panels/AssetGridItem.cpp
index c01a3c4e9..8ab9ef279 100644
--- a/src/esengine/editor/panels/AssetGridItem.cpp
+++ b/src/esengine/editor/panels/AssetGridItem.cpp
@@ -1,3 +1,14 @@
+/**
+ * @file AssetGridItem.cpp
+ * @brief Grid item widget implementation
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
+
#include "AssetGridItem.hpp"
#include "../../ui/UIContext.hpp"
#include "../../ui/font/Font.hpp"
@@ -7,14 +18,24 @@
namespace esengine::editor {
+// =============================================================================
+// Helper Functions
+// =============================================================================
+
namespace {
- f64 getCurrentTimeSeconds() {
- auto now = std::chrono::steady_clock::now();
- auto duration = now.time_since_epoch();
- return std::chrono::duration<f64>(duration).count();
- }
+
+f64 getCurrentTimeSeconds() {
+ auto now = std::chrono::steady_clock::now();
+ auto duration = now.time_since_epoch();
+ return std::chrono::duration<f64>(duration).count();
+}
+
} // namespace
+// =============================================================================
+// Constructor
+// =============================================================================
+
AssetGridItem::AssetGridItem(const ui::WidgetId& id, const AssetEntry& entry)
: Widget(id), entry_(entry) {
setWidth(ui::SizeValue::px(ITEM_WIDTH));
@@ -25,17 +46,30 @@ void AssetGridItem::setSelected(bool selected) {
selected_ = selected;
}
+// =============================================================================
+// Layout
+// =============================================================================
+
glm::vec2 AssetGridItem::measure(f32 availableWidth, f32 availableHeight) {
(void)availableWidth;
(void)availableHeight;
return {ITEM_WIDTH, ITEM_HEIGHT};
}
+// =============================================================================
+// Rendering
+// =============================================================================
+
void AssetGridItem::render(ui::UIBatchRenderer& renderer) {
ui::UIContext* ctx = getContext();
if (!ctx) return;
ui::Rect bounds = getBounds();
+
+ if (bounds.width <= 0 || bounds.height <= 0) {
+ return;
+ }
+
const auto& theme = ctx->getTheme();
if (selected_) {
@@ -81,6 +115,10 @@ void AssetGridItem::render(ui::UIBatchRenderer& renderer) {
}
}
+// =============================================================================
+// Event Handling
+// =============================================================================
+
bool AssetGridItem::onMouseDown(const ui::MouseButtonEvent& event) {
if (event.button == ui::MouseButton::Left) {
f64 currentTime = getCurrentTimeSeconds();
diff --git a/src/esengine/editor/panels/AssetGridItem.hpp b/src/esengine/editor/panels/AssetGridItem.hpp
index 748c5b125..1b2ced89f 100644
--- a/src/esengine/editor/panels/AssetGridItem.hpp
+++ b/src/esengine/editor/panels/AssetGridItem.hpp
@@ -1,5 +1,19 @@
+/**
+ * @file AssetGridItem.hpp
+ * @brief Grid item widget for displaying assets in the browser
+ *
+ * @author ESEngine Team
+ * @date 2026
+ *
+ * @copyright Copyright (c) 2026 ESEngine Team
+ * Licensed under the MIT License.
+ */
#pragma once
+// =============================================================================
+// Includes
+// =============================================================================
+
#include "../../ui/widgets/Widget.hpp"
#include "../../events/Signal.hpp"
#include "AssetBrowserTypes.hpp"
@@ -8,6 +22,10 @@
namespace esengine::editor {
+// =============================================================================
+// AssetGridItem Class
+// =============================================================================
+
class AssetGridItem : public ui::Widget {
public:
static constexpr f32 ITEM_WIDTH = 80.0f;