Skip to content
Open
6 changes: 3 additions & 3 deletions src/ru/stablex/ui/UIBuilder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,9 @@ class UIBuilder {
}

if( cls != null ){
if( UIBuilder._imports.exists(cls) ) Err.trigger('Class is already imported: ' + cls);
UIBuilder._imports.set(cls, fullyQualifiedName);

if( !UIBuilder._imports.exists(cls) ){ // Err.trigger('Class is already imported: ' + cls);
UIBuilder._imports.set(cls, fullyQualifiedName);
}
}else{
Err.trigger('Wrong class name: ' + fullyQualifiedName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ru/stablex/ui/widgets/Bmp.hx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Bmp extends Widget{
* Setter src
*
*/
private inline function set_src(src:String) : String {
private function set_src(src:String) : String {
if( src != null ){
this._bitmapData = null;
}
Expand Down
35 changes: 26 additions & 9 deletions src/ru/stablex/ui/widgets/Box.hx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class Box extends Widget{
* get object width
*
*/
@:noCompletion static private inline function _objWidth (obj:DisplayObject) : Float {
@:noCompletion static private function _objWidth (obj:DisplayObject, ignoreRot:Bool=false) : Float {
// #if html5
if( Std.is(obj, Widget) ){
return cast(obj, Widget).w;
return cast(obj, Widget).get_rotated_w() * cast(obj, Widget).scaleX;
}else if( Std.is(obj, flash.text.TextField) ){
return cast(obj, flash.text.TextField).textWidth + 4;
}else{
Expand All @@ -76,10 +76,10 @@ class Box extends Widget{
* get object height
*
*/
@:noCompletion static private inline function _objHeight (obj:DisplayObject) : Float {
@:noCompletion static private function _objHeight (obj:DisplayObject, ignoreRot:Bool=false) : Float {
// #if html5
if( Std.is(obj, Widget) ){
return cast(obj, Widget).h;
return cast(obj, Widget).get_rotated_h() * cast(obj, Widget).scaleY;
}else if( Std.is(obj, flash.text.TextField) ){
return cast(obj, flash.text.TextField).textHeight + 4;
}else{
Expand Down Expand Up @@ -126,29 +126,38 @@ class Box extends Widget{
*******************************************************************************/


override public function onCreate() : Void {
super.onCreate();
//trace("onCreate Box - " + name);
alignElements();
}

/**
* Refresh widgets. Re-apply skin box and realigns children
*
*/
override public function refresh() : Void {
//trace("Box starting refresh - " + name);
if( this.autoWidth || this.autoHeight ){
var w : Float = (this.autoWidth ? this._calcWidth() : this._width);
var h : Float = (this.autoHeight ? this._calcHeight() : this._height);

if( this._width != w || this._height != h ){

this._width = w;
this._height = h;

this.dispatchEvent(new WidgetEvent(WidgetEvent.RESIZE));
_onResize();
//this.dispatchEvent(new WidgetEvent(WidgetEvent.RESIZE));
}
}//if( autoSize )

super.refresh();

if( this.layout == null ){
if ( this.layout == null ) {
//trace(" Box align in refresh");
this.alignElements();
}
//trace("Box ending refresh");
}//function refresh()


Expand All @@ -165,7 +174,6 @@ class Box extends Widget{
var childW : Float = 0;

for(i in 0...this.numChildren){
child = this.getChildAt(i);
child = this.getChildAt(i);
if( child.visible ){
childW = Box._objWidth(child);
Expand Down Expand Up @@ -244,6 +252,7 @@ class Box extends Widget{
*
*/
public function alignElements () : Void {
//trace(" in align - " + name);
if( this.unifyChildren ){
this._unifyChildren();
}
Expand Down Expand Up @@ -317,6 +326,7 @@ class Box extends Widget{
*
*/
@:noCompletion private function _vAlignTop () : Void {
//trace(" align top - " + name);
//vertical box
if( this.vertical ){
var lastY : Float = this.paddingTop;
Expand All @@ -343,6 +353,7 @@ class Box extends Widget{
*
*/
@:noCompletion private function _vAlignMiddle () : Void {
//trace(" align middle - " + name);
//vertical box
if(this.vertical){
//count sum children height
Expand Down Expand Up @@ -386,6 +397,7 @@ class Box extends Widget{
*
*/
@:noCompletion private function _vAlignBottom () : Void {
//trace(" align bottom - " + name);
//vertical box
if( this.vertical ){
var lastY : Float = this.h - this.paddingBottom;
Expand Down Expand Up @@ -414,6 +426,7 @@ class Box extends Widget{
*
*/
@:noCompletion private function _hAlignLeft () : Void {
//trace(" align left - " + name);
//vertical box
if(this.vertical){
for(i in 0...this.numChildren){
Expand All @@ -440,6 +453,7 @@ class Box extends Widget{
*
*/
@:noCompletion private function _hAlignRight () : Void {
//trace(" align right - " + name);
//vertical box
if(this.vertical){
var child : DisplayObject;
Expand Down Expand Up @@ -468,6 +482,7 @@ class Box extends Widget{
*
*/
@:noCompletion private function _hAlignCenter () : Void {
//trace(" align center - " + name);
//vertical box
if(this.vertical){
var child : DisplayObject;
Expand Down Expand Up @@ -567,6 +582,7 @@ class Box extends Widget{
*
*/
@:noCompletion private function _onChildResize (e:WidgetEvent = null) : Void {
//trace("resized child of " + name);
if( this.created ){
if( this.autoWidth || this.autoHeight ){
if( e != null ){
Expand All @@ -575,7 +591,8 @@ class Box extends Widget{
child != null && child.visible != false
&& !(this.autoWidth && child._widthUsePercent)
&& !(this.autoHeight && child._heightUsePercent)
){
) {
//trace(" child is " + child.name);
this.refresh();
}
}else{
Expand Down
Loading