Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Substance] SubstanceColorSchemeBundle alphas are not keyed correctly #193

Closed
kirill-grouchnikov opened this issue Aug 22, 2019 · 2 comments

Comments

@kirill-grouchnikov
Copy link
Owner

commented Aug 22, 2019

While color schemes effectively have two levels of keys in colorSchemeMap (association kind and component state), the alphas only use one key level in stateAlphaMap (component state).

This means that code like this (from Twilight skin):

        defaultSchemeBundle.registerColorScheme(enabledScheme, 0.6f,
                ComponentState.DISABLED_UNSELECTED);
        defaultSchemeBundle.registerColorScheme(activeScheme, 0.6f,
                ComponentState.DISABLED_SELECTED);

        defaultSchemeBundle.registerColorScheme(markActiveScheme, 0.6f,
                ColorSchemeAssociationKind.MARK, ComponentState.DISABLED_SELECTED,
                ComponentState.DISABLED_UNSELECTED);

only happens to work because it uses the same alpha value of 0.6f in the third call. But if a skin needs to use a different alpha for the specific association kind (like MARK), it cannot. Even worse, the last call to registerColorScheme wins, overwriting the original values for the specific component state(s).

The getAlpha and getHighlightAlpha should be changed to accept association kind as well, along with all places that use SubstanceColorSchemeUtilities.getAlpha - where every call needs to be explicit about the association kind that it's going to use.

@kirill-grouchnikov

This comment has been minimized.

Copy link
Owner Author

commented Aug 23, 2019

SubstanceColorSchemeBundle.registerColorScheme APIs that accept the alpha will be split into two separate APIs.

The first one - already exists, so no change there - accepts color scheme, component state(s) and association kind. The second one - which is a new one - accepts alpha and component state(s).

This is an API breaking change, as a call like this:

        defaultSchemeBundle.registerColorScheme(markActiveScheme, 0.6f,
                ColorSchemeAssociationKind.MARK, ComponentState.DISABLED_SELECTED,
                ComponentState.DISABLED_UNSELECTED);

will have to be replaced by this:

        defaultSchemeBundle.registerAlpha(0.6f,
                ComponentState.DISABLED_SELECTED,
                ComponentState.DISABLED_UNSELECTED);
        defaultSchemeBundle.registerColorScheme(markActiveScheme,
                ColorSchemeAssociationKind.MARK, ComponentState.DISABLED_SELECTED,
                ComponentState.DISABLED_UNSELECTED);

It still will be 2.5 instead of 3.0.

@kirill-grouchnikov

This comment has been minimized.

Copy link
Owner Author

commented Aug 23, 2019

The same change will apply to registerHighlightColorScheme. It will go from:

defaultColorSchemeBundle.registerHighlightColorScheme(greenControls,
	0.75f, ComponentState.ROLLOVER_UNSELECTED);
defaultColorSchemeBundle.registerHighlightColorScheme(greenControls,
	0.85f, ComponentState.SELECTED);
defaultColorSchemeBundle.registerHighlightColorScheme(greenControls,
	0.95f, ComponentState.ROLLOVER_SELECTED);
defaultColorSchemeBundle.registerHighlightColorScheme(greenControls,
	1.0f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED);

to

defaultColorSchemeBundle.registerHighlightAlpha(0.75f, ComponentState.ROLLOVER_UNSELECTED);
defaultColorSchemeBundle.registerHighlightAlpha(0.85f, ComponentState.SELECTED);
defaultColorSchemeBundle.registerHighlightAlpha(0.95f, ComponentState.ROLLOVER_SELECTED);
defaultColorSchemeBundle.registerHighlightAlpha(1.0f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED);
defaultColorSchemeBundle.registerHighlightColorScheme(greenControls, ComponentState.ROLLOVER_UNSELECTED,
	ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED,
	ComponentState.ARMED, ComponentState.ROLLOVER_ARMED);
kirill-grouchnikov added a commit that referenced this issue Aug 23, 2019
Night Shade skin, some API tweaks
* Kotlin -> 1.3.50
* Kotlin coroutines -> 1.3.0
* Gradle -> 5.6
* Fix for Substance alpha APIs - #193
* Tweak scroll bar track background under dark skins - #192
* New Night Shade skin - #191
* Add onTimelineDone to Torch DSL
* Small tweak to general area of Twilight skin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.