Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void ApplyBaseStyles()

// Font styling
style.fontSize = Tokens.FontSize.Base;
style.unityFontStyleAndWeight = FontStyle.Bold;
style.unityFontStyleAndWeight = FontStyle.Normal;

// No border for glassmorphic look
style.borderTopWidth = 0;
Expand All @@ -124,6 +124,9 @@ private void ApplyBaseStyles()

// Smooth glassmorphic transitions
JTheme.ApplyTransition(this);

// Pointer cursor for clickable element
JTheme.ApplyPointerCursor(this);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// JIconButton.cs
//
// Author:
// JasonXuDeveloper <jason@xgamedev.net>
//
// Copyright (c) 2025 JEngine
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using JEngine.UI.Editor.Theming;
using UnityEngine;
using UnityEngine.UIElements;

namespace JEngine.UI.Editor.Components.Button
{
/// <summary>
/// A small icon button with transparent background, suitable for toolbars and inline actions.
/// </summary>
public class JIconButton : UnityEngine.UIElements.Button
{
/// <summary>
/// Creates a new icon button.
/// </summary>
/// <param name="text">The button text (typically an icon character or short text).</param>
/// <param name="onClick">Click handler.</param>
/// <param name="tooltip">Optional tooltip.</param>
public JIconButton(string text, Action onClick = null, string tooltip = null)
{
this.text = text;
this.tooltip = tooltip;

AddToClassList("j-icon-button");
ApplyStyles();

if (onClick != null)
{
clicked += onClick;
}

// Hover events
RegisterCallback<MouseEnterEvent>(OnMouseEnter);
RegisterCallback<MouseLeaveEvent>(OnMouseLeave);
}

private void ApplyStyles()
{
// Small size
style.width = 22;
style.height = 18;
style.minWidth = 18;
style.minHeight = 18;

// No padding/margin
style.marginLeft = 2;
style.marginRight = 0;
style.marginTop = 0;
style.marginBottom = 0;
style.paddingLeft = 0;
style.paddingRight = 0;
style.paddingTop = 0;
style.paddingBottom = 0;

// Transparent background
style.backgroundColor = Color.clear;

// No border
style.borderTopWidth = 0;
style.borderRightWidth = 0;
style.borderBottomWidth = 0;
style.borderLeftWidth = 0;
style.borderTopLeftRadius = Tokens.BorderRadius.Sm;
style.borderTopRightRadius = Tokens.BorderRadius.Sm;
style.borderBottomLeftRadius = Tokens.BorderRadius.Sm;
style.borderBottomRightRadius = Tokens.BorderRadius.Sm;

// Text styling
style.fontSize = Tokens.FontSize.Xs;
style.color = Tokens.Colors.TextMuted;
style.unityTextAlign = TextAnchor.MiddleCenter;

// Pointer cursor
JTheme.ApplyPointerCursor(this);

// Smooth transitions
JTheme.ApplyTransition(this);
}

private void OnMouseEnter(MouseEnterEvent evt)
{
style.color = Tokens.Colors.TextPrimary;
style.backgroundColor = Tokens.Colors.BgElevated;
}

private void OnMouseLeave(MouseLeaveEvent evt)
{
style.color = Tokens.Colors.TextMuted;
style.backgroundColor = Color.clear;
}

/// <summary>
/// Sets the button tooltip.
/// </summary>
public JIconButton WithTooltip(string tooltip)
{
this.tooltip = tooltip;
return this;
}

/// <summary>
/// Sets custom size for the button.
/// </summary>
public JIconButton WithSize(float width, float height)
{
style.width = width;
style.height = height;
return this;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ private void ApplyBaseStyles()
style.borderTopRightRadius = Tokens.BorderRadius.Sm;
style.borderBottomLeftRadius = Tokens.BorderRadius.Sm;
style.borderBottomRightRadius = Tokens.BorderRadius.Sm;
style.paddingTop = 4;
style.paddingRight = 10;
style.paddingBottom = 4;
style.paddingLeft = 10;
style.paddingTop = Tokens.Spacing.Sm;
style.paddingRight = Tokens.Spacing.MD;
style.paddingBottom = Tokens.Spacing.Sm;
style.paddingLeft = Tokens.Spacing.MD;
// Remove all margins (like JDropdown does)
style.marginLeft = 0;
style.marginRight = 0;
style.marginTop = 0;
style.marginBottom = 0;
style.minHeight = 22;
style.maxHeight = 24;
style.fontSize = 11;
style.fontSize = Tokens.FontSize.Sm;
style.unityFontStyleAndWeight = FontStyle.Normal;
// No border for cleaner look
style.borderTopWidth = 0;
Expand All @@ -126,6 +126,9 @@ private void ApplyBaseStyles()
style.overflow = Overflow.Hidden;
style.textOverflow = TextOverflow.Ellipsis;
style.whiteSpace = WhiteSpace.NoWrap;

// Pointer cursor for clickable element
JTheme.ApplyPointerCursor(this);
}

private void OnClicked()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
// THE SOFTWARE.

using JEngine.UI.Editor.Theming;
using UnityEngine;
using UnityEngine.UIElements;

namespace JEngine.UI.Editor.Components.Feedback
Expand All @@ -48,11 +47,8 @@ public JLogView(int maxLines = 100) : base("j-log-view")
_currentLineCount = 0;

// Apply theme-aware background
// Dark mode: subtle layer (not too dark)
// Light mode: surface layer (grey)
style.backgroundColor = Tokens.IsDarkTheme
? Tokens.Colors.BgSubtle
: Tokens.Colors.BgSurface;
// Use input background for consistent control styling
style.backgroundColor = Tokens.Colors.BgInput;

// Standard borders
style.borderTopColor = Tokens.Colors.Border;
Expand Down Expand Up @@ -135,7 +131,7 @@ public JLogView Log(string message, bool isError = false)
entry.style.fontSize = Tokens.FontSize.Sm;
entry.style.paddingTop = Tokens.Spacing.Xs;
entry.style.paddingBottom = Tokens.Spacing.Xs;
entry.style.borderBottomColor = new Color(1, 1, 1, 0.05f);
entry.style.borderBottomColor = Tokens.Colors.BorderSubtle;
entry.style.borderBottomWidth = 1;
entry.style.color = isError ? Tokens.Colors.StatusError : Tokens.Colors.TextSecondary;
entry.style.whiteSpace = WhiteSpace.Normal;
Expand Down
Loading