gui2: new layout modules basically work now.

This commit is contained in:
Martin Preuss
2026-04-12 17:01:30 +02:00
parent 505910bd12
commit 710af679cb
8 changed files with 517 additions and 29 deletions

View File

@@ -203,7 +203,7 @@ LayoutCtx_LayoutExpand:
; @clobbers r16-r25
LayoutCtx_LayoutSpread:
rcall layoutCtxCalcExpandPerExpandableItem ; r17:r16=space to add to expandable items (r16-r25)
; rcall layoutCtxCalcExpandPerExpandableItem ; r17:r16=space to add to expandable items (r16-r25)
rcall layoutCtxCalcSpreadValue ; r17:r16=space to add to expandable items and between (r16-r25)
push r16
push r17
@@ -483,10 +483,55 @@ layoutCtxPack_done:
; ---------------------------------------------------------------------------
; @routine layout2Pack
;
; @param X pointer to current item
; @param Y current widget
; @param r17:r16 space available to the child widget
; @param r21:r20 default size of the child widget
; @param r19:r18 pos
; @param r25 pack flags
; @clobbers r16-r19, r25
layout2Pack:
sub r16, r20 ; r17:r16=(size-defaultSize)
sbc r17, r21
brcs layout2Pack_done
andi r25, 3
cpi r25, WIDGET_PACK_END
breq layout2Pack_end
cpi r25, WIDGET_PACK_CENTER
breq layout2Pack_center
cpi r25, WIDGET_PACK_FILLED
breq layout2Pack_filled
rjmp layout2Pack_done
layout2Pack_end:
add r18, r16 ; just add difference to pos
adc r19, r17
rjmp layout2Pack_done
layout2Pack_center:
lsr r17
ror r16
add r18, r16 ; just add half difference to pos
adc r19, r17
rjmp layout2Pack_done
layout2Pack_filled:
add r16, r20 ; get total size back
adc r17, r21
mov r20, r16
mov r21, r17
layout2Pack_done:
ret
; @end
; ---------------------------------------------------------------------------
; @routine layoutCtxCalcExpandPerExpandableItem
;
; @param X pointer to layout context
; @return r17:r16 space per expandable item
; @clobbers r16-r25
layoutCtxCalcExpandPerExpandableItem:
@@ -527,7 +572,9 @@ layoutCtxCalcSpreadValue:
tst r16
breq layoutCtxCalcSpreadValue_none ; no expandable item, nothing to expand
rcall layoutCtxCalcAvailableExtraSpace ; r21:r20=available extra space (r16-r24)
push r16
rcall layoutCtxCalcAvailableExtraSpace ; r21:r20=available extra space (r16-r24)
pop r16
brcc layoutCtxCalcExpandPerExpandableItem_none ; jmp if no extra space
mov r22, r16
clr r23