internal static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex) { var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); painterObj.hideFlags = hideFlags; painterObj.transform.SetSiblingIndex(siblingIndex); return(ChartHelper.GetOrAddComponent <Painter>(painterObj)); }
public static TooltipView CreateView(Tooltip tooltip, ThemeStyle theme, Transform parent) { var view = new TooltipView(); view.tooltip = tooltip; view.theme = theme.tooltip; view.gameObject = ChartHelper.AddObject("view", parent, anchorMin, anchorMax, pivot, Vector3.zero); view.gameObject.transform.localPosition = Vector3.zero; view.transform = view.gameObject.transform; view.background = ChartHelper.GetOrAddComponent <Image>(view.gameObject); view.background.sprite = tooltip.backgroundImage; view.background.type = tooltip.backgroundType; view.background.color = ChartHelper.IsClearColor(tooltip.backgroundColor) ? Color.white : tooltip.backgroundColor; view.border = ChartHelper.GetOrAddComponent <Outline>(view.gameObject); view.border.enabled = tooltip.borderWidth > 0; view.border.useGraphicAlpha = false; view.border.effectColor = tooltip.borderColor; view.border.effectDistance = new Vector2(tooltip.borderWidth, -tooltip.borderWidth); view.layout = ChartHelper.GetOrAddComponent <VerticalLayoutGroup>(view.gameObject); view.layout.childControlHeight = false; view.layout.childControlWidth = false; view.layout.childForceExpandHeight = false; view.layout.childForceExpandWidth = false; view.layout.padding = new RectOffset(tooltip.paddingLeftRight, tooltip.paddingLeftRight, tooltip.paddingTopBottom, tooltip.paddingTopBottom); view.title = ChartHelper.AddChartLabel("title", view.gameObject.transform, tooltip.titleLabelStyle, theme.tooltip, "", Color.clear, TextAnchor.MiddleLeft); var item = CreateViewItem(0, view.gameObject.transform, tooltip, theme.tooltip); view.m_Items.Add(item); view.Refresh(); return(view); }
public static LegendItem AddLegendItem(BaseChart chart, Legend legend, int i, string legendName, Transform parent, ThemeStyle theme, string content, Color itemColor, bool active, int legendIndex) { var objName = i + "_" + legendName; var anchorMin = new Vector2(0, 0.5f); var anchorMax = new Vector2(0, 0.5f); var pivot = new Vector2(0, 0.5f); var sizeDelta = new Vector2(100, 30); var iconSizeDelta = new Vector2(legend.itemWidth, legend.itemHeight); var textStyle = legend.labelStyle.textStyle; var contentColor = GetContentColor(chart, legendIndex, legendName, legend, theme, active); var objAnchorMin = new Vector2(0, 1); var objAnchorMax = new Vector2(0, 1); var objPivot = new Vector2(0, 1); var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta); var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta); var img = ChartHelper.GetOrAddComponent <Image>(btnObj); img.color = Color.clear; img.raycastTarget = true; ChartHelper.GetOrAddComponent <Button>(btnObj); ChartHelper.GetOrAddComponent <Image>(iconObj); var label = ChartHelper.AddChartLabel("content", btnObj.transform, legend.labelStyle, theme.legend, content, contentColor, TextAnchor.MiddleLeft); label.SetActive(true); var item = new LegendItem(); item.index = i; item.name = objName; item.legendName = legendName; item.SetObject(btnObj); item.SetIconSize(legend.itemWidth, legend.itemHeight); item.SetIconColor(itemColor); item.SetIconImage(legend.GetIcon(i)); item.SetContentPosition(legend.labelStyle.offset); item.SetContent(content); //item.SetBackground(legend.background); return(item); }
public override void InitComponent() { component.painter = chart.painter; component.refreshComponent = delegate() { var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); component.gameObject = backgroundObj; backgroundObj.hideFlags = chart.chartHideFlags; var backgroundImage = ChartHelper.GetOrAddComponent <Image>(backgroundObj); ChartHelper.UpdateRectTransform(backgroundObj, chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); backgroundImage.sprite = component.image; backgroundImage.type = component.imageType; backgroundImage.color = chart.theme.GetBackgroundColor(component); backgroundObj.transform.SetSiblingIndex(0); backgroundObj.SetActive(component.show); }; component.refreshComponent(); }