Skip to content

Add support for button color binding and unit tests#40

Merged
IvanMurzak merged 19 commits intomainfrom
35-can-you-add-button-support
Nov 24, 2025
Merged

Add support for button color binding and unit tests#40
IvanMurzak merged 19 commits intomainfrom
35-can-you-add-button-support

Conversation

@IvanMurzak
Copy link
Owner

@IvanMurzak IvanMurzak commented Nov 23, 2025

Introduce support for button color binding using MultiColorBinderEntry and GenericMultiColorBinder. Implement comprehensive unit tests to validate color updates across different button states and themes, ensuring accurate handling of color entries and error scenarios.

image

- Implement tests for switching themes in buttons, ensuring colors update correctly across different states.
- Add tests for updating colors in buttons, verifying that changes in the theme reflect accurately.
- Create tests for handling alpha overrides in button colors, ensuring that alpha values are preserved when switching themes.
- Introduce tests for button states, confirming that all five button states (Normal, Highlighted, Pressed, Selected, Disabled) are correctly set and retrieved.
- Validate the creation of MultiColorBinder instances, ensuring proper initialization of color entries and labels.
- Implement error handling tests for invalid indices and labels when setting colors.
@IvanMurzak IvanMurzak linked an issue Nov 23, 2025 that may be closed by this pull request
@IvanMurzak IvanMurzak self-assigned this Nov 23, 2025
@IvanMurzak IvanMurzak requested a review from Copilot November 23, 2025 11:48
@IvanMurzak IvanMurzak added the enhancement New feature or request label Nov 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces button color binding support for the Unity theme system. It implements a flexible multi-color binding architecture that allows UI components (specifically buttons) to bind their color properties to theme colors, with support for alpha overrides and dynamic theme switching.

Key changes:

  • Implemented a base multi-color binder architecture with BaseMultiColorBinder and GenericMultiColorBinder
  • Added ButtonColorBinder to bind all 5 button states (Normal, Highlighted, Pressed, Selected, Disabled)
  • Created comprehensive test suites covering creation, color setting, theme switching, and alpha overrides

Reviewed changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
MultiColorBinderEntry.cs Data structure for storing color entry label and binding data
BaseMultiColorBinder.cs Abstract base class providing core multi-color binding functionality and lifecycle management
BaseMultiColorBinder.Public.cs Public API methods for setting colors and alpha overrides by index or label
BaseMultiColorBinder.Validate.cs Validation logic for color entries in editor
GenericMultiColorBinder.cs Generic implementation for components requiring multi-color binding
ButtonColorBinder.cs Concrete implementation for Unity Button ColorBlock binding
MultiColorBinderEntryDrawer.cs Custom property drawer for editor UI
TestUtils.*.cs Test utility functions and constants for multi-color binder testing
TestMultiColorBinder.*.cs Comprehensive test suites for runtime and editor modes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 61 out of 61 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Implemented SelectableColorBinder to bind theme colors to Unity Selectable's ColorBlock, supporting all five states: Normal, Highlighted, Pressed, Selected, and Disabled.
- Created associated tests to ensure functionality for Selectable states, including color setting, alpha overrides, and theme switching.
- Updated existing test cases to replace Button references with Selectable, ensuring comprehensive coverage for the new binder.
- Simplified test methods in TestMultiColorBinder.SwitchTheme.cs by replacing manual theme switching and color assertions with utility methods for better readability and maintainability.
- Updated TestMultiColorBinder.UpdateColors.cs to utilize utility methods for color updates and assertions, reducing code duplication.
- Refactored TestMultiColorBinder.ButtonStates.cs to leverage utility methods for state color assertions and alpha overrides, enhancing test clarity.
- Streamlined TestMultiColorBinder.Create.cs by using utility methods for initialization and label checks, improving test structure.
- Enhanced TestMultiColorBinder.SetColors.Alpha.cs and TestMultiColorBinder.SetColors.cs to utilize utility methods for setting colors and validating states, ensuring consistent testing practices.
…Block

Refactor BaseMultiColorBinder to improve color entry initialization
…rBinderEntriesDrawer, and MultiColorBinderEntryDrawer for consistency; update FixedMultiColorBinderEntries to use colorBindings instead of entries.
…ate entry labels; adjust margin settings in MultiColorBinderEntryDrawer for improved layout consistency
@IvanMurzak IvanMurzak merged commit 8d03dc2 into main Nov 24, 2025
49 checks passed
@IvanMurzak IvanMurzak deleted the 35-can-you-add-button-support branch November 24, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can you add Button support?

1 participant

Comments