ui/app: rename StageVisible and StageInvisible

StageRunning and StagePaused better reflect their use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-05-12 14:59:07 +02:00
parent 4441a3e13e
commit e2a1f07b84
8 changed files with 30 additions and 30 deletions
+6 -6
View File
@@ -43,8 +43,8 @@ type Input interface {
const (
StageDead Stage = iota
StageInvisible
StageVisible
StagePaused
StageRunning
)
const (
@@ -101,10 +101,10 @@ func (l Stage) String() string {
switch l {
case StageDead:
return "StageDead"
case StageInvisible:
return "StageInvisible"
case StageVisible:
return "StageVisible"
case StagePaused:
return "StagePaused"
case StageRunning:
return "StageRunning"
default:
panic("unexpected Stage value")
}
+6 -6
View File
@@ -96,7 +96,7 @@ func onCreateView(env *C.JNIEnv, class C.jclass, view C.jobject) C.jlong {
views[handle] = w
w.loadConfig(env, class)
windows <- ow
w.setStage(StageInvisible)
w.setStage(StagePaused)
return handle
}
@@ -113,7 +113,7 @@ func onDestroyView(env *C.JNIEnv, class C.jclass, handle C.jlong) {
func onStopView(env *C.JNIEnv, class C.jclass, handle C.jlong) {
w := views[handle]
w.started = false
w.setStage(StageInvisible)
w.setStage(StagePaused)
}
//export onStartView
@@ -131,7 +131,7 @@ func onSurfaceDestroyed(env *C.JNIEnv, class C.jclass, handle C.jlong) {
w.mu.Lock()
w.win = nil
w.mu.Unlock()
w.setStage(StageInvisible)
w.setStage(StagePaused)
}
//export onSurfaceChanged
@@ -155,7 +155,7 @@ func onLowMemory() {
func onConfigurationChanged(env *C.JNIEnv, class C.jclass, view C.jlong) {
w := views[view]
w.loadConfig(env, class)
if w.stage >= StageVisible {
if w.stage >= StageRunning {
w.draw(true)
}
}
@@ -166,7 +166,7 @@ func onFrameCallback(env *C.JNIEnv, class C.jclass, view C.jlong, nanos C.jlong)
if !exist {
return
}
if w.stage < StageVisible {
if w.stage < StageRunning {
return
}
w.mu.Lock()
@@ -197,7 +197,7 @@ func (w *window) setVisible() {
if width == 0 || height == 0 {
return
}
w.setStage(StageVisible)
w.setStage(StageRunning)
w.draw(true)
}
+3 -3
View File
@@ -59,7 +59,7 @@ func onCreate(view C.CFTypeRef) {
C.gio_addLayerToView(view, w.layer)
views[view] = w
windows <- ow
w.w.event(ChangeStage{StageInvisible})
w.w.event(ChangeStage{StagePaused})
}
//export onDraw
@@ -72,7 +72,7 @@ func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int) {
w.visible.Store(true)
C.gio_updateView(view, w.layer)
if !wasVisible {
w.w.event(ChangeStage{StageVisible})
w.w.event(ChangeStage{StageRunning})
}
isSync := false
if sync != 0 {
@@ -96,7 +96,7 @@ func onDraw(view C.CFTypeRef, dpi, sdpi, width, height C.CGFloat, sync C.int) {
func onStop(view C.CFTypeRef) {
w := views[view]
w.visible.Store(false)
w.w.event(ChangeStage{StageInvisible})
w.w.event(ChangeStage{StagePaused})
}
//export onDestroy
+1 -1
View File
@@ -56,7 +56,7 @@ func createWindow(opts *WindowOptions) error {
w.w = newWindow(w)
go func() {
windows <- w.w
w.w.event(ChangeStage{StageVisible})
w.w.event(ChangeStage{StageRunning})
w.draw(true)
select {}
w.cleanup()
+3 -3
View File
@@ -134,7 +134,7 @@ func (w *window) draw(sync bool) {
}
cfg := getConfig()
cfg.Now = time.Now()
w.setStage(StageVisible)
w.setStage(StageRunning)
w.w.event(Draw{
Size: image.Point{
X: width,
@@ -168,13 +168,13 @@ func gio_onTerminate(view C.CFTypeRef) {
//export gio_onHide
func gio_onHide(view C.CFTypeRef) {
w := views[view]
w.setStage(StageInvisible)
w.setStage(StagePaused)
}
//export gio_onShow
func gio_onShow(view C.CFTypeRef) {
w := views[view]
w.setStage(StageVisible)
w.setStage(StageRunning)
}
//export gio_onCreate
+3 -3
View File
@@ -157,7 +157,7 @@ func createWindow(opts *WindowOptions) error {
}
go func() {
windows <- w.w
w.setStage(StageVisible)
w.setStage(StageRunning)
w.loop()
w.destroy()
conn.destroy()
@@ -935,9 +935,9 @@ func (w *window) updateOutputs() {
}
w.mu.Unlock()
if !found {
w.setStage(StageInvisible)
w.setStage(StagePaused)
} else {
w.setStage(StageVisible)
w.setStage(StageRunning)
w.draw(true)
}
}
+3 -3
View File
@@ -239,7 +239,7 @@ func createNativeWindow(opts *WindowOptions) (*window, error) {
}
w := &window{
hwnd: hwnd,
stage: StageInvisible,
stage: StagePaused,
}
winMap[hwnd] = w
w.hdc, err = getDC(hwnd)
@@ -324,9 +324,9 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr
case _WM_SIZE:
switch wParam {
case _SIZE_MINIMIZED:
w.setStage(StageInvisible)
w.setStage(StagePaused)
case _SIZE_MAXIMIZED, _SIZE_RESTORED:
w.setStage(StageVisible)
w.setStage(StageRunning)
w.draw(true)
}
}
+5 -5
View File
@@ -62,7 +62,7 @@ func newWindow(nw *window) *Window {
w := &Window{
driver: nw,
events: make(chan Event),
stage: StageInvisible,
stage: StagePaused,
}
return w
}
@@ -103,7 +103,7 @@ func (w *Window) Draw(root *ui.Ops) {
w.hasNextFrame = false
w.syncGPU = false
w.mu.Unlock()
if stage < StageVisible {
if stage < StageRunning {
return
}
if w.gpu != nil {
@@ -176,7 +176,7 @@ func (w *Window) updateAnimation() {
w.mu.Lock()
defer w.mu.Unlock()
animate := false
if w.stage >= StageVisible && w.hasNextFrame {
if w.stage >= StageRunning && w.hasNextFrame {
if dt := time.Until(w.nextFrame); dt <= 0 {
animate = true
} else {
@@ -244,7 +244,7 @@ func (w *Window) event(e Event) {
if e.Size == (image.Point{}) {
panic(errors.New("internal error: zero-sized Draw"))
}
if w.stage < StageVisible {
if w.stage < StageRunning {
// No drawing if not visible.
break
}
@@ -270,7 +270,7 @@ func (w *Window) event(e Event) {
w.syncGPU = false
w.mu.Unlock()
switch {
case stage < StageVisible:
case stage < StageRunning:
w.gpu.Release()
w.gpu = nil
case sync: