public override void Draw() { var disabled = IsDisabled(); var font = Game.Renderer.Fonts[Font]; var rect = RenderBounds; var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height)); var state = disabled ? "checkbox-disabled" : Depressed && HasPressedState ? "checkbox-pressed" : Widget.MouseOverWidget == this ? "checkbox-hover" : "checkbox"; WidgetUtils.DrawPanel(state, check); var textSize = font.Measure(Text); font.DrawText(Text, new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y) / 2), Color.White); if (IsChecked() || (Depressed && HasPressedState && !disabled)) { var checkType = GetCheckType(); if (HasPressedState && (Depressed || disabled)) { checkType += "-disabled"; } var offset = new float2(rect.Left + CheckOffset, rect.Top + CheckOffset); WidgetUtils.DrawRGBA(ChromeProvider.GetImage("checkbox-bits", checkType), offset); } }
public override void DrawOuter() { if (!IsVisible()) { return; } var rb = RenderBounds; var ScrollbarHeight = rb.Height - 2 * ScrollbarWidth; var thumbHeight = ContentHeight == 0 ? 0 : Math.Max(MinimumThumbSize, (int)(ScrollbarHeight * Math.Min(rb.Height * 1f / ContentHeight, 1f))); var thumbOrigin = rb.Y + ScrollbarWidth + (int)((ScrollbarHeight - thumbHeight) * (-1f * ListOffset / (ContentHeight - rb.Height))); if (thumbHeight == ScrollbarHeight) { thumbHeight = 0; } backgroundRect = new Rectangle(rb.X, rb.Y, rb.Width - ScrollbarWidth + 1, rb.Height); upButtonRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y, ScrollbarWidth, ScrollbarWidth); downButtonRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth); scrollbarRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y + ScrollbarWidth - 1, ScrollbarWidth, ScrollbarHeight + 2); thumbRect = new Rectangle(rb.Right - ScrollbarWidth, thumbOrigin, ScrollbarWidth, thumbHeight); var upHover = Ui.MouseOverWidget == this && upButtonRect.Contains(Viewport.LastMousePos); var upDisabled = thumbHeight == 0 || ListOffset >= 0; var downHover = Ui.MouseOverWidget == this && downButtonRect.Contains(Viewport.LastMousePos); var downDisabled = thumbHeight == 0 || ListOffset <= Bounds.Height - ContentHeight; var thumbHover = Ui.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos); WidgetUtils.DrawPanel(Background, backgroundRect); WidgetUtils.DrawPanel("scrollpanel-bg", scrollbarRect); ButtonWidget.DrawBackground("button", upButtonRect, upDisabled, UpPressed, upHover, false); ButtonWidget.DrawBackground("button", downButtonRect, downDisabled, DownPressed, downHover, false); if (thumbHeight > 0) { ButtonWidget.DrawBackground("scrollthumb", thumbRect, false, HasMouseFocus && thumbHover, thumbHover, false); } var upOffset = !UpPressed || upDisabled ? 4 : 4 + ButtonDepth; var downOffset = !DownPressed || downDisabled ? 4 : 4 + ButtonDepth; WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", UpPressed || upDisabled ? "up_pressed" : "up_arrow"), new float2(upButtonRect.Left + upOffset, upButtonRect.Top + upOffset)); WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", DownPressed || downDisabled ? "down_pressed" : "down_arrow"), new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset)); Game.Renderer.EnableScissor(backgroundRect.InflateBy(-1, -1, -1, -1)); foreach (var child in Children) { child.DrawOuter(); } Game.Renderer.DisableScissor(); }
public override void Draw() { if (!IsVisible()) { return; } Value = GetValue(); var tr = ThumbRect; var rb = RenderBounds; var trackWidth = rb.Width - rb.Height; var trackOrigin = rb.X + rb.Height / 2; var trackRect = new Rectangle(trackOrigin - 1, rb.Y + (rb.Height - TrackHeight) / 2, trackWidth + 2, TrackHeight); // Tickmarks var tick = ChromeProvider.GetImage("slider", "tick"); for (var i = 0; i < Ticks; i++) { var tickPos = new float2( trackOrigin + (i * (trackRect.Width - (int)tick.size.X) / (Ticks - 1)) - tick.size.X / 2, trackRect.Bottom); WidgetUtils.DrawRGBA(tick, tickPos); } // Track WidgetUtils.DrawPanel(Track, trackRect); // Thumb var thumbHover = Ui.MouseOverWidget == this && tr.Contains(Viewport.LastMousePos); ButtonWidget.DrawBackground(Thumb, tr, IsDisabled(), isMoving, thumbHover, false); }
public override void Draw() { var name = GetImageName(); var collection = GetImageCollection(); WidgetUtils.DrawRGBA( ChromeProvider.GetImage(collection, name), RenderOrigin); }
public override void Draw() { var name = GetImageName(); var collection = GetImageCollection(); var sprite = ChromeProvider.GetImage(collection, name); if (sprite == null) { throw new ArgumentException("Sprite {0}/{1} was not found.".F(collection, name)); } WidgetUtils.DrawRGBA(sprite, RenderOrigin); }
public override void Draw() { base.Draw(); var stateOffset = (Depressed) ? new int2(VisualHeight, VisualHeight) : new int2(0, 0); var image = ChromeProvider.GetImage("scrollbar", IsDisabled() ? "down_pressed" : "down_arrow"); var rb = RenderBounds; WidgetUtils.DrawRGBA(image, stateOffset + new float2(rb.Right - rb.Height + 4, rb.Top + (rb.Height - image.bounds.Height) / 2)); WidgetUtils.FillRectWithColor(new Rectangle(stateOffset.X + rb.Right - rb.Height, stateOffset.Y + rb.Top + 3, 1, rb.Height - 6), Color.White); }
public override void Draw() { var disabled = IsDisabled(); var highlighted = IsHighlighted(); var font = Game.Renderer.Fonts[Font]; var color = GetColor(); var colordisabled = GetColorDisabled(); var contrast = GetContrastColor(); var rect = RenderBounds; var text = GetText(); var textSize = font.Measure(text); var check = new Rectangle(rect.Location, new Size(Bounds.Height, Bounds.Height)); var state = disabled ? "checkbox-disabled" : highlighted ? "checkbox-highlighted" : Depressed && HasPressedState ? "checkbox-pressed" : Ui.MouseOverWidget == this ? "checkbox-hover" : "checkbox"; WidgetUtils.DrawPanel(state, check); var position = new float2(rect.Left + rect.Height * 1.5f, RenderOrigin.Y - BaseLine + (Bounds.Height - textSize.Y) / 2); if (Contrast) { font.DrawTextWithContrast(text, position, disabled ? colordisabled : color, contrast, 2); } else { font.DrawText(text, position, disabled ? colordisabled : color); } if (IsChecked() || (Depressed && HasPressedState && !disabled)) { var checkType = GetCheckType(); if (HasPressedState && (Depressed || disabled)) { checkType += "-disabled"; } var offset = new float2(rect.Left + CheckOffset, rect.Top + CheckOffset); WidgetUtils.DrawRGBA(ChromeProvider.GetImage("checkbox-bits", checkType), offset); } }