diff --git a/avr/devices/c03/test/main.asm b/avr/devices/c03/test/main.asm index 1021f05..275a101 100644 --- a/avr/devices/c03/test/main.asm +++ b/avr/devices/c03/test/main.asm @@ -383,7 +383,7 @@ mkTestWidgets: push xl ; MLayout push xh ldi r16, (1< shift 2 times right + lsr r17 + andi r17, 3 + rcall mLayoutPackCell ; R21:R20=relative pos, R19:R18=new size (r16, r17, r18, r19) + ldd xl, Y+WIDGET_OFFS_Y_LO + ldd xh, Y+WIDGET_OFFS_Y_HI + add xl, r20 + adc xh, r21 + std Y+WIDGET_OFFS_Y_LO, xl + std Y+WIDGET_OFFS_Y_HI, xh + std Y+WIDGET_OFFS_HEIGHT_LO, r18 + std Y+WIDGET_OFFS_HEIGHT_HI, r19 + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine mLayoutCallbackPositionY @@ -347,37 +401,6 @@ add xl, r20 adc xh, r21 clc ret - - ldd r16, Y+OBJECT_OFFS_FLAGS - sbrs r16, WIDGET_FLAGS_VISIBLE_BIT - rjmp mLayoutCallbackPositionY_ret - ldd r10, Y+WIDGET_OFFS_TMP_LO ; calculated cell width - ldd r11, Y+WIDGET_OFFS_TMP_HI - ldd r12, Y+WIDGET_OFFS_HEIGHT_LO ; default height - ldd r13, Y+WIDGET_OFFS_HEIGHT_HI - ldd r17, Y+WIDGET_OFFS_PACK - lsr r17 ; WIDGET_PACK_VSELF0_BIT = 2 -> shift 2 times right - lsr r17 - andi r17, 3 - push r18 - push r19 - rcall mLayoutPackCell ; R21:R20=relative pos (r16, r17, r18, r19) - pop r19 - pop r18 - add r20, xl - adc r21, xh - std Y+WIDGET_OFFS_Y_LO, r20 ; set new Y - std Y+WIDGET_OFFS_Y_HI, r21 -; std Y+WIDGET_OFFS_HEIGHT_LO, r12 ; set new height -; std Y+WIDGET_OFFS_HEIGHT_HI, r13 - add xl, r18 ; advance Y - adc xh, r19 - add xl, r22 ; add spacing - adc xh, r22 - sub xh, r22 -mLayoutCallbackPositionY_ret: - clc - ret ; @end diff --git a/avr/modules/lcd2/gui2/base/mlayout_column.asm b/avr/modules/lcd2/gui2/base/mlayout_column.asm index e102bd6..7630b13 100644 --- a/avr/modules/lcd2/gui2/base/mlayout_column.asm +++ b/avr/modules/lcd2/gui2/base/mlayout_column.asm @@ -128,20 +128,10 @@ mLayoutColumnLayoutHorizontally: ; prepare first row rcall mLayoutSetupFirstContiguous ; set max column widths to first row (r18, r19, Z) - - ; possibly distribute free space to expandable columns - push r22 ; spacing - push r23 ; border - rcall mLayoutColumnExpandColumns ; (r16-r23) - pop r23 - pop r22 - + rcall mLayoutColumnExpandColumns ; (r16-r23) rcall mLayoutColumnGridX rcall mLayoutColumnCopyXTmpFromFirstRow - push r25 - clr r25 - rcall mLayoutColumnPackX ; (r10-r13, r16-r21, X) - pop r25 + rcall mLayoutColumnPackX ; (r10-r13, r16-r21, X) pop yh pop yl @@ -168,22 +158,12 @@ mLayoutColumnLayoutVertically: pop r23 pop r22 - ; prepare first column - rcall mLayoutSetupFirstSkipped ; set max column heights to first column (r18, r19, Z) - - ; possibly distribute free space to expandable columns - push r22 ; spacing - push r23 ; border -; rcall mLayoutColumnExpandRows ; (r16-r23) - pop r23 - pop r22 - - rcall mLayoutColumnPositionY + rcall mLayoutSetupFirstSkipped ; set max column heights to first column (r18, r19, Z) + rcall mLayoutColumnExpandRows ; (r16-r23) + rcall mLayoutColumnGridY rcall mLayoutColumnCopyTmpFromFirstColumn + rcall mLayoutColumnPackY ; (r10-r13, r16-r21, X) -; rcall mLayoutColumnCopyTmpFromFirstColumn ; copy TMP of every column from first row to following (r18-r21, Z) -; rcall mLayoutColumnPositionAllY ; (r12, r13, r16-r21, Y) - pop yh pop yl ret @@ -310,54 +290,6 @@ mLayoutColumnCopyYTmpAcrossRow: -; --------------------------------------------------------------------------- -; @routine mLayoutColumnPositionAllX -; -; Set X and width to all columns of the row -; -; @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 r12, r13, r16-r21, X - -mLayoutColumnPositionAllX: - mov xl, r23 ; start at border - clr xh - push yl - push yh - ldi zl, LOW(mLayoutCallbackColumnPositionXRow) - ldi zh, HIGH(mLayoutCallbackColumnPositionXRow) - rcall mLayoutForEveryObjectSkipped ; (r12, r13, r16-r21, Y) - pop yh - pop yl - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine mLayoutCallbackColumnPositionXRow -; -; @param Y widget -; @clobbers r12, r13, r16-r21, X - -mLayoutCallbackColumnPositionXRow: - push yl - push yh - push zl - push zh - rcall mLayoutColumnGridX ; (r12, r13, r16-r21, X, Z) - pop zh - pop zl - pop yh - pop yl - clc - ret -; @end - - - ; --------------------------------------------------------------------------- ; @routine mLayoutColumnGridX ; @@ -396,77 +328,34 @@ mLayoutColumnGridX: ; @clobbers r10-r13, r16-r21, X mLayoutColumnPackX: - M_MLAYOUT_FOREVERY_CONT mLayoutCallbackPackX ; (r10-r13, r16-r21, X) + push r25 + clr r25 + M_MLAYOUT_FOREVERY_CONT mLayoutCallbackPackX ; (r10-r13, r16-r21, X) + pop r25 ret ; @end ; --------------------------------------------------------------------------- -; @routine mLayoutColumnPositionAllY +; @routine mLayoutColumnGridY ; -; Set Y and height to all columns of the row +; Set Y and height to all rows of a column ; ; @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 r12, r13, r16-r21, Y, Z - -mLayoutColumnPositionAllY: - push yl - push yh - ldi zl, LOW(mLayoutCallbackColumnPositionYColumn) - ldi zh, HIGH(mLayoutCallbackColumnPositionYColumn) - rcall mLayoutForEveryObjectContiguous ; (r12, r13, r16-r21, Y) - pop yh - pop yl - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine mLayoutCallbackColumnPositionYColumn -; -; @param Y widget -; @clobbers r12, r13, r16-r21, Y - -mLayoutCallbackColumnPositionYColumn: - push yl - push yh - push zl - push zh - rcall mLayoutColumnPositionY ; (r12, r13, r16-r21, X, Z) - pop zh - pop zl - pop yh - pop yl - clc - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine mLayoutColumnPositionY -; -; Set X and width to all columns of the row -; -; @param Y first widget of current row -; @param r22 spacing between widgets -; @param r23 border at beginning and end -; @param R25 widgets per row/column ; @clobbers r12, r13, r16-r21, X, Z -mLayoutColumnPositionY: +mLayoutColumnGridY: mov xl, r23 ; start at border clr xh push yl push yh - ldi zl, LOW(mLayoutCallbackPositionY) - ldi zh, HIGH(mLayoutCallbackPositionY) - rcall mLayoutForEveryObjectSkipped ; (r12, r13, r16-r21, Y) + ldi zl, LOW(mLayoutCallbackGridY) + ldi zh, HIGH(mLayoutCallbackGridY) + rcall mLayoutForEveryObjectSkipped ; (r12, r13, r16-r21, Y) pop yh pop yl ret @@ -474,6 +363,26 @@ mLayoutColumnPositionY: +; --------------------------------------------------------------------------- +; @routine mLayoutColumnPackY +; +; 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 +; @clobbers r10-r13, r16-r21, X + +mLayoutColumnPackY: + push r25 + clr r25 + M_MLAYOUT_FOREVERY_CONT mLayoutCallbackPackY ; (r10-r13, r16-r21, X) + pop r25 + ret +; @end + + + ; --------------------------------------------------------------------------- ; @routine mLayoutColumnExpandColumns ; @@ -530,8 +439,8 @@ mLayoutColumnExpandColumns_ret: mLayoutColumnCalcAddSpacePerColumn: push r22 push r23 - rcall mLayoutColumnCalcAdditionalSpace ; r21:r20=additional space (R18, R19) - brcc mLayoutColumnCalcAddSpacePerElement_ret + rcall mLayoutColumnCalcAdditionalSpaceContiguous ; r21:r20=additional space (R18, R19) + brcc mLayoutColumnCalcAddSpacePerColumn_ret push r20 push r21 ldi r22, (1<