added style support to GuiBuilder
This commit is contained in:
@@ -123,9 +123,15 @@ class GuiF {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function fill() {
|
public function fill() {
|
||||||
|
if (Reflect.hasField(data, "style")) {
|
||||||
|
var style = Provider.get(IResources).styles.get(Reflect.field(data, "style"));
|
||||||
|
for (key in Reflect.fields(style)) {
|
||||||
|
Reflect.setField(data, key, Reflect.field(style, key));
|
||||||
|
}
|
||||||
|
}
|
||||||
var fields:Array<String> = Reflect.fields(data);
|
var fields:Array<String> = Reflect.fields(data);
|
||||||
for (field in fields) {
|
for (field in fields) {
|
||||||
if (field == "type") continue;
|
if (field == "type" || field == "style") continue;
|
||||||
if (field == "_includes") continue;
|
if (field == "_includes") continue;
|
||||||
var value:Dynamic = Reflect.field(data, field);
|
var value:Dynamic = Reflect.field(data, field);
|
||||||
if (field == "_include") {
|
if (field == "_include") {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class LabelView extends TextView {
|
|||||||
fill = false;
|
fill = false;
|
||||||
textField.selectable = false;
|
textField.selectable = false;
|
||||||
textField.wordWrap = false;
|
textField.wordWrap = false;
|
||||||
|
textField.multiline = true;
|
||||||
layoutHAlign = HAlign.CENTER;
|
layoutHAlign = HAlign.CENTER;
|
||||||
layoutVAlign = VAlign.MIDDLE;
|
layoutVAlign = VAlign.MIDDLE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class TextView extends SpriteView implements ITextView<Sprite, TextField> {
|
|||||||
textFormat = textField.defaultTextFormat;
|
textFormat = textField.defaultTextFormat;
|
||||||
textFormat.font = "Arial";
|
textFormat.font = "Arial";
|
||||||
textFormat.size = 16;
|
textFormat.size = 16;
|
||||||
|
textFormat.align = TextFormatAlign.CENTER;
|
||||||
content.addChild(textField);
|
content.addChild(textField);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +151,10 @@ class TextView extends SpriteView implements ITextView<Sprite, TextField> {
|
|||||||
if (contentSize && !Std.is(skin, ISize)) {
|
if (contentSize && !Std.is(skin, ISize)) {
|
||||||
#if html5
|
#if html5
|
||||||
var h = textField.textHeight;
|
var h = textField.textHeight;
|
||||||
if (h > textFormat.size * 1.5) h = h / 2;
|
//var w = textField.textWidth;
|
||||||
|
//if (h > textFormat.size * 1.5) h = h / 2;
|
||||||
textField.height = h;
|
textField.height = h;
|
||||||
|
//textField.width = w;
|
||||||
#end
|
#end
|
||||||
width = textField.width + paddings * 2;
|
width = textField.width + paddings * 2;
|
||||||
height = textField.height + paddings * 2;
|
height = textField.height + paddings * 2;
|
||||||
|
|||||||
@@ -10,4 +10,7 @@ interface IResources {
|
|||||||
public var movie(default, null):ResMap<MovieClip>;
|
public var movie(default, null):ResMap<MovieClip>;
|
||||||
public var text(default, null):ResMap<String>;
|
public var text(default, null):ResMap<String>;
|
||||||
public var float(default, null):ResMap<Float>;
|
public var float(default, null):ResMap<Float>;
|
||||||
|
public var styles(default, null):ResMap<Dynamic>;
|
||||||
|
|
||||||
|
public function loadStyles(asset:String):Void;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package haxework.resources;
|
package haxework.resources;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import haxe.Json;
|
||||||
import flash.display.MovieClip;
|
import flash.display.MovieClip;
|
||||||
import haxework.core.Tuple;
|
import haxework.core.Tuple;
|
||||||
import haxe.ds.StringMap;
|
import haxe.ds.StringMap;
|
||||||
@@ -51,6 +53,7 @@ class Resources implements IResources {
|
|||||||
public var movie(default, null):ResMap<MovieClip>;
|
public var movie(default, null):ResMap<MovieClip>;
|
||||||
public var text(default, null):ResMap<String>;
|
public var text(default, null):ResMap<String>;
|
||||||
public var float(default, null):ResMap<Float>;
|
public var float(default, null):ResMap<Float>;
|
||||||
|
public var styles(default, null):ResMap<Dynamic>;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
image = new ResMap<BitmapData>();
|
image = new ResMap<BitmapData>();
|
||||||
@@ -58,5 +61,13 @@ class Resources implements IResources {
|
|||||||
movie = new ResMap<MovieClip>();
|
movie = new ResMap<MovieClip>();
|
||||||
text = new ResMap<String>();
|
text = new ResMap<String>();
|
||||||
float = new ResMap<Float>();
|
float = new ResMap<Float>();
|
||||||
|
styles = new ResMap<Dynamic>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadStyles(asset:String):Void {
|
||||||
|
var stylesData = Json.parse(Assets.getText(asset));
|
||||||
|
for (key in Reflect.fields(stylesData)) {
|
||||||
|
styles.put(key, Reflect.field(stylesData, key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user