gui2: added Button, RootWindow. Touch now works again.

This commit is contained in:
Martin Preuss
2026-01-19 18:33:36 +01:00
parent 715c4f22c4
commit edc291261f
6 changed files with 959 additions and 527 deletions

View File

@@ -26,7 +26,8 @@
.equ GUIAPP_SIGNAL_RAISE = OBJECT_SIGNAL_NEXTFREE+0 ; app->cntrl: X=WIDGET to raise
.equ GUIAPP_SIGNAL_SHOW = OBJECT_SIGNAL_NEXTFREE+1 ; cntrl->app
.equ GUIAPP_SIGNAL_HIDE = OBJECT_SIGNAL_NEXTFREE+2 ; cntrl->app
.equ GUIAPP_SIGNAL_NEXTFREE = OBJECT_SIGNAL_NEXTFREE+3
.equ GUIAPP_SIGNAL_DEBUG = OBJECT_SIGNAL_NEXTFREE+3
.equ GUIAPP_SIGNAL_NEXTFREE = OBJECT_SIGNAL_NEXTFREE+4
; SDRAM data for guiapp
.equ GUIAPP_SD_OFFS_FLAGS = 0
@@ -75,7 +76,7 @@ GuiApp_Init:
; ---------------------------------------------------------------------------
; @routine GuiApp_Every100ms
; @routine GuiApp_Every100ms @global
;
; @param Z byte address of guiapp object (for LPM!)
@@ -89,7 +90,7 @@ GuiApp_Every100ms:
; ---------------------------------------------------------------------------
; @routine GuiApp_Every100ms
; @routine GuiApp_MsgReceived @global
;
; @param Z byte address of guiapp object (for LPM!)
@@ -109,7 +110,7 @@ GuiApp_MsgReceived:
GuiApp_OnTimer:
; check for touch event
; rcall guiAppCheckTouch
rcall guiAppCheckTouch
; send timer signal to all accepting widgets
push zl
@@ -154,14 +155,25 @@ GuiApp_OnTimer_ret:
; @param X pointer to touch event in SDRAM
GuiApp_OnTouch:
bigcall onAppDebug
push zl
push zh
adiw zh:zl, GUIAPP_OFFS_ROOTWIDGET_LO
lpm r18, Z+
lpm zh, Z
rcall GuiApp_GetSdramPtr
ldd r18, Y+GUIAPP_SD_OFFS_TOUCHWIDGET_LO
ldd r19, Y+GUIAPP_SD_OFFS_TOUCHWIDGET_HI
mov r16, r18
or r16, r19
breq GuiApp_OnTouch_sendToAll
mov zl, r18
or r18, zh
breq GuiApp_OnTouch_done
mov zh, r19
ldi r16, WIDGET_SIGNAL_TOUCH
clr r17
bigcall OBJ_HandleSignal
rjmp GuiApp_OnTouch_done
GuiApp_OnTouch_sendToAll:
rcall GuiApp_GetRootWidgetToZ
brcc GuiApp_OnTouch_done
; send touch signal (TODO: check for grabbed touch)
bigcall Widget_Tree_SendTouchSignal
GuiApp_OnTouch_done:
@@ -326,6 +338,62 @@ GuiApp_ShowView_ret:
; ---------------------------------------------------------------------------
; @routine GuiApp_GrabTouchEvents
;
; @param Z byte address of gui app object (for LPM!)
; @param X byte address of widget grabbing touch events
; @return CFLAG set if grabbed, cleared otherwise
; @clobbers R16, R17, Y
GuiApp_GrabTouchEvents:
rcall OBJ_IsObject ; (none)
brcc GuiApp_GrabTouchEvents_ret
rcall GuiApp_GetSdramPtr ; (none)
ldd r16, Y+GUIAPP_SD_OFFS_TOUCHWIDGET_LO
ldd r17, Y+GUIAPP_SD_OFFS_TOUCHWIDGET_HI
or r16, r17
clc
brne GuiApp_GrabTouchEvents_ret ; only grab if not already grabbed!
std Y+GUIAPP_SD_OFFS_TOUCHWIDGET_LO, xl
std Y+GUIAPP_SD_OFFS_TOUCHWIDGET_HI, xh
sec
GuiApp_GrabTouchEvents_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine GuiApp_UngrabTouchEvents
;
; @param Z byte address of gui app object (for LPM!)
; @param X byte address of widget ungrabbing touch events
; @return CFLAG set if ungrabbed, cleared otherwise
; @clobbers R16, R17
GuiApp_UngrabTouchEvents:
rcall OBJ_IsObject ; (none)
brcc GuiApp_UngrabTouchEvents_ret
rcall GuiApp_GetSdramPtr ; (none)
ldd r16, Y+GUIAPP_SD_OFFS_TOUCHWIDGET_LO
ldd r17, Y+GUIAPP_SD_OFFS_TOUCHWIDGET_HI
eor r16, xl
eor r17, xh
or r16, r17
clc
brne GuiApp_UngrabTouchEvents_ret ; only ungrab same widget!
clr r16
std Y+GUIAPP_SD_OFFS_TOUCHWIDGET_LO, r16
std Y+GUIAPP_SD_OFFS_TOUCHWIDGET_HI, r16
sec
GuiApp_UngrabTouchEvents_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine guiAppHideCurrent
;