gui2: X-layout works now!
This commit is contained in:
@@ -132,14 +132,16 @@ mLayoutColumnLayoutHorizontally:
|
||||
; possibly distribute free space to expandable columns
|
||||
push r22 ; spacing
|
||||
push r23 ; border
|
||||
push r25
|
||||
; rcall mLayoutColumnExpandColumns ; (r16-r23, r25)
|
||||
pop r25
|
||||
rcall mLayoutColumnExpandColumns ; (r16-r23)
|
||||
pop r23
|
||||
pop r22
|
||||
|
||||
rcall mLayoutColumnPositionX
|
||||
rcall mLayoutColumnGridX
|
||||
rcall mLayoutColumnCopyXTmpFromFirstRow
|
||||
push r25
|
||||
clr r25
|
||||
rcall mLayoutColumnPackX ; (r10-r13, r16-r21, X)
|
||||
pop r25
|
||||
|
||||
pop yh
|
||||
pop yl
|
||||
@@ -345,7 +347,7 @@ mLayoutCallbackColumnPositionXRow:
|
||||
push yh
|
||||
push zl
|
||||
push zh
|
||||
rcall mLayoutColumnPositionX ; (r12, r13, r16-r21, X, Z)
|
||||
rcall mLayoutColumnGridX ; (r12, r13, r16-r21, X, Z)
|
||||
pop zh
|
||||
pop zl
|
||||
pop yh
|
||||
@@ -357,7 +359,7 @@ mLayoutCallbackColumnPositionXRow:
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnPositionX
|
||||
; @routine mLayoutColumnGridX
|
||||
;
|
||||
; Set X and width to all columns of the row
|
||||
;
|
||||
@@ -367,13 +369,13 @@ mLayoutCallbackColumnPositionXRow:
|
||||
; @param R25 widgets per row/column
|
||||
; @clobbers r12, r13, r16-r21, X, Z
|
||||
|
||||
mLayoutColumnPositionX:
|
||||
mLayoutColumnGridX:
|
||||
mov xl, r23 ; start at border
|
||||
clr xh
|
||||
push yl
|
||||
push yh
|
||||
ldi zl, LOW(mLayoutCallbackPositionX)
|
||||
ldi zh, HIGH(mLayoutCallbackPositionX)
|
||||
ldi zl, LOW(mLayoutCallbackGridX)
|
||||
ldi zh, HIGH(mLayoutCallbackGridX)
|
||||
rcall mLayoutForEveryObjectContiguous ; (r12, r13, r16-r21, Y)
|
||||
pop yh
|
||||
pop yl
|
||||
@@ -382,6 +384,24 @@ mLayoutColumnPositionX:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnPackX
|
||||
;
|
||||
; Pack each widget inside its cell.
|
||||
;
|
||||
; @param Y first widget of current row
|
||||
; @param r22 spacing between widgets
|
||||
; @param r23 border at beginning and and
|
||||
; @param R25 widgets per row/column
|
||||
; @clobbers r10-r13, r16-r21, X
|
||||
|
||||
mLayoutColumnPackX:
|
||||
M_MLAYOUT_FOREVERY_CONT mLayoutCallbackPackX ; (r10-r13, r16-r21, X)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnPositionAllY
|
||||
;
|
||||
@@ -463,15 +483,29 @@ mLayoutColumnPositionY:
|
||||
; @param R25 widgets per row/column
|
||||
; @return CFLAG set if there is additional space to distribute
|
||||
; @return r21:r20 space to add to every expandable widget
|
||||
; @clobbers r16-r23
|
||||
; @clobbers r16-r21
|
||||
|
||||
mLayoutColumnExpandColumns:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetParent
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r18, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r19, Y+WIDGET_OFFS_WIDTH_HI
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
rcall mLayoutColumnCalcAddSpacePerColumn ; r21:r20=additional space (r16-r23)
|
||||
brcc mLayoutColumnExpandColumns_ret
|
||||
|
||||
ldi r22, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) ; value
|
||||
rcall mLayoutExpandChildrenMatchingPackContiguous ; (r18, r19)
|
||||
push r22
|
||||
push r23
|
||||
ldi r22, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) ; value
|
||||
rcall mLayoutExpandMatchingPackContiguous ; (r18, r19)
|
||||
pop r23
|
||||
pop r22
|
||||
|
||||
mLayoutColumnExpandColumns_ret:
|
||||
ret
|
||||
@@ -485,47 +519,83 @@ mLayoutColumnExpandColumns_ret:
|
||||
; Calculate additional space per expandable widget in a row.
|
||||
;
|
||||
; @param Y first widget of current row
|
||||
; @param r19:r18 width of parent widget
|
||||
; @return CFLAG set if there is additional space to distribute
|
||||
; @return r21:r20 space to add to every expandable widget
|
||||
; @param r22 spacing between widgets
|
||||
; @param r23 border at beginning and and
|
||||
; @param r25 widgets per row/column
|
||||
; @clobbers r16-r23
|
||||
; @clobbers r16-r21
|
||||
|
||||
mLayoutColumnCalcAddSpacePerColumn:
|
||||
rcall mLayoutSumContiguous ; r21:r20 needed minimum row width (r18, r19)
|
||||
ldd r18, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r19, Y+WIDGET_OFFS_WIDTH_HI
|
||||
sub r18, r20
|
||||
sbc r19, r21
|
||||
brcc mLayoutColumnCalcAddSpacePerElement_none
|
||||
breq mLayoutColumnCalcAddSpacePerElement_none
|
||||
; r19:r18=space to distribute
|
||||
push r22
|
||||
push r23
|
||||
rcall mLayoutColumnCalcAdditionalSpace ; r21:r20=additional space (R18, R19)
|
||||
brcc mLayoutColumnCalcAddSpacePerElement_ret
|
||||
push r20
|
||||
push r21
|
||||
ldi r22, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) ; value
|
||||
rcall mLayoutCountMatchingPackContiguous ; r20=num of matching items (r18, r19)
|
||||
mov r22, r20
|
||||
clr r23
|
||||
pop r21
|
||||
pop r20
|
||||
tst r22
|
||||
breq mLayoutColumnCalcAddSpacePerElement_none ; don't divide by zero!
|
||||
|
||||
push r25
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per expandable widget (r25)
|
||||
pop r25
|
||||
mov r20, r16
|
||||
mov r21, r17
|
||||
sec
|
||||
rjmp mLayoutColumnCalcAddSpacePerElement_ret
|
||||
mLayoutColumnCalcAddSpacePerElement_none:
|
||||
clr r20
|
||||
clr r21
|
||||
clc
|
||||
mLayoutColumnCalcAddSpacePerElement_ret:
|
||||
pop r23
|
||||
pop r22
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCalcAdditionalSpace
|
||||
;
|
||||
; Calculate additional space in a row.
|
||||
;
|
||||
; @param Y first widget of current row
|
||||
; @param r19:r18 width of parent widget
|
||||
; @param r22 spacing between widgets
|
||||
; @param r23 border at beginning and and
|
||||
; @param r25 widgets per row/column
|
||||
; @return CFLAG set if there is additional space to distribute
|
||||
; @return r21:r20 available additional space
|
||||
; @clobbers r18, r19
|
||||
|
||||
mLayoutColumnCalcAdditionalSpace:
|
||||
push r18
|
||||
push r19
|
||||
ldi r22, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) ; value
|
||||
rcall mLayoutCountChildrenMatchingPackContiguous ; r20=num of matching children (r18, r19, r25)
|
||||
rcall mLayoutSumContiguous ; r21:r20 needed minimum row width (r18, r19)
|
||||
pop r19
|
||||
pop r18
|
||||
tst r20
|
||||
breq mLayoutColumnCalcAddSpacePerElement_none ; don't divide by zero!
|
||||
mov r22, r20
|
||||
clr r23
|
||||
sub r18, r20
|
||||
sbc r19, r21
|
||||
brcs mLayoutColumnCalcAdditionalSpace_none
|
||||
breq mLayoutColumnCalcAdditionalSpace_none
|
||||
mov r20, r18
|
||||
mov r21, r19
|
||||
push r25
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per expandable widget (r25)
|
||||
pop r25
|
||||
mov r20, r16
|
||||
mov r21, r17
|
||||
sec
|
||||
rjmp mLayoutColumnCalcAddSpacePerElement_ret
|
||||
mLayoutColumnCalcAddSpacePerElement_none:
|
||||
rjmp mLayoutColumnCalcAdditionalSpace_ret
|
||||
mLayoutColumnCalcAdditionalSpace_none:
|
||||
clr r20
|
||||
clr r21
|
||||
clc
|
||||
mLayoutColumnCalcAddSpacePerElement_ret:
|
||||
mLayoutColumnCalcAdditionalSpace_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -548,7 +618,7 @@ mLayoutColumnExpandRows:
|
||||
|
||||
ldi r22, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; value
|
||||
rcall mLayoutExpandChildrenMatchingPackSkipped ; (r18, r19)
|
||||
rcall mLayoutExpandMatchingPackSkipped ; (r18, r19)
|
||||
|
||||
mLayoutColumnExpandRows_ret:
|
||||
ret
|
||||
|
||||
Reference in New Issue
Block a user