From 9feb1a68b339720dfb1d36bade0d01bdc56978da Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 23 Feb 2024 10:21:05 -0800 Subject: [PATCH] fix duplicate icon drawing code and switch to MultiSkin in a couple places --- .../components/MinimalComboBoxStyles.hx | 17 +- .../components/MinimalDatePickerStyles.hx | 212 +++++++++--------- .../components/MinimalFormItemStyles.hx | 41 ++-- .../MinimalHierarchicalItemRendererStyles.hx | 64 +++--- .../MinimalPopUpDatePickerStyles.hx | 19 +- .../components/MinimalPopUpListViewStyles.hx | 35 ++- 6 files changed, 194 insertions(+), 194 deletions(-) diff --git a/src/com/feathersui/themes/minimal/components/MinimalComboBoxStyles.hx b/src/com/feathersui/themes/minimal/components/MinimalComboBoxStyles.hx index 0850ebd..022497a 100644 --- a/src/com/feathersui/themes/minimal/components/MinimalComboBoxStyles.hx +++ b/src/com/feathersui/themes/minimal/components/MinimalComboBoxStyles.hx @@ -61,17 +61,11 @@ class MinimalComboBoxStyles { var icon = new MultiSkin(); var defaultIcon = new Shape(); - defaultIcon.graphics.beginFill(theme.labelTextColor); - defaultIcon.graphics.drawRect(2.0, 0.0, 1.0, 5.0); - defaultIcon.graphics.drawRect(0.0, 2.0, 5.0, 1.0); - defaultIcon.graphics.endFill(); + drawArrowIcon(defaultIcon, theme.labelTextColor); icon.defaultView = defaultIcon; var disabledIcon = new Shape(); - disabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - disabledIcon.graphics.drawRect(2.0, 0.0, 1.0, 5.0); - disabledIcon.graphics.drawRect(0.0, 2.0, 5.0, 1.0); - disabledIcon.graphics.endFill(); + drawArrowIcon(disabledIcon, theme.labelTextDisabledColor); icon.disabledView = disabledIcon; button.icon = icon; @@ -89,4 +83,11 @@ class MinimalComboBoxStyles { }); } } + + private static function drawArrowIcon(icon:Shape, color:UInt):Void { + icon.graphics.beginFill(color); + icon.graphics.drawRect(2.0, 0.0, 1.0, 5.0); + icon.graphics.drawRect(0.0, 2.0, 5.0, 1.0); + icon.graphics.endFill(); + } } diff --git a/src/com/feathersui/themes/minimal/components/MinimalDatePickerStyles.hx b/src/com/feathersui/themes/minimal/components/MinimalDatePickerStyles.hx index 1010315..4966a2f 100644 --- a/src/com/feathersui/themes/minimal/components/MinimalDatePickerStyles.hx +++ b/src/com/feathersui/themes/minimal/components/MinimalDatePickerStyles.hx @@ -64,10 +64,9 @@ class MinimalDatePickerStyles { var isDesktop = DeviceUtil.isDesktop(); if (button.backgroundSkin == null) { var backgroundSkin = new MultiSkin(); - var buttonSkin = new MinimalButtonSkin(theme); - backgroundSkin.defaultView = buttonSkin; + backgroundSkin.defaultView = new MinimalButtonSkin(theme); + backgroundSkin.disabledView = new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None); backgroundSkin.setViewForState(ButtonState.UP, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); - backgroundSkin.setViewForState(ButtonState.DISABLED, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); if (isDesktop) { backgroundSkin.width = 16.0; backgroundSkin.height = 16.0; @@ -78,30 +77,17 @@ class MinimalDatePickerStyles { button.backgroundSkin = backgroundSkin; } if (button.icon == null) { - var icon = new Shape(); - icon.graphics.beginFill(0xff00ff, 0.0); - icon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); - icon.graphics.endFill(); - icon.graphics.beginFill(theme.labelTextColor); - icon.graphics.moveTo(2.0, 4.0); - icon.graphics.lineTo(6.0, 0.0); - icon.graphics.lineTo(6.0, 8.0); - icon.graphics.lineTo(2.0, 4.0); - icon.graphics.endFill(); - button.icon = icon; - } - if (button.getIconForState(ButtonState.DISABLED) == null) { + var icon = new MultiSkin(); + + var defaultIcon = new Shape(); + drawDecrementMonthIcon(defaultIcon, theme.labelTextColor); + icon.defaultView = defaultIcon; + var disabledIcon = new Shape(); - disabledIcon.graphics.beginFill(0xff00ff, 0.0); - disabledIcon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); - disabledIcon.graphics.endFill(); - disabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - disabledIcon.graphics.moveTo(2.0, 4.0); - disabledIcon.graphics.lineTo(6.0, 0.0); - disabledIcon.graphics.lineTo(6.0, 8.0); - disabledIcon.graphics.lineTo(2.0, 4.0); - disabledIcon.graphics.endFill(); - button.setIconForState(ButtonState.DISABLED, disabledIcon); + drawDecrementMonthIcon(disabledIcon, theme.labelTextDisabledColor); + icon.disabledView = disabledIcon; + + button.icon = icon; } button.setPadding(2.0); button.gap = 2.0; @@ -112,10 +98,9 @@ class MinimalDatePickerStyles { var isDesktop = DeviceUtil.isDesktop(); if (button.backgroundSkin == null) { var backgroundSkin = new MultiSkin(); - var buttonSkin = new MinimalButtonSkin(theme); - backgroundSkin.defaultView = buttonSkin; + backgroundSkin.defaultView = new MinimalButtonSkin(theme); + backgroundSkin.disabledView = new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None); backgroundSkin.setViewForState(ButtonState.UP, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); - backgroundSkin.setViewForState(ButtonState.DISABLED, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); if (isDesktop) { backgroundSkin.width = 16.0; backgroundSkin.height = 16.0; @@ -126,30 +111,17 @@ class MinimalDatePickerStyles { button.backgroundSkin = backgroundSkin; } if (button.icon == null) { - var icon = new Shape(); - icon.graphics.beginFill(0xff00ff, 0.0); - icon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); - icon.graphics.endFill(); - icon.graphics.beginFill(theme.labelTextColor); - icon.graphics.moveTo(2.0, 0.0); - icon.graphics.lineTo(6.0, 4.0); - icon.graphics.lineTo(2.0, 8.0); - icon.graphics.lineTo(2.0, 0.0); - icon.graphics.endFill(); - button.icon = icon; - } - if (button.getIconForState(ButtonState.DISABLED) == null) { + var icon = new MultiSkin(); + + var defaultIcon = new Shape(); + drawIncrementMonthIcon(defaultIcon, theme.labelTextColor); + icon.defaultView = defaultIcon; + var disabledIcon = new Shape(); - disabledIcon.graphics.beginFill(0xff00ff, 0.0); - disabledIcon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); - disabledIcon.graphics.endFill(); - disabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - disabledIcon.graphics.moveTo(2.0, 0.0); - disabledIcon.graphics.lineTo(6.0, 4.0); - disabledIcon.graphics.lineTo(2.0, 8.0); - disabledIcon.graphics.lineTo(2.0, 0.0); - disabledIcon.graphics.endFill(); - button.setIconForState(ButtonState.DISABLED, disabledIcon); + drawIncrementMonthIcon(disabledIcon, theme.labelTextDisabledColor); + icon.disabledView = disabledIcon; + + button.icon = icon; } button.setPadding(2.0); button.gap = 2.0; @@ -160,10 +132,9 @@ class MinimalDatePickerStyles { var isDesktop = DeviceUtil.isDesktop(); if (button.backgroundSkin == null) { var backgroundSkin = new MultiSkin(); - var buttonSkin = new MinimalButtonSkin(theme); - backgroundSkin.defaultView = buttonSkin; + backgroundSkin.defaultView = new MinimalButtonSkin(theme); + backgroundSkin.disabledView = new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None); backgroundSkin.setViewForState(ButtonState.UP, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); - backgroundSkin.setViewForState(ButtonState.DISABLED, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); if (isDesktop) { backgroundSkin.width = 16.0; backgroundSkin.height = 16.0; @@ -174,32 +145,17 @@ class MinimalDatePickerStyles { button.backgroundSkin = backgroundSkin; } if (button.icon == null) { - var icon = new Shape(); - icon.graphics.beginFill(theme.labelTextColor); - icon.graphics.moveTo(0.0, 4.0); - icon.graphics.lineTo(4.0, 0.0); - icon.graphics.lineTo(4.0, 8.0); - icon.graphics.lineTo(0.0, 4.0); - icon.graphics.moveTo(4.0, 4.0); - icon.graphics.lineTo(8.0, 0.0); - icon.graphics.lineTo(8.0, 8.0); - icon.graphics.lineTo(4.0, 4.0); - icon.graphics.endFill(); - button.icon = icon; - } - if (button.getIconForState(ButtonState.DISABLED) == null) { + var icon = new MultiSkin(); + + var defaultIcon = new Shape(); + drawDecrementYearIcon(defaultIcon, theme.labelTextColor); + icon.defaultView = defaultIcon; + var disabledIcon = new Shape(); - disabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - disabledIcon.graphics.moveTo(0.0, 4.0); - disabledIcon.graphics.lineTo(4.0, 0.0); - disabledIcon.graphics.lineTo(4.0, 8.0); - disabledIcon.graphics.lineTo(0.0, 4.0); - disabledIcon.graphics.moveTo(4.0, 4.0); - disabledIcon.graphics.lineTo(8.0, 0.0); - disabledIcon.graphics.lineTo(8.0, 8.0); - disabledIcon.graphics.lineTo(4.0, 4.0); - disabledIcon.graphics.endFill(); - button.setIconForState(ButtonState.DISABLED, disabledIcon); + drawDecrementYearIcon(disabledIcon, theme.labelTextDisabledColor); + icon.disabledView = disabledIcon; + + button.icon = icon; } button.setPadding(2.0); button.gap = 2.0; @@ -210,10 +166,9 @@ class MinimalDatePickerStyles { var isDesktop = DeviceUtil.isDesktop(); if (button.backgroundSkin == null) { var backgroundSkin = new MultiSkin(); - var buttonSkin = new MinimalButtonSkin(theme); - backgroundSkin.defaultView = buttonSkin; + backgroundSkin.defaultView = new MinimalButtonSkin(theme); + backgroundSkin.disabledView = new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None); backgroundSkin.setViewForState(ButtonState.UP, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); - backgroundSkin.setViewForState(ButtonState.DISABLED, new MinimalRectangleSkin(SolidColor(0xff00ff, 0.0), None)); if (isDesktop) { backgroundSkin.width = 16.0; backgroundSkin.height = 16.0; @@ -224,32 +179,17 @@ class MinimalDatePickerStyles { button.backgroundSkin = backgroundSkin; } if (button.icon == null) { - var icon = new Shape(); - icon.graphics.beginFill(theme.labelTextColor); - icon.graphics.moveTo(0.0, 0.0); - icon.graphics.lineTo(4.0, 4.0); - icon.graphics.lineTo(0.0, 8.0); - icon.graphics.lineTo(0.0, 0.0); - icon.graphics.moveTo(4.0, 0.0); - icon.graphics.lineTo(8.0, 4.0); - icon.graphics.lineTo(4.0, 8.0); - icon.graphics.lineTo(4.0, 0.0); - icon.graphics.endFill(); - button.icon = icon; - } - if (button.getIconForState(ButtonState.DISABLED) == null) { + var icon = new MultiSkin(); + + var defaultIcon = new Shape(); + drawIncrementYearIcon(defaultIcon, theme.labelTextColor); + icon.defaultView = defaultIcon; + var disabledIcon = new Shape(); - disabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - disabledIcon.graphics.moveTo(0.0, 0.0); - disabledIcon.graphics.lineTo(4.0, 4.0); - disabledIcon.graphics.lineTo(0.0, 8.0); - disabledIcon.graphics.lineTo(0.0, 0.0); - disabledIcon.graphics.moveTo(4.0, 0.0); - disabledIcon.graphics.lineTo(8.0, 4.0); - disabledIcon.graphics.lineTo(4.0, 8.0); - disabledIcon.graphics.lineTo(4.0, 0.0); - disabledIcon.graphics.endFill(); - button.setIconForState(ButtonState.DISABLED, disabledIcon); + drawIncrementYearIcon(disabledIcon, theme.labelTextDisabledColor); + icon.disabledView = disabledIcon; + + button.icon = icon; } button.setPadding(2.0); button.gap = 2.0; @@ -345,4 +285,60 @@ class MinimalDatePickerStyles { }); } } + + private static function drawDecrementMonthIcon(icon:Shape, color:UInt):Void { + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); + icon.graphics.endFill(); + icon.graphics.beginFill(color); + icon.graphics.moveTo(2.0, 4.0); + icon.graphics.lineTo(6.0, 0.0); + icon.graphics.lineTo(6.0, 8.0); + icon.graphics.lineTo(2.0, 4.0); + icon.graphics.endFill(); + } + + private static function drawIncrementMonthIcon(icon:Shape, color:UInt):Void { + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); + icon.graphics.endFill(); + icon.graphics.beginFill(color); + icon.graphics.moveTo(2.0, 0.0); + icon.graphics.lineTo(6.0, 4.0); + icon.graphics.lineTo(2.0, 8.0); + icon.graphics.lineTo(2.0, 0.0); + icon.graphics.endFill(); + } + + private static function drawDecrementYearIcon(icon:Shape, color:UInt):Void { + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); + icon.graphics.endFill(); + icon.graphics.beginFill(color); + icon.graphics.moveTo(0.0, 4.0); + icon.graphics.lineTo(4.0, 0.0); + icon.graphics.lineTo(4.0, 8.0); + icon.graphics.lineTo(0.0, 4.0); + icon.graphics.moveTo(4.0, 4.0); + icon.graphics.lineTo(8.0, 0.0); + icon.graphics.lineTo(8.0, 8.0); + icon.graphics.lineTo(4.0, 4.0); + icon.graphics.endFill(); + } + + private static function drawIncrementYearIcon(icon:Shape, color:UInt):Void { + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 8.0, 8.0); + icon.graphics.endFill(); + icon.graphics.beginFill(color); + icon.graphics.moveTo(0.0, 0.0); + icon.graphics.lineTo(4.0, 4.0); + icon.graphics.lineTo(0.0, 8.0); + icon.graphics.lineTo(0.0, 0.0); + icon.graphics.moveTo(4.0, 0.0); + icon.graphics.lineTo(8.0, 4.0); + icon.graphics.lineTo(4.0, 8.0); + icon.graphics.lineTo(4.0, 0.0); + icon.graphics.endFill(); + } } diff --git a/src/com/feathersui/themes/minimal/components/MinimalFormItemStyles.hx b/src/com/feathersui/themes/minimal/components/MinimalFormItemStyles.hx index aed4715..1bd0f1d 100644 --- a/src/com/feathersui/themes/minimal/components/MinimalFormItemStyles.hx +++ b/src/com/feathersui/themes/minimal/components/MinimalFormItemStyles.hx @@ -8,6 +8,7 @@ package com.feathersui.themes.minimal.components; +import feathers.skins.MultiSkin; import feathers.controls.FormItem; import feathers.style.Theme; import openfl.display.Shape; @@ -31,20 +32,16 @@ class MinimalFormItemStyles { if (styleProvider.getStyleFunction(FormItem, null) == null) { styleProvider.setStyleFunction(FormItem, null, function(formItem:FormItem):Void { if (formItem.requiredSkin == null) { - var requiredSkin = new Shape(); - requiredSkin.graphics.lineStyle(1.0, theme.dangerTextColor); - requiredSkin.graphics.moveTo(3.0, 0.5); - requiredSkin.graphics.lineTo(3.0, 4.5); - - requiredSkin.graphics.moveTo(1.0, 1.5); - requiredSkin.graphics.lineTo(5.0, 3.5); - requiredSkin.graphics.moveTo(1.0, 3.5); - requiredSkin.graphics.lineTo(5.0, 1.5); - - requiredSkin.graphics.lineStyle(); - requiredSkin.graphics.beginFill(0xff00ff, 0.0); - requiredSkin.graphics.drawRect(0.0, 0.0, 6.0, 5.0); - requiredSkin.graphics.endFill(); + var requiredSkin = new MultiSkin(); + + var defaultIcon = new Shape(); + drawRequiredIcon(defaultIcon, theme.dangerTextColor); + requiredSkin.defaultView = defaultIcon; + + var disabledIcon = new Shape(); + drawRequiredIcon(disabledIcon, theme.labelTextDisabledColor); + requiredSkin.disabledView = disabledIcon; + formItem.requiredSkin = requiredSkin; } @@ -59,4 +56,20 @@ class MinimalFormItemStyles { }); } } + + private static function drawRequiredIcon(icon:Shape, color:UInt):Void { + icon.graphics.lineStyle(1.0, color); + icon.graphics.moveTo(3.0, 0.5); + icon.graphics.lineTo(3.0, 4.5); + + icon.graphics.moveTo(1.0, 1.5); + icon.graphics.lineTo(5.0, 3.5); + icon.graphics.moveTo(1.0, 3.5); + icon.graphics.lineTo(5.0, 1.5); + + icon.graphics.lineStyle(); + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 6.0, 5.0); + icon.graphics.endFill(); + } } diff --git a/src/com/feathersui/themes/minimal/components/MinimalHierarchicalItemRendererStyles.hx b/src/com/feathersui/themes/minimal/components/MinimalHierarchicalItemRendererStyles.hx index ab2d117..6041e09 100644 --- a/src/com/feathersui/themes/minimal/components/MinimalHierarchicalItemRendererStyles.hx +++ b/src/com/feathersui/themes/minimal/components/MinimalHierarchicalItemRendererStyles.hx @@ -77,54 +77,46 @@ class MinimalHierarchicalItemRendererStyles { button.icon = icon; var defaultIcon = new Shape(); - defaultIcon.graphics.beginFill(0xff00ff, 0.0); - defaultIcon.graphics.drawRect(0.0, 0.0, 10.0, 10.0); - defaultIcon.graphics.endFill(); - defaultIcon.graphics.beginFill(theme.labelTextColor); - defaultIcon.graphics.moveTo(2.0, 2.0); - defaultIcon.graphics.lineTo(8.0, 5.0); - defaultIcon.graphics.lineTo(2.0, 8.0); - defaultIcon.graphics.lineTo(2.0, 2.0); - defaultIcon.graphics.endFill(); + drawDisclosureIconClosed(defaultIcon, theme.labelTextColor); icon.defaultView = defaultIcon; var disabledIcon = new Shape(); - disabledIcon.graphics.beginFill(0xff00ff, 0.0); - disabledIcon.graphics.drawRect(0.0, 0.0, 10.0, 10.0); - disabledIcon.graphics.endFill(); - disabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - disabledIcon.graphics.moveTo(2.0, 2.0); - disabledIcon.graphics.lineTo(8.0, 5.0); - disabledIcon.graphics.lineTo(2.0, 8.0); - disabledIcon.graphics.lineTo(2.0, 2.0); - disabledIcon.graphics.endFill(); + drawDisclosureIconClosed(disabledIcon, theme.labelTextDisabledColor); icon.disabledView = disabledIcon; var selectedIcon = new Shape(); - selectedIcon.graphics.beginFill(0xff00ff, 0.0); - selectedIcon.graphics.drawRect(0.0, 0.0, 10.0, 10.0); - selectedIcon.graphics.endFill(); - selectedIcon.graphics.beginFill(theme.labelTextColor); - selectedIcon.graphics.moveTo(2.0, 2.0); - selectedIcon.graphics.lineTo(8.0, 2.0); - selectedIcon.graphics.lineTo(5.0, 8.0); - selectedIcon.graphics.lineTo(2.0, 2.0); - selectedIcon.graphics.endFill(); + drawDisclosureIconOpen(selectedIcon, theme.labelTextColor); icon.selectedView = selectedIcon; var selectedDisabledIcon = new Shape(); - selectedDisabledIcon.graphics.beginFill(0xff00ff, 0.0); - selectedDisabledIcon.graphics.drawRect(0.0, 0.0, 10.0, 10.0); - selectedDisabledIcon.graphics.endFill(); - selectedDisabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - selectedDisabledIcon.graphics.moveTo(2.0, 2.0); - selectedDisabledIcon.graphics.lineTo(8.0, 2.0); - selectedDisabledIcon.graphics.lineTo(5.0, 8.0); - selectedDisabledIcon.graphics.lineTo(2.0, 2.0); - selectedDisabledIcon.graphics.endFill(); + drawDisclosureIconOpen(selectedDisabledIcon, theme.labelTextDisabledColor); icon.setViewForState(DISABLED(true), selectedDisabledIcon); } }); } } + + private static function drawDisclosureIconClosed(icon:Shape, color:UInt):Void { + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 10.0, 10.0); + icon.graphics.endFill(); + icon.graphics.beginFill(color); + icon.graphics.moveTo(2.0, 2.0); + icon.graphics.lineTo(8.0, 5.0); + icon.graphics.lineTo(2.0, 8.0); + icon.graphics.lineTo(2.0, 2.0); + icon.graphics.endFill(); + } + + private static function drawDisclosureIconOpen(icon:Shape, color:UInt):Void { + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 10.0, 10.0); + icon.graphics.endFill(); + icon.graphics.beginFill(color); + icon.graphics.moveTo(2.0, 2.0); + icon.graphics.lineTo(8.0, 2.0); + icon.graphics.lineTo(5.0, 8.0); + icon.graphics.lineTo(2.0, 2.0); + icon.graphics.endFill(); + } } diff --git a/src/com/feathersui/themes/minimal/components/MinimalPopUpDatePickerStyles.hx b/src/com/feathersui/themes/minimal/components/MinimalPopUpDatePickerStyles.hx index bde7bc6..72154f0 100644 --- a/src/com/feathersui/themes/minimal/components/MinimalPopUpDatePickerStyles.hx +++ b/src/com/feathersui/themes/minimal/components/MinimalPopUpDatePickerStyles.hx @@ -8,6 +8,7 @@ package com.feathersui.themes.minimal.components; +import feathers.skins.MultiSkin; import feathers.utils.DeviceUtil; import com.feathersui.themes.minimal.skins.MinimalRectangleSkin; import com.feathersui.themes.minimal.skins.MinimalButtonSkin; @@ -50,15 +51,17 @@ class MinimalPopUpDatePickerStyles { button.backgroundSkin = backgroundSkin; } if (button.icon == null) { - var icon = new Shape(); - drawIcon(icon, theme.labelTextColor); - button.icon = icon; + var icon = new MultiSkin(); - if (button.getIconForState(ButtonState.DISABLED) == null) { - var disabledIcon = new Shape(); - drawIcon(disabledIcon, theme.labelTextDisabledColor); - button.setIconForState(ButtonState.DISABLED, disabledIcon); - } + var defaultIcon = new Shape(); + drawIcon(defaultIcon, theme.labelTextColor); + icon.defaultView = defaultIcon; + + var disabledIcon = new Shape(); + drawIcon(disabledIcon, theme.labelTextDisabledColor); + icon.disabledView = disabledIcon; + + button.icon = icon; } if (button.textFormat == null) { button.textFormat = theme.getTextFormat(); diff --git a/src/com/feathersui/themes/minimal/components/MinimalPopUpListViewStyles.hx b/src/com/feathersui/themes/minimal/components/MinimalPopUpListViewStyles.hx index 794d6bb..31baeb2 100644 --- a/src/com/feathersui/themes/minimal/components/MinimalPopUpListViewStyles.hx +++ b/src/com/feathersui/themes/minimal/components/MinimalPopUpListViewStyles.hx @@ -39,29 +39,11 @@ class MinimalPopUpListViewStyles { var icon = new MultiSkin(); var defaultIcon = new Shape(); - defaultIcon.graphics.beginFill(0xff00ff, 0.0); - defaultIcon.graphics.drawRect(0.0, 0.0, 18.0, 18.0); - defaultIcon.graphics.endFill(); - defaultIcon.graphics.beginFill(theme.labelTextColor); - defaultIcon.graphics.drawRect(9.0, 7.0, 1.0, 5.0); - defaultIcon.graphics.drawRect(7.0, 9.0, 5.0, 1.0); - defaultIcon.graphics.endFill(); - defaultIcon.graphics.beginFill(theme.backgroundColor); - defaultIcon.graphics.drawRect(0.0, 0.0, 1.0, 18.0); - defaultIcon.graphics.endFill(); + drawArrowIcon(defaultIcon, theme.labelTextColor, theme.backgroundColor); icon.defaultView = defaultIcon; var disabledIcon = new Shape(); - disabledIcon.graphics.beginFill(0xff00ff, 0.0); - disabledIcon.graphics.drawRect(0.0, 0.0, 18.0, 18.0); - disabledIcon.graphics.endFill(); - disabledIcon.graphics.beginFill(theme.labelTextDisabledColor); - disabledIcon.graphics.drawRect(9.0, 7.0, 1.0, 5.0); - disabledIcon.graphics.drawRect(7.0, 9.0, 5.0, 1.0); - disabledIcon.graphics.endFill(); - disabledIcon.graphics.beginFill(theme.backgroundColor); - disabledIcon.graphics.drawRect(0.0, 0.0, 1.0, 18.0); - disabledIcon.graphics.endFill(); + drawArrowIcon(disabledIcon, theme.labelTextDisabledColor, theme.backgroundColor); icon.disabledView = disabledIcon; button.icon = icon; @@ -74,4 +56,17 @@ class MinimalPopUpListViewStyles { }); } } + + private static function drawArrowIcon(icon:Shape, iconColor:UInt, backgroundColor:UInt):Void { + icon.graphics.beginFill(0xff00ff, 0.0); + icon.graphics.drawRect(0.0, 0.0, 18.0, 18.0); + icon.graphics.endFill(); + icon.graphics.beginFill(iconColor); + icon.graphics.drawRect(9.0, 7.0, 1.0, 5.0); + icon.graphics.drawRect(7.0, 9.0, 5.0, 1.0); + icon.graphics.endFill(); + icon.graphics.beginFill(backgroundColor); + icon.graphics.drawRect(0.0, 0.0, 1.0, 18.0); + icon.graphics.endFill(); + } }