From ddf9476920eba6cf54f9e9896e76c2e2fc331e58 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sun, 1 May 2022 12:40:09 +0200 Subject: [PATCH] Added support for borderless windows. --- allg5ui/rendererfactory.go | 1 + sdlui/renderer.go | 10 +++++++--- sdlui/rendererfactory.go | 7 ++++--- ui/rendererfactory.go | 7 ++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/allg5ui/rendererfactory.go b/allg5ui/rendererfactory.go index 148924a..f55831b 100644 --- a/allg5ui/rendererfactory.go +++ b/allg5ui/rendererfactory.go @@ -13,6 +13,7 @@ type rendererFactory struct{} func (f rendererFactory) New(title string, width, height int, opts ui.NewRendererOptions) (ui.Renderer, error) { renderer, err := NewRenderer(width, height, allg5.NewDisplayOptions{ + Frameless: opts.Borderless, Resizable: opts.Resizable, Vsync: opts.VSync, }) diff --git a/sdlui/renderer.go b/sdlui/renderer.go index 1558eb2..ce72923 100644 --- a/sdlui/renderer.go +++ b/sdlui/renderer.go @@ -33,9 +33,10 @@ var _ ui.Renderer = &Renderer{} var _ ui.Texture = &Renderer{} type NewRendererOptions struct { - Location sdl.Point - Resizable bool - VSync bool + Borderless bool + Location sdl.Point + Resizable bool + VSync bool } func NewRenderer(title string, width, height int32, opts NewRendererOptions) (*Renderer, error) { @@ -57,6 +58,9 @@ func NewRenderer(title string, width, height int32, opts NewRendererOptions) (*R } sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, "1") windowFlags := uint32(sdl.WINDOW_SHOWN) + if opts.Borderless { + windowFlags |= sdl.WINDOW_BORDERLESS + } if opts.Resizable { windowFlags |= sdl.WINDOW_RESIZABLE } diff --git a/sdlui/rendererfactory.go b/sdlui/rendererfactory.go index 7ee84fd..78f55c7 100644 --- a/sdlui/rendererfactory.go +++ b/sdlui/rendererfactory.go @@ -18,8 +18,9 @@ func (f rendererFactory) New(title string, width, height int, opts ui.NewRendere location.Y = int32(opts.Location.Y) } return NewRenderer(title, int32(width), int32(height), NewRendererOptions{ - Location: location, - Resizable: opts.Resizable, - VSync: opts.VSync, + Borderless: opts.Borderless, + Location: location, + Resizable: opts.Resizable, + VSync: opts.VSync, }) } diff --git a/ui/rendererfactory.go b/ui/rendererfactory.go index 07d338a..5490e4d 100644 --- a/ui/rendererfactory.go +++ b/ui/rendererfactory.go @@ -40,7 +40,8 @@ func SetRendererFactory(factory RendererFactory) { // NewRendererOptions provides options when creating a new renderer. type NewRendererOptions struct { - Location *geom.PointF32 - Resizable bool - VSync bool + Location *geom.PointF32 + Borderless bool + Resizable bool + VSync bool }