gui2: more work on preparing code sharing for all layout modules.

This commit is contained in:
Martin Preuss
2026-04-10 00:07:53 +02:00
parent 12cdc6c637
commit 7d556c0f26
2 changed files with 314 additions and 139 deletions

View File

@@ -97,27 +97,15 @@ HLayout2_Init:
; @clobbers any, !Y
HLayout2_OnLayout:
; create layout context
bigcall OBJ_CountDirectChildren ; r16=num of children (r18, r19)
tst r16
breq HLayout2_OnLayout_ret
push r16
bigcall LayoutCtx_new ; X=new ctx (r16, r17, r18, r19, r24, r25)
pop r16
; create and preset context
rcall LayoutCtx_CreateContextFor1D
brcc HLayout2_OnLayout_ret
; set borders and spacing in layout context
bigcall Widget_GetBorderAndSpacing ; (none)
adiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
st X+, r23 ; store border
st X, r22 ; store spacing
sbiw xh:xl, (LAYOUT_CTX_OFFS_BORDERS+1)
; do layout
mov r25, r16
rcall hLayout2Horizontally
rcall hLayout2Vertically
; release layout context
bigcall LayoutCtx_free
; force re-drawing of this widget, clear layout bit
ldd r16, Y+OBJECT_OFFS_FLAGS
sbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
@@ -173,19 +161,61 @@ HLayout2_OnGetDefaultWidth:
; @clobbers any, !X, !Y
hLayout2Vertically:
rcall hLayout2PrepareVertical ; (any, !R25, !X, !Y)
rcall hLayout2ReadLayoutWriteVertical ; (r16-r24)
ret
; @end
; ---------------------------------------------------------------------------
; @routine hLayout2PrepareVertical
;
; @param Y pointer to widget
; @param X layout context
; @param r25 number of children
; @clobbers any, !R25, !X, !Y,
hLayout2PrepareVertical:
push xl
push xh
push yl
push yh
push r25
rcall Layout2_SetDefaultHeights
pop r25
pop yh
pop yl
pop xh
pop xl
ldd r20, Y+WIDGET_OFFS_HEIGHT_LO
ldd r21, Y+WIDGET_OFFS_HEIGHT_HI
adiw xh:xl, LAYOUT_CTX_OFFS_TOTALSIZE_LO
st X+, r20
st X, r21
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
; layout
ret
; @end
; ---------------------------------------------------------------------------
; @routine hLayout2ReadLayoutWriteHorizontal
;
; @param Y pointer to widget
; @param X layout context
; @param r25 number of children
; @clobbers r16-r24
hLayout2ReadLayoutWriteVertical:
push yl
push yh
push r24
bigcall OBJ_GetFirstChild
mov yl, r18
mov yh, r19
; read positions and flags into new layout context
push r25
push yl
@@ -194,21 +224,24 @@ hLayout2Vertically:
pop yh
pop yl
pop r25
; get default heights
push r25
push yl
push yh
bigcall LayoutCtx_SetDefaultHeightContiguous
pop yh
pop yl
pop r25
pop r24
; layout
bigcall LayoutCtx_GetMaxDefaultSize ; r19:r18=max default size (r18, r19, r20, r21, r24)
bigcall LayoutCtx_GetMaxSize ; r19:r18=max default size (r18, r19, r20, r21, r24)
bigcall LayoutCtx_SetFixedSize ; (r24)
push r25
bigcall LayoutCtxSetPos ; (r16-r25)
pop r25
; pack
push r25
push yl
push yh
bigcall LayoutCtx_PackYContiguous
pop yh
pop yl
pop r25
; write back dims
push r25
push yl
@@ -224,6 +257,9 @@ hLayout2Vertically:
; ---------------------------------------------------------------------------
; @routine hLayout2Horizontally
;
@@ -233,6 +269,36 @@ hLayout2Vertically:
; @clobbers any, !Y
hLayout2Horizontally:
rcall hLayout2PrepareHorizontal ; (any, !R25, !X, !Y)
rcall hLayout2ReadLayoutWriteHorizontal ; (r16-r24)
ret
; @end
; ---------------------------------------------------------------------------
; @routine hLayout2PrepareHorizontal
;
; @param Y pointer to widget
; @param X layout context
; @param r25 number of children
; @clobbers any, !R25, !X, !Y,
hLayout2PrepareHorizontal:
push xl
push xh
push yl
push yh
push r25
rcall Layout2_SetDefaultWidths ; (any, !Y)
pop r25
pop yh
pop yl
pop xh
pop xl
; setup layout context for horizontal operations
ldd r20, Y+WIDGET_OFFS_WIDTH_LO
ldd r21, Y+WIDGET_OFFS_WIDTH_HI
@@ -240,27 +306,33 @@ hLayout2Horizontally:
st X+, r20
st X, r21
sbiw xh:xl, (LAYOUT_CTX_OFFS_TOTALSIZE_LO+1)
ret
; @end
; ---------------------------------------------------------------------------
; @routine hLayout2ReadLayoutWriteHorizontal
;
; @param Y pointer to widget
; @param X layout context
; @param r25 number of children
; @clobbers r16-r24
hLayout2ReadLayoutWriteHorizontal:
; layout
ldd r24, Y+HLAYOUT2_OFFS_MODE
push yl
push yh
push r24
bigcall OBJ_GetFirstChild
bigcall OBJ_GetFirstChild ; (none)
mov yl, r18
mov yh, r19
; read X positions and flags into new layout context
push r25
push yl
push yh
bigcall LayoutCtx_ReadXDimsContiguous
pop yh
pop yl
pop r25
; get default widths
push r25
push yl
push yh
bigcall LayoutCtx_SetDefaultWidthContiguous
bigcall LayoutCtx_ReadXDimsContiguous ; (r16, r18, r19, r24, Y)
pop yh
pop yl
pop r25
@@ -268,21 +340,31 @@ hLayout2Horizontally:
; layout
push r25
cpi r24, HLAYOUT_MODE_SPREAD
breq hLayout2Horizontally_spread
bigcall LayoutCtx_LayoutExpand ; (r16-r25)
rjmp hLayout2Horizontally_writeBack
hLayout2Horizontally_spread:
bigcall LayoutCtx_LayoutSpread ; (r16-r25)
hLayout2Horizontally_writeBack:
breq hLayout2ReadLayoutWriteHorizontal_spread
bigcall LayoutCtx_LayoutExpand ; (r16-r25)
rjmp hLayout2ReadLayoutWriteHorizontal_pack
hLayout2ReadLayoutWriteHorizontal_spread:
bigcall LayoutCtx_LayoutSpread ; (r16-r25)
hLayout2ReadLayoutWriteHorizontal_pack:
pop r25
; pack
push r25
push yl
push yh
bigcall LayoutCtx_PackXContiguous ; (r16-r21, r24, r25, Y)
pop yh
pop yl
pop r25
; write back dims
push r25
push yl
push yh
bigcall LayoutCtx_WriteXDimsContiguous
bigcall LayoutCtx_WriteXDimsContiguous ; (r16, r18, r19, r24, Y)
pop yh
pop yl
pop r25
pop yh
pop yl
ret
@@ -294,6 +376,7 @@ hLayout2Horizontally_writeBack:
; ***************************************************************************
; data in FLASH

View File

@@ -26,10 +26,8 @@
.equ LAYOUT_CTX_ITEM_OFFS_POS_HI = 1
.equ LAYOUT_CTX_ITEM_OFFS_SIZE_LO = 2
.equ LAYOUT_CTX_ITEM_OFFS_SIZE_HI = 3
.equ LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO = 4
.equ LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_HI = 5
.equ LAYOUT_CTX_ITEM_OFFS_FLAGS = 6
.equ LAYOUT_CTX_ITEM_SIZE = 7 ; CAVEAT: change code in LayoutCtx_new if size changed!
.equ LAYOUT_CTX_ITEM_OFFS_FLAGS = 4
.equ LAYOUT_CTX_ITEM_SIZE = 5 ; CAVEAT: change code in LayoutCtx_new if size changed!
@@ -82,12 +80,10 @@ LayoutCtx_new:
mov r25, r17
lsl r24 ; x2
rol r25
add r24, r16
adc r25, r17 ; x3
lsl r24 ; x6
lsl r24 ; x4
rol r25
add r24, r16
adc r25, r17 ; x7
adc r25, r17 ; x5
ldi r16, LOW(LAYOUT_CTX_OFFS_ITEMS)
ldi r17, HIGH(LAYOUT_CTX_OFFS_ITEMS)
add r24, r16
@@ -132,6 +128,37 @@ LayoutCtx_free:
; ---------------------------------------------------------------------------
; @routine LayoutCtx_CreateContextFor1D @global
;
; @param Y pointer to widget
; @return CFLAG set if context created, cleared on error
; @return X pointer to newly created context
; @clobbers any, !Y
LayoutCtx_CreateContextFor1D:
; create layout context
bigcall OBJ_CountDirectChildren ; r16=num of children (r18, r19)
tst r16
clc
breq LayoutCtx_CreateContextFor1D_ret
push r16
bigcall LayoutCtx_new ; X=new ctx (r16, r17, r18, r19, r24, r25)
pop r16
brcc LayoutCtx_CreateContextFor1D_ret
; set borders and spacing in layout context
bigcall Widget_GetBorderAndSpacing ; (none)
adiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
st X+, r23 ; store border
st X, r22 ; store spacing
sbiw xh:xl, (LAYOUT_CTX_OFFS_BORDERS+1)
sec
LayoutCtx_CreateContextFor1D_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine LayoutCtx_LayoutExpand
;
@@ -167,31 +194,32 @@ LayoutCtx_LayoutSpread:
; ---------------------------------------------------------------------------
; @routine LayoutCtx_GetMaxDefaultSize
; @routine LayoutCtx_GetMaxSize
;
; @param X pointer to ctx
; @return r19:r18 maximum default size
; @clobbers r18, r19, r20, r21, r24
LayoutCtx_GetMaxDefaultSize:
LayoutCtx_GetMaxSize:
push xl
push xh
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
ld r24, X+ ; X now points to first item
clr r18
clr r19
LayoutCtx_GetMaxDefaultSize_loop:
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
LayoutCtx_GetMaxSize_loop:
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_SIZE_LO
ld r20, X+
ld r21, X
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO+1)
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_SIZE_LO+1)
cp r18, r20
cpc r19, r21
brcc LayoutCtx_GetMaxDefaultSize_next
brcc LayoutCtx_GetMaxSize_next
mov r18, r20
mov r19, r21
LayoutCtx_GetMaxDefaultSize_next:
LayoutCtx_GetMaxSize_next:
adiw xh:xl, LAYOUT_CTX_ITEM_SIZE
dec r24
pop xh
@@ -244,10 +272,10 @@ layoutCtxSetSizeWithExtra:
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
ld r24, X+ ; number of items (X now points to first item)
layoutCtxSetSizeWithExtra_loop:
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_SIZE_LO
ld r20, X+
ld r21, X
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO+1)
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_SIZE_LO+1)
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_FLAGS
ld r22, X
sbiw xh:xl, LAYOUT_CTX_ITEM_OFFS_FLAGS
@@ -282,17 +310,16 @@ LayoutCtxSetPos:
push xl
push xh
adiw xh:xl, LAYOUT_CTX_OFFS_BORDERS
ld r18, X+ ; borders (start calculated size with one border)
ld r18, X+ ; borders (start calculated size with one border)
clr r19
ld r22, X+ ; spacing
ld r22, X+ ; spacing
clr r23
ld r24, X+ ; number of items (X now points to first item)
LayoutCtxSetPos_loop: ; r19:r18=current pos, r22=spacing, r23=border, X=1st item
push r18
push r19
rcall layoutCtxPack ; (r16-r21, r25)
pop r19
pop r18
ld r24, X+ ; number of items (X now points to first item)
LayoutCtxSetPos_loop: ; r19:r18=current pos, r22=spacing, r23=border, X=1st item
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_POS_LO ; store pos
st X+, r18
st X, r19
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_POS_LO+1)
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_SIZE_LO
ld r20, X+
ld r21, X
@@ -334,11 +361,10 @@ layoutCtxSetPosWithExtra:
add r18, r16 ; add space to border
adc r19, r17
layoutCtxSetPosWithExtra_loop: ; r19:r18=current pos, r22=spacing, r23=border, X=1st item
push r18
push r19
rcall layoutCtxPack ; (r16-r21, r25)
pop r19
pop r18
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_POS_LO
st X+, r18
st X, r19
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_POS_LO+1)
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_SIZE_LO
ld r20, X+
ld r21, X
@@ -360,21 +386,23 @@ layoutCtxSetPosWithExtra_loop: ; r19:r18=current pos, r22=spac
; ---------------------------------------------------------------------------
; @routine layoutCtxPack
;
; @param X pointer to current item
; @param r19:r18 current pos
; @clobbers r16-r21, r25
; @param X pointer to current item
; @param r21:r20 default size of the widget
; @return r19:r18 calculated pos
; @return r21:r20 calculated size
; @clobbers r16-r19, r25
layoutCtxPack:
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_SIZE_LO
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_POS_LO
ld r18, X+ ; pos lo
ld r19, X+ ; pos hi
ld r16, X+ ; size lo
ld r17, X+ ; size hi
ld r20, X+ ; default size lo
ld r21, X+ ; default size lo
ld r25, X ; flags
sbiw xh:xl, LAYOUT_CTX_ITEM_OFFS_FLAGS
sub r16, r20 ; r17:r16=(size-defaultSize)
sbc r17, r21
brcs layoutCtxPack_store
brcs layoutCtxPack_done
andi r25, 3
cpi r25, WIDGET_PACK_END
breq layoutCtxPack_end
@@ -382,29 +410,27 @@ layoutCtxPack:
breq layoutCtxPack_center
cpi r25, WIDGET_PACK_FILLED
breq layoutCtxPack_filled
rjmp layoutCtxPack_store
rjmp layoutCtxPack_done
layoutCtxPack_end:
add r18, r16 ; just add difference to pos
adc r19, r17
rjmp layoutCtxPack_store
rjmp layoutCtxPack_done
layoutCtxPack_center:
lsr r17
ror r16
add r18, r16 ; just add half difference to pos
adc r19, r17
rjmp layoutCtxPack_store
rjmp layoutCtxPack_done
layoutCtxPack_filled:
add r16, r20 ; get size back into r17:r16
add r16, r20 ; get total size back
adc r17, r21
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_SIZE_LO
st X+, r16 ; set item to full size
st X, r17
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_SIZE_LO+1)
layoutCtxPack_store:
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_POS_LO
st X+, r18
st X, r19
sbiw xh:xl, (LAYOUT_CTX_ITEM_OFFS_POS_LO+1)
mov r20, r16
mov r21, r17
layoutCtxPack_done:
ret
; @end
@@ -521,10 +547,10 @@ LayoutCtx_CalcMinimumSize:
lsl r18 ; add border at beginning and end
rol r19
LayoutCtx_CalcMinimumSize_loop:
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_SIZE_LO
ld r16, X+ ; LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
ld r17, X ; LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_HI
adiw xh:xl, (LAYOUT_CTX_ITEM_SIZE-LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_HI)
adiw xh:xl, (LAYOUT_CTX_ITEM_SIZE-LAYOUT_CTX_ITEM_OFFS_SIZE_HI)
add r18, r16 ; add size
adc r19, r17
add r18, r22 ; add spacing
@@ -625,13 +651,14 @@ LayoutCtx_ReadXDimsSkipped:
; @param X pointer to ctx
; @param Y pointer to first widget to handle
; @param r25 number of widgets to handle
; @clobbers r16, r18, r19, r24, Y
LayoutCtx_WriteXDimsContiguous:
push xl
push xh
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
ld r24, X+ ; X now points to first item
M_LAYOUT_FOREVERY_CONT layoutCtxCbCopyItemToWidgetX
M_LAYOUT_FOREVERY_CONT layoutCtxCbCopyItemToWidgetX ; (r16, r18, r19, Y)
pop xh
pop xl
ret
@@ -740,18 +767,21 @@ LayoutCtx_WriteYDimsSkipped:
; ---------------------------------------------------------------------------
; @routine LayoutCtx_SetDefaultWidthContiguous
; @routine LayoutCtx_PackXContiguous
;
; @param X pointer to ctx
; @param Y pointer to first widget to handle
; @param r25 number of widgets to handle
; @return CFLAG set if more widgets to handle, cleared otherwise
; @return Y pointer to next widget to handle (if CFLAG set)
; @clobbers r16-r21, r24, r25, Y
LayoutCtx_SetDefaultWidthContiguous:
LayoutCtx_PackXContiguous:
push xl
push xh
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
ld r24, X+ ; X now points to first item
M_LAYOUT_FOREVERY_CONT layoutCtxCbsetDefaultWidth
M_LAYOUT_FOREVERY_CONT layoutCtxCbPackX ; (r16-r21, r25, Y)
pop xh
pop xl
ret
@@ -760,18 +790,20 @@ LayoutCtx_SetDefaultWidthContiguous:
; ---------------------------------------------------------------------------
; @routine LayoutCtx_SetDefaultWidthSkipped
; @routine LayoutCtx_PackXSkipped
;
; @param X pointer to ctx
; @param Y pointer to first widget to handle
; @param r25 number of widgets to skip in each round
; @return CFLAG set if more widgets to handle, cleared otherwise
; @return Y pointer to next widget to handle (if CFLAG set)
LayoutCtx_SetDefaultWidthSkipped:
LayoutCtx_PackXSkipped:
push xl
push xh
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
ld r24, X+ ; X now points to first item
M_LAYOUT_FOREVERY_SKIPPED layoutCtxCbsetDefaultWidth
M_LAYOUT_FOREVERY_SKIPPED layoutCtxCbPackX
pop xh
pop xl
ret
@@ -780,18 +812,20 @@ LayoutCtx_SetDefaultWidthSkipped:
; ---------------------------------------------------------------------------
; @routine LayoutCtx_SetDefaultHeightContiguous
; @routine LayoutCtx_PackYContiguous
;
; @param X pointer to ctx
; @param Y pointer to first widget to handle
; @param r25 number of widgets to handle
; @return CFLAG set if more widgets to handle, cleared otherwise
; @return Y pointer to next widget to handle (if CFLAG set)
LayoutCtx_SetDefaultHeightContiguous:
LayoutCtx_PackYContiguous:
push xl
push xh
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
ld r24, X+ ; X now points to first item
M_LAYOUT_FOREVERY_CONT layoutCtxCbsetDefaultHeight
M_LAYOUT_FOREVERY_CONT layoutCtxCbPackY
pop xh
pop xl
ret
@@ -800,18 +834,20 @@ LayoutCtx_SetDefaultHeightContiguous:
; ---------------------------------------------------------------------------
; @routine LayoutCtx_SetDefaultHeightSkipped
; @routine LayoutCtx_PackYSkipped
;
; @param X pointer to ctx
; @param Y pointer to first widget to handle
; @param r25 number of widgets to skip in each round
; @return CFLAG set if more widgets to handle, cleared otherwise
; @return Y pointer to next widget to handle (if CFLAG set)
LayoutCtx_SetDefaultHeightSkipped:
LayoutCtx_PackYSkipped:
push xl
push xh
adiw xh:xl, LAYOUT_CTX_OFFS_NUMITEMS
ld r24, X+ ; X now points to first item
M_LAYOUT_FOREVERY_SKIPPED layoutCtxCbsetDefaultHeight
M_LAYOUT_FOREVERY_SKIPPED layoutCtxCbPackY
pop xh
pop xl
ret
@@ -824,6 +860,7 @@ LayoutCtx_SetDefaultHeightSkipped:
; ---------------------------------------------------------------------------
; @routine layoutCtxCbCopyWidgetXToItem
;
@@ -841,9 +878,9 @@ layoutCtxCbCopyWidgetXToItem:
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_POS_LO
ldd r16, Y+WIDGET_OFFS_X_HI
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_POS_HI
ldd r16, Y+WIDGET_OFFS_WIDTH_LO
ldd r16, Y+WIDGET_OFFS_TMP_LO
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_SIZE_LO
ldd r16, Y+WIDGET_OFFS_WIDTH_HI
ldd r16, Y+WIDGET_OFFS_TMP_HI
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_SIZE_HI
clr r16
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
@@ -864,7 +901,8 @@ layoutCtxCbCopyWidgetXToItem_ret:
;
; @param Y widget
; @param X item
; @param r24 number of items left in layout context
; @param r24 number of items left in layout context (gets decremented)
; @clobbers r16
layoutCtxCbCopyItemToWidgetX:
tst r24
@@ -903,9 +941,9 @@ layoutCtxCbCopyWidgetYToItem:
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_POS_LO
ldd r16, Y+WIDGET_OFFS_Y_HI
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_POS_HI
ldd r16, Y+WIDGET_OFFS_HEIGHT_LO
ldd r16, Y+WIDGET_OFFS_TMP_LO
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_SIZE_LO
ldd r16, Y+WIDGET_OFFS_HEIGHT_HI
ldd r16, Y+WIDGET_OFFS_TMP_HI
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_SIZE_HI
clr r16
st X+, r16 ; LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
@@ -952,60 +990,57 @@ layoutCtxCbCopyItemToWidgetY_ret:
; ---------------------------------------------------------------------------
; @routine layoutCtxCbsetDefaultWidth
; @routine layoutCtxCbPackX
;
; @param Y widget
; @param X item
; @param r24 number of items left in layout context
; @param r24 number of items left in layout context (gets decremented)
; @clobbers r16-r21, r25
layoutCtxCbsetDefaultWidth:
layoutCtxCbPackX:
tst r24
sec
breq layoutCtxCbsetDefaultWidth_ret
push xl
push xh
push r24
bigcall Widget_GetDefaultWidth ; r19:r18=result
pop r24
pop xh
pop xl
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
st X+, r18
st X, r19
adiw xh:xl, 2
breq layoutCtxCbPackX_ret
ldd r20, Y+WIDGET_OFFS_TMP_LO
ldd r21, Y+WIDGET_OFFS_TMP_LO
rcall layoutCtxPack ; (r16-r19, r25)
std Y+WIDGET_OFFS_X_LO, r18
std Y+WIDGET_OFFS_X_HI, r19
std Y+WIDGET_OFFS_WIDTH_LO, r20
std Y+WIDGET_OFFS_WIDTH_HI, r21
adiw xh:xl, LAYOUT_CTX_ITEM_SIZE
dec r24
clc
layoutCtxCbsetDefaultWidth_ret:
layoutCtxCbPackX_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine layoutCtxCbsetDefaultHeight
; @routine layoutCtxCbPackY
;
; @param Y widget
; @param X item
; @param r24 number of items left in layout context
layoutCtxCbsetDefaultHeight:
layoutCtxCbPackY:
tst r24
sec
breq layoutCtxCbsetDefaultHeight_ret
push xl
push xh
push r24
bigcall Widget_GetDefaultHeight ; r19:r18=result
pop r24
pop xh
pop xl
adiw xh:xl, LAYOUT_CTX_ITEM_OFFS_DEFAULTSIZE_LO
st X+, r18
st X, r19
adiw xh:xl, 2
breq layoutCtxCbPackY_ret
ldd r20, Y+WIDGET_OFFS_TMP_LO
ldd r21, Y+WIDGET_OFFS_TMP_LO
rcall layoutCtxPack
std Y+WIDGET_OFFS_Y_LO, r18
std Y+WIDGET_OFFS_Y_HI, r19
std Y+WIDGET_OFFS_HEIGHT_LO, r20
std Y+WIDGET_OFFS_HEIGHT_HI, r21
adiw xh:xl, LAYOUT_CTX_ITEM_SIZE
dec r24
clc
layoutCtxCbsetDefaultHeight_ret:
layoutCtxCbPackY_ret:
ret
; @end
@@ -1013,6 +1048,7 @@ layoutCtxCbsetDefaultHeight_ret:
; ---------------------------------------------------------------------------
; @routine layoutForEveryObjectContiguous
;
@@ -1115,6 +1151,62 @@ layoutForEveryObjectSkipped_ret:
; ---------------------------------------------------------------------------
; @routine Layout2_SetDefaultWidths
;
; Set default width in WIDGET_OFFS_TMP_LO/HI of child widgets
;
; @param Y pointer to widget
; @clobbers any, !Y
Layout2_SetDefaultWidths:
push yl
push yh
bigcall OBJ_GetFirstChild
brcc Layout2_SetDefaultWidths_ret
Layout2_SetDefaultWidths_loop:
mov yl, r18
mov yh, r19
bigcall Widget_GetDefaultWidth
std Y+WIDGET_OFFS_TMP_LO, r18
std Y+WIDGET_OFFS_TMP_HI, r19
bigcall OBJ_GetNext
brcs Layout2_SetDefaultWidths_loop
Layout2_SetDefaultWidths_ret:
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine Layout2_SetDefaultHeights
;
; Set default height in WIDGET_OFFS_TMP_LO/HI of child widgets
;
; @param Y pointer to widget
; @clobbers any, !Y
Layout2_SetDefaultHeights:
push yl
push yh
bigcall OBJ_GetFirstChild
brcc Layout2_SetDefaultHeights_ret
Layout2_SetDefaultHeights_loop:
mov yl, r18
mov yh, r19
bigcall Widget_GetDefaultHeight
std Y+WIDGET_OFFS_TMP_LO, r18
std Y+WIDGET_OFFS_TMP_HI, r19
bigcall OBJ_GetNext
brcs Layout2_SetDefaultHeights_loop
Layout2_SetDefaultHeights_ret:
pop yh
pop yl
ret
; @end