Skip to content

Commit

Permalink
discard one frame the first time a contextual window is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
aarzilli committed Jan 23, 2017
1 parent 110e634 commit f1c1f93
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
45 changes: 26 additions & 19 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type context struct {
changed int32
activateEditor *TextEditor
cmds []command.Command
trashFrame bool
}

func contextAllCommands(ctx *context) {
Expand All @@ -46,31 +47,36 @@ func (ctx *context) setupMasterWindow(layout *panel, updatefn UpdateFn) {
}

func (ctx *context) Update() {
contextBegin(ctx, ctx.Windows[0].layout)
for i := 0; i < len(ctx.Windows); i++ {
ctx.Windows[i].began = false
}
for i := 0; i < len(ctx.Windows); i++ { // this must not use range or tooltips won't work
win := ctx.Windows[i]
if win.updateFn != nil {
win.specialPanelBegin()
win.updateFn(win)
for count := 0; count < 2; count++ {
contextBegin(ctx, ctx.Windows[0].layout)
for i := 0; i < len(ctx.Windows); i++ {
ctx.Windows[i].began = false
}
for i := 0; i < len(ctx.Windows); i++ { // this must not use range or tooltips won't work
win := ctx.Windows[i]
if win.updateFn != nil {
win.specialPanelBegin()
win.updateFn(win)
}

if !win.began {
win.close = true
continue
}
if !win.began {
win.close = true
continue
}

if win.title == tooltipWindowTitle {
win.close = true
}
if win.title == tooltipWindowTitle {
win.close = true
}

if win.flags&windowPopup != 0 {
panelEnd(ctx, win)
if win.flags&windowPopup != 0 {
panelEnd(ctx, win)
}
}
contextEnd(ctx)
if !ctx.trashFrame {
break
}
}
contextEnd(ctx)
}

func contextBegin(ctx *context, layout *panel) {
Expand All @@ -82,6 +88,7 @@ func contextBegin(ctx *context, layout *panel) {
w.cmds.Reset()
}

ctx.trashFrame = false
ctx.Windows[0].layout = layout
panelBegin(ctx, ctx.Windows[0], "")
layout.Offset = &ctx.Windows[0].Scrollbar
Expand Down
4 changes: 4 additions & 0 deletions nucular.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ func (win *Window) specialPanelBegin() {
win.layout.Offset = &win.Scrollbar
}

if win.first && (win.flags&windowContextual != 0 || win.flags&windowHDynamic != 0) {
ctx.trashFrame = true
}

win.first = false
}

Expand Down

0 comments on commit f1c1f93

Please sign in to comment.