gui2: implement OnGetDefaultWidth/Height

This commit is contained in:
Martin Preuss
2026-04-12 11:03:10 +02:00
parent 66be348ecd
commit 42b7ce1814
3 changed files with 116 additions and 20 deletions

View File

@@ -1637,5 +1637,116 @@ Layout2_SetDefaultHeights_ret:
; ---------------------------------------------------------------------------
; @routine Layout2_SumTmpValues
;
; Ignores invisible widgets.
;
; @param Y pointer to widget
; @return r19:r18 total size of all child widgets plus space between
; @clobbers r16, r17, r18, r19, r20, r21, r22, r23, Z
Layout2_SumTmpValues:
ldd zl, Y+WIDGET_OFFS_STYLE_LO
ldd zh, Y+WIDGET_OFFS_STYLE_HI
; get spacing
adiw zh:zl, WIDGET_STYLE_OFFS_SPACING
lpm r22, Z
sbiw zh:zl, WIDGET_STYLE_OFFS_SPACING
; get outer border
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
lpm r23, Z
sbiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
; start adding
clr r20
clr r21
push yl
push yh
bigcall OBJ_GetFirstChild
brcc Layout2_SumTmpValues_finish
Layout2_SumTmpValues_loop:
mov yl, r18
mov yh, r19
ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp Layout2_SumTmpValues_next
ldd r18, Y+WIDGET_OFFS_TMP_LO
ldd r19, Y+WIDGET_OFFS_TMP_HI
add r20, r18 ; add widget size
adc r21, r19
add r20, r22 ; add spacing
adc r21, r22
sub r21, r22
Layout2_SumTmpValues_next:
bigcall OBJ_GetNext
brcs Layout2_SumTmpValues_loop
Layout2_SumTmpValues_loopEnd:
mov r16, r20
or r16, r21
breq Layout2_SumTmpValues_finish
sub r20, r22 ; sub last spacing
sbc r21, r22
add r21, r22
Layout2_SumTmpValues_finish:
add r20, r23 ; add outer border (begin)
adc r21, r23
sub r21, r23
add r20, r23 ; add outer border (end)
adc r21, r23
sub r21, r23
Layout2_SumTmpValues_done:
mov r18, r20
mov r19, r21
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine Layout2_GetMaxTmp
;
; Ignores invisible widgets.
;
; @param Y pointer to widget
; @return r19:r18 maximum value in WIDGET_OFFS_TMP_LO/HI of children
; @clobbers r20, r21
Layout2_GetMaxTmp:
clr r20
clr r21
push yl
push yh
bigcall OBJ_GetFirstChild
Layout2_GetMaxTmp_loop:
brcc Layout2_GetMaxTmp_ret
mov yl, r18
mov yh, r19
ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp Layout2_GetMaxTmp_next
ldd r18, Y+WIDGET_OFFS_TMP_LO
ldd r19, Y+WIDGET_OFFS_TMP_HI
; max
cp r20, r18
cpc r21, r19
brcc Layout2_GetMaxTmp_next
mov r20, r18
mov r21, r19
Layout2_GetMaxTmp_next:
bigcall OBJ_GetNext
rjmp Layout2_GetMaxTmp_loop
Layout2_GetMaxTmp_ret:
mov r18, r20
mov r19, r21
pop yh
pop yl
ret
; @end
#endif