From d615619aba3a1f3e681389e987e5ce8adef9e041 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Wed, 8 Apr 2020 18:21:29 -0700 Subject: [PATCH] Bugfix: Don't draw in the level behind open windows * With the Window Manager update you can open the Level Settings window while editing a level, to change its wallpaper or page type. But you could "draw" in the level "through" the opened window. This bug is now fixed: if the cursor is on top of a managed UI window, the Canvas loop is not called. --- pkg/editor_ui.go | 3 ++- pkg/windows/add_edit_level.go | 18 +++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/editor_ui.go b/pkg/editor_ui.go index f194e03..7aa9270 100644 --- a/pkg/editor_ui.go +++ b/pkg/editor_ui.go @@ -273,7 +273,8 @@ func (u *EditorUI) Loop(ev *event.State) error { u.ToolBar.Compute(u.d.Engine) // Only forward events to the Canvas if the UI hasn't stopped them. - if !stopPropagation { + // Also ignore events if a managed ui.Window is overlapping the canvas. + if !(stopPropagation || u.Supervisor.IsPointInWindow(u.cursor)) { u.Canvas.Loop(ev) } return nil diff --git a/pkg/windows/add_edit_level.go b/pkg/windows/add_edit_level.go index 9f296a3..a52410e 100644 --- a/pkg/windows/add_edit_level.go +++ b/pkg/windows/add_edit_level.go @@ -29,15 +29,18 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window { newPageType = level.Bounded.String() newWallpaper = "notebook.png" isNewLevel = config.EditLevel == nil + title = "New Drawing" ) // Given a level to edit? if config.EditLevel != nil { newPageType = config.EditLevel.PageType.String() newWallpaper = config.EditLevel.Wallpaper + title = "Page Settings" } - window := ui.NewWindow("New Drawing") + window := ui.NewWindow(title) + window.SetButtons(ui.CloseButton) window.Configure(ui.Config{ Width: 540, Height: 350, @@ -119,9 +122,8 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window { ******************/ label2 := ui.NewLabel(ui.Label{ - // Text: "Wallpaper", - TextVariable: &newWallpaper, - Font: balance.LabelFont, + Text: "Wallpaper", + Font: balance.LabelFont, }) frame.Pack(label2, ui.Pack{ Side: ui.N, @@ -170,12 +172,6 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window { ******************/ bottomFrame := ui.NewFrame("Button Frame") - // bottomFrame.Configure(ui.Config{ - // BorderSize: 1, - // BorderStyle: ui.BorderSunken, - // BorderColor: render.Black, - // }) - // bottomFrame.SetBackground(render.Grey) frame.Pack(bottomFrame, ui.Pack{ Side: ui.N, FillX: true, @@ -221,7 +217,7 @@ func NewAddEditLevel(config AddEditLevel) *ui.Window { } for _, t := range buttons { // If we're editing settings on an existing level, skip the Continue. - if isNewLevel && t.Label == "OK" { + if (isNewLevel && t.Label == "OK") || (!isNewLevel && t.Label != "OK") { continue } btn := ui.NewButton(t.Label, ui.NewLabel(ui.Label{