Skip to content

Commit

Permalink
Button, Label, TextCallout, ToggleButton: add public condenseWhite st…
Browse files Browse the repository at this point in the history
…yle to pass to internal TextField
  • Loading branch information
joshtynjala committed Sep 12, 2024
1 parent 5bbcf2a commit caabba2
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/feathers/controls/Button.hx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,28 @@ class Button extends BasicButton implements ITextControl implements IHTMLTextCon
@:style
public var wordWrap:Bool = false;

#if (openfl >= "9.2.0" || flash)
/**
Determines if the whitespace in the `htmlText` is condensed or affects
the text layout.
In the following example, the button's HTML text whitespace is condensed:
```haxe
button.htmlText = "<p>Hello</p>\n<p>World</p>";
button.condenseWhite = true;
```
@default false
@see `Button.htmlText`
@since 1.4.0
**/
@:style
public var condenseWhite:Bool = false;
#end

private var _stateToIcon:Map<ButtonState, DisplayObject> = new Map();
private var _iconMeasurements:Measurements = null;
private var _currentIcon:DisplayObject = null;
Expand Down Expand Up @@ -1038,6 +1060,10 @@ class Button extends BasicButton implements ITextControl implements IHTMLTextCon
this.textField.styleSheet = this.styleSheet;
this._updatedTextStyles = true;
}
if (this.textField.condenseWhite != this.condenseWhite) {
this.textField.condenseWhite = this.condenseWhite;
this._updatedTextStyles = true;
}
#end
var textFormat = this.getCurrentTextFormat();
var simpleTextFormat = textFormat != null ? textFormat.toSimpleTextFormat() : null;
Expand Down
26 changes: 26 additions & 0 deletions src/feathers/controls/Label.hx
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,28 @@ class Label extends FeathersControl implements ITextControl implements IHTMLText
@:style
public var wordWrap:Bool = false;

#if (openfl >= "9.2.0" || flash)
/**
Determines if the whitespace in the `htmlText` is condensed or affects
the text layout.
In the following example, the label's HTML text whitespace is condensed:
```haxe
label.htmlText = "<p>Hello</p>\n<p>World</p>";
label.condenseWhite = true;
```
@default false
@see `Label.htmlText`
@since 1.4.0
**/
@:style
public var condenseWhite:Bool = false;
#end

private var _currentBackgroundSkin:DisplayObject = null;
private var _backgroundSkinMeasurements:Measurements = null;

Expand Down Expand Up @@ -697,6 +719,10 @@ class Label extends FeathersControl implements ITextControl implements IHTMLText
this.textField.styleSheet = this.styleSheet;
this._updatedTextStyles = true;
}
if (this.textField.condenseWhite != this.condenseWhite) {
this.textField.condenseWhite = this.condenseWhite;
this._updatedTextStyles = true;
}
#end
var textFormat = this.getCurrentTextFormat();
var simpleTextFormat = textFormat != null ? textFormat.toSimpleTextFormat() : null;
Expand Down
23 changes: 23 additions & 0 deletions src/feathers/controls/TextCallout.hx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,28 @@ class TextCallout extends Callout implements ITextControl implements IHTMLTextCo
@:style
public var wordWrap:Bool = false;

#if (openfl >= "9.2.0" || flash)
/**
Determines if the whitespace in the `htmlText` is condensed or affects
the text layout.
In the following example, the callout's HTML text whitespace is condensed:
```haxe
callout.htmlText = "<p>Hello</p>\n<p>World</p>";
callout.condenseWhite = true;
```
@default false
@see `TextCallout.htmlText`
@since 1.4.0
**/
@:style
public var condenseWhite:Bool = false;
#end

private function initializeTextCalloutTheme():Void {
#if !feathersui_disable_default_theme
feathers.themes.steel.components.SteelTextCalloutStyles.initialize();
Expand Down Expand Up @@ -305,6 +327,7 @@ class TextCallout extends Callout implements ITextControl implements IHTMLTextCo
this.label.embedFonts = this.embedFonts;
#if (openfl >= "9.2.0" || flash)
this.label.styleSheet = this.styleSheet;
this.label.condenseWhite = this.condenseWhite;
#end
}

Expand Down
26 changes: 26 additions & 0 deletions src/feathers/controls/ToggleButton.hx
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,28 @@ class ToggleButton extends BasicToggleButton implements ITextControl implements
@:style
public var wordWrap:Bool = false;

#if (openfl >= "9.2.0" || flash)
/**
Determines if the whitespace in the `htmlText` is condensed or affects
the text layout.
In the following example, the button's HTML text whitespace is condensed:
```haxe
button.htmlText = "<p>Hello</p>\n<p>World</p>";
button.condenseWhite = true;
```
@default false
@see `Button.htmlText`
@since 1.4.0
**/
@:style
public var condenseWhite:Bool = false;
#end

/**
The font styles used to render the button's text when the button is
disabled.
Expand Down Expand Up @@ -1117,6 +1139,10 @@ class ToggleButton extends BasicToggleButton implements ITextControl implements
this.textField.styleSheet = this.styleSheet;
this._updatedTextStyles = true;
}
if (this.textField.condenseWhite != this.condenseWhite) {
this.textField.condenseWhite = this.condenseWhite;
this._updatedTextStyles = true;
}
#end
var textFormat = this.getCurrentTextFormat();
var simpleTextFormat = textFormat != null ? textFormat.toSimpleTextFormat() : null;
Expand Down

0 comments on commit caabba2

Please sign in to comment.