public void DrawDraged(Vector2 position, float transitionAlpha) { if ((m_icon != null) || Text != null) { if (m_icon != null) { string texture = m_icon; if (texture == null) { // texture is still being loaded on other thread DrawLoadingIcon(Vector4.One, GetIconPosition(), transitionAlpha); } else { MyGUIHelper.OutsideBorder(position + GetIconPosition(), m_iconSize, 2, MyGuiConstants.THEMED_GUI_LINE_COLOR); MyGuiManager.DrawSpriteBatch(m_icon, position + GetIconPosition(), m_iconSize, Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } } else if (Text != null) { var leftTop = position + GetTextPosition(); var size = MyGuiManager.MeasureString(MyFontEnum.Blue, Text, 0.8f); MyGUIHelper.OutsideBorder(leftTop, size, 2, MyGuiConstants.THEMED_GUI_LINE_COLOR); MyGUIHelper.FillRectangle(leftTop, size, TreeView.GetColor(MyGuiConstants.TREEVIEW_SELECTED_ITEM_COLOR, transitionAlpha)); Color textColor = TreeView.GetColor(MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER, transitionAlpha); MyGuiManager.DrawString(MyFontEnum.Blue, Text, position + GetTextPosition(), 0.8f, textColor, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } } }
public void Draw(float transitionAlpha) { if (!Visible || !TreeView.Contains(m_currentOrigin, m_currentSize)) { return; } bool isHighlighted = TreeView.HooveredItem == this; Vector2 expandIconPosition = GetExpandIconPosition(); Vector2 iconPosition = GetIconPosition(); Vector2 textPosition = GetTextPosition(); Vector4 baseColor = Enabled ? Vector4.One : MyGuiConstants.TREEVIEW_DISABLED_ITEM_COLOR; if (TreeView.FocusedItem == this) { Color selectedColor = TreeView.GetColor(MyGuiConstants.TREEVIEW_SELECTED_ITEM_COLOR * baseColor, transitionAlpha); if (TreeView.WholeRowHighlight()) { MyGUIHelper.FillRectangle(new Vector2(TreeView.GetPosition().X, m_currentOrigin.Y), new Vector2(TreeView.GetBodySize().X, m_currentSize.Y), selectedColor); } else { MyGUIHelper.FillRectangle(m_currentOrigin, m_currentSize, selectedColor); } } if (GetItemCount() > 0) { Vector4 expandColor = (isHighlighted) ? baseColor * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : baseColor; MyGuiManager.DrawSpriteBatch(IsExpanded ? m_collapseIcon : m_expandIcon, m_currentOrigin + expandIconPosition, m_expandIconSize, TreeView.GetColor(expandColor, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } if (m_icon == null) { // texture is still being loaded on other thread DrawLoadingIcon(baseColor, iconPosition, transitionAlpha); } else { MyGuiManager.DrawSpriteBatch(m_icon, m_currentOrigin + iconPosition, m_iconSize, TreeView.GetColor(baseColor, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } Vector4 textColor = (isHighlighted) ? MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER * baseColor : MyGuiConstants.TREEVIEW_TEXT_COLOR * baseColor; MyGuiManager.DrawString(MyFontEnum.Blue, Text, m_currentOrigin + textPosition, 0.8f, TreeView.GetColor(textColor, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); if (IconTexts != null) { IconTexts.Draw(m_currentOrigin + iconPosition, m_iconSize, transitionAlpha, isHighlighted); } }