split WID_SIGNAL_GETMINSIZE into two signals.

This commit is contained in:
Martin Preuss
2025-06-02 23:38:08 +02:00
parent 888792a201
commit 56e222a97e
2 changed files with 80 additions and 36 deletions

View File

@@ -72,15 +72,16 @@
.equ OBJ_SIGNAL_TIMER = 3 .equ OBJ_SIGNAL_TIMER = 3
.equ OBJ_SIGNAL_NEXTFREE = 4 .equ OBJ_SIGNAL_NEXTFREE = 4
.equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE .equ WID_SIGNAL_SHOW = OBJ_SIGNAL_NEXTFREE
.equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1 .equ WID_SIGNAL_HIDE = OBJ_SIGNAL_NEXTFREE+1
.equ WID_SIGNAL_DRAW = OBJ_SIGNAL_NEXTFREE+2 .equ WID_SIGNAL_DRAW = OBJ_SIGNAL_NEXTFREE+2
.equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3 .equ WID_SIGNAL_LAYOUT = OBJ_SIGNAL_NEXTFREE+3
.equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4 .equ WID_SIGNAL_TOUCH = OBJ_SIGNAL_NEXTFREE+4
.equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5 .equ WID_SIGNAL_MOUSE = OBJ_SIGNAL_NEXTFREE+5
.equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6 .equ WID_SIGNAL_KEY = OBJ_SIGNAL_NEXTFREE+6
.equ WID_SIGNAL_GETMINSIZE = OBJ_SIGNAL_NEXTFREE+7 .equ WID_SIGNAL_GETMINWIDTH = OBJ_SIGNAL_NEXTFREE+7
.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+8 .equ WID_SIGNAL_GETMINHEIGHT = OBJ_SIGNAL_NEXTFREE+8
.equ WID_SIGNAL_NEXTFREE = OBJ_SIGNAL_NEXTFREE+9

View File

@@ -11,7 +11,7 @@
; *************************************************************************** ; ***************************************************************************
; defs ; defs
.equ WID_WIDGET_INTER_BORDER = 1 .equ WID_WIDGET_INTER_BORDER = 2
@@ -99,55 +99,98 @@ WID_Widget_end:
; @clobbers any, !Y ; @clobbers any, !Y
WID_Widget_Handler: WID_Widget_Handler:
cpi r16, WID_SIGNAL_GETMINSIZE cpi r16, WID_SIGNAL_GETMINWIDTH
breq WID_Widget_Handler_getMinSize breq WID_Widget_Handler_getMinWidth
cpi r16, WID_SIGNAL_GETMINHEIGHT
breq WID_Widget_Handler_getMinHeight
; for now just forward signal to all children ; for now just forward signal to all children
WID_Widget_Handler_forward: WID_Widget_Handler_forward:
rcall OBJ_ForwardSignalToChildren rcall OBJ_ForwardSignalToChildren
ret ret
WID_Widget_Handler_getMinSize: WID_Widget_Handler_getMinWidth:
rjmp widgetGetMinSize rjmp widgetGetMinWidth
WID_Widget_Handler_getMinHeight:
rjmp widgetGetMinHeight
; @end ; @end
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine widgetGetMinSize ; @routine widgetGetMinWidth
; ;
; @return r18 minimum width of widget ; @return r19:r18 minimum width of widget
; @return r19 minimum height of widget
; @clobbers any, !Y ; @clobbers any, !Y
widgetGetMinSize: widgetGetMinWidth:
push yl push yl
push yh push yh
rcall Tree_GetFirstChildObject ; (none) rcall Tree_GetFirstChildObject ; (none)
clr r20 clr r24
clr r21 clr r25
widgetGetMinSize_loop: widgetGetMinWidth_loop:
mov r17, xl mov r17, xl
or r17, xh or r17, xh
breq widgetGetMinSize_loopEnd breq widgetGetMinWidth_loopEnd
mov yl, xl mov yl, xl
mov yh, yl mov yh, yl
push r20 push r24
push r21 push r25
ldi r16, WID_SIGNAL_GETMINSIZE ldi r16, WID_SIGNAL_GETMINWIDTH
ldi r18, 1 ; default value for when the signal is not handled ldi r18, 1 ; default value for when the signal is not handled
ldi r19, 1 ; default value for when the signal is not handled ldi r19, 0 ; default value for when the signal is not handled
rcall OBJ_Handler ; ask child for its minimum size rcall OBJ_Handler ; ask child for its minimum size
pop r21 pop r25
pop r20 pop r24
add r20, r18 ; TODO: handle carry later add r24, r18 ; TODO: handle carry later
subi r20, -WID_WIDGET_INTER_BORDER adc r25, r19
add r21, r19 ; TODO: handle carry later adiw r25:r24, WID_WIDGET_INTER_BORDER
subi r21, -WID_WIDGET_INTER_BORDER
rcall Tree_GetNextSibling ; (none) rcall Tree_GetNextSibling ; (none)
rjmp widgetGetMinSize_loop rjmp widgetGetMinWidth_loop
widgetGetMinSize_loopEnd: widgetGetMinWidth_loopEnd:
mov r18, r20 mov r18, r24
mov r19, r21 mov r19, r25
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine widgetGetMinHeight
;
; @return r19:r18 minimum width of widget
; @clobbers any, !Y
widgetGetMinHeight:
push yl
push yh
rcall Tree_GetFirstChildObject ; (none)
clr r24
clr r25
widgetGetMinHeight_loop:
mov r17, xl
or r17, xh
breq widgetGetMinHeight_loopEnd
mov yl, xl
mov yh, yl
push r24
push r25
ldi r16, WID_SIGNAL_GETMINHEIGHT
ldi r18, 1 ; default value for when the signal is not handled
ldi r19, 0 ; default value for when the signal is not handled
rcall OBJ_Handler ; ask child for its minimum size
pop r25
pop r24
add r24, r18 ; TODO: handle carry later
adc r25, r19
adiw r25:r24, WID_WIDGET_INTER_BORDER
rcall Tree_GetNextSibling ; (none)
rjmp widgetGetMinHeight_loop
widgetGetMinHeight_loopEnd:
mov r18, r24
mov r19, r25
pop yh pop yh
pop yl pop yl
ret ret