fixes for openfl html5 build
This commit is contained in:
23
README.md
23
README.md
@@ -8,28 +8,29 @@ Gui framework for Haxe.
|
||||
|
||||
### Example
|
||||
|
||||
Build form using `haxework.gui.ViewBuilder`.
|
||||
Build form using macro @:template.
|
||||
|
||||
form.json:
|
||||
|
||||
```json
|
||||
{
|
||||
"@type":"haxework.gui.VGroupView",
|
||||
"skin":{"@type":"haxework.gui.skin.ColorSkin", "color":"0xffff00"},
|
||||
"paddings":20,
|
||||
"layoutMargin":10,
|
||||
"$type": "haxework.gui.VGroupView",
|
||||
"skin": [{"$type": "haxework.gui.skin.ColorSkin", "color": "0xffff00"}],
|
||||
"geometry.padding": 20,
|
||||
"layout.margin": 10,
|
||||
"views":[
|
||||
{
|
||||
"id": "view1",
|
||||
"type":"haxework.gui.SpriteView",
|
||||
"pWidth":100, "pHeight":100,
|
||||
"skin":{"@type":"haxework.gui.skin.ColorSkin", "color":"0xff0000"}
|
||||
"geometry.size.stretch": true,
|
||||
"skin":[{"$type":"haxework.gui.skin.ColorSkin", "color": "0xff0000"}]
|
||||
},
|
||||
{
|
||||
"id": "view2",
|
||||
"type": "haxework.gui.SpriteView",
|
||||
"pWidth":100, "height":50,
|
||||
"skin":{"@type":"haxework.gui.skin.ColorSkin", "color":"0x00ff00"}
|
||||
"geometry.size.width": "100%",
|
||||
"geometry.size.height": 50,
|
||||
"skin": [{"$type":"haxework.gui.skin.ColorSkin", "color": "0x00ff00"}]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -38,8 +39,8 @@ form.json:
|
||||
```haxe
|
||||
@:template("form.json")
|
||||
class FormView extends VGroupView {
|
||||
@:view public var view1:IView;
|
||||
@:view("view2") public var anyVarName:IView;
|
||||
@:view public var view1:SpriteView;
|
||||
@:view("view2") public var anyVarName:SpriteView;
|
||||
}
|
||||
|
||||
var form = new FormView();
|
||||
|
||||
@@ -9,7 +9,7 @@ view:
|
||||
skinId: panel
|
||||
views:
|
||||
- id: colors
|
||||
$type: haxework.gui.DataView
|
||||
$type: haxework.gui.DataView<Int>
|
||||
geometry.size.stretch: true
|
||||
layout:
|
||||
$type: haxework.gui.layout.TailLayout
|
||||
|
||||
@@ -10,13 +10,10 @@ class GroupView extends SpriteView implements IGroupView {
|
||||
public var views(default, set):Array<IView<Dynamic>>;
|
||||
public var layout(default, default):ILayout;
|
||||
|
||||
private var viewsById:Map<String, IView<Dynamic>>;
|
||||
|
||||
public function new(?layout:ILayout) {
|
||||
super();
|
||||
this.layout = layout == null ? new DefaultLayout() : layout;
|
||||
views = [];
|
||||
viewsById = new Map<String, IView<Dynamic>>();
|
||||
}
|
||||
|
||||
override private function set_width(value:Float):Float {
|
||||
@@ -61,7 +58,6 @@ class GroupView extends SpriteView implements IGroupView {
|
||||
|
||||
public function addView(view:IView<Dynamic>):IView<Dynamic> {
|
||||
views.push(view);
|
||||
viewsById.set(view.id, view);
|
||||
if (view.content != null) content.addChild(view.content);
|
||||
view.parent = this;
|
||||
toUpdate();
|
||||
@@ -71,7 +67,6 @@ class GroupView extends SpriteView implements IGroupView {
|
||||
public function insertView(view:IView<Dynamic>, index:Int):IView<Dynamic> {
|
||||
if (index < 0) index = views.length + index;
|
||||
views.insert(index, view);
|
||||
viewsById.set(view.id, view);
|
||||
if (view.content != null) content.addChild(view.content);
|
||||
view.parent = this;
|
||||
toUpdate();
|
||||
@@ -80,7 +75,6 @@ class GroupView extends SpriteView implements IGroupView {
|
||||
|
||||
public function addViewFirst(view:IView<Dynamic>):IView<Dynamic> {
|
||||
views.unshift(view);
|
||||
viewsById.set(view.id, view);
|
||||
content.addChild(view.content);
|
||||
view.parent = this;
|
||||
toUpdate();
|
||||
@@ -89,7 +83,6 @@ class GroupView extends SpriteView implements IGroupView {
|
||||
|
||||
public function removeView(view:IView<Dynamic>):IView<Dynamic> {
|
||||
view.parent = null;
|
||||
viewsById.remove(view.id);
|
||||
views.remove(view);
|
||||
if (view.content != null) content.removeChild(view.content);
|
||||
toUpdate();
|
||||
@@ -101,31 +94,4 @@ class GroupView extends SpriteView implements IGroupView {
|
||||
removeView(views[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public function removeViewById(id:String):IView<Dynamic> {
|
||||
if (viewsById.exists(id)) {
|
||||
return removeView(viewsById.get(id));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function findViewById<V:IView<Dynamic>>(id:String, ?clazz:Class<V>):Null<V> {
|
||||
var idd:Array<String> = id.split(":");
|
||||
if (idd.length > 1) {
|
||||
var id0 = idd.shift();
|
||||
if (viewsById.exists(id0)) {
|
||||
var g:GroupView = findViewById(id0);
|
||||
return g.findViewById(idd.join(":"), clazz);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (viewsById.exists(id)) {
|
||||
return cast viewsById.get(id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package haxework.gui;
|
||||
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import haxework.gui.core.HAlign;
|
||||
import haxework.gui.core.VAlign;
|
||||
import haxework.gui.layout.ILayout;
|
||||
|
||||
interface IGroupView extends IView<Dynamic> {
|
||||
@@ -20,8 +18,4 @@ interface IGroupView extends IView<Dynamic> {
|
||||
public function removeView(view:IView<Dynamic>):IView<Dynamic>;
|
||||
|
||||
public function removeAllViews():Void;
|
||||
|
||||
public function removeViewById(id:String):IView<Dynamic>;
|
||||
|
||||
public function findViewById<V:IView<Dynamic>>(id:String, ?clazz:Class<V>):Null<V>;
|
||||
}
|
||||
|
||||
@@ -144,8 +144,10 @@ class TextView extends SpriteView implements ITextView {
|
||||
|
||||
private function updateTextSize():Void {
|
||||
var size = TextUtil.getSize(textField);
|
||||
if (!Math.isNaN(size.x) && !Math.isNaN(size.y)) {
|
||||
setContentSize(size.x, size.y, "text");
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():Void {
|
||||
textField.embedFonts = fontEmbed;
|
||||
|
||||
@@ -45,7 +45,7 @@ class ViewUpdater {
|
||||
if (updateViews.length > count) {
|
||||
repeat++;
|
||||
if (repeat > 100) {
|
||||
L.e("ViewUpdater", 'repeat limit: ${updateViews}');
|
||||
L.e("ViewUpdater", 'repeat limit: ${[for (view in updateViews) view.id]}');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user