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
-1
View File
@@ -56,7 +56,6 @@ class LPTCManager2026 extends Application {
addChild(mainPanel);
dr = new NekoDrawer();
//dr.addEventListener(NekoDrawerEvent.STATUS_CHANGE, onDrawerStatusChange);
addChild(dr);
model.addEventListener(NekoDrawerEvent.DRAWER_STATE_CHANGE, onDrawerStateChange);
+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()");
}
}
+9
View File
@@ -10,6 +10,11 @@ class Constants {
public static final MAIN_COLOR2:Int = 0x69808A;
public static final MAIN_COLOR3:Int = 0xECEFF0;
public static final BUTTON_NORMAL_STATE_COLOR:Int = 0x050EB7;
public static final BUTTON_SELECTED_STATE_COLOR:Int = 0xFF5F0F;
public static final BUTTON_DISABLED_STATE_COLOR:Int = 0x69808A;
public static final BUTTON_INVERTED_NORMAL_STATE_COLOR:Int = 0xECEFF0;
// Fonts
public static final MONTSERRAT_LIGHT_300:String = "MontserratLight300";
public static final MONTSERRAT_REGULAR_400:String = "MontserratRegular400";
@@ -20,6 +25,10 @@ class Constants {
public static final MAIN_HEADER_WIDTH_RATIO:Float = 1;
public static final MAIN_HEADER_HEIGHT_RATIO:Float = 0.1;
// Strings
public static final MENU_ITEM_0_STRING:String = "Cavalier·e·s";
public static final MENU_ITEM_1_STRING:String = "Licences FFE";
private function new() {
}
+44 -10
View File
@@ -1,5 +1,10 @@
package view;
import openfl.display.Stage;
import haxe.CallStack.StackItem;
import openfl.Assets;
import components.NekoIconButton;
import feathers.layout.HorizontalLayout;
import model.Constants;
import components.NekoRectangle;
import feathers.events.FeathersEvent;
@@ -8,26 +13,55 @@ import t9.util.ColorTraces.*;
class MainFooter extends LayoutGroup {
public function new() {
private var ridersButton:NekoIconButton;
private var ffeLicencesButton:NekoIconButton;
public function new() {
super();
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
}
override private function initialize():Void {
override private function initialize():Void {
super.initialize();
final sw:Int = stage.stageWidth;
final sh:Int = stage.stageHeight;
final footerWidth = Std.int(sw * Constants.MAIN_HEADER_WIDTH_RATIO);
final footerHeight = Std.int(sh * Constants.MAIN_HEADER_HEIGHT_RATIO);
autoSizeMode = CONTENT;
backgroundSkin = new NekoRectangle( Constants.MAIN_COLOR2,
0,
sh - footerHeight,
footerWidth,
footerHeight);
variant = LayoutGroup.VARIANT_TOOL_BAR;
backgroundSkin = new NekoRectangle(Constants.MAIN_COLOR3);
//variant = LayoutGroup.VARIANT_TOOL_BAR;
// Layout settings
var l:HorizontalLayout = new HorizontalLayout();
l.setPadding(footerWidth * .030);
l.gap = footerWidth * .4;
l.horizontalAlign = CENTER;
l.verticalAlign = MIDDLE;
layout = l;
// Drawer button
ridersButton = new NekoIconButton(Assets.getText("vector/rider_icon_black.svg"),
40,
40,
Constants.BUTTON_NORMAL_STATE_COLOR,
Constants.BUTTON_SELECTED_STATE_COLOR,
Constants.BUTTON_DISABLED_STATE_COLOR,
Constants.MENU_ITEM_0_STRING);
//ridersButton.addEventListener(TriggerEvent.TRIGGER, onRidersBtnPress);
addChild(ridersButton);
// Drawer button
ffeLicencesButton = new NekoIconButton(Assets.getText("vector/certificate_icon_black.svg"),
40,
40,
Constants.BUTTON_NORMAL_STATE_COLOR,
Constants.BUTTON_SELECTED_STATE_COLOR,
Constants.BUTTON_DISABLED_STATE_COLOR,
Constants.MENU_ITEM_1_STRING);
//ffeLicencesButton.addEventListener(TriggerEvent.TRIGGER, onFfeLicencesButtonPress);
addChild(ffeLicencesButton);
}
private function onCreationComplete(event:FeathersEvent):Void {
+7 -3
View File
@@ -47,10 +47,14 @@ class MainHeader extends LayoutGroup {
var l:HorizontalLayout = new HorizontalLayout();
l.paddingLeft = l.paddingRight = Std.int(headerHeight * .3);
l.paddingTop = l.paddingBottom = Std.int(headerHeight * .2);
l.verticalAlign = MIDDLE;
layout = l;
// Drawer button
drawerBtn = new NekoIconButton(Assets.getBitmapData("bitmaps/menu_white.png"), 0, 0, Std.int(headerHeight * .5), Std.int(headerHeight * .5));
drawerBtn = new NekoIconButton(Assets.getText("vector/menu_icon_black.svg"),
Std.int(headerHeight * .5),
Std.int(headerHeight * .5),
Constants.BUTTON_INVERTED_NORMAL_STATE_COLOR);
drawerBtn.addEventListener(TriggerEvent.TRIGGER, onDBtnPress);
addChild(drawerBtn);
@@ -60,12 +64,12 @@ class MainHeader extends LayoutGroup {
//lb1.backgroundSkin = new NekoRectangle(Constants.ACCENT_COLOR2);
//lb1.verticalAlign = VerticalAlign.TOP;
lb1.text = "Cavalier·e·s";
lb1.text = Constants.MENU_ITEM_0_STRING;
lb1.embedFonts = true;
var fnt:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
lb1.textFormat = new TextFormat(fnt.fontName, Std.int(headerHeight * .4), Constants.MAIN_COLOR3);
//addChild(lb1);
addChild(lb1);
}
private function onCreationComplete(event:FeathersEvent):Void {
+3 -3
View File
@@ -21,13 +21,13 @@ class MainPanel extends Panel {
super.initialize();
autoSizeMode = STAGE;
backgroundSkin = new NekoRectangle(Constants.MAIN_COLOR3);
backgroundSkin = new NekoRectangle(Constants.MAIN_COLOR2);
mh = new MainHeader();
addChild(mh);
header = mh;
mf = new MainFooter();
addChild(mf);
footer = mf;
}
private function onCreationComplete(event:FeathersEvent):Void {