diff --git a/src/main/haxework/view/layout/DefaultLayout.hx b/src/main/haxework/view/layout/DefaultLayout.hx index ffb9fac..968ccd3 100755 --- a/src/main/haxework/view/layout/DefaultLayout.hx +++ b/src/main/haxework/view/layout/DefaultLayout.hx @@ -14,8 +14,14 @@ class DefaultLayout extends Layout { setViewHeight(group, view); placeViewHorizontal(group, view); placeViewVertical(group, view); - width = Math.max(width, view.width); - height = Math.max(height, view.height); + switch view.geometry.width { + case FIXED(_): width = Math.max(width, view.width + view.geometry.margin.horizontal); + case _: width = Math.max(width, view.geometry.minWidth + view.geometry.margin.horizontal); + } + switch view.geometry.height { + case FIXED(_): height = Math.max(height, view.height + view.geometry.margin.vertical); + case _: height = Math.max(height, view.geometry.minHeight + view.geometry.margin.vertical); + } } if (!overflow) group.setContentSize(width, height, "group"); } @@ -30,29 +36,32 @@ class DefaultLayout extends Layout { placeViewVertical(group, view); false; case LAYOUT: - view.visible; + var result:Bool = view.visible; + result; } })); } private function setViewWidth(group:IGroupView, view:IView):Void { - view.width = switch view.geometry.width { + var width = switch view.geometry.width { case FIXED(value): value; case PERCENT(value): var calcWidth = value / 100 * (group.width - view.geometry.margin.horizontal - group.geometry.padding.horizontal); Math.max(view.geometry.minWidth, calcWidth); } + view.width = width; } private function setViewHeight(group:IGroupView, view:IView):Void { - view.height = switch view.geometry.height { + var height = switch view.geometry.height { case FIXED(value): value; case PERCENT(value): var calcHeigth = value / 100 * (group.height - view.geometry.margin.vertical - group.geometry.padding.vertical); Math.max(view.geometry.minHeight, calcHeigth); } + view.height = height; } private function placeViewHorizontal(group:IGroupView, view:IView):Void { diff --git a/src/main/haxework/view/layout/HorizontalLayout.hx b/src/main/haxework/view/layout/HorizontalLayout.hx index 6346097..197cd37 100755 --- a/src/main/haxework/view/layout/HorizontalLayout.hx +++ b/src/main/haxework/view/layout/HorizontalLayout.hx @@ -24,9 +24,9 @@ class HorizontalLayout extends DefaultLayout { } switch (view.geometry.height) { case FIXED(value): - maxSize = Math.max(maxSize, value); + maxSize = Math.max(maxSize, value + view.geometry.margin.vertical); case _: - maxSize = Math.max(maxSize, view.geometry.minHeight); + maxSize = Math.max(maxSize, view.geometry.minHeight + view.geometry.margin.vertical); } } diff --git a/src/main/haxework/view/layout/VerticalLayout.hx b/src/main/haxework/view/layout/VerticalLayout.hx index 8341711..2a4023a 100755 --- a/src/main/haxework/view/layout/VerticalLayout.hx +++ b/src/main/haxework/view/layout/VerticalLayout.hx @@ -24,9 +24,9 @@ class VerticalLayout extends DefaultLayout { } switch (view.geometry.width) { case FIXED(value): - maxSize = Math.max(maxSize, value); + maxSize = Math.max(maxSize, value + view.geometry.margin.horizontal); case _: - maxSize = Math.max(maxSize, view.geometry.minWidth); + maxSize = Math.max(maxSize, view.geometry.minWidth + view.geometry.margin.horizontal); } } diff --git a/src/main/haxework/view/popup/PopupManager.hx b/src/main/haxework/view/popup/PopupManager.hx index 2ef91bf..a8962eb 100755 --- a/src/main/haxework/view/popup/PopupManager.hx +++ b/src/main/haxework/view/popup/PopupManager.hx @@ -28,11 +28,16 @@ class PopupManager { public function close(popup:P):Void { popups.remove(popup); if (closeAnimateFactory != null) { - closeAnimateFactory(popup).start(function(_) { - cast(Root.instance.view, IGroupView).removeView(popup); - }); + closeAnimateFactory(popup).start(function(_) remove(popup)); } else { - cast(Root.instance.view, IGroupView).removeView(popup); + remove(popup); + } + } + + public function remove(popup:P):Void { + var container = cast(Root.instance.view, IGroupView); + if (container.views.indexOf(popup) > -1) { + container.removeView(popup); } }