Trying to set icon size & text size for ToolBarToggleButton WIP
This commit is contained in:
@@ -10,6 +10,7 @@ import openfl.events.Event;
|
||||
import openfl.geom.ColorTransform;
|
||||
import openfl.text.Font;
|
||||
import openfl.utils.Assets;
|
||||
import t9.util.ColorTraces.*;
|
||||
|
||||
class ToolbarToggleButton extends ToggleButton {
|
||||
|
||||
@@ -17,13 +18,24 @@ class ToolbarToggleButton extends ToggleButton {
|
||||
private var svgIcon:Shape;
|
||||
private var unselectedColor:Int;
|
||||
private var selectedColor:Int;
|
||||
private var iconSize:Int;
|
||||
private var textSize:Int;
|
||||
|
||||
public function new(pSvgIconPath:String = null, pUnselectedColor:Int = 0x00FF00, pSelectedColor:Int = 0x000000) {
|
||||
super();
|
||||
|
||||
public function new(pSvgIconPath:String = null,
|
||||
pUnselectedColor:Int = 0x00FF00,
|
||||
pSelectedColor:Int = 0x000000,
|
||||
pIconSize:Int = 40,
|
||||
pTextSize:Int = 16) {
|
||||
super();
|
||||
|
||||
svgIconPath = pSvgIconPath;
|
||||
unselectedColor = pSelectedColor;
|
||||
selectedColor = pUnselectedColor;
|
||||
iconSize = pIconSize;
|
||||
textSize = pTextSize;
|
||||
|
||||
traceRed("iconSize : " + iconSize + " / textSize : " + textSize);
|
||||
}
|
||||
|
||||
override private function initialize():Void {
|
||||
@@ -39,14 +51,14 @@ class ToolbarToggleButton extends ToggleButton {
|
||||
colorizeIcon(unselectedColor);
|
||||
new SVG(svgIconPath).render(svgIcon.graphics);
|
||||
icon = svgIcon;
|
||||
icon.width = icon.height = 40;
|
||||
icon.width = icon.height = iconSize;
|
||||
|
||||
iconOffsetY = 0;
|
||||
}
|
||||
|
||||
// text
|
||||
var fnt:Font = Assets.getFont(Constants.MONTSERRAT_REGULAR_400);
|
||||
textFormat = new TextFormat(fnt.fontName, 16, unselectedColor);
|
||||
textFormat = new TextFormat(fnt.fontName, textSize, unselectedColor);
|
||||
selectedTextFormat = new TextFormat(fnt.fontName, 16, selectedColor);
|
||||
|
||||
addEventListener(Event.CHANGE, onButtonStateChange);
|
||||
@@ -63,5 +75,4 @@ class ToolbarToggleButton extends ToggleButton {
|
||||
private function onButtonStateChange(e:Event):Void {
|
||||
selected ? colorizeIcon(selectedColor) : colorizeIcon(unselectedColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user