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
feat: Redesign ProjectLauncherPanel and add MouseMoveCallback for hover
esengineca851848621e
diff --git a/src/esengine/editor/EditorApplication.cpp b/src/esengine/editor/EditorApplication.cppindex 6e5329ccc..3208b08f8 100644--- a/src/esengine/editor/EditorApplication.cpp+++ b/src/esengine/editor/EditorApplication.cpp@@ -117,6 +117,13 @@ void EditorApplication::onInit() {}});+ // Wire up mouse move events to UI system for hover detection+ getPlatform().setMouseMoveCallback([this](f32 x, f32 y) {+ if (uiContext_) {+ uiContext_->processMouseMove(x, y);+ }+ });+// Wire up text input events to UI systemgetPlatform().setTextInputCallback([this](const std::string& text) {if (uiContext_) {diff --git a/src/esengine/editor/panels/ProjectLauncherPanel.cpp b/src/esengine/editor/panels/ProjectLauncherPanel.cppindex 43bfd6664..a6645dd40 100644--- a/src/esengine/editor/panels/ProjectLauncherPanel.cpp+++ b/src/esengine/editor/panels/ProjectLauncherPanel.cpp@@ -19,10 +19,35 @@#include "../../ui/widgets/ScrollView.hpp"#include "../../ui/layout/StackLayout.hpp"#include "../../ui/rendering/UIBatchRenderer.hpp"+#include "../../ui/icons/Icons.hpp"#include "../../core/Log.hpp"namespace esengine::editor {+namespace {++glm::vec4 hexColor(u32 hex, f32 alpha = 1.0f) {+ return glm::vec4(+ ((hex >> 16) & 0xFF) / 255.0f,+ ((hex >> 8) & 0xFF) / 255.0f,+ (hex & 0xFF) / 255.0f,+ alpha+ );+}++constexpr f32 HEADER_PADDING_TOP = 60.0f;+constexpr f32 HEADER_PADDING_HORIZONTAL = 40.0f;+constexpr f32 HEADER_PADDING_BOTTOM = 40.0f;+constexpr f32 CONTENT_GAP = 60.0f;+constexpr f32 ACTIONS_MIN_WIDTH = 280.0f;+constexpr f32 RECENT_MAX_WIDTH = 600.0f;+constexpr f32 FOOTER_HEIGHT = 50.0f;+constexpr f32 BUTTON_HEIGHT = 40.0f;+constexpr f32 BUTTON_GAP = 12.0f;+constexpr f32 RECENT_ITEM_HEIGHT = 52.0f;++} // namespace+// =============================================================================// Constructor / Destructor// =============================================================================@@ -44,57 +69,42 @@ ProjectLauncherPanel::~ProjectLauncherPanel() = default;// =============================================================================void ProjectLauncherPanel::setupUI() {- // Left panel - branding and actionsauto leftPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".left"));- leftPanel->setBackgroundColor(glm::vec4(0.08f, 0.08f, 0.10f, 1.0f));- auto leftLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 8.0f);+ leftPanel->setBackgroundColor(hexColor(0x1e1e1e));+ auto leftLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 0.0f);leftPanel->setLayout(std::move(leftLayout));- leftPanel->setPadding(ui::Insets(60.0f, 50.0f, 40.0f, 50.0f));+ leftPanel->setPadding(ui::Insets(HEADER_PADDING_TOP, HEADER_PADDING_HORIZONTAL,+ HEADER_PADDING_BOTTOM, HEADER_PADDING_HORIZONTAL));leftPanel_ = leftPanel.get();- auto titleLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".title"), "ESENGINE");- titleLabel->setFontSize(42.0f);- titleLabel->setColor(glm::vec4(1.0f));+ auto titleLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".title"), "ESEngine Editor");+ titleLabel->setFontSize(32.0f);+ titleLabel->setColor(hexColor(0xffffff));titleLabel_ = titleLabel.get();leftPanel->addChild(std::move(titleLabel));+ auto subtitleSpacer = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".subtitle_spacer"));+ subtitleSpacer->setHeight(ui::SizeValue::px(8.0f));+ leftPanel->addChild(std::move(subtitleSpacer));+auto subtitleLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".subtitle"),- "Game Development Platform");+ "Professional Game Development Tool");subtitleLabel->setFontSize(14.0f);- subtitleLabel->setColor(glm::vec4(0.5f, 0.5f, 0.5f, 1.0f));+ subtitleLabel->setColor(hexColor(0x858585));subtitleLabel_ = subtitleLabel.get();leftPanel->addChild(std::move(subtitleLabel));- auto spacer1 = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".spacer1"));- spacer1->setHeight(ui::SizeValue::px(60.0f));- leftPanel->addChild(std::move(spacer1));-- auto newProjectButton = makeUnique<ui::Button>(ui::WidgetId(getId().path + ".new"),- "New Project");- newProjectButton->setButtonStyle(ui::ButtonStyle::Primary);- newProjectButton->setWidth(ui::SizeValue::px(220.0f));- newProjectButton->setHeight(ui::SizeValue::px(48.0f));- newProjectButton->setFontSize(15.0f);- newProjectButton->setCornerRadii(ui::CornerRadii::all(6.0f));- newProjectButton_ = newProjectButton.get();- connections_.push_back(- sink(newProjectButton_->onClick).connect([this]() {- ES_LOG_INFO("ProjectLauncher: New project requested");- onCreateProjectRequested.publish();- }));- leftPanel->addChild(std::move(newProjectButton));-- auto spacer2 = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".spacer2"));- spacer2->setHeight(ui::SizeValue::px(12.0f));- leftPanel->addChild(std::move(spacer2));+ auto actionsSpacer = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".actions_spacer"));+ actionsSpacer->setHeight(ui::SizeValue::px(40.0f));+ leftPanel->addChild(std::move(actionsSpacer));auto openProjectButton = makeUnique<ui::Button>(ui::WidgetId(getId().path + ".open"),"Open Project");- openProjectButton->setButtonStyle(ui::ButtonStyle::Secondary);- openProjectButton->setWidth(ui::SizeValue::px(220.0f));- openProjectButton->setHeight(ui::SizeValue::px(48.0f));- openProjectButton->setFontSize(15.0f);- openProjectButton->setCornerRadii(ui::CornerRadii::all(6.0f));+ openProjectButton->setButtonStyle(ui::ButtonStyle::Primary);+ openProjectButton->setWidth(ui::SizeValue::percent(100.0f));+ openProjectButton->setHeight(ui::SizeValue::px(BUTTON_HEIGHT));+ openProjectButton->setFontSize(13.0f);+ openProjectButton->setCornerRadii(ui::CornerRadii::all(2.0f));openProjectButton_ = openProjectButton.get();connections_.push_back(sink(openProjectButton_->onClick).connect([this]() {@@ -103,30 +113,57 @@ void ProjectLauncherPanel::setupUI() {}));leftPanel->addChild(std::move(openProjectButton));+ auto buttonSpacer = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".button_spacer"));+ buttonSpacer->setHeight(ui::SizeValue::px(BUTTON_GAP));+ leftPanel->addChild(std::move(buttonSpacer));++ auto newProjectButton = makeUnique<ui::Button>(ui::WidgetId(getId().path + ".new"),+ "Create Project");+ newProjectButton->setButtonStyle(ui::ButtonStyle::Secondary);+ newProjectButton->setWidth(ui::SizeValue::percent(100.0f));+ newProjectButton->setHeight(ui::SizeValue::px(BUTTON_HEIGHT));+ newProjectButton->setFontSize(13.0f);+ newProjectButton->setCornerRadii(ui::CornerRadii::all(2.0f));+ newProjectButton_ = newProjectButton.get();+ connections_.push_back(+ sink(newProjectButton_->onClick).connect([this]() {+ ES_LOG_INFO("ProjectLauncher: New project requested");+ onCreateProjectRequested.publish();+ }));+ leftPanel->addChild(std::move(newProjectButton));++ auto flexSpacer = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".flex_spacer"));+ flexSpacer->setHeight(ui::SizeValue::percent(100.0f));+ leftPanel->addChild(std::move(flexSpacer));+auto versionLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".version"),"Version 1.0.0");versionLabel->setFontSize(11.0f);- versionLabel->setColor(glm::vec4(0.35f, 0.35f, 0.35f, 1.0f));+ versionLabel->setColor(hexColor(0x6e6e6e));versionLabel_ = versionLabel.get();leftPanel->addChild(std::move(versionLabel));addChild(std::move(leftPanel));- // Right panel - recent projectsauto rightPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".right"));- rightPanel->setBackgroundColor(glm::vec4(0.11f, 0.11f, 0.13f, 1.0f));- auto rightLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 16.0f);+ rightPanel->setBackgroundColor(hexColor(0x1e1e1e));+ auto rightLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 0.0f);rightPanel->setLayout(std::move(rightLayout));- rightPanel->setPadding(ui::Insets(40.0f, 40.0f, 40.0f, 40.0f));+ rightPanel->setPadding(ui::Insets(HEADER_PADDING_TOP, HEADER_PADDING_HORIZONTAL,+ HEADER_PADDING_BOTTOM, HEADER_PADDING_HORIZONTAL));rightPanel_ = rightPanel.get();auto recentLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".recent_label"),- "Recent Projects");- recentLabel->setFontSize(18.0f);- recentLabel->setColor(glm::vec4(0.9f, 0.9f, 0.9f, 1.0f));+ "RECENT PROJECTS");+ recentLabel->setFontSize(13.0f);+ recentLabel->setColor(hexColor(0xcccccc));recentLabel_ = recentLabel.get();rightPanel->addChild(std::move(recentLabel));+ auto recentSpacer = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".recent_spacer"));+ recentSpacer->setHeight(ui::SizeValue::px(16.0f));+ rightPanel->addChild(std::move(recentSpacer));+auto recentScrollView = makeUnique<ui::ScrollView>(ui::WidgetId(getId().path + ".recent_scroll"));recentScrollView->setScrollDirection(ui::ScrollDirection::Vertical);@@ -136,7 +173,7 @@ void ProjectLauncherPanel::setupUI() {recentScrollView_ = recentScrollView.get();auto recentListPanel = makeUnique<ui::Panel>(ui::WidgetId(getId().path + ".recent_list"));- auto listLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 8.0f);+ auto listLayout = makeUnique<ui::StackLayout>(ui::StackDirection::Vertical, 1.0f);recentListPanel->setLayout(std::move(listLayout));recentListPanel_ = recentListPanel.get();recentScrollView->setContent(std::move(recentListPanel));@@ -161,8 +198,8 @@ void ProjectLauncherPanel::refreshRecentProjects() {auto emptyLabel = makeUnique<ui::Label>(ui::WidgetId(getId().path + ".empty"),"No recent projects");- emptyLabel->setFontSize(14.0f);- emptyLabel->setColor(glm::vec4(0.5f, 0.5f, 0.5f, 1.0f));+ emptyLabel->setFontSize(13.0f);+ emptyLabel->setColor(hexColor(0x858585));recentListPanel_->addChild(std::move(emptyLabel));return;}@@ -178,11 +215,12 @@ void ProjectLauncherPanel::createRecentProjectItem(const RecentProject& project,std::string projectPath = project.path;auto itemButton = makeUnique<ui::Button>(ui::WidgetId(itemId), project.name);- itemButton->setButtonStyle(ui::ButtonStyle::Secondary);+ itemButton->setButtonStyle(ui::ButtonStyle::Ghost);itemButton->setWidth(ui::SizeValue::percent(100.0f));- itemButton->setHeight(ui::SizeValue::px(56.0f));- itemButton->setFontSize(14.0f);- itemButton->setCornerRadii(ui::CornerRadii::all(6.0f));+ itemButton->setHeight(ui::SizeValue::px(RECENT_ITEM_HEIGHT));+ itemButton->setFontSize(13.0f);+ itemButton->setCornerRadii(ui::CornerRadii::all(2.0f));+ itemButton->setTextAlignment(ui::HAlign::Left);connections_.push_back(sink(itemButton->onClick).connect([this, projectPath]() {@@ -204,30 +242,35 @@ glm::vec2 ProjectLauncherPanel::measure(f32 availableWidth, f32 availableHeight)void ProjectLauncherPanel::layout(const ui::Rect& bounds) {Widget::layout(bounds);- f32 leftWidth = std::max(320.0f, bounds.width * 0.35f);- f32 rightWidth = bounds.width - leftWidth;+ f32 contentWidth = bounds.width - HEADER_PADDING_HORIZONTAL * 2;+ f32 leftWidth = ACTIONS_MIN_WIDTH;+ f32 rightWidth = contentWidth - leftWidth - CONTENT_GAP;++ if (rightWidth > RECENT_MAX_WIDTH) {+ rightWidth = RECENT_MAX_WIDTH;+ }if (leftPanel_) {- leftPanel_->layout(ui::Rect{bounds.x, bounds.y, leftWidth, bounds.height});+ leftPanel_->layout(ui::Rect{+ bounds.x,+ bounds.y,+ leftWidth + HEADER_PADDING_HORIZONTAL * 2,+ bounds.height+ });}if (rightPanel_) {- rightPanel_->layout(ui::Rect{bounds.x + leftWidth, bounds.y, rightWidth, bounds.height});+ rightPanel_->layout(ui::Rect{+ bounds.x + leftWidth + HEADER_PADDING_HORIZONTAL * 2 + CONTENT_GAP,+ bounds.y,+ rightWidth + HEADER_PADDING_HORIZONTAL * 2,+ bounds.height+ });}}void ProjectLauncherPanel::render(ui::UIBatchRenderer& renderer) {- renderer.pushClipRect(getBounds());- renderer.drawRect(getBounds(), glm::vec4(0.12f, 0.12f, 0.12f, 1.0f));-- for (usize i = 0; i < getChildCount(); ++i) {- auto* child = getChild(i);- if (child && child->isVisible()) {- child->renderTree(renderer);- }- }-- renderer.popClipRect();+ renderer.drawRect(getBounds(), hexColor(0x1e1e1e));}} // namespace esengine::editordiff --git a/src/esengine/editor/panels/ProjectLauncherPanel.hpp b/src/esengine/editor/panels/ProjectLauncherPanel.hppindex 8f8ee5b85..6b086d94a 100644--- a/src/esengine/editor/panels/ProjectLauncherPanel.hpp+++ b/src/esengine/editor/panels/ProjectLauncherPanel.hpp@@ -10,14 +10,11 @@*/#pragma once-// =============================================================================-// Includes-// =============================================================================-#include "../../ui/widgets/Widget.hpp"#include "../../ui/core/Types.hpp"#include "../../events/Signal.hpp"#include "../../events/Connection.hpp"+#include "../project/ProjectTypes.hpp"#include <string>#include <vector>@@ -27,16 +24,15 @@ class Dispatcher;}namespace esengine::ui {-class Button;+class Panel;class Label;+class Button;class ScrollView;-class Panel;}namespace esengine::editor {class ProjectManager;-struct RecentProject;// =============================================================================// ProjectLauncherPanel@@ -48,24 +44,12 @@ public:Dispatcher& dispatcher);~ProjectLauncherPanel() override;- // =========================================================================- // Signals- // =========================================================================-Signal<void(const std::string&)> onProjectOpened;Signal<void()> onCreateProjectRequested;Signal<void()> onBrowseProjectRequested;- // =========================================================================- // Methods- // =========================================================================-void refreshRecentProjects();- // =========================================================================- // Widget Overrides- // =========================================================================-glm::vec2 measure(f32 availableWidth, f32 availableHeight) override;void layout(const ui::Rect& bounds) override;void render(ui::UIBatchRenderer& renderer) override;@@ -81,9 +65,9 @@ private:ui::Panel* rightPanel_ = nullptr;ui::Label* titleLabel_ = nullptr;ui::Label* subtitleLabel_ = nullptr;- ui::Label* versionLabel_ = nullptr;ui::Button* newProjectButton_ = nullptr;ui::Button* openProjectButton_ = nullptr;+ ui::Label* versionLabel_ = nullptr;ui::Label* recentLabel_ = nullptr;ui::ScrollView* recentScrollView_ = nullptr;ui::Panel* recentListPanel_ = nullptr;diff --git a/src/esengine/platform/Platform.hpp b/src/esengine/platform/Platform.hppindex 4dc4b0d75..397a22aa0 100644--- a/src/esengine/platform/Platform.hpp+++ b/src/esengine/platform/Platform.hpp@@ -139,6 +139,13 @@ using ScrollCallback = std::function<void(f32 deltaX, f32 deltaY, f32 x, f32 y)>*/using TextInputCallback = std::function<void(const std::string& text)>;+/**+ * @brief Callback type for mouse move events+ * @param x Mouse X position+ * @param y Mouse Y position+ */+using MouseMoveCallback = std::function<void(f32 x, f32 y)>;+// =============================================================================// Platform Class// =============================================================================@@ -302,6 +309,12 @@ public:*/virtual void setTextInputCallback(TextInputCallback callback) = 0;+ /**+ * @brief Sets the mouse move callback+ * @param callback Function to call on mouse move events+ */+ virtual void setMouseMoveCallback(MouseMoveCallback callback) = 0;+// =========================================================================// Factory// =========================================================================diff --git a/src/esengine/platform/native/NativePlatform.cpp b/src/esengine/platform/native/NativePlatform.cppindex 1334a2afb..ed55fdf0a 100644--- a/src/esengine/platform/native/NativePlatform.cpp+++ b/src/esengine/platform/native/NativePlatform.cpp@@ -264,6 +264,10 @@ void NativePlatform::setTextInputCallback(TextInputCallback callback) {textInputCallback_ = std::move(callback);}+void NativePlatform::setMouseMoveCallback(MouseMoveCallback callback) {+ mouseMoveCallback_ = std::move(callback);+}+// =============================================================================// GLFW Callbacks// =============================================================================@@ -318,7 +322,10 @@ void NativePlatform::glfwCursorPosCallback(GLFWwindow* window, double xpos, doubplatform->mouseX_ = xpos;platform->mouseY_ = ypos;- // Emit move event if mouse is pressed (drag)+ if (platform->mouseMoveCallback_) {+ platform->mouseMoveCallback_(static_cast<f32>(xpos), static_cast<f32>(ypos));+ }+if (platform->mousePressed_ && platform->touchCallback_) {TouchPoint point;point.id = 0;diff --git a/src/esengine/platform/native/NativePlatform.hpp b/src/esengine/platform/native/NativePlatform.hppindex 241160175..7d39dcb14 100644--- a/src/esengine/platform/native/NativePlatform.hpp+++ b/src/esengine/platform/native/NativePlatform.hpp@@ -175,6 +175,12 @@ public:*/void setTextInputCallback(TextInputCallback callback) override;+ /**+ * @brief Sets mouse move callback+ * @param callback Function to call on mouse move+ */+ void setMouseMoveCallback(MouseMoveCallback callback) override;+private:// =========================================================================// GLFW Callbacks@@ -223,6 +229,7 @@ private:ResizeCallback resizeCallback_; ///< Window resize callbackScrollCallback scrollCallback_; ///< Scroll event callbackTextInputCallback textInputCallback_; ///< Text input callback+ MouseMoveCallback mouseMoveCallback_; ///< Mouse move callbackstatic NativePlatform* instance_; ///< Singleton instance for callbacks};diff --git a/src/esengine/platform/web/WebPlatform.cpp b/src/esengine/platform/web/WebPlatform.cppindex 7b8797cac..5c4c4920c 100644--- a/src/esengine/platform/web/WebPlatform.cpp+++ b/src/esengine/platform/web/WebPlatform.cpp@@ -152,6 +152,10 @@ public:textInputCallback_ = std::move(callback);}+ void setMouseMoveCallback(MouseMoveCallback callback) override {+ mouseMoveCallback_ = std::move(callback);+ }+// Static instance for callbacksstatic WebPlatform* instance_;@@ -209,13 +213,21 @@ private:static EM_BOOL mouseCallback(int eventType, const EmscriptenMouseEvent* event, void* userData) {auto* platform = static_cast<WebPlatform*>(userData);++ f32 x = static_cast<f32>(event->targetX);+ f32 y = static_cast<f32>(event->targetY);++ if (eventType == EMSCRIPTEN_EVENT_MOUSEMOVE && platform->mouseMoveCallback_) {+ platform->mouseMoveCallback_(x, y);+ }+if (!platform->touchCallback_) return false;TouchType type;switch (eventType) {case EMSCRIPTEN_EVENT_MOUSEDOWN: type = TouchType::Begin; break;case EMSCRIPTEN_EVENT_MOUSEMOVE:- if (!(event->buttons & 1)) return false; // Only when button pressed+ if (!(event->buttons & 1)) return true;type = TouchType::Move;break;case EMSCRIPTEN_EVENT_MOUSEUP: type = TouchType::End; break;@@ -224,8 +236,8 @@ private:TouchPoint point;point.id = 0;- point.x = static_cast<f32>(event->targetX);- point.y = static_cast<f32>(event->targetY);+ point.x = x;+ point.y = y;platform->touchCallback_(type, point);return true;@@ -279,6 +291,7 @@ private:ResizeCallback resizeCallback_;ScrollCallback scrollCallback_;TextInputCallback textInputCallback_;+ MouseMoveCallback mouseMoveCallback_;};WebPlatform* WebPlatform::instance_ = nullptr;diff --git a/src/esengine/ui/core/Theme.hpp b/src/esengine/ui/core/Theme.hppindex 38ba301e2..13f4ba8d2 100644--- a/src/esengine/ui/core/Theme.hpp+++ b/src/esengine/ui/core/Theme.hpp@@ -43,18 +43,19 @@ struct ThemeColors {glm::vec4 surfaceHover{0.165f, 0.176f, 0.180f, 1.0f};glm::vec4 textPrimary{0.8f, 0.8f, 0.8f, 1.0f};- glm::vec4 textSecondary{0.616f, 0.616f, 0.616f, 1.0f};- glm::vec4 textDisabled{0.416f, 0.416f, 0.416f, 1.0f};- glm::vec4 textPlaceholder{0.416f, 0.416f, 0.416f, 1.0f};+ glm::vec4 textSecondary{0.522f, 0.522f, 0.522f, 1.0f};+ glm::vec4 textDisabled{0.431f, 0.431f, 0.431f, 1.0f};+ glm::vec4 textPlaceholder{0.431f, 0.431f, 0.431f, 1.0f};- glm::vec4 accent{0.0f, 0.478f, 0.8f, 1.0f};+ glm::vec4 accent{0.055f, 0.388f, 0.612f, 1.0f};glm::vec4 accentHover{0.067f, 0.467f, 0.733f, 1.0f};- glm::vec4 accentPressed{0.055f, 0.388f, 0.612f, 1.0f};+ glm::vec4 accentPressed{0.043f, 0.310f, 0.490f, 1.0f};- glm::vec4 button{0.235f, 0.235f, 0.235f, 1.0f};- glm::vec4 buttonHover{0.298f, 0.298f, 0.298f, 1.0f};- glm::vec4 buttonPressed{0.2f, 0.2f, 0.2f, 1.0f};+ glm::vec4 button{0.176f, 0.176f, 0.188f, 1.0f};+ glm::vec4 buttonHover{0.216f, 0.216f, 0.239f, 1.0f};+ glm::vec4 buttonPressed{0.157f, 0.157f, 0.169f, 1.0f};glm::vec4 buttonDisabled{0.176f, 0.176f, 0.176f, 1.0f};+ glm::vec4 buttonBorder{0.243f, 0.243f, 0.259f, 1.0f};glm::vec4 input{0.051f, 0.051f, 0.051f, 1.0f};glm::vec4 inputBorder{0.2f, 0.2f, 0.2f, 1.0f};diff --git a/src/esengine/ui/widgets/Button.cpp b/src/esengine/ui/widgets/Button.cppindex 63dfb059e..3c661e190 100644--- a/src/esengine/ui/widgets/Button.cpp+++ b/src/esengine/ui/widgets/Button.cpp@@ -114,7 +114,17 @@ void Button::render(UIBatchRenderer& renderer) {glm::vec4 bgColor = style.getBackgroundColor(state);CornerRadii radii = cornerRadii_.isZero() ? style.cornerRadii : cornerRadii_;- if (buttonStyle_ != ButtonStyle::Text) {+ bool drawBackground = true;+ if (buttonStyle_ == ButtonStyle::Text) {+ drawBackground = false;+ } else if (buttonStyle_ == ButtonStyle::Ghost) {+ drawBackground = state.hovered || state.pressed;+ if (drawBackground) {+ bgColor = ctx->getTheme().colors.buttonHover;+ }+ }++ if (drawBackground) {if (radii.isZero()) {renderer.drawRect(bounds, bgColor);} else {@@ -122,7 +132,7 @@ void Button::render(UIBatchRenderer& renderer) {}}- if (state.focused && buttonStyle_ != ButtonStyle::Text) {+ if (state.focused && buttonStyle_ != ButtonStyle::Text && buttonStyle_ != ButtonStyle::Ghost) {glm::vec4 focusColor = ctx->getTheme().colors.accent;focusColor.a = 0.3f;renderer.drawRoundedRectOutline(bounds, focusColor, radii, 2.0f);@@ -136,13 +146,13 @@ void Button::render(UIBatchRenderer& renderer) {MSDFFont* font = fontName_.empty() ? ctx->getDefaultMSDFFont() : ctx->getMSDFFont(fontName_);if (font) {renderer.drawTextInBounds(text_, textBounds, *font, fontSize_, textColor,- HAlign::Center, VAlign::Center);+ textAlign_, VAlign::Center);}#elif ES_FEATURE_BITMAP_FONTBitmapFont* font = fontName_.empty() ? ctx->getDefaultBitmapFont() : ctx->getBitmapFont(fontName_);if (font) {renderer.drawTextInBounds(text_, textBounds, *font, fontSize_, textColor,- HAlign::Center, VAlign::Center);+ textAlign_, VAlign::Center);}#endif}diff --git a/src/esengine/ui/widgets/Button.hpp b/src/esengine/ui/widgets/Button.hppindex ea02b6756..1d00e7d0f 100644--- a/src/esengine/ui/widgets/Button.hpp+++ b/src/esengine/ui/widgets/Button.hpp@@ -35,7 +35,8 @@ enum class ButtonStyle : u8 {Default,Primary,Secondary,- Text+ Text,+ Ghost};// =============================================================================@@ -109,6 +110,12 @@ public:/** @brief Gets the corner radii */const CornerRadii& getCornerRadii() const { return cornerRadii_; }+ /** @brief Sets the text horizontal alignment */+ void setTextAlignment(HAlign align) { textAlign_ = align; }++ /** @brief Gets the text horizontal alignment */+ HAlign getTextAlignment() const { return textAlign_; }+// =========================================================================// Widget Overrides// =========================================================================@@ -133,6 +140,7 @@ private:f32 fontSize_ = 14.0f;ButtonStyle buttonStyle_ = ButtonStyle::Default;CornerRadii cornerRadii_;+ HAlign textAlign_ = HAlign::Center;glm::vec2 cachedTextSize_{0.0f};bool textSizeDirty_ = true;