public void AppendLine() { RealocateLines(); m_currentLine = m_lines[++m_linesCount]; m_currentLineRestFreeSpace = m_maxLineWidth; RealocateRichTexts(); }
private void Init() { m_helperSb.Clear(); m_sizeDirty = true; m_size = Vector2.Zero; m_lineSeparatorsCount = 0; m_lineSeparatorsCapacity = 32; m_richTextsOffset = 0; m_richTexsCapacity = 32; m_currentLineRestFreeSpace = m_maxLineWidth; m_lineSeparatorFirst = 0; m_lineSeparators = new List <MyRichLabelLine>(m_lineSeparatorsCapacity); for (int i = 0; i < m_lineSeparatorsCapacity; i++) { m_lineSeparators.Add(new MyRichLabelLine(m_minLineHeight)); } m_currentLine = m_lineSeparators[0]; m_richTextsPool = new List <MyRichLabelText>(m_richTexsCapacity); for (int i = 0; i < m_richTexsCapacity; i++) { m_richTextsPool.Add(new MyRichLabelText() { ShowTextShadow = this.ShowTextShadow, Tag = m_parent.Name }); } }
private void AppendPart(MyRichLabelPart part) { m_currentLine = m_lineSeparators[GetIndexSafe(m_lineSeparatorsCount)]; m_currentLine.AddPart(part); m_currentLineRestFreeSpace = m_maxLineWidth - m_currentLine.Size.X; m_sizeDirty = true; }
private void Init() { m_helperSb.Clear(); m_sizeDirty = true; m_size = Vector2.Zero; m_lineSeparatorsCount = 0; m_lineSeparatorsCapacity = 32; m_richTextsOffset = 0; m_richTexsCapacity = 32; m_currentLineRestFreeSpace = m_maxLineWidth; m_lineSeparatorFirst = 0; m_lineSeparators = new List<MyRichLabelLine>(m_lineSeparatorsCapacity); for (int i = 0; i < m_lineSeparatorsCapacity; i++) { m_lineSeparators.Add(new MyRichLabelLine(m_minLineHeight)); } m_currentLine = m_lineSeparators[0]; m_richTextsPool = new List<MyRichLabelText>(m_richTexsCapacity); for (int i = 0; i < m_richTexsCapacity; i++) { m_richTextsPool.Add(new MyRichLabelText() { ShowTextShadow = this.ShowTextShadow, Tag = m_parent.Name }); } }
public void AppendLine() { if (m_lineSeparatorsCount == m_visibleLinesCount) { m_lineSeparatorFirst = GetIndexSafe(1); m_currentLine = m_lineSeparators[GetIndexSafe(m_lineSeparatorsCount)]; m_currentLine.ClearParts(); } else { ReallocateLines(); ++m_lineSeparatorsCount; m_currentLine = m_lineSeparators[GetIndexSafe(m_lineSeparatorsCount)]; } m_currentLineRestFreeSpace = m_maxLineWidth; ReallocateRichTexts(); m_sizeDirty = true; }
/// <summary> /// Draws label /// </summary> /// <param name="position">Top-left position</param> /// <param name="offset"></param> /// <param name="drawSizeMax"></param> /// <returns></returns> public bool Draw(Vector2 position, float offset, Vector2 drawSizeMax) { RectangleF scissorRect = new RectangleF(position, drawSizeMax); OnAdjustingScissorRectangle(ref scissorRect); Vector2 textSize = Size; using (MyGuiManager.UsingScissorRectangle(ref scissorRect)) { // Compute data for text positioning. Vector2 drawPosition = Vector2.Zero; float horizontalAdjustment = 0.0f; switch (TextAlign) { case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP: case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER: case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM: break; case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP: case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER: case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM: drawPosition.X = 0.5f * drawSizeMax.X - 0.5f * textSize.X; horizontalAdjustment = 0.5f; break; case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP: case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER: case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM: drawPosition.X = drawSizeMax.X - textSize.X; horizontalAdjustment = 1.0f; break; } switch (TextAlign) { case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP: case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP: case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP: break; case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER: case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER: case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER: drawPosition.Y = 0.5f * drawSizeMax.Y - 0.5f * textSize.Y; break; case MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM: case MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM: case MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM: drawPosition.Y = drawSizeMax.Y - textSize.Y; break; } drawPosition.Y -= offset; for (int i = 0; i <= m_lineSeparatorsCount; ++i) { MyRichLabelLine currentLine = m_lineSeparators[GetIndexSafe(i)]; var lineSize = currentLine.Size; var pos = position + drawPosition; pos.X += horizontalAdjustment * (textSize.X - lineSize.X); currentLine.Draw(pos); drawPosition.Y += lineSize.Y; } } return(true); }
public void Clear() { m_lines.Clear(); m_currentLine = null; Init(); }
private void AppendPart(MyRichLabelPart part) { m_currentLine = m_lines[m_linesCount]; m_currentLine.AddPart(part); m_currentLineRestFreeSpace = m_maxLineWidth - m_currentLine.GetSize().X; }
public void AppendLine() { RealocateLines(); m_currentLine = m_lines[++m_linesCount]; m_currentLineRestFreeSpace = m_maxLineWidth; RealocateRichTexts(); }
public void Clear() { m_lines.Clear(); m_currentLine = null; Init(); }
private void AppendPart(MyRichLabelPart part) { m_currentLine = m_lines[m_linesCount]; m_currentLine.AddPart(part); m_currentLineRestFreeSpace = m_maxLineWidth - m_currentLine.GetSize().X; }
private void AppendPart(MyRichLabelPart part) { m_currentLine = m_lineSeparators[GetIndexSafe(m_lineSeparatorsCount)]; m_currentLine.AddPart(part); m_currentLineRestFreeSpace = m_maxLineWidth - m_currentLine.Size.X; m_sizeDirty = true; }
public void AppendLine() { if (m_lineSeparatorsCount == m_visibleLinesCount) { m_lineSeparatorFirst = GetIndexSafe(1); m_currentLine = m_lineSeparators[GetIndexSafe(m_lineSeparatorsCount)]; m_currentLine.ClearParts(); } else { ReallocateLines(); ++m_lineSeparatorsCount; m_currentLine = m_lineSeparators[GetIndexSafe(m_lineSeparatorsCount)]; } m_currentLineRestFreeSpace = m_maxLineWidth; ReallocateRichTexts(); m_sizeDirty = true; }