private UIComponent InitComponent(UIComponent component, UIParamPropsBase properties, bool isFixed = true) { var parentComponent = GetParentComponent(properties); ParentTreeDict.Add(component, parentComponent); properties.Component = component; component.tooltip = properties.ToolTip; var addUIComponent = !(properties is UIButtonParamProps) || (properties as UIButtonParamProps).AddUIComponent; if (!string.IsNullOrEmpty(properties.Name)) { component.name = properties.Name; } component.width = addUIComponent ? properties.GetWidth() : 0; component.height = addUIComponent ? properties.Height : 0; component.eventClick += properties.EventClick; if (isFixed) { if (properties.StackWidths) { component.relativePosition = properties.GetRelativePositionByStackedWidths(m_stackedWidths); } else if (properties.ColShare > -1) { component.relativePosition = properties.GetRelativePositionByColumnShare(m_totalColShare); } else if (addUIComponent) { component.relativePosition = properties.GetRelativePositionByColumnCount(m_colIndex); } HandleNextPositioning(properties); } return(component); }
protected UIComponent GetParentComponent(UIParamPropsBase properties) { if (properties.ParentComponent == null) { properties.ParentComponent = this; } return(properties.ParentComponent); }
protected UISlicedSprite CreateUISlicedSprite(UIParamPropsBase properties) { var parentComponent = GetParentComponent(properties); UISlicedSprite sprite = (UISlicedSprite)InitComponent(parentComponent.AddUIComponent <UISlicedSprite>(), properties); if (properties.Atlas != null) { sprite.atlas = properties.Atlas; } sprite.zOrder = 1; return(sprite); }
private void HandleNextPositioning(UIParamPropsBase properties) { m_colIndex++; if (properties.StackWidths) { m_stackedWidths += properties.Width + properties.Margins.x; } if (properties.ColShare > -1) { m_totalColShare += properties.ColShare + properties.ColOffset; } if (m_colIndex * properties.Component.width > ParentTreeDict[properties.Component].width) { //var diff = ((m_colIndex + 1) * properties.Component.width) - ParentTreeDict[properties.Component].width; //PropagateParentComponentWidthUpdates(ParentTreeDict[properties.Component], diff); } if ((m_colIndex == properties.ColumnCount && properties.ColShare == -1) || properties.ForceRowEnd || m_totalColShare >= 12) { m_colIndex = 0; m_totalColShare = 0; m_stackedWidths = 0; if (properties.SameLine == false) { m_rowIndex++; var rowHeightAdditive = properties.Component.height + properties.Margins.y + properties.Margins.w; PropagateParentComponentHeightUpdates(properties.Component, rowHeightAdditive); foreach (var kvp in ParentTreeDict) { if (kvp.Key.parent != this && kvp.Key.parent != null) { if (properties.Component?.parent?.parent != null) { if (kvp.Key.parent == properties.Component.parent.parent) { } } } } } } }