protected override void DrawSelection(ICaret caret, Color color, ITextComponentWrapper text, Vector2 offset) { int index = LocalIndex(); int selectionIndex = LocalSelectionIndex(text); using (var helper = new VertexHelper()) { Caret.Draw(CalculateCaretDrawRect(text, offset, index, selectionIndex), color, helper); } }
public override void Draw(RenderContext context, GraphicsManager gfx) { context.Rectangle(ShapeMode.Fill, CalculatedPosition, _renderedSize.X, _renderedSize.Y, Color.White); if (string.IsNullOrEmpty(Text)) { var textSize = Font.Measure(Placeholder); var textPosition = CalculatedPosition + new Vector2( 0, CalculatedSize.Y / 2 - textSize.Height / 2); context.DrawString(Font, Placeholder, textPosition + new Vector2(3, -1), (c, i, arg3, arg4) => new GlyphTransformData(arg3) { Color = Color.LightSlateGray }); } else { var textSize = Font.Measure(Text); var textPosition = CalculatedPosition + new Vector2( 0, CalculatedSize.Y / 2 - textSize.Height / 2); context.DrawString(Font, Text, textPosition + new Vector2(3, -1), (c, i, arg3, arg4) => new GlyphTransformData(arg3) { Color = Color.Black }); } if (Focused) { caret.Draw(context, gfx); } if (BorderColor.HasValue) { var oldThickness = gfx.LineThickness; gfx.LineThickness = BorderThickness; context.Rectangle(ShapeMode.Stroke, CalculatedPosition, _renderedSize.X, _renderedSize.Y, BorderColor.Value); gfx.LineThickness = oldThickness; } }
public static bool Draw(string text, Size size, Caret.CaretType caretType, ColorName barColorName, AnimBool expanded) { Color initialColor = GUI.color; bool result = false; GUIStyle barStyle = BarStyle(size, expanded.target); var labelStyle = new GUIStyle(LabelStyle(size, expanded.target)) { normal = { textColor = Colors.TextColor(barColorName) } }; float barHeight = barStyle.fixedHeight; float caretSize = barHeight * CARET_SIZE_RATIO; GUILayout.BeginVertical(GUILayout.Height(barHeight)); { GUI.color = Colors.BarColor(barColorName, expanded.target); if (GUILayout.Button(GUIContent.none, barStyle, GUILayout.ExpandWidth(true))) { expanded.target = !expanded.target; Properties.ResetKeyboardFocus(); Event.current.Use(); result = true; } GUI.color = initialColor; GUILayout.Space(-barHeight); GUILayout.Label(new GUIContent(text), labelStyle, GUILayout.ExpandWidth(true), GUILayout.Height(barHeight)); GUILayout.Space(-barHeight); Caret.Draw(expanded, barColorName, caretType, caretSize); } GUILayout.EndVertical(); return(result); }