gui2: main windows basically work now!

This commit is contained in:
Martin Preuss
2026-03-09 13:56:51 +01:00
parent e3ae1f9b35
commit cc7f2dc1db
6 changed files with 251 additions and 53 deletions

View File

@@ -14,6 +14,8 @@
; ***************************************************************************
; defines
.equ GUIAPP_WINDOWSTACK_ENTRIES = 8
; Widget in flash
.equ GUIAPP_OFFS_BEGIN = OBJECT_SIZE
@@ -26,7 +28,9 @@
.equ GUIAPP_OFFS_TOUCHWIDGET_LO = GUIAPP_OFFS_BEGIN+6
.equ GUIAPP_OFFS_TOUCHWIDGET_HI = GUIAPP_OFFS_BEGIN+7
.equ GUIAPP_OFFS_GUITIMER = GUIAPP_OFFS_BEGIN+8
.equ GUIAPP_SIZE = WIDGET_OFFS_BEGIN+9
.equ GUIAPP_OFFS_WINDOWSTACK_POS = GUIAPP_OFFS_BEGIN+9
.equ GUIAPP_OFFS_WINDOWSTACK_BEGIN = GUIAPP_OFFS_BEGIN+10
.equ GUIAPP_SIZE = GUIAPP_OFFS_WINDOWSTACK_BEGIN+(GUIAPP_WINDOWSTACK_ENTRIES*2)
.equ GUIAPP_GUITIMER = 2
@@ -111,10 +115,6 @@ GuiApp_Init:
std Y+GUIAPP_OFFS_ROOTWINDOW_LO, xl
std Y+GUIAPP_OFFS_ROOTWINDOW_HI, xh
; debug
std Y+GUIAPP_OFFS_CURRENTWINDOW_LO, xl
std Y+GUIAPP_OFFS_CURRENTWINDOW_HI, xh
ldi r16, GUIAPP_GUITIMER
std Y+GUIAPP_OFFS_GUITIMER, r16
@@ -271,7 +271,9 @@ GuiApp_SetRootWindow:
; @routine GuiApp_GetCurrentWindow @global
;
; @param Y address of object in SDRAM
; @param CFLAG set if response is not a NULL pointer
; @return CFLAG set if response is not a NULL pointer
; @return r19:r18 current window
; @clobbers none
GuiApp_GetCurrentWindow:
ldd r18, Y+GUIAPP_OFFS_CURRENTWINDOW_LO
@@ -288,20 +290,6 @@ GuiApp_GetCurrentWindow_ret:
; ---------------------------------------------------------------------------
; @routine GuiApp_SetCurrentWindow @global
;
; @param Y address of object in SDRAM
; @param X address of new window
GuiApp_SetCurrentWindow:
std Y+GUIAPP_OFFS_CURRENTWINDOW_LO, xl
std Y+GUIAPP_OFFS_CURRENTWINDOW_HI, xh
ret
; @end
; ---------------------------------------------------------------------------
; @routine GuiApp_GetScreenSaver @global
;
@@ -402,6 +390,173 @@ GuiApp_OnTouch:
; ---------------------------------------------------------------------------
; @routine GuiApp_EnterWindow
;
; @param Y address of object in SDRAM
; @param X main window to enter
; @return CFLAG set if new window active
GuiApp_EnterWindow:
rcall GuiApp_GetCurrentWindow ; r19:r18=current window
brcc GuiApp_EnterWindow_l1 ; jmp if no current window
push xl
push xh
push yl
push yh
mov yl, r18
mov yh, r19
ldi r16, WIDGET_SIGNAL_HIDE
clr r17
bigcall OBJ_TreeHandleSignalChildenFirst
mov xl, yl
mov xh, yh
pop yh
pop yl
rcall guiAppPushMainWindow ; push current window onto stack
pop xh
pop xl
brcc GuiApp_EnterWindow_ret
GuiApp_EnterWindow_l1:
rcall guiAppSetCurrentWindow
push yl
push yh
mov yl, xl
mov yh, xh
ldi r16, WIDGET_SIGNAL_SHOW
clr r17
bigcall OBJ_TreeHandleSignal
pop yh
pop yl
sec
GuiApp_EnterWindow_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine GuiApp_LeaveWindow
;
; @param Y address of object in SDRAM
GuiApp_LeaveWindow:
rcall GuiApp_GetCurrentWindow ; r19:r18=current window
brcc GuiApp_LeaveWindow_ret ; jmp if no current window
push yl
push yh
mov yl, r18
mov yh, r19
ldi r16, WIDGET_SIGNAL_HIDE
clr r17
bigcall OBJ_TreeHandleSignalChildenFirst
pop yh
pop yl
GuiApp_LeaveWindow_l1:
rcall guiAppPopMainWindow ; X=popped window
brcc GuiApp_LeaveWindow_noPrevious
rcall guiAppSetCurrentWindow
push yl
push yh
mov yl, xl
mov yh, xh
ldi r16, WIDGET_SIGNAL_SHOW
clr r17
bigcall OBJ_TreeHandleSignal
pop yh
pop yl
rjmp GuiApp_LeaveWindow_ret
GuiApp_LeaveWindow_noPrevious:
clr xl
clr xh
rcall guiAppSetCurrentWindow
GuiApp_LeaveWindow_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine guiAppSetCurrentWindow
;
; @param Y address of object in SDRAM
; @param X address of new window
guiAppSetCurrentWindow:
std Y+GUIAPP_OFFS_CURRENTWINDOW_LO, xl
std Y+GUIAPP_OFFS_CURRENTWINDOW_HI, xh
ret
; @end
; ---------------------------------------------------------------------------
; @routine guiAppPushMainWindow
;
; @param Y address of object in SDRAM
; @param X window to push on stack and activate
; @return CFLAG set if pushed, cleared on error
guiAppPushMainWindow:
ldd r16, Y+GUIAPP_OFFS_WINDOWSTACK_POS
cpi r16, GUIAPP_WINDOWSTACK_ENTRIES
brcc GuiApp_PushMainWindow_ret
mov zl, yl
mov zh, yh
adiw zh:zl, GUIAPP_OFFS_WINDOWSTACK_BEGIN
clr r17
lsl r16
rol r17
add zl, r16
adc zh, r17
st Z+, xl
st Z, xh
ldd r16, Y+GUIAPP_OFFS_WINDOWSTACK_POS
inc r16
std Y+GUIAPP_OFFS_WINDOWSTACK_POS, r16
sec
GuiApp_PushMainWindow_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine guiAppPopMainWindow
;
; @param Y address of object in SDRAM
; @return CFLAG set if popped, cleared on error
; @return X window popped from stack
guiAppPopMainWindow:
ldd r16, Y+GUIAPP_OFFS_WINDOWSTACK_POS
tst r16
clc
breq guiAppPopMainWindow_ret
dec r16
std Y+GUIAPP_OFFS_WINDOWSTACK_POS, r16
mov zl, yl
mov zh, yh
adiw zh:zl, GUIAPP_OFFS_WINDOWSTACK_BEGIN
clr r17
lsl r16
rol r17
add zl, r16
adc zh, r17
ld xl, Z+
ld xh, Z
sec
guiAppPopMainWindow_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine guiAppSendTimerEvents
@@ -432,7 +587,7 @@ guiAppSendTimerEvents:
guiAppCheckSendGuiEvents:
push yl
push yh
rcall GuiApp_GetCurrentWindow
rcall GuiApp_GetRootWindow
brcc guiAppCheckSendGuiEvents_done
ldd r16, Y+GUIAPP_OFFS_GUITIMER
@@ -602,7 +757,7 @@ GuiApp_DefaultSignalmap:
; header
.dw Object_DefaultSignalmap*2 ; next table to use
; entries
.db 0, OBJECT_SIGNAL_TIMER, LOW(GuiApp_OnTimer), HIGH(GuiApp_OnTimer)
.db 0, OBJECT_SIGNAL_TIMER, LOW(GuiApp_OnTimer), HIGH(GuiApp_OnTimer)
.db 0, OBJECT_SIGNAL_DESTROY, LOW(GuiApp_OnDestroy), HIGH(GuiApp_OnDestroy)
.db 0, 0, 0, 0 ; end of table