gui2: more code sharing.
This commit is contained in:
@@ -437,7 +437,6 @@ layoutCtxSetPosWithExtra_loop: ; r19:r18=current pos, r22=spac
|
||||
; @routine layoutCtxPack
|
||||
;
|
||||
; @param X pointer to current item
|
||||
; @param Y current widget
|
||||
; @param r21:r20 default size of the widget
|
||||
; @return r19:r18 calculated pos
|
||||
; @return r21:r20 calculated size
|
||||
@@ -451,77 +450,50 @@ layoutCtxPack:
|
||||
ld r17, X+ ; size hi
|
||||
ld r25, X ; flags
|
||||
sbiw xh:xl, LAYOUT_CTX_ITEM_OFFS_FLAGS
|
||||
sub r16, r20 ; r17:r16=(size-defaultSize)
|
||||
sbc r17, r21
|
||||
brcs layoutCtxPack_done
|
||||
andi r25, 3
|
||||
cpi r25, WIDGET_PACK_END
|
||||
breq layoutCtxPack_end
|
||||
cpi r25, WIDGET_PACK_CENTER
|
||||
breq layoutCtxPack_center
|
||||
cpi r25, WIDGET_PACK_FILLED
|
||||
breq layoutCtxPack_filled
|
||||
rjmp layoutCtxPack_done
|
||||
layoutCtxPack_end:
|
||||
add r18, r16 ; just add difference to pos
|
||||
adc r19, r17
|
||||
rjmp layoutCtxPack_done
|
||||
layoutCtxPack_center:
|
||||
lsr r17
|
||||
ror r16
|
||||
add r18, r16 ; just add half difference to pos
|
||||
adc r19, r17
|
||||
rjmp layoutCtxPack_done
|
||||
layoutCtxPack_filled:
|
||||
add r16, r20 ; get total size back
|
||||
adc r17, r21
|
||||
mov r20, r16
|
||||
mov r21, r17
|
||||
layoutCtxPack_done:
|
||||
ret
|
||||
rjmp layoutPack
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine layout2Pack
|
||||
; @routine layoutPack
|
||||
;
|
||||
; @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
|
||||
; @return r19:r18 calculated pos
|
||||
; @return r21:r20 calculated size
|
||||
; @clobbers r16-r19, r25
|
||||
|
||||
layout2Pack:
|
||||
layoutPack:
|
||||
sub r16, r20 ; r17:r16=(size-defaultSize)
|
||||
sbc r17, r21
|
||||
brcs layout2Pack_done
|
||||
brcs layoutPack_done
|
||||
andi r25, 3
|
||||
cpi r25, WIDGET_PACK_END
|
||||
breq layout2Pack_end
|
||||
breq layoutPack_end
|
||||
cpi r25, WIDGET_PACK_CENTER
|
||||
breq layout2Pack_center
|
||||
breq layoutPack_center
|
||||
cpi r25, WIDGET_PACK_FILLED
|
||||
breq layout2Pack_filled
|
||||
rjmp layout2Pack_done
|
||||
layout2Pack_end:
|
||||
breq layoutPack_filled
|
||||
rjmp layoutPack_done
|
||||
layoutPack_end:
|
||||
add r18, r16 ; just add difference to pos
|
||||
adc r19, r17
|
||||
rjmp layout2Pack_done
|
||||
layout2Pack_center:
|
||||
rjmp layoutPack_done
|
||||
layoutPack_center:
|
||||
lsr r17
|
||||
ror r16
|
||||
add r18, r16 ; just add half difference to pos
|
||||
adc r19, r17
|
||||
rjmp layout2Pack_done
|
||||
layout2Pack_filled:
|
||||
rjmp layoutPack_done
|
||||
layoutPack_filled:
|
||||
add r16, r20 ; get total size back
|
||||
adc r17, r21
|
||||
mov r20, r16
|
||||
mov r21, r17
|
||||
layout2Pack_done:
|
||||
layoutPack_done:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
@@ -1476,6 +1476,7 @@ widgetCalcAbsPosAndBorders:
|
||||
; @param R13:R12 size of object to pack (i.e. width or height)
|
||||
; @return R21:R20 pos
|
||||
; @clobbers r17, r18, r19
|
||||
; @todo move layoutPack here and use that (shares more code)
|
||||
|
||||
widgetPack:
|
||||
; subtract borders
|
||||
|
||||
Reference in New Issue
Block a user