[view] fix layouts resize

This commit is contained in:
2019-06-07 17:19:07 +03:00
parent b7ad9df8af
commit 400d91ef6e
4 changed files with 27 additions and 13 deletions

View File

@@ -14,8 +14,14 @@ class DefaultLayout extends Layout {
setViewHeight(group, view); setViewHeight(group, view);
placeViewHorizontal(group, view); placeViewHorizontal(group, view);
placeViewVertical(group, view); placeViewVertical(group, view);
width = Math.max(width, view.width); switch view.geometry.width {
height = Math.max(height, view.height); 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"); if (!overflow) group.setContentSize(width, height, "group");
} }
@@ -30,29 +36,32 @@ class DefaultLayout extends Layout {
placeViewVertical(group, view); placeViewVertical(group, view);
false; false;
case LAYOUT: case LAYOUT:
view.visible; var result:Bool = view.visible;
result;
} }
})); }));
} }
private function setViewWidth(group:IGroupView, view:IView<Dynamic>):Void { private function setViewWidth(group:IGroupView, view:IView<Dynamic>):Void {
view.width = switch view.geometry.width { var width = switch view.geometry.width {
case FIXED(value): case FIXED(value):
value; value;
case PERCENT(value): case PERCENT(value):
var calcWidth = value / 100 * (group.width - view.geometry.margin.horizontal - group.geometry.padding.horizontal); var calcWidth = value / 100 * (group.width - view.geometry.margin.horizontal - group.geometry.padding.horizontal);
Math.max(view.geometry.minWidth, calcWidth); Math.max(view.geometry.minWidth, calcWidth);
} }
view.width = width;
} }
private function setViewHeight(group:IGroupView, view:IView<Dynamic>):Void { private function setViewHeight(group:IGroupView, view:IView<Dynamic>):Void {
view.height = switch view.geometry.height { var height = switch view.geometry.height {
case FIXED(value): case FIXED(value):
value; value;
case PERCENT(value): case PERCENT(value):
var calcHeigth = value / 100 * (group.height - view.geometry.margin.vertical - group.geometry.padding.vertical); var calcHeigth = value / 100 * (group.height - view.geometry.margin.vertical - group.geometry.padding.vertical);
Math.max(view.geometry.minHeight, calcHeigth); Math.max(view.geometry.minHeight, calcHeigth);
} }
view.height = height;
} }
private function placeViewHorizontal(group:IGroupView, view:IView<Dynamic>):Void { private function placeViewHorizontal(group:IGroupView, view:IView<Dynamic>):Void {

View File

@@ -24,9 +24,9 @@ class HorizontalLayout extends DefaultLayout {
} }
switch (view.geometry.height) { switch (view.geometry.height) {
case FIXED(value): case FIXED(value):
maxSize = Math.max(maxSize, value); maxSize = Math.max(maxSize, value + view.geometry.margin.vertical);
case _: case _:
maxSize = Math.max(maxSize, view.geometry.minHeight); maxSize = Math.max(maxSize, view.geometry.minHeight + view.geometry.margin.vertical);
} }
} }

View File

@@ -24,9 +24,9 @@ class VerticalLayout extends DefaultLayout {
} }
switch (view.geometry.width) { switch (view.geometry.width) {
case FIXED(value): case FIXED(value):
maxSize = Math.max(maxSize, value); maxSize = Math.max(maxSize, value + view.geometry.margin.horizontal);
case _: case _:
maxSize = Math.max(maxSize, view.geometry.minWidth); maxSize = Math.max(maxSize, view.geometry.minWidth + view.geometry.margin.horizontal);
} }
} }

View File

@@ -28,11 +28,16 @@ class PopupManager {
public function close(popup:P):Void { public function close(popup:P):Void {
popups.remove(popup); popups.remove(popup);
if (closeAnimateFactory != null) { if (closeAnimateFactory != null) {
closeAnimateFactory(popup).start(function(_) { closeAnimateFactory(popup).start(function(_) remove(popup));
cast(Root.instance.view, IGroupView).removeView(popup);
});
} else { } 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);
} }
} }