NekoIconButton reshaping in progress...

TODO :
Is there a reason NekoIconButton heritates from Button Feathers component or not ?
This commit is contained in:
2025-11-20 16:02:35 +01:00
parent d27fe111b9
commit db50bec414
10 changed files with 142 additions and 28 deletions
+73 -10
View File
@@ -1,20 +1,83 @@
package components;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import feathers.controls.Button;
import feathers.controls.Label;
import feathers.events.FeathersEvent;
import format.SVG;
import model.Constants;
import openfl.Assets;
import openfl.display.Shape;
import openfl.geom.ColorTransform;
import openfl.text.Font;
import openfl.text.TextFormat;
import t9.util.ColorTraces.*;
class NekoIconButton extends Button {
private var bmp:Bitmap;
public function new(pSkin:BitmapData, pX:Int = 0, pY:Int = 0, pWidth:Int = 100, pHeight:Int = 100) {
super();
private var svgSkinPath:String;
private var w:Int;
private var h:Int;
private var normalStateColor:Int;
private var selectedStateColor:Int;
private var disabledStateColor:Int;
private var backgroundColor:Int;
private var t:String;
bmp = new Bitmap(pSkin);
backgroundSkin = bmp;
bmp.width = pWidth;
bmp.height = pHeight;
bmp.smoothing = true;
private var iconShape:Shape;
private var lb1:Label;
public function new(pSvgSkinPath:String,
pWidth:Int = 100,
pHeight:Int = 100,
pNormalStateColor:Int = 0x000000,
pSelectedStateColor:Int = 0xFF0000,
pDisabledStateColor:Int = 0xAAAAAA,
pBackgroundColor:Int = null,
pText:String = null) {
super();
svgSkinPath = pSvgSkinPath;
w = pWidth;
h = pHeight;
normalStateColor = pNormalStateColor;
selectedStateColor = pSelectedStateColor;
disabledStateColor = pDisabledStateColor;
backgroundColor = pBackgroundColor;
t = pText;
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
if(pBackgroundColor == null){
backgroundSkin = new NekoRectangle(0xFF0000, 0, 0, pWidth, pHeight);
backgroundSkin.alpha = 0;
} else {
backgroundSkin = new NekoRectangle(pBackgroundColor, 0, 0, pWidth, pHeight);
}
iconShape = new Shape();
new SVG(pSvgSkinPath).render(iconShape.graphics);
iconShape.width = pWidth;
iconShape.height = pHeight;
var ct = new ColorTransform();
ct.color = pNormalStateColor;
iconShape.transform.colorTransform = ct;
addChild(iconShape);
if(pText != null){
lb1.text = Constants.MENU_ITEM_0_STRING;
lb1.embedFonts = true;
var fnt:Font = Assets.getFont(Constants.MONTSERRAT_LIGHT_300);
lb1.textFormat = new TextFormat(fnt.fontName, 20, Constants.BUTTON_NORMAL_STATE_COLOR);
addChild(lb1);
}
}
override private function initialize():Void {
}
private function onCreationComplete(event:FeathersEvent):Void {
traceBlue(this + " --> onCreationComplete()");
}
}