package view;

import feathers.layout.HorizontalLayoutData;
import feathers.controls.Label;
import feathers.controls.LayoutGroup;
import feathers.events.FeathersEvent;
import feathers.layout.HorizontalLayout;
import feathers.skins.RectangleSkin;
import feathers.text.TextFormat;
import model.Constants;
import openfl.Assets;
import openfl.text.Font;
import t9.util.ColorTraces.*;

class ToolBar extends LayoutGroup {

    private var lbl1:Label;

	public function new() {
		super();

		addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
	}

	override private function initialize():Void {
		super.initialize();

        final sw:Int = stage.stageWidth;
        final sh:Int = stage.stageHeight;
        final headerWidth = Std.int(sw * Constants.MAIN_HEADER_WIDTH_RATIO);
        final headerHeight = Std.int(sh * Constants.MAIN_HEADER_HEIGHT_RATIO);

		autoSizeMode = CONTENT;
		backgroundSkin = new RectangleSkin(SolidColor(Constants.ACCENT_COLOR2, 1));
		//variant = LayoutGroup.VARIANT_TOOL_BAR;

        // Layout settings
		var l:HorizontalLayout = new HorizontalLayout();
		l.setPadding(Std.int(headerHeight * .1));
		l.verticalAlign = MIDDLE;
        layout = l;
		
        // Title label
        lbl1 = new Label();
		
		//lbl1.layoutData = ld1;
        //lb1.backgroundSkin = new RectangleSkin(SolidColor(Constants.ACCENT_COLOR2, 1));

		//lb1.verticalAlign = VerticalAlign.TOP;
		var fnt:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
		lbl1.text = "Toolbar";
		lbl1.embedFonts = true;
		lbl1.textFormat = new TextFormat(fnt.fontName, Std.int(headerHeight * .3), Constants.MAIN_COLOR3);
		addChild(lbl1);
	}

	private function onCreationComplete(event:FeathersEvent):Void {
		traceBlue(this + " --> onCreationComplete() - w: " + width + " h: " + height );
	}

}