From d9b3ac44066bf8bb2de8959721274711863824a3 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Tue, 18 Sep 2018 13:29:48 +0200 Subject: [PATCH] do not draw a garbage frame while we are moving a window --- nucular.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/nucular.go b/nucular.go index 35a245d..d77b5c4 100644 --- a/nucular.go +++ b/nucular.go @@ -216,13 +216,26 @@ func (win *Window) style() *nstyle.Window { } func panelBegin(ctx *context, win *Window, title string) { - win.usingSub = false + in := &ctx.Input style := &ctx.Style font := style.Font - in := &ctx.Input + wstyle := win.style() + + // window dragging + if win.moving { + if in == nil || !in.Mouse.Down(mouse.ButtonLeft) { + if win.flags&windowDocked == 0 && in != nil { + win.ctx.DockedWindows.Dock(win, in.Mouse.Pos, win.ctx.Windows[0].Bounds, win.ctx.Style.Scaling) + } + win.moving = false + } else { + win.move(in.Mouse.Delta, in.Mouse.Pos) + } + } + + win.usingSub = false in.Mouse.clip = nk_null_rect layout := win.layout - wstyle := win.style() window_padding := wstyle.Padding item_spacing := wstyle.Spacing @@ -358,17 +371,7 @@ func panelBegin(ctx *context, win *Window, title string) { dwh.Draw(&win.ctx.Style, &win.cmds) } - // window dragging - if win.moving { - if in == nil || !in.Mouse.Down(mouse.ButtonLeft) { - if win.flags&windowDocked == 0 && in != nil { - win.ctx.DockedWindows.Dock(win, in.Mouse.Pos, win.ctx.Windows[0].Bounds, win.ctx.Style.Scaling) - } - win.moving = false - } else { - win.move(in.Mouse.Delta, in.Mouse.Pos) - } - } else if (win.flags&WindowMovable != 0) && win.toplevel() { + if (win.flags&WindowMovable != 0) && win.toplevel() { var move rect.Rect move.X = win.Bounds.X move.Y = win.Bounds.Y