gui2: implement OnGetDefaultWidth/Height
This commit is contained in:
@@ -126,11 +126,9 @@ HLayout2_OnLayout_ret:
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout2_OnGetDefaultHeight:
|
||||
; rcall Layout_SetDefaultHeights
|
||||
; rcall Layout_GetMaxTmp
|
||||
; bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
ldi r18, 10
|
||||
clr r19
|
||||
rcall Layout2_SetDefaultHeights
|
||||
rcall Layout2_GetMaxTmp
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
|
||||
@@ -146,10 +144,8 @@ HLayout2_OnGetDefaultHeight:
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout2_OnGetDefaultWidth:
|
||||
; rcall Layout_SetDefaultWidths
|
||||
; rcall Layout_SumTmpValues ; r19:r18=default width
|
||||
ldi r18, 10
|
||||
clr r19
|
||||
rcall Layout2_SetDefaultWidths
|
||||
rcall Layout2_SumTmpValues ; r19:r18=default width
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -204,11 +204,6 @@ mcLayoutVertically:
|
||||
ldd r25, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
rcall LayoutCtx_PackYVertical ; (r16, r18, r19, r24, Z)
|
||||
|
||||
|
||||
;mov zl, yl
|
||||
;mov zh, yh
|
||||
;bigcall DEBUG_DUMPWDG
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -254,12 +249,6 @@ mcLayoutHorizontally:
|
||||
ldd r25, Y+MCLAYOUT_OFFS_COLUMNS
|
||||
rcall LayoutCtx_PackXHorizontal ; (r16, r18, r19, r24, Z)
|
||||
|
||||
;bigjmp DEBUG_DUMPCTX ; still correct, maybe packXHorizontal doesn't set pos correctly?
|
||||
|
||||
;mov zl, yl
|
||||
;mov zh, yh
|
||||
;bigcall DEBUG_DUMPWDG
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user