public override void Draw(float transitionAlpha, float backgroundTransitionAlpha) { base.Draw(transitionAlpha, backgroundTransitionAlpha); var textArea = new MyRectangle2D(m_textPadding.TopLeftOffset, Size - m_textPadding.SizeChange); textArea.LeftTop += GetPositionAbsoluteTopLeft() + m_textPadding.TopLeftOffset; Vector2 carriageOffset = GetCarriageOffset(CarriagePositionIndex); var scissor = new RectangleF(textArea.LeftTop, textArea.Size); // Adjust the scissor a little bit, because currently it's hiding the carriage at its left side, and it's // too far out on the edges. scissor.X -= 0.001f; scissor.Y -= 0.001f; AdjustScissorRectangle(ref scissor); using (MyGuiManager.UsingScissorRectangle(ref scissor)) { DrawSelectionBackgrounds(textArea, backgroundTransitionAlpha); DrawText(m_scrollbar.Value); // Draw carriage line // Carriage blinker time is solved here in Draw because I want to be sure it will be drawn even in low FPS if (HasFocus && Selectable) { // This condition controls "blinking", so most often is carrier visible and blinks very fast // It also depends on FPS, but as we have max FPS set to 60, it won't go faster, nor will it omit a "blink". int carriageInterval = m_carriageBlinkerTimer % 20; if ((carriageInterval >= 0) && (carriageInterval <= 15)) { MyGuiManager.DrawSpriteBatch(MyGuiConstants.BLANK_TEXTURE, textArea.LeftTop + carriageOffset, 1, GetCarriageHeight(), ApplyColorMaskModifiers(Vector4.One, Enabled, transitionAlpha), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } } m_carriageBlinkerTimer++; if (m_drawScrollbar) { m_scrollbar.Draw(ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha)); } } //m_scrollbar.DebugDraw(); }
public void Draw(float transitionAlpha) { var scissor = new RectangleF(m_body.GetPosition(), m_body.GetSize()); using (MyGuiManager.UsingScissorRectangle(ref scissor)) { m_body.Draw(transitionAlpha); } Color borderColor = MyGuiControlBase.ApplyColorMaskModifiers(MyGuiConstants.TREEVIEW_VERTICAL_LINE_COLOR, true, transitionAlpha); MyGUIHelper.OutsideBorder(m_position, m_size, 2, borderColor); m_vScrollbar.Draw(Color.White); m_hScrollbar.Draw(Color.White); }
public override void Draw(float transitionAlpha, float backgroundTransitionAlpha) { base.Draw(transitionAlpha, backgroundTransitionAlpha); var scrollbarMask = ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha); if (m_scrollbarV != null) { m_scrollbarV.ScrollBarScale = ScrollBarVScale; m_scrollbarV.Draw(scrollbarMask); } if (m_scrollbarH != null) { m_scrollbarH.ScrollBarScale = ScrollBarHScale; m_scrollbarH.Draw(scrollbarMask); } //DebugDraw(); }
public override void Draw(float transitionAlpha) { Debug.Assert(m_visibleRowIndexOffset >= 0); base.Draw(transitionAlpha); var positionTopLeft = GetPositionAbsoluteTopLeft(); m_styleDef.Texture.Draw(positionTopLeft, Size, ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha)); var position = positionTopLeft + new Vector2(m_itemsRectangle.X, m_itemsRectangle.Y); int index = m_visibleRowIndexOffset; //if at least one item has an icon, draw it with spacing to all of them (alighment) Vector2 iconSize = Vector2.Zero; Vector2 iconOffset = Vector2.Zero; if (ShouldDrawIconSpacing()) { iconSize = MyGuiConstants.LISTBOX_ICON_SIZE; iconOffset = MyGuiConstants.LISTBOX_ICON_OFFSET; } for (int i = 0; i < VisibleRowsCount; ++i) { var idx = i + m_visibleRowIndexOffset; if (idx >= Items.Count) { break; } Debug.Assert(idx >= 0); if (idx < 0) { continue; } while (index < Items.Count && !Items[index].Visible) { index++; } if (index >= Items.Count) { break; } var item = Items[index]; index++; if (item != null) { Color color = ApplyColorMaskModifiers(item.ColorMask * ColorMask, Enabled, transitionAlpha); bool isHighlit = SelectedItems.Contains(item) || item == m_mouseOverItem; MyFontEnum font = item.FontOverride ?? (isHighlit ? m_styleDef.ItemFontHighlight : m_styleDef.ItemFontNormal); if (isHighlit) { MyGuiManager.DrawSpriteBatch(m_styleDef.ItemTextureHighlight, position, ItemSize, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); } if (!String.IsNullOrEmpty(item.Icon)) { MyGuiManager.DrawSpriteBatch( texture: item.Icon, normalizedCoord: position + iconOffset, normalizedSize: iconSize, color: color, drawAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP ); } MyGuiManager.DrawString(font, item.Text, position + new Vector2(iconSize.X + 2 * iconOffset.X, 0) + new Vector2(m_styleDef.TextOffset, 0f), TextScale, color, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, maxTextWidth: ItemSize.X - iconSize.X - 2 * iconOffset.X); } position.Y += ItemSize.Y; } //DebugDraw(); if (m_styleDef.DrawScroll) { m_scrollBar.Draw(ApplyColorMaskModifiers(ColorMask, Enabled, transitionAlpha)); } }