gui2: more work (vlayout doesn't work, yet).

This commit is contained in:
Martin Preuss
2026-03-09 02:08:33 +01:00
parent 92efebccf1
commit 0758579b43
11 changed files with 657 additions and 523 deletions

View File

@@ -27,7 +27,8 @@
; ---------------------------------------------------------------------------
; @routine Layout_SetDefaultWidths
;
; Set defaultWidth in WIDGET_OFFS_TMP_LO/HI
; Set default width in WIDGET_OFFS_TMP_LO/HI of child widgets
; Ignores invisible widgets.
;
; @param Y pointer to widget
; @clobbers any, !Y
@@ -36,15 +37,19 @@ Layout_SetDefaultWidths:
push yl
push yh
bigcall OBJ_GetFirstChild
brcc Layout_SetDefaultWidths_ret
Layout_SetDefaultWidths_loop:
brcc Layout_SetDefaultWidths_ret
mov yl, r18
mov yh, r19
ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp Layout_SetDefaultWidths_next
bigcall Widget_GetDefaultWidth
std Y+WIDGET_OFFS_TMP_LO, r18
std Y+WIDGET_OFFS_TMP_HI, r19
Layout_SetDefaultWidths_next:
rcall OBJ_GetNext
rjmp Layout_SetDefaultWidths_loop
brcs Layout_SetDefaultWidths_loop
Layout_SetDefaultWidths_ret:
pop yh
pop yl
@@ -56,6 +61,9 @@ Layout_SetDefaultWidths_ret:
; ---------------------------------------------------------------------------
; @routine Layout_SetDefaultHeights
;
; Set default height in WIDGET_OFFS_TMP_LO/HI of child widgets
; Ignores invisible widgets.
;
; @param Y pointer to widget
; @clobbers any, !Y
@@ -63,15 +71,19 @@ Layout_SetDefaultHeights:
push yl
push yh
bigcall OBJ_GetFirstChild
brcc Layout_SetDefaultHeights_ret
Layout_SetDefaultHeights_loop:
brcc Layout_SetDefaultHeights_ret
mov yl, r18
mov yh, r19
ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp Layout_SetDefaultHeights_next
bigcall Widget_GetDefaultHeight
std Y+WIDGET_OFFS_TMP_LO, r18
std Y+WIDGET_OFFS_TMP_HI, r19
Layout_SetDefaultHeights_next:
rcall OBJ_GetNext
rjmp Layout_SetDefaultHeights_loop
brcs Layout_SetDefaultHeights_loop
Layout_SetDefaultHeights_ret:
pop yh
pop yl
@@ -83,6 +95,8 @@ Layout_SetDefaultHeights_ret:
; ---------------------------------------------------------------------------
; @routine Layout_SumTmpValues
;
; Ignores invisible widgets.
;
; @param Y pointer to widget
; @return r19:r18 total width of all child widgets plus space between
; @clobbers r16, r17, r18, r19, r20, r21, r22, r23, Z
@@ -105,20 +119,23 @@ Layout_SumTmpValues:
push yl
push yh
bigcall OBJ_GetFirstChild
brcc Layout_SumTmpValues_loopEnd
Layout_SumTmpValues_loop:
brcc Layout_SumTmpValues_loopEnd
mov yl, r18
mov yh, r19
ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp Layout_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 r20, r22
sub r20, r22
adc r21, r22
sub r21, r22
Layout_SumTmpValues_next:
rcall OBJ_GetNext
rjmp Layout_SumTmpValues_loop
brcs Layout_SumTmpValues_loop
Layout_SumTmpValues_loopEnd:
mov r16, r20
or r16, r21
@@ -145,9 +162,11 @@ Layout_SumTmpValues_done:
; ---------------------------------------------------------------------------
; @routine Layout_GetMaxTmp
;
; Ignores invisible widgets.
;
; @param Y pointer to widget
; @return r19:r18 maximum value in WIDGET_OFFS_TMP_LO/HI of children
; @clobbers any, !Y
; @clobbers r20, r21
Layout_GetMaxTmp:
clr r20
@@ -159,6 +178,9 @@ Layout_GetMaxTmp_loop:
brcc Layout_GetMaxTmp_ret
mov yl, r18
mov yh, r19
ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp Layout_GetMaxTmp_next
ldd r18, Y+WIDGET_OFFS_TMP_LO
ldd r19, Y+WIDGET_OFFS_TMP_HI
; max
@@ -181,34 +203,35 @@ Layout_GetMaxTmp_ret:
; ---------------------------------------------------------------------------
; @routine Layout_AddToTmpOfFillXChildren
; @routine LayoutCountChildrenWithPackMode
;
; @param Y pointer to widget
; @param R21:R20 value to add to tmp value of expandable widgets
; @param r22 mask for OBJECT_OFFS_OPTS_LO (e.g. 1<<WIDGET_OPTSLO_FILLX_BIT)
; @param r22 mask for WIDGET_OFFS_PACK
; @param r23 value for WIDGET_OFFS_PACK
; @return r16 number of matching children
; @clobbers r17, r18, r19
Layout_AddToTmpOfFillXChildren:
LayoutCountChildrenWithPackMode:
clr r16
push yl
push yh
bigcall OBJ_GetFirstChild
Layout_AddToTmpOfFillXChildren_loop:
brcc Layout_AddToTmpOfFillXChildren_done
LayoutCountChildrenWithPackMode_loop:
brcc LayoutCountChildrenWithPackMode_done
mov yl, r18
mov yh, r19
ldd r17, Y+OBJECT_OFFS_OPTS_LO
ldd r17, Y+OBJECT_OFFS_FLAGS
sbrs r17, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
rjmp LayoutCountChildrenWithPackMode_next
ldd r17, Y+WIDGET_OFFS_PACK
eor r17, r23
and r17, r22
breq Layout_AddToTmpOfFillXChildren_next
ldd r16, Y+WIDGET_OFFS_TMP_LO
ldd r17, Y+WIDGET_OFFS_TMP_HI
add r16, r20
adc r17, r21
std Y+WIDGET_OFFS_TMP_LO, r16
std Y+WIDGET_OFFS_TMP_HI, r17
Layout_AddToTmpOfFillXChildren_next:
brne LayoutCountChildrenWithPackMode_next
inc r16
LayoutCountChildrenWithPackMode_next:
rcall OBJ_GetNext
rjmp Layout_AddToTmpOfFillXChildren_loop
Layout_AddToTmpOfFillXChildren_done:
rjmp LayoutCountChildrenWithPackMode_loop
LayoutCountChildrenWithPackMode_done:
pop yh
pop yl
ret
@@ -217,30 +240,71 @@ Layout_AddToTmpOfFillXChildren_done:
; ---------------------------------------------------------------------------
; @routine LayoutCountExpandableChildren
; @routine LayoutCountVisibleChildren
;
; @param Y pointer to widget
; @param r22 mask for OBJECT_OFFS_OPTS_LO (e.g. 1<<WIDGET_OPTSLO_FILLX_BIT)
; @return r16 number of children with opt WIDGET_OPTSLO_FILLX_BIT
; @return r16 number of matching children
; @clobbers r17, r18, r19
LayoutCountExpandableChildren:
LayoutCountVisibleChildren:
clr r16
push yl
push yh
bigcall OBJ_GetFirstChild
LayoutCountExpandableChildren_loop:
brcc LayoutCountExpandableChildren_done
LayoutCountVisibleChildren_loop:
brcc LayoutCountVisibleChildren_done
mov yl, r18
mov yh, r19
ldd r17, Y+OBJECT_OFFS_OPTS_LO
and r17, r22
breq LayoutCountExpandableChildren_next
inc r16
LayoutCountExpandableChildren_next:
ldd r17, Y+OBJECT_OFFS_FLAGS
sbrc r17, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
inc r16
LayoutCountVisibleChildren_next:
rcall OBJ_GetNext
rjmp LayoutCountExpandableChildren_loop
LayoutCountExpandableChildren_done:
rjmp LayoutCountVisibleChildren_loop
LayoutCountVisibleChildren_done:
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine LayoutIncTmpOnMatchingPack
;
; Ignores invisible widgets.
;
; @param Y pointer to widget
; @param R21:R20 value to add to tmp value of expandable widgets
; @param r22 mask for WIDGET_OFFS_PACK
; @param r23 value for WIDGET_OFFS_PACK
; @clobbers r16, r18, r19
LayoutIncTmpOnMatchingPack:
push yl
push yh
bigcall OBJ_GetFirstChild
brcc LayoutIncTmpOnMatchingPack_done
LayoutIncTmpOnMatchingPack_loop:
mov yl, r18
mov yh, r19
ldd r16, Y+OBJECT_OFFS_FLAGS
sbrs r16, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
rjmp LayoutIncTmpOnMatchingPack_next
ldd r16, Y+WIDGET_OFFS_PACK
eor r16, r23
and r16, r22
brne LayoutIncTmpOnMatchingPack_next
ldd r18, Y+WIDGET_OFFS_TMP_LO
ldd r19, Y+WIDGET_OFFS_TMP_HI
add r18, r20
adc r19, r21
std Y+WIDGET_OFFS_TMP_LO, r18
std Y+WIDGET_OFFS_TMP_HI, r19
LayoutIncTmpOnMatchingPack_next:
rcall OBJ_GetNext
brcs LayoutIncTmpOnMatchingPack_loop
LayoutIncTmpOnMatchingPack_done:
pop yh
pop yl
ret
@@ -251,5 +315,8 @@ LayoutCountExpandableChildren_done:
#endif