Skip to content

Commit

Permalink
bugfix: nested menus not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aarzilli committed Feb 21, 2017
1 parent 369161a commit 885e89a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion _demo/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (
"runtime/pprof"
"runtime/trace"
"time"
"image"

"github.com/aarzilli/nucular"
"github.com/aarzilli/nucular/label"
"github.com/aarzilli/nucular/rect"
nstyle "github.com/aarzilli/nucular/style"
)

var whichdemo int = 4
var whichdemo int = 9

const dotrace = false
const scaling = 1.8
Expand Down Expand Up @@ -77,6 +79,8 @@ func main() {
pd := &panelDebug{}
pd.Init()
wnd = nucular.NewMasterWindow(pd.Update, nucular.WindowNoScrollbar)
case 9:
wnd = nucular.NewMasterWindow(nestedMenu, nucular.WindowNoScrollbar)
}
wnd.SetStyle(nstyle.FromTheme(theme, scaling))
wnd.Main()
Expand Down Expand Up @@ -248,3 +252,19 @@ func (pd *panelDebug) groupOrBlock(w *nucular.Window, name string, flags nucular
}
}
}

func nestedMenu(w *nucular.Window) {
w.Row(20).Static(180)
w.Label("Test", "CC")
w.ContextualOpen(0, image.Point{0,0}, w.LastWidgetBounds, func (w *nucular.Window) {
w.Row(20).Dynamic(1)
if w.MenuItem(label.TA("Submenu", "CC")) {
w.ContextualOpen(0, image.Point{ 0, 0 }, rect.Rect{ 0, 0, 0, 0}, func(w *nucular.Window) {
w.Row(20).Dynamic(1)
if w.MenuItem(label.TA("Done", "CC")) {
fmt.Printf("done\n")
}
})
}
})
}
1 change: 1 addition & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (ctx *context) Update() {
}
}
contextEnd(ctx)
ctx.Reset()
if !ctx.trashFrame {
break
}
Expand Down
1 change: 0 additions & 1 deletion shiny.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ func (w *masterWindow) updateLocked() {
d.Dot = fixed.P(bounds.Min.X, bounds.Min.Y+w.ctx.Style.Font.Metrics().Ascent.Ceil())
d.DrawString(s)
}
w.ctx.Reset()
if nprimitives > 0 {
w.wnd.Upload(w.bounds.Min, w.wndb, w.bounds)
w.wnd.Publish()
Expand Down

0 comments on commit 885e89a

Please sign in to comment.