[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);
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<Dynamic>):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<Dynamic>):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<Dynamic>):Void {

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}