Skip to content
This repository has been archived by the owner on Oct 14, 2019. It is now read-only.

Commit

Permalink
Fix #110
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Jun 11, 2014
1 parent 8235c5b commit 90c059b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
18 changes: 17 additions & 1 deletion src/haxe/ui/toolkit/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package haxe.ui.toolkit;
import flash.display.Sprite;
import haxe.ui.toolkit.containers.Accordion;
import haxe.ui.toolkit.containers.Stack;
import haxe.ui.toolkit.controls.Button;
import haxe.ui.toolkit.core.Macros;
import haxe.ui.toolkit.core.Root;
import haxe.ui.toolkit.core.Toolkit;
Expand Down Expand Up @@ -30,14 +31,29 @@ class Main /* extends Sprite */ {
Toolkit.setTransitionForClass(Accordion, "slide");
Toolkit.setTransitionForClass(Stack, "fade");
Toolkit.theme = new DefaultTheme();
//Toolkit.theme = new GradientTheme();
Toolkit.theme = new GradientTheme();
//Toolkit.theme = new WindowsTheme();
Macros.addStyleSheet("assets/test.css");
Toolkit.setTransitionForClass(Stack, "none");
Toolkit.init();
Toolkit.openFullscreen(function(root:Root) {
var t2:TestController2 = new TestController2();
root.addChild(t2.view);
return;

var button:Button = new Button();
button.x = 100;
button.y = 100;
button.style.width = 150;
button.style.height = 100;
button.style.color = 0xFF00FF;
button.style.fontSize = 40;
button.style.icon = "img/slinky_tiny.jpg";
button.style.iconPosition = "top";
button.text = "Styled";
//button.icon = "img/slinky_tiny.jpg";
root.addChild(button);

});
}
}
Expand Down
18 changes: 10 additions & 8 deletions src/haxe/ui/toolkit/controls/Button.hx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ class Button extends StateComponent implements IFocusable implements IClonable<S
if (_icon == null) {
_icon = new Image();
_icon.id = "icon";
_icon.style.padding = 100;
}
_icon.resource = value;
organiseChildren();
if (_icon.resource != value) {
_icon.resource = value;
organiseChildren();
}
} else {
if (_icon != null) {
_icon.visible = false;
Expand Down Expand Up @@ -210,15 +211,14 @@ class Button extends StateComponent implements IFocusable implements IClonable<S
_spacers.push(spacer);
}
}

if (_iconPosition == "fill" && _icon != null) {
_icon.stretch = true;
_icon.width = width;
_icon.height = height;
}

if (_ready) {
invalidate(InvalidationFlag.STYLE);
}
invalidate(InvalidationFlag.STYLE);
}

//******************************************************************************************
Expand Down Expand Up @@ -422,8 +422,10 @@ class Button extends StateComponent implements IFocusable implements IClonable<S
}

private function set_iconPosition(value:String):String {
_iconPosition = value;
organiseChildren();
if (_iconPosition != value) {
_iconPosition = value;
organiseChildren();
}
return value;
}

Expand Down

0 comments on commit 90c059b

Please sign in to comment.