From caabba2665decbbd012ecdfffd50e07ea6a005c7 Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Thu, 12 Sep 2024 12:55:38 -0700 Subject: [PATCH] Button, Label, TextCallout, ToggleButton: add public condenseWhite style to pass to internal TextField --- src/feathers/controls/Button.hx | 26 ++++++++++++++++++++++++++ src/feathers/controls/Label.hx | 26 ++++++++++++++++++++++++++ src/feathers/controls/TextCallout.hx | 23 +++++++++++++++++++++++ src/feathers/controls/ToggleButton.hx | 26 ++++++++++++++++++++++++++ 4 files changed, 101 insertions(+) diff --git a/src/feathers/controls/Button.hx b/src/feathers/controls/Button.hx index 4ea632f8..6ec95a1d 100644 --- a/src/feathers/controls/Button.hx +++ b/src/feathers/controls/Button.hx @@ -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 = "

Hello

\n

World

"; + button.condenseWhite = true; + ``` + + @default false + + @see `Button.htmlText` + + @since 1.4.0 + **/ + @:style + public var condenseWhite:Bool = false; + #end + private var _stateToIcon:Map = new Map(); private var _iconMeasurements:Measurements = null; private var _currentIcon:DisplayObject = null; @@ -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; diff --git a/src/feathers/controls/Label.hx b/src/feathers/controls/Label.hx index d937ef2b..aa1d39a6 100644 --- a/src/feathers/controls/Label.hx +++ b/src/feathers/controls/Label.hx @@ -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 = "

Hello

\n

World

"; + 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; @@ -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; diff --git a/src/feathers/controls/TextCallout.hx b/src/feathers/controls/TextCallout.hx index bded1bd2..24922160 100644 --- a/src/feathers/controls/TextCallout.hx +++ b/src/feathers/controls/TextCallout.hx @@ -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 = "

Hello

\n

World

"; + 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(); @@ -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 } diff --git a/src/feathers/controls/ToggleButton.hx b/src/feathers/controls/ToggleButton.hx index ae687c0e..df0e1d6c 100644 --- a/src/feathers/controls/ToggleButton.hx +++ b/src/feathers/controls/ToggleButton.hx @@ -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 = "

Hello

\n

World

"; + 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. @@ -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;