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

FeathersControl: Improve disabledAlpha property #177

Merged
merged 3 commits into from
Apr 26, 2024
Merged
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
43 changes: 36 additions & 7 deletions src/feathers/core/FeathersControl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ class FeathersControl extends MeasureSprite implements IUIControl implements IVa
return this._enabled;
}
this._enabled = value;
if (this._enabled || this.disabledAlpha == null) {
if (this._enabled || this._disabledAlpha == null) {
super.alpha = this._explicitAlpha;
} else if (!this._enabled && this.disabledAlpha != null) {
super.alpha = this.disabledAlpha;
} else if (!this._enabled && this._disabledAlpha != null) {
super.alpha = this._disabledAlpha;
}
this.setInvalid(STATE);
if (this._enabled) {
Expand Down Expand Up @@ -342,22 +342,44 @@ class FeathersControl extends MeasureSprite implements IUIControl implements IVa

#if (flash && haxe_ver < 4.3) @:setter(alpha) #else override #end private function set_alpha(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end {
this._explicitAlpha = value;
if (this._enabled || this.disabledAlpha == null) {
if (this._enabled || this._disabledAlpha == null) {
super.alpha = value;
}
#if (!flash || haxe_ver >= 4.3)
return this._explicitAlpha;
#end
}


private var _disabledAlpha:Null<Float> = null;
/**
When `disabledAlpha` is not `null`, sets the `alpha` property to this
value when the the `enabled` property is set to `false`.

@since 1.0.0
**/
@:style
public var disabledAlpha:Null<Float> = null;
@style
public var disabledAlpha(get, set):Null<Float>;

private function get_disabledAlpha():Null<Float> {
return this._disabledAlpha;
}

private function set_disabledAlpha(value:Null<Float>):Null<Float> {
if (!this.setStyle("disabledAlpha")) {
return this._disabledAlpha;
}
// in a -final build, this forces the clearStyle
// function to be kept if the property is kept
// otherwise, it would be removed by dce
this._previousClearStyle = this.clearStyle_disabledAlpha;
this._disabledAlpha = value;
if (this._enabled || this._disabledAlpha == null) {
super.alpha = this._explicitAlpha;
} else if (!this._enabled && this._disabledAlpha != null) {
super.alpha = this._disabledAlpha;
}
return this._disabledAlpha;
}

private var _focusManager:IFocusManager = null;

Expand Down Expand Up @@ -612,6 +634,13 @@ class FeathersControl extends MeasureSprite implements IUIControl implements IVa
return this._focusRectSkin;
}

@:noCompletion
private function clearStyle_disabledAlpha():Null<Float> {
this._disabledAlpha = null;
super.alpha = this._explicitAlpha;
return this._disabledAlpha;
}

@:noCompletion
private function clearStyle_focusPaddingTop():Float {
this._focusPaddingTop = 0.0;
Expand Down
Loading