gui2: more work on gui.
This commit is contained in:
@@ -25,11 +25,21 @@
|
||||
.equ GUIAPP_OFFS_CURRENTWINDOW_HI = GUIAPP_OFFS_BEGIN+5
|
||||
.equ GUIAPP_OFFS_TOUCHWIDGET_LO = GUIAPP_OFFS_BEGIN+6
|
||||
.equ GUIAPP_OFFS_TOUCHWIDGET_HI = GUIAPP_OFFS_BEGIN+7
|
||||
.equ GUIAPP_OFFS_DRAWTIMER = GUIAPP_OFFS_BEGIN+8
|
||||
.equ GUIAPP_OFFS_GUITIMER = GUIAPP_OFFS_BEGIN+8
|
||||
.equ GUIAPP_SIZE = WIDGET_OFFS_BEGIN+9
|
||||
|
||||
|
||||
.equ GUIAPP_DRAWTIMER = 2
|
||||
.equ GUIAPP_GUITIMER = 2
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data
|
||||
|
||||
.dseg
|
||||
|
||||
guiapp_touch_event:
|
||||
.byte WIDGET_TOUCH_SIZE
|
||||
|
||||
|
||||
|
||||
@@ -105,8 +115,8 @@ GuiApp_Init:
|
||||
std Y+GUIAPP_OFFS_ROOTWINDOW_LO, xl
|
||||
std Y+GUIAPP_OFFS_ROOTWINDOW_HI, xh
|
||||
|
||||
ldi r16, GUIAPP_DRAWTIMER
|
||||
std Y+GUIAPP_OFFS_DRAWTIMER, r16
|
||||
ldi r16, GUIAPP_GUITIMER
|
||||
std Y+GUIAPP_OFFS_GUITIMER, r16
|
||||
|
||||
GuiApp_Init_ret:
|
||||
ret
|
||||
@@ -353,8 +363,13 @@ GuiApp_OnDestroy:
|
||||
; @routine GuiApp_OnTimer
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
GuiApp_OnTimer:
|
||||
rcall guiAppCheckTouch ; (any, !Y)
|
||||
rcall guiAppSendTimerEvents ; (any, !Y)
|
||||
rcall guiAppCheckSendGuiEvents ; (any, !Y)
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -372,6 +387,165 @@ GuiApp_OnMsgReceived:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine GuiApp_OnTouch
|
||||
;
|
||||
; @param Y address of object in SDRAM
|
||||
; @clobbers any, !Y
|
||||
|
||||
GuiApp_OnTouch:
|
||||
rcall guiAppSendTouchEvents
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppSendTimerEvents
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppSendTimerEvents:
|
||||
push yl
|
||||
push yh
|
||||
ldd r16, Y+GUIAPP_OFFS_ROOTWINDOW_LO
|
||||
ldd yh, Y+GUIAPP_OFFS_ROOTWINDOW_HI
|
||||
mov yl, r16
|
||||
or yl, yh
|
||||
breq guiAppSendTimerEvents_done
|
||||
ldi r16, OBJECT_SIGNAL_TIMER
|
||||
clr r17
|
||||
ldi r20, OBJECT_OPTSLO_TIMER_BIT
|
||||
mov r21, r20
|
||||
bigcall OBJ_TreeHandleSignalIfMatchingOptsLo
|
||||
guiAppSendTimerEvents_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppCheckSendGuiEvents
|
||||
;
|
||||
; Send GUI events to current window if timer elapsed.
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppCheckSendGuiEvents:
|
||||
push yl
|
||||
push yh
|
||||
ldd r16, Y+GUIAPP_OFFS_CURRENTWINDOW_LO
|
||||
ldd yh, Y+GUIAPP_OFFS_CURRENTWINDOW_HI
|
||||
mov yl, r16
|
||||
or yl, yh
|
||||
breq guiAppCheckSendGuiEvents_done
|
||||
|
||||
ldd r16, Y+GUIAPP_OFFS_GUITIMER
|
||||
tst r16
|
||||
breq guiAppCheckSendGuiEvents_done
|
||||
dec r16
|
||||
std Y+GUIAPP_OFFS_GUITIMER, r16
|
||||
brne guiAppCheckSendGuiEvents_done
|
||||
|
||||
; timer elapsed, send layout events, draw events
|
||||
ldi r16, WIDGET_SIGNAL_LAYOUT
|
||||
clr r17
|
||||
ldi r20, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
bigcall OBJ_TreeHandleSignalIfFlagsSet ; (any, !Y)
|
||||
|
||||
ldi r16, WIDGET_SIGNAL_DRAW
|
||||
clr r17
|
||||
ldi r20, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
bigcall OBJ_TreeHandleSignalIfFlagsSet ; (any, !Y)
|
||||
|
||||
ldi r16, GUIAPP_GUITIMER
|
||||
std Y+GUIAPP_OFFS_GUITIMER, r16
|
||||
|
||||
guiAppCheckSendGuiEvents_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppSendTouchEvents
|
||||
;
|
||||
; Send touch events to current window or grabbing widget.
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppSendTouchEvents:
|
||||
push yl
|
||||
push yh
|
||||
ldd r18, Y+GUIAPP_OFFS_TOUCHWIDGET_LO
|
||||
ldd r19, Y+GUIAPP_OFFS_TOUCHWIDGET_HI
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
breq GuiApp_OnTouch_sendToAll
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldi r16, WIDGET_SIGNAL_TOUCH
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal
|
||||
rjmp GuiApp_OnTouch_done
|
||||
GuiApp_OnTouch_sendToAll:
|
||||
ldd r18, Y+GUIAPP_OFFS_CURRENTWINDOW_LO
|
||||
ldd r19, Y+GUIAPP_OFFS_CURRENTWINDOW_HI
|
||||
mov r16, r18
|
||||
or r16, r19
|
||||
breq GuiApp_OnTouch_done
|
||||
; send touch signal
|
||||
ldi r16, WIDGET_SIGNAL_TOUCH
|
||||
clr r17
|
||||
ldi r20, (1<<WIDGET_OPTSLO_INPUT_BIT)
|
||||
ldi r21, (1<<WIDGET_OPTSLO_INPUT_BIT)
|
||||
bigcall OBJ_TreeHandleSignalIfMatchingOptsLo
|
||||
GuiApp_OnTouch_done:
|
||||
pop yh
|
||||
pop yl
|
||||
; send keepAlive to screensaver
|
||||
rcall GuiApp_PreventScreenSaver
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine guiAppCheckTouch
|
||||
;
|
||||
; @param Y ptr to GUIAPP
|
||||
; @clobbers any, !Y
|
||||
|
||||
guiAppCheckTouch:
|
||||
bigcall Display_InputGetState ; r16=flags, r5:r4=x, r7:r6=y
|
||||
mov r17, r16
|
||||
andi r17, (1<<DISPLAY_IFLAGS_CHGCOORD_BIT) | (1<<DISPLAY_IFLAGS_CHGPRESS_BIT)
|
||||
breq guiAppCheckTouch_ret
|
||||
ldi xl, LOW(guiapp_touch_event)
|
||||
ldi xh, HIGH(guiapp_touch_event)
|
||||
st X+, r4 ; X
|
||||
st X+, r5
|
||||
st X+, r6 ; Y
|
||||
st X+, r7
|
||||
st X, r16 ; flags
|
||||
sbiw xh:xl, 4 ; (4 times incremented)
|
||||
; send touch signal
|
||||
ldi r16, WIDGET_SIGNAL_TOUCH
|
||||
clr r17
|
||||
bigcall OBJ_HandleSignal
|
||||
guiAppCheckTouch_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -617,10 +617,9 @@ OBJ_TreeHandleSignal_done:
|
||||
; @param xh param2
|
||||
; @param r20 mask for OBJECT_OFFS_OPTS_LO
|
||||
; @param r21 value for OBJECT_OFFS_OPTS_LO to match
|
||||
; @return CFLAG set if handled, cleared otherwise
|
||||
; @clobbers any, !R16, !R17, !X, !Y
|
||||
|
||||
OBJ_TreeHandleSignalIfMatchingOpts:
|
||||
OBJ_TreeHandleSignalIfMatchingOptsLo:
|
||||
push yl
|
||||
push yh
|
||||
; call signal handler
|
||||
@@ -631,27 +630,75 @@ OBJ_TreeHandleSignalIfMatchingOpts:
|
||||
ldd r18, Y+OBJECT_OFFS_OPTS_LO
|
||||
eor r18, r21
|
||||
and r18, r20
|
||||
brne OBJ_TreeHandleSignalIfMatchingOpts_l1
|
||||
brne OBJ_TreeHandleSignalIfMatchingOptsLo_l1
|
||||
push r20
|
||||
push r21
|
||||
rcall OBJ_HandleSignal ; (any, !Y)
|
||||
pop r21
|
||||
pop r20
|
||||
OBJ_TreeHandleSignalIfMatchingOpts_l1:
|
||||
OBJ_TreeHandleSignalIfMatchingOptsLo_l1:
|
||||
pop xh
|
||||
pop xl
|
||||
pop r17
|
||||
pop r16
|
||||
; handle children
|
||||
rcall OBJ_GetFirstChild ; r19:r18=object (none)
|
||||
OBJ_TreeHandleSignalIfMatchingOpts_loop:
|
||||
brcc OBJ_TreeHandleSignalIfMatchingOpts_done
|
||||
OBJ_TreeHandleSignalIfMatchingOptsLo_loop:
|
||||
brcc OBJ_TreeHandleSignalIfMatchingOptsLo_done
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
rcall OBJ_TreeHandleSignalIfMatchingOpts ; recursion!
|
||||
rcall OBJ_TreeHandleSignalIfMatchingOptsLo ; recursion!
|
||||
rcall OBJ_GetNext ; r19:r18=object (none)
|
||||
rjmp OBJ_TreeHandleSignalIfMatchingOpts_loop
|
||||
OBJ_TreeHandleSignalIfMatchingOpts_done:
|
||||
rjmp OBJ_TreeHandleSignalIfMatchingOptsLo_loop
|
||||
OBJ_TreeHandleSignalIfMatchingOptsLo_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine OBJ_TreeHandleSignalIfFlagsSet @global @recursive
|
||||
;
|
||||
; @param Y address of object
|
||||
; @param R16 signal number
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @param r20 flags to match
|
||||
; @clobbers any, !R16, !R17, !X, !Y
|
||||
|
||||
OBJ_TreeHandleSignalIfFlagsSet:
|
||||
push yl
|
||||
push yh
|
||||
; call signal handler
|
||||
push r16
|
||||
push r17
|
||||
push xl
|
||||
push xh
|
||||
ldd r18, Y+OBJECT_OFFS_FLAGS
|
||||
and r18, r20
|
||||
eor r18, r20
|
||||
brne OBJ_TreeHandleSignalIfFlagsSet_l1
|
||||
push r20
|
||||
rcall OBJ_HandleSignal ; (any, !Y)
|
||||
pop r20
|
||||
OBJ_TreeHandleSignalIfFlagsSet_l1:
|
||||
pop xh
|
||||
pop xl
|
||||
pop r17
|
||||
pop r16
|
||||
; handle children
|
||||
rcall OBJ_GetFirstChild ; r19:r18=object (none)
|
||||
OBJ_TreeHandleSignalIfFlagsSet_loop:
|
||||
brcc OBJ_TreeHandleSignalIfFlagsSet_done
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
rcall OBJ_TreeHandleSignalIfFlagsSet ; recursion!
|
||||
rcall OBJ_GetNext ; r19:r18=object (none)
|
||||
rjmp OBJ_TreeHandleSignalIfFlagsSet_loop
|
||||
OBJ_TreeHandleSignalIfFlagsSet_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
@@ -672,7 +719,6 @@ OBJ_TreeHandleSignalIfMatchingOpts_done:
|
||||
; @param R17 selector
|
||||
; @param xl param1
|
||||
; @param xh param2
|
||||
; @return CFLAG set if handled, cleared otherwise
|
||||
; @clobbers any, !R16, !R17, !X, !Y
|
||||
|
||||
OBJ_TreeHandleSignalChildenFirst:
|
||||
|
||||
@@ -81,21 +81,8 @@ RootWindow_Init:
|
||||
|
||||
std Y+ROOTWINDOW_OFFS_GUIAPP_LO, xl
|
||||
std Y+ROOTWINDOW_OFFS_GUIAPP_HI, xh
|
||||
|
||||
; set pos and size of widget to display size
|
||||
clr r16
|
||||
std Y+WIDGET_OFFS_X_LO, r16
|
||||
std Y+WIDGET_OFFS_X_HI, r16
|
||||
std Y+WIDGET_OFFS_Y_LO, r16
|
||||
std Y+WIDGET_OFFS_Y_HI, r16
|
||||
ldi r16, LOW(DISPLAY_WIDTH)
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_WIDTH)
|
||||
std Y+WIDGET_OFFS_WIDTH_HI, r16
|
||||
ldi r16, LOW(DISPLAY_HEIGHT)
|
||||
std Y+WIDGET_OFFS_HEIGHT_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_HEIGHT)
|
||||
std Y+WIDGET_OFFS_HEIGHT_HI, r16
|
||||
|
||||
bigcall Widget_SetFullScreen
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(RootWindow_DefaultSignalmap*2)
|
||||
@@ -155,21 +142,7 @@ RootWindow_OnLayout_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
; all children are MainWindow, set to fullscreen
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r20
|
||||
std Y+WIDGET_OFFS_WIDTH_HI, r21
|
||||
std Y+WIDGET_OFFS_HEIGHT_LO, r22
|
||||
std Y+WIDGET_OFFS_HEIGHT_HI, r23
|
||||
clr r16
|
||||
std Y+WIDGET_OFFS_X_LO, r16
|
||||
std Y+WIDGET_OFFS_X_HI, r16
|
||||
std Y+WIDGET_OFFS_Y_LO, r16
|
||||
std Y+WIDGET_OFFS_Y_HI, r16
|
||||
|
||||
; force redraw
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
|
||||
bigcall Widget_SetFullScreen
|
||||
rcall OBJ_GetNext
|
||||
rjmp RootWindow_OnLayout_loop
|
||||
RootWindow_OnLayout_ret:
|
||||
|
||||
@@ -271,6 +271,37 @@ Widget_Move:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_SetFullScreen @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @clobbers r16
|
||||
|
||||
Widget_SetFullScreen:
|
||||
; set pos and size of widget to display size
|
||||
clr r16
|
||||
std Y+WIDGET_OFFS_X_LO, r16
|
||||
std Y+WIDGET_OFFS_X_HI, r16
|
||||
std Y+WIDGET_OFFS_Y_LO, r16
|
||||
std Y+WIDGET_OFFS_Y_HI, r16
|
||||
ldi r16, LOW(DISPLAY_WIDTH)
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_WIDTH)
|
||||
std Y+WIDGET_OFFS_WIDTH_HI, r16
|
||||
ldi r16, LOW(DISPLAY_HEIGHT)
|
||||
std Y+WIDGET_OFFS_HEIGHT_LO, r16
|
||||
ldi r16, HIGH(DISPLAY_HEIGHT)
|
||||
std Y+WIDGET_OFFS_HEIGHT_HI, r16
|
||||
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
ori r16, (1<<WIDGET_FLAGS_LAYOUT_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_GetDefaultWidth @global
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user