diff --git a/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.cpp b/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.cpp index 9161523d..72c99593 100644 --- a/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.cpp +++ b/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.cpp @@ -86,6 +86,23 @@ BorderlessWindowChromeHitTarget HitTestBorderlessWindowChrome( return BorderlessWindowChromeHitTarget::None; } +BorderlessWindowChromeButtonBehavior ResolveBorderlessWindowChromeButtonBehavior( + BorderlessWindowChromeHitTarget target) { + switch (target) { + case BorderlessWindowChromeHitTarget::PinButton: + return BorderlessWindowChromeButtonBehavior::Toggle; + case BorderlessWindowChromeHitTarget::MinimizeButton: + case BorderlessWindowChromeHitTarget::MaximizeRestoreButton: + return BorderlessWindowChromeButtonBehavior::Action; + case BorderlessWindowChromeHitTarget::CloseButton: + return BorderlessWindowChromeButtonBehavior::DestructiveAction; + case BorderlessWindowChromeHitTarget::DragRegion: + case BorderlessWindowChromeHitTarget::None: + default: + return BorderlessWindowChromeButtonBehavior::None; + } +} + } // namespace XCEngine::UI::Editor::Host namespace XCEngine::UI::Editor::Host { @@ -228,11 +245,12 @@ void AppendPinGlyph( UIColor ResolveButtonFillColor( BorderlessWindowChromeHitTarget target, const BorderlessWindowChromeState& state, - const BorderlessWindowChromePalette& palette, - bool topmostPinned) { + const BorderlessWindowChromePalette& palette) { + const BorderlessWindowChromeButtonBehavior behavior = + ResolveBorderlessWindowChromeButtonBehavior(target); const bool hovered = state.hoveredTarget == target; const bool pressed = state.pressedTarget == target; - if (target == BorderlessWindowChromeHitTarget::CloseButton) { + if (behavior == BorderlessWindowChromeButtonBehavior::DestructiveAction) { if (pressed) { return palette.closeButtonPressedColor; } @@ -242,16 +260,14 @@ UIColor ResolveButtonFillColor( return kTransparentColor; } - if (target == BorderlessWindowChromeHitTarget::PinButton && topmostPinned && - !hovered && !pressed) { - return palette.buttonActiveColor; - } - - if (pressed) { - return palette.buttonPressedColor; - } - if (hovered) { - return palette.buttonHoverColor; + if (behavior == BorderlessWindowChromeButtonBehavior::Toggle || + behavior == BorderlessWindowChromeButtonBehavior::Action) { + if (pressed) { + return palette.buttonPressedColor; + } + if (hovered) { + return palette.buttonHoverColor; + } } return kTransparentColor; } @@ -261,13 +277,17 @@ UIColor ResolveIconColor( const BorderlessWindowChromeState& state, const BorderlessWindowChromePalette& palette, bool topmostPinned) { - if (target == BorderlessWindowChromeHitTarget::CloseButton && + const BorderlessWindowChromeButtonBehavior behavior = + ResolveBorderlessWindowChromeButtonBehavior(target); + if (behavior == BorderlessWindowChromeButtonBehavior::DestructiveAction && (state.hoveredTarget == target || state.pressedTarget == target)) { return palette.closeIconHoverColor; } - if (target == BorderlessWindowChromeHitTarget::PinButton && topmostPinned) { - return palette.iconActiveColor; + if (behavior == BorderlessWindowChromeButtonBehavior::Toggle) { + return topmostPinned + ? palette.toggleIconOnColor + : palette.toggleIconOffColor; } return palette.iconColor; @@ -298,7 +318,7 @@ void AppendBorderlessWindowChrome( continue; } - const UIColor fill = ResolveButtonFillColor(button.target, state, palette, topmostPinned); + const UIColor fill = ResolveButtonFillColor(button.target, state, palette); if (fill.a > 0.0f) { drawList.AddFilledRect(button.rect, fill); } diff --git a/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.h b/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.h index aa37aa3b..a0cea07c 100644 --- a/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.h +++ b/editor/app/Platform/Win32/Chrome/BorderlessWindowChrome.h @@ -19,6 +19,13 @@ enum class BorderlessWindowChromeHitTarget : std::uint8_t { CloseButton }; +enum class BorderlessWindowChromeButtonBehavior : std::uint8_t { + None = 0, + Toggle, + Action, + DestructiveAction, +}; + struct BorderlessWindowChromeMetrics { float buttonWidth = 46.0f; float buttonInsetX = 0.0f; @@ -32,16 +39,16 @@ struct BorderlessWindowChromePalette { ::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f); ::XCEngine::UI::UIColor buttonPressedColor = ::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f); - ::XCEngine::UI::UIColor buttonActiveColor = - ::XCEngine::UI::UIColor(0.20f, 0.20f, 0.20f, 1.0f); ::XCEngine::UI::UIColor closeButtonHoverColor = ::XCEngine::UI::UIColor(0.84f, 0.28f, 0.22f, 1.0f); ::XCEngine::UI::UIColor closeButtonPressedColor = ::XCEngine::UI::UIColor(0.72f, 0.20f, 0.16f, 1.0f); ::XCEngine::UI::UIColor iconColor = ::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f); - ::XCEngine::UI::UIColor iconActiveColor = - ::XCEngine::UI::UIColor(1.0f, 1.0f, 1.0f, 1.0f); + ::XCEngine::UI::UIColor toggleIconOffColor = + ::XCEngine::UI::UIColor(0.64f, 0.64f, 0.64f, 1.0f); + ::XCEngine::UI::UIColor toggleIconOnColor = + ::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f); ::XCEngine::UI::UIColor closeIconHoverColor = ::XCEngine::UI::UIColor(1.0f, 1.0f, 1.0f, 1.0f); }; @@ -70,6 +77,9 @@ BorderlessWindowChromeHitTarget HitTestBorderlessWindowChrome( const BorderlessWindowChromeLayout& layout, const ::XCEngine::UI::UIPoint& point); +BorderlessWindowChromeButtonBehavior ResolveBorderlessWindowChromeButtonBehavior( + BorderlessWindowChromeHitTarget target); + void AppendBorderlessWindowChrome( ::XCEngine::UI::UIDrawList& drawList, const BorderlessWindowChromeLayout& layout, diff --git a/editor/app/Platform/Win32/Chrome/EditorWindowChromeController.cpp b/editor/app/Platform/Win32/Chrome/EditorWindowChromeController.cpp index af4bd621..f99b8e2c 100644 --- a/editor/app/Platform/Win32/Chrome/EditorWindowChromeController.cpp +++ b/editor/app/Platform/Win32/Chrome/EditorWindowChromeController.cpp @@ -39,10 +39,8 @@ bool IsVerboseResizeTraceEnabled() { } bool IsChromeButtonTarget(Host::BorderlessWindowChromeHitTarget target) { - return target == Host::BorderlessWindowChromeHitTarget::PinButton || - target == Host::BorderlessWindowChromeHitTarget::MinimizeButton || - target == Host::BorderlessWindowChromeHitTarget::MaximizeRestoreButton || - target == Host::BorderlessWindowChromeHitTarget::CloseButton; + return Host::ResolveBorderlessWindowChromeButtonBehavior(target) != + Host::BorderlessWindowChromeButtonBehavior::None; } float ResolveLeadingChromeButtonLeft( diff --git a/editor/app/UtilityWindows/EditorUtilityWindowRegistry.cpp b/editor/app/UtilityWindows/EditorUtilityWindowRegistry.cpp index 67fd1eff..0bc0ef7d 100644 --- a/editor/app/UtilityWindows/EditorUtilityWindowRegistry.cpp +++ b/editor/app/UtilityWindows/EditorUtilityWindowRegistry.cpp @@ -28,7 +28,7 @@ constexpr EditorUtilityWindowDescriptor kColorPickerUtilityWindowDescriptor = { .title = L"Color Picker", .chromePolicy = kUtilityWindowChromePolicy, .nativeStylePolicy = kUtilityWindowNativeStylePolicy, - .preferredOuterSize = UISize(400.0f, 620.0f), + .preferredOuterSize = UISize(400.0f, 600.0f), .minimumOuterSize = UISize(360.0f, 560.0f), };