public void RenderRow(ITreeViewItemWrapper <TSource> item, ITreeviewSourceDecoder <TSource> treeviewSourceDecoder, EventType currentEventType) { if (item == null) { throw new ArgumentNullException("item"); } if (treeviewSourceDecoder == null) { throw new ArgumentNullException("treeviewSourceDecoder"); } var gridRect = new Rect(0, 0, 0, 0); guiLayout.BeginHorizontal(); guiLayout.Space(1); // In order to use the GUI.DrawTexture which takes absolute position on the page // we have to get the relative location of the space we just drew. if (currentEventType == EventType.repaint) { gridRect = guiLayout.GetLastRect(); } var structureX = RenderTreeviewIcons(item, gridRect, currentEventType); var iconTopLeft = new Vector2(gridRect.x + structureX, gridRect.y); guiLayout.Space(gridRect.x + structureX); var itemIconDimensions = iconRenderer.RenderItemIcon(item, iconTopLeft); if (itemIconDimensions.x > 0) { rowClickableLocations.RegisterRowIcon(new Rect(iconTopLeft.x, iconTopLeft.y, itemIconDimensions.x, itemIconDimensions.y), item); } guiLayout.Space(itemIconDimensions.x); var renderContext = new RenderDisplayContext(item.IsSelected, item.IsExpanded, item.IsActive); treeviewSourceDecoder.RenderDisplay(item.Value, renderContext); if (currentEventType == EventType.repaint) { gridRect = guiLayout.GetLastRect(); rowClickableLocations.RegisterRowContent(gridRect, item); } guiLayout.EndHorizontal(); }
public override Texture2D ItemIcon(Treeview_DataModel item, RenderDisplayContext context) { if (item.EntityID < 0) { return(null); } if (item.IsUnit) { return(this.LoadImageFromFile(string.Format("Images/DamageUnits/{0}", GetTexureID(item.Health)))); } return(this.LoadImageFromFile(string.Format("Images/DamageMembers/{0}", item.Health))); }
private void RenderDisplayFunction(Treeview_DataModel item, RenderDisplayContext context) { if (item == null) { return; } var text = item.Text; GUIStyle style = new GUIStyle(); style.alignment = TextAnchor.MiddleLeft; style.fixedHeight = 16f; style.normal.textColor = context.IsSelected ? ContentRenderingColours.SelectedText : ContentRenderingColours.NormalText; GUIStyle styleToggle = new GUIStyle(GUI.skin.toggle); style.fixedHeight = 16f; styleToggle.border.top = 0; styleToggle.border.bottom = 0; styleToggle.normal.textColor = context.IsSelected ? ContentRenderingColours.SelectedText : ContentRenderingColours.NormalText; style.alignment = TextAnchor.MiddleLeft; bool beforeChange = item.IsAggregated; this._guiLayout.BeginHorizontal(); //if (item.IsUnit) //item.IsAggregated = GUILayout.Toggle(item.IsAggregated, "", styleToggle, new GUILayoutOption[] { GUILayout.MaxWidth(10.0f) }); if (item.IsAggregated) { if (GUILayout.Button(this.toogleNotVisible, GUIStyle.none, GUILayout.Width(15), GUILayout.Height(15))) { item.IsAggregated = false; } } else { if (GUILayout.Button(this.toogleVisible, GUIStyle.none, GUILayout.Width(15), GUILayout.Height(15))) { item.IsAggregated = true; } } this._guiLayout.Label(" " + text, style); this._guiLayout.EndHorizontal(); // item toggle handling if (item.IsAggregated != beforeChange) { item.IsSelfAggregated = item.IsAggregated; if (item.IsUnit) { HideChildren_Rec(item, !item.IsAggregated); } else { HideMember(item, !item.IsAggregated); } if (!item.IsSelfAggregated) { UntoggleFathers_Rec(item); } } }