public override void DrawCheckBox(PicoGfx gfx, CheckBox checkbox) { var x = checkbox.GlobalX; var y = checkbox.GlobalY; var w = checkbox.W; var h = checkbox.H; if (!checkbox.Active) { Color fillColor = !checkbox.Checked ? FrameFillColor : CheckboxFillColor; DrawFrame( gfx, x, y, w, h, ref FrameOuterBorderColor, ref FrameInnerBorderColor, ref fillColor, drawShadow: true); } else { DrawFrame( gfx, x, y + 1, w, h, ref FrameOuterBorderColor, ref FrameInnerBorderColor, ref CheckboxFillColor, drawShadow: false); } }
public override void DrawSlider(PicoGfx gfx, Slider slider) { int x = slider.GlobalX; int y = slider.GlobalY; int w = slider.W; int h = slider.H; //var textSize = canvas.MeasureText(slider.Value.ToString(), _font); //var labelPosX = (x) + (w / 2 - textSize.Width / 2); //var labelPosY = (y + 2) + (h / 2 - textSize.Height / 2); float valueFactor = (float)(slider.Value) / (slider.MaxValue - slider.MinValue); if (slider.Orientation == Orientation.Horizontal) { DrawFrame( gfx, x, y, w, h, ref FrameOuterBorderColor, ref FrameInnerBorderColor, ref FrameFillColor, drawShadow: true); int indicatorSize = (int)(valueFactor * w); indicatorSize = Calculate.Clamp(indicatorSize, 0, w - 4); gfx.SetColor(ref SliderFillColor); gfx.FillRect(x + 2, y + 2, indicatorSize, h - 4); //canvas.DrawText($"{slider.Value}", _font, labelPosX, labelPosY, 2); } else { DrawFrame( gfx, x, y, w, h, ref FrameOuterBorderColor, ref FrameInnerBorderColor, ref FrameFillColor, drawShadow: true); int indicatorSize = (int)(((float)(slider.Value) / (slider.MaxValue - slider.MinValue)) * h); indicatorSize = Calculate.Clamp(indicatorSize, 0, h - 4); gfx.SetColor(ref SliderFillColor); gfx.FillRect(x + 2, y + 2, w - 3, indicatorSize); } }
internal PicoGui(PicoGfx gfx, int width, int height) { _guiSurface = new PicoSurface(gfx, width, height, PicoSurface.AccessType.Target); _uiMouseState = new UIMouseState(); _theme = new DefaultTheme(); _root = new Container(this, width, height); PicoGui.Instance = this; }
public void Render(PicoGfx gfx) { if (_invalidated) { gfx.BeginSurface(_guiSurface); _root.Draw(gfx, _theme); gfx.EndSurface(); _invalidated = false; } gfx.DrawSurface(_guiSurface, 0, 0); }
public PicoGame() { Instance = this; PicoPlatform.Initialize(); _gfx = new PicoGfx(); _input = new PicoInput(); PicoPlatform.TerminateRequested += (sender, args) => this.Quit(); PicoPlatform.DisplayResized += OnDisplayResize; PicoPlatform.GamePadAdded += (sender, gamepadDesc) => _input.AddGamePad(gamepadDesc); PicoPlatform.GamePadRemoved += (sender, slot) => _input.RemoveGamePad(slot); }
private void DrawFrame(PicoGfx gfx, int x, int y, int w, int h, ref Color outerBorderColor, ref Color innerBorderColor, ref Color fillColor, bool drawShadow) { gfx.SetColor(ref outerBorderColor); gfx.DrawRect(x, y, w, h); gfx.SetColor(ref innerBorderColor); gfx.DrawRect(x + 1, y + 1, w - 2, h - 2); gfx.SetColor(ref fillColor); gfx.FillRect(x + 2, y + 2, w - 4, h - 4); if (drawShadow) { gfx.SetColor(ref outerBorderColor); gfx.DrawHLine(x, x + w - 1, y + h); } }
public override void DrawPanel(PicoGfx gfx, Panel panel) { var x = panel.GlobalX; var y = panel.GlobalY; var w = panel.W; var h = panel.H; DrawFrame( gfx, x, y, w, h, ref FrameOuterBorderColor, ref FrameInnerBorderColor, ref FrameFillColor, drawShadow: true); }
internal override void Draw(PicoGfx gfx, PicoGuiTheme theme) { var x = (this.GlobalX); var y = (this.GlobalY); var w = (this.W); var h = (this.H); gfx.BeginClip(x, y, w, h); foreach (var widget in _children) { widget.Draw(gfx, theme); } gfx.EndClip(); }
public override void DrawButton(PicoGfx gfx, Button button) { var x = (button.GlobalX); var y = (button.GlobalY); var w = button.W; var h = button.H; var textSize = new Size( button.Label.Length * 8, 8 ); var labelPosX = (x) + (w / 2 - textSize.Width / 2); var labelPosY = (y + 2) + (h / 2 - textSize.Height / 2); if (!button.Active) { DrawFrame( gfx, x, y, w, h, ref FrameOuterBorderColor, ref FrameInnerBorderColor, ref ButtonFillColor, drawShadow: true); gfx.DrawText(labelPosX, labelPosY, _font, button.Label); } else { DrawFrame( gfx, x, y + 1, w, h, ref FrameOuterBorderColor, ref FrameInnerBorderColor, ref ButtonActiveFillColor, drawShadow: false); gfx.DrawText(labelPosX, labelPosY + 1, _font, button.Label); } }
internal abstract void Draw(PicoGfx gfx, PicoGuiTheme theme);
private void Draw(PicoGfx gfx) { }
public abstract void Draw(PicoGfx gfx);
internal override void Draw(PicoGfx gfx, PicoGuiTheme theme) { theme.DrawCheckBox(gfx, this); }
internal override void Draw(PicoGfx gfx, PicoGuiTheme theme) { theme.DrawPanel(gfx, this); base.Draw(gfx, theme); }
internal override void Draw(PicoGfx gfx, PicoGuiTheme theme) { theme.DrawSlider(gfx, this); }
public abstract void DrawButton(PicoGfx gfx, Button button);
public abstract void DrawCheckBox(PicoGfx gfx, CheckBox checkbox);
public abstract void DrawSlider(PicoGfx gfx, Slider slider);
public abstract void DrawPanel(PicoGfx gfx, Panel panel);