[view] fixes
This commit is contained in:
@@ -4,6 +4,7 @@ import flash.display.DisplayObject;
|
||||
import flash.display.InteractiveObject;
|
||||
import flash.geom.Rectangle;
|
||||
import haxework.view.geometry.Geometry;
|
||||
import haxework.view.geometry.Size;
|
||||
import haxework.view.geometry.SizeSet;
|
||||
import haxework.view.group.IGroupView;
|
||||
import haxework.view.skin.ISkin;
|
||||
@@ -18,8 +19,8 @@ class View<C:DisplayObject> implements IView<C> {
|
||||
@:provide var theme:ITheme;
|
||||
|
||||
public var geometry(default, default):Geometry;
|
||||
public var skin(default, default):ISkin<Dynamic>;
|
||||
public var style(default, default):StyleId;
|
||||
public var skin(default, set):ISkin<Dynamic>;
|
||||
public var style(default, set):StyleId;
|
||||
|
||||
public var id(default, default):String;
|
||||
|
||||
@@ -29,6 +30,8 @@ class View<C:DisplayObject> implements IView<C> {
|
||||
public var width(default, null):Float;
|
||||
public var height(default, null):Float;
|
||||
|
||||
public var size(default, null):Size;
|
||||
|
||||
public var content(default, null):C;
|
||||
|
||||
public var parent(default, null):Null<IGroupView>;
|
||||
@@ -39,11 +42,12 @@ class View<C:DisplayObject> implements IView<C> {
|
||||
|
||||
public var rect(get, null):Rectangle;
|
||||
|
||||
private var size:SizeSet;
|
||||
private var sizeSet:SizeSet;
|
||||
|
||||
public function new(content:C) {
|
||||
id = Type.getClassName(Type.getClass(this)) + counter++;
|
||||
size = new SizeSet();
|
||||
sizeSet = new SizeSet();
|
||||
size = 0;
|
||||
this.content = content;
|
||||
x = 0;
|
||||
y = 0;
|
||||
@@ -80,10 +84,13 @@ class View<C:DisplayObject> implements IView<C> {
|
||||
}
|
||||
|
||||
public function setSize(width:Float, height:Float, type:String = "default"):Void {
|
||||
if (size.update([width, height], type)) {
|
||||
var s = size.toSize();
|
||||
this.width = s.width;
|
||||
this.height = s.height;
|
||||
if (sizeSet.update([width, height], type)) {
|
||||
var s = sizeSet.toSize();
|
||||
this.width = s.width + geometry.padding.horizontal;
|
||||
this.height = s.height + geometry.padding.vertical;
|
||||
size = sizeSet.toSize(false);
|
||||
size.width += geometry.padding.horizontal;
|
||||
size.height += geometry.padding.vertical;
|
||||
toUpdateParent();
|
||||
toRedraw();
|
||||
}
|
||||
@@ -113,6 +120,16 @@ class View<C:DisplayObject> implements IView<C> {
|
||||
return this.skin;
|
||||
}
|
||||
|
||||
private function set_style(value:StyleId):StyleId {
|
||||
if (value != null && style != value) {
|
||||
style = value;
|
||||
if (theme != null) {
|
||||
theme.bind(style, this);
|
||||
}
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
private function set_visible(value:Bool):Bool {
|
||||
if (visible != value) {
|
||||
visible = value;
|
||||
|
||||
Reference in New Issue
Block a user