diff --git a/_demo/demo.go b/_demo/demo.go index 3281917..73af0e3 100644 --- a/_demo/demo.go +++ b/_demo/demo.go @@ -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 @@ -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() @@ -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") + } + }) + } + }) +} diff --git a/context.go b/context.go index 24d442a..aa1ea05 100644 --- a/context.go +++ b/context.go @@ -73,6 +73,7 @@ func (ctx *context) Update() { } } contextEnd(ctx) + ctx.Reset() if !ctx.trashFrame { break } diff --git a/shiny.go b/shiny.go index f2041c7..4e3cda6 100644 --- a/shiny.go +++ b/shiny.go @@ -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()