Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @:access(Component)
- public function refresh() {
- trace('Layout::refresh - ${component.id}, autoWidth: ${component.autoWidth}, autoHeight: ${component.autoHeight}, layoutDirty: ${component.layoutDirty}, childrenLayedOut: ${component.childrenLayedOut}');
- if (component.layoutDirty == false) {
- trace(' skipping, layout not dirty');
- return;
- }
- /*
- if (component.childrenLayedOut == false && (component.autoWidth == true || component.autoHeight == true)) {
- trace(' skipping, children not layed out and auto width/height is true');
- return;
- }
- */
- if (component.childrenLayedOut == false) {
- trace(' skipping, children not layed out');
- return;
- }
- /*
- if (component.percentWidth != null && component.parentComponent.percentWidth != null) {
- //return;
- }
- */
- var calculatedWidth:Null<Float> = null;
- var calculatedHeight:Null<Float> = null;
- if (component.autoWidth == true || component.autoHeight == true) {
- var size:Size = calcAutoSize();
- if (component.autoWidth == true) {
- calculatedWidth = size.width;
- }
- if (component.autoHeight == true) {
- calculatedHeight = size.height;
- }
- }
- if (component.percentWidth != null) {
- if (component.parentComponent.percentWidth == null) {
- /*
- var ucx = component.parentComponent.width - component.parentComponent.padding * 2;
- trace(">>>>>>>>>>>>>>>>>>> component.id " + component.id);
- trace(">>>>>>>>>>>>>>>>>>> parent.id " + component.parentComponent.id);
- for (child in component.parentComponent.children) {
- if (child.percentWidth == null) {
- ucx -= child.width + component.spacing;
- }
- }
- */
- var ucx = component.parentComponent.layout.calcUsableSize().width;
- calculatedWidth = (ucx * component.percentWidth) / 100;
- }
- }
- if (component.percentHeight != null) {
- if (component.parentComponent.percentHeight == null) {
- /*
- var ucy = component.parentComponent.height - component.parentComponent.padding * 2;
- for (child in component.children) {
- if (child.percentHeight == null) {
- ucy -= child.height + component.spacing;
- }
- }
- */
- var ucy = component.parentComponent.layout.calcUsableSize().height;
- calculatedHeight = (ucy * component.percentHeight) / 100;
- }
- }
- if (component.autoWidth == false && component.percentWidth == null) {
- calculatedWidth = component.width;
- }
- if (component.autoHeight == false && component.percentHeight == null) {
- calculatedHeight = component.height;
- }
- if (layoutRefreshStats.exists(component.id) == false) {
- layoutRefreshStats.set(component.id, 0);
- }
- layoutRefreshStats.set(component.id, layoutRefreshStats.get(component.id) + 1);
- component.layoutDirty = false;
- //if (component.parentComponent != null && (component.parentComponent.autoWidth == true || component.parentComponent.autoHeight == true)) {
- if (component.parentComponent != null) {
- component.parentComponent.layoutDirty = true;
- }
- if (calculatedWidth != component._componentWidth || calculatedHeight != component._componentHeight) {
- //component.resize(calculatedWidth, calculatedHeight);
- }
- component.resize(calculatedWidth, calculatedHeight);
- //repositionChildren();
- for (child in component.children) {
- var ucx = component.layout.calcUsableSize().width;// component.width - component.padding * 2 - ((component.children.length - 1) * component.spacing);
- var ucy = component.layout.calcUsableSize().height;// component.height - component.padding * 2;// - ((component.children.length - 1) * component.spacing);
- calculatedWidth = null;
- calculatedHeight = null;
- if (child.percentWidth != null) {
- calculatedWidth = (ucx * child.percentWidth) / 100;
- }
- if (child.percentHeight != null) {
- calculatedHeight = (ucy * child.percentHeight) / 100;
- }
- child.resize(calculatedWidth, calculatedHeight);
- child.layout.repositionChildren();
- }
- repositionChildren();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement