[skin] process contentSize views in bitmap skins
This commit is contained in:
@@ -175,7 +175,7 @@ class TextView extends SpriteView implements ITextView {
|
|||||||
if (t != null) textField.text = t;
|
if (t != null) textField.text = t;
|
||||||
textField.setTextFormat(textFormat);
|
textField.setTextFormat(textFormat);
|
||||||
updateTextSize();
|
updateTextSize();
|
||||||
if (contentSize) {
|
if (contentSize && _text != null && _text.length > 0) {
|
||||||
#if html5
|
#if html5
|
||||||
var h = _textHeight;
|
var h = _textHeight;
|
||||||
var w = _textWidth;
|
var w = _textWidth;
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ class FrameSwitcher extends GroupView implements IFrameSwitcher {
|
|||||||
prev = current;
|
prev = current;
|
||||||
}
|
}
|
||||||
current = frames.get(id);
|
current = frames.get(id);
|
||||||
|
if (current == null) {
|
||||||
|
throw 'frame "$id" not found';
|
||||||
|
}
|
||||||
addView(current);
|
addView(current);
|
||||||
//ToDo:
|
//ToDo:
|
||||||
if (content.stage != null) content.stage.focus = cast(current, SpriteView).content;
|
if (content.stage != null) content.stage.focus = cast(current, SpriteView).content;
|
||||||
|
|||||||
@@ -231,6 +231,6 @@ class ListView<D> extends GroupView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IListItemView<D> extends IView<Dynamic> {
|
interface IListItemView<D> extends IView<Dynamic> {
|
||||||
public var item_index(default, set):Int;
|
public var item_index(default, default):Int;
|
||||||
public var data(default, set):D;
|
public var data(default, set):D;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ class BitmapSkin implements ISkin<SpriteView> {
|
|||||||
public function draw(view:SpriteView):Void {
|
public function draw(view:SpriteView):Void {
|
||||||
if (image == null) return;
|
if (image == null) return;
|
||||||
DrawUtil.draw(view.content.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color);
|
DrawUtil.draw(view.content.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color);
|
||||||
|
if (view.contentSize) {
|
||||||
|
view.w = image.width;
|
||||||
|
view.h = image.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ class ButtonBitmapSkin implements ISkin<ButtonView> {
|
|||||||
if (images == null) return;
|
if (images == null) return;
|
||||||
var image:BitmapData = view.disabled ? disableImage == null ? disable : disableImage : images.get(view.state);
|
var image:BitmapData = view.disabled ? disableImage == null ? disable : disableImage : images.get(view.state);
|
||||||
DrawUtil.draw(view.content.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color);
|
DrawUtil.draw(view.content.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color);
|
||||||
|
if (view.contentSize) {
|
||||||
|
view.w = image.width;
|
||||||
|
view.h = image.height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package haxework.gui.skin;
|
package haxework.gui.skin;
|
||||||
|
|
||||||
|
import flash.display.BitmapData;
|
||||||
|
|
||||||
class Skin {
|
class Skin {
|
||||||
|
|
||||||
|
public static function bitmap(image:BitmapData): ISkin<SpriteView> {
|
||||||
|
return new BitmapSkin(image);
|
||||||
|
}
|
||||||
|
|
||||||
public static function color(color: Int, alpha: Float = 1.0): ISkin<SpriteView> {
|
public static function color(color: Int, alpha: Float = 1.0): ISkin<SpriteView> {
|
||||||
return new ColorSkin(color, alpha);
|
return new ColorSkin(color, alpha);
|
||||||
}
|
}
|
||||||
@@ -9,4 +15,12 @@ class Skin {
|
|||||||
public static function border(color: Int, alpha: Float = 1.0, tickness: Float = 1.0): ISkin<SpriteView> {
|
public static function border(color: Int, alpha: Float = 1.0, tickness: Float = 1.0): ISkin<SpriteView> {
|
||||||
return new BorderSkin(color, alpha, tickness);
|
return new BorderSkin(color, alpha, tickness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function size(width:Float, height:Float): ISkin<Dynamic> {
|
||||||
|
return new SizeSkin(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function text(fontColor:Int, fontSize:Int, fontFamily:String = null):ISkin<ITextView> {
|
||||||
|
return new TextSkin(fontColor, fontSize, fontFamily);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,18 @@ package haxework.gui.skin;
|
|||||||
class TextSkin implements ISkin<ITextView> {
|
class TextSkin implements ISkin<ITextView> {
|
||||||
|
|
||||||
public var fontColor(default, default):Int;
|
public var fontColor(default, default):Int;
|
||||||
|
public var fontSize(default, default):Int;
|
||||||
public var fontFamily(default, default):String;
|
public var fontFamily(default, default):String;
|
||||||
|
|
||||||
public function new(fontColor:Int = 0xffffff, fontFamily:String = null) {
|
public function new(fontColor:Int, fontSize:Int, fontFamily:String) {
|
||||||
this.fontColor = fontColor;
|
this.fontColor = fontColor;
|
||||||
|
this.fontSize = fontSize;
|
||||||
this.fontFamily = fontFamily;
|
this.fontFamily = fontFamily;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function draw(view:ITextView):Void {
|
public function draw(view:ITextView):Void {
|
||||||
view.fontColor = fontColor;
|
view.fontColor = fontColor;
|
||||||
|
view.fontSize = fontSize;
|
||||||
view.fontFamily = fontFamily;
|
view.fontFamily = fontFamily;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user