Skip to content

Commit

Permalink
rename core.StageMgr to core.Stages; more associated renames and clea…
Browse files Browse the repository at this point in the history
…n up from RenderWin to RenderWindow rename
  • Loading branch information
kkoreilly committed Apr 17, 2024
1 parent 29fec7a commit 3ded301
Show file tree
Hide file tree
Showing 27 changed files with 238 additions and 245 deletions.
14 changes: 7 additions & 7 deletions core/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ func StandardAppBarBack(tb *Toolbar) *Button {
bt := NewButton(tb, "back").SetIcon(icons.ArrowBack).SetTooltip("Back").SetKey(keymap.HistPrev)
// TODO(kai/abc): app bar back button disabling
// bt.StyleFirst(func(s *styles.Style) {
// if tb.Scene.Stage.MainMgr == nil {
// if tb.Scene.Stage.Mains == nil {
// return
// }
// s.SetState(tb.Scene.Stage.MainMgr.Stack.Len() <= 1 && len(AllRenderWins) <= 1, states.Disabled)
// s.SetState(tb.Scene.Stage.Mains.Stack.Len() <= 1 && len(AllRenderWins) <= 1, states.Disabled)
// })
bt.OnClick(func(e events.Event) {
if slen := tb.Scene.Stage.MainMgr.Stack.Len(); slen > 1 {
if slen := tb.Scene.Stage.Mains.Stack.Len(); slen > 1 {
if tb.Scene.Stage.CloseOnBack {
tb.Scene.Close()
} else {
tb.Scene.Stage.MainMgr.Stack.ValueByIndex(slen - 2).Raise()
tb.Scene.Stage.Mains.Stack.ValueByIndex(slen - 2).Raise()
}
return
}
Expand Down Expand Up @@ -193,15 +193,15 @@ func (tb *Toolbar) StandardOverflowMenu(m *Scene) { //types:add
})
NewButton(m).SetText("Minimize").SetIcon(icons.Minimize).
OnClick(func(e events.Event) {
win := tb.Scene.RenderWin()
win := tb.Scene.RenderWindow()
if win != nil {
win.Minimize()
}
})
NewSeparator(m)
NewButton(m).SetText("Close window").SetIcon(icons.Close).SetKey(keymap.WinClose).
OnClick(func(e events.Event) {
win := tb.Scene.RenderWin()
win := tb.Scene.RenderWindow()
if win != nil {
win.CloseReq()
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func ConfigAppChooser(ch *Chooser, tb *Toolbar) *Chooser {

ch.AddItemsFunc(func() {
for _, rw := range AllRenderWindows {
for _, kv := range rw.MainStageMgr.Stack.Order {
for _, kv := range rw.Mains.Stack.Order {
st := kv.Value
// we do not include ourself
if st == tb.Scene.Stage {
Expand Down
4 changes: 2 additions & 2 deletions core/body.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ func (bd *Body) SetStyles() {
})
}

// SetTitle sets the title in the Body, Scene, and Stage, RenderWin, and title widget.
// SetTitle sets the title in the Body, Scene, and Stage, RenderWindow, and title widget.
// This is the one place to change the title for everything.
func (bd *Body) SetTitle(title string) *Body {
bd.Nm = title
bd.Title = title
bd.Scene.Nm = title
if bd.Scene.Stage != nil {
bd.Scene.Stage.Title = title
win := bd.Scene.RenderWin()
win := bd.Scene.RenderWindow()
if win != nil {
win.SetName(title)
win.SetTitle(title)
Expand Down
2 changes: 1 addition & 1 deletion core/dialogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NonNilContext(ctx Widget) Widget {
if !reflectx.AnyIsNil(ctx) {
return ctx
}
return CurrentRenderWindow.MainStageMgr.Top().Scene
return CurrentRenderWindow.Mains.Top().Scene
}

// NewDialog returns a new [DialogStage] that does not take up the
Expand Down
6 changes: 3 additions & 3 deletions core/enumgen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 13 additions & 12 deletions core/eventmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,22 @@ type EventMgr struct {
DragData any
}

// MainStageMgr returns the MainStageMgr for our Main Stage
func (em *EventMgr) MainStageMgr() *StageMgr {
// Mains returns the stack of main stages for our scene.
func (em *EventMgr) Mains() *Stages {
if em.Scene == nil {
return nil
}
return em.Scene.MainStageMgr()
return em.Scene.Stage.Mains
}

// RenderWin returns the overall render window, which could be nil
func (em *EventMgr) RenderWin() *RenderWindow {
mgr := em.MainStageMgr()
// RenderWindow returns the overall render window in which we reside,
// which could be nil.
func (em *EventMgr) RenderWindow() *RenderWindow {
mgr := em.Mains()
if mgr == nil {
return nil
}
return mgr.RenderWin
return mgr.RenderWindow
}

///////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -623,7 +624,7 @@ func (em *EventMgr) HandleLong(e events.Event, deep Widget, w *Widget, pos *imag
// fmt.Println("setting new:", deep)
*pos = e.WindowPos()
*t = time.AfterFunc(stime, func() {
win := em.RenderWin()
win := em.RenderWindow()
if win == nil {
return
}
Expand Down Expand Up @@ -806,15 +807,15 @@ func (em *EventMgr) DropFinalize(de *events.DragDrop) {
// if available.
func (em *EventMgr) Clipboard() system.Clipboard {
var gwin system.Window
if win := em.RenderWin(); win != nil {
if win := em.RenderWindow(); win != nil {
gwin = win.SystemWindow
}
return system.TheApp.Clipboard(gwin)
}

// SetCursor sets window cursor to given Cursor
func (em *EventMgr) SetCursor(cur cursors.Cursor) {
win := em.RenderWin()
win := em.RenderWindow()
if win == nil {
return
}
Expand Down Expand Up @@ -1062,7 +1063,7 @@ func (em *EventMgr) ManagerKeyChordEvents(e events.Event) {
if e.Type() != events.KeyChord {
return
}
win := em.RenderWin()
win := em.RenderWindow()
if win == nil {
return
}
Expand Down Expand Up @@ -1094,7 +1095,7 @@ func (em *EventMgr) ManagerKeyChordEvents(e events.Event) {
dstr := time.Now().Format("Mon_Jan_2_15:04:05_MST_2006")
fnm, _ := filepath.Abs("./GrabOf_" + sc.Name() + "_" + dstr + ".png")
imagex.Save(sc.Pixels, fnm)
fmt.Printf("Saved RenderWin Image to: %s\n", fnm)
fmt.Printf("Saved RenderWindow Image to: %s\n", fnm)
e.SetHandled()
case keymap.ZoomIn:
win.StepZoom(1)
Expand Down
8 changes: 4 additions & 4 deletions core/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (wb *WidgetBase) EventMgr() *EventMgr {
// SystemEventMgr returns the lower-level system event
// manager for this [Widget]'s [Scene].
func (wb *WidgetBase) SystemEventMgr() *events.Mgr {
return wb.Scene.RenderWin().SystemWindow.EventMgr()
return wb.Scene.RenderWindow().SystemWindow.EventMgr()
}

// Clipboard returns the clipboard for the [Widget] to use.
Expand Down Expand Up @@ -420,7 +420,7 @@ func (wb *WidgetBase) HandleLongHoverTooltip() {
})
wb.On(events.LongHoverEnd, func(e events.Event) {
if wb.Scene.Stage != nil {
wb.Scene.Stage.PopupMgr.PopDeleteType(TooltipStage)
wb.Scene.Stage.Popups.PopDeleteType(TooltipStage)
}
})

Expand All @@ -435,7 +435,7 @@ func (wb *WidgetBase) HandleLongHoverTooltip() {
})
wb.On(events.LongPressEnd, func(e events.Event) {
if wb.Scene.Stage != nil {
wb.Scene.Stage.PopupMgr.PopDeleteType(TooltipStage)
wb.Scene.Stage.Popups.PopDeleteType(TooltipStage)
}
})
}
Expand Down Expand Up @@ -465,7 +465,7 @@ func (wb *WidgetBase) HandleWidgetStateFromFocus() {
func (wb *WidgetBase) HandleWidgetMagnify() {
wb.On(events.Magnify, func(e events.Event) {
ev := e.(*events.TouchMagnify)
wb.EventMgr().RenderWin().StepZoom(ev.ScaleFactor - 1)
wb.EventMgr().RenderWindow().StepZoom(ev.ScaleFactor - 1)
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestWidgetEventManager(t *testing.T) {
assert.Equal(t, &w.Scene.EventMgr, w.EventMgr())

b.AssertRender(t, "events/event-manager", func() {
assert.Equal(t, w.Scene.RenderWin().SystemWindow.EventMgr(), w.SystemEventMgr())
assert.Equal(t, w.Scene.RenderWindow().SystemWindow.EventMgr(), w.SystemEventMgr())
assert.Equal(t, w.EventMgr().Clipboard(), w.Clipboard())
})
}
Expand Down
Loading

0 comments on commit 3ded301

Please sign in to comment.