gui2: finalized mlayout module.

This commit is contained in:
Martin Preuss
2026-03-23 23:20:13 +01:00
parent 0015a0a06c
commit 07a6c5a540
3 changed files with 178 additions and 1285 deletions

View File

@@ -583,7 +583,7 @@ GUI2_MODULE_BEGIN:
.include "modules/lcd2/gui2/base/layout.asm" .include "modules/lcd2/gui2/base/layout.asm"
.include "modules/lcd2/gui2/base/hlayout.asm" .include "modules/lcd2/gui2/base/hlayout.asm"
.include "modules/lcd2/gui2/base/vlayout.asm" .include "modules/lcd2/gui2/base/vlayout.asm"
.include "modules/lcd2/gui2/base/mlayout2.asm" .include "modules/lcd2/gui2/base/mlayout.asm"
.include "modules/lcd2/gui2/base/mlayout_column.asm" .include "modules/lcd2/gui2/base/mlayout_column.asm"
.include "modules/lcd2/gui2/base/guiapp.asm" .include "modules/lcd2/gui2/base/guiapp.asm"
.include "modules/lcd2/gui2/base/mainwindow.asm" .include "modules/lcd2/gui2/base/mainwindow.asm"

View File

@@ -7,8 +7,8 @@
; * Please see toplevel file COPYING of that project for license details. * ; * Please see toplevel file COPYING of that project for license details. *
; *************************************************************************** ; ***************************************************************************
#ifndef AQH_AVR_GUI2_MLAYOUT2_ASM #ifndef AQH_AVR_GUI2_MLAYOUT_ASM
#define AQH_AVR_GUI2_MLAYOUT2_ASM #define AQH_AVR_GUI2_MLAYOUT_ASM
; TODO: ; TODO:
; - use this class also for HLayout and VLayout, those are just special ; - use this class also for HLayout and VLayout, those are just special
@@ -43,6 +43,8 @@
; *************************************************************************** ; ***************************************************************************
; defines ; defines
@@ -212,7 +214,6 @@ MLayout_GetFirstChildToY:
brcc MLayout_GetFirstChildToY_ret brcc MLayout_GetFirstChildToY_ret
mov yl, r18 mov yl, r18
mov yh, r19 mov yh, r19
sec
MLayout_GetFirstChildToY_ret: MLayout_GetFirstChildToY_ret:
pop r19 pop r19
pop r18 pop r18
@@ -238,40 +239,18 @@ mLayoutCallbackSetTmp:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutCallbackPositionX ; @routine mLayoutCallbackSetXTmp
; ;
; @param Y widget ; @param Y widget
; @param r22 spacing between widgets ; @param r21:r20 TMP to set
; @param X current X pos ; @param X X to set
; @clobbers r12, r13, r16-r21 ; @clobbers none
mLayoutCallbackPositionX: mLayoutCallbackSetXTmp:
ldd r16, Y+OBJECT_OFFS_FLAGS std Y+WIDGET_OFFS_X_LO, xl
sbrs r16, WIDGET_FLAGS_VISIBLE_BIT std Y+WIDGET_OFFS_X_HI, xh
rjmp mLayoutCallbackPositionX_ret std Y+WIDGET_OFFS_TMP_LO, r20
ldd r18, Y+WIDGET_OFFS_TMP_LO ; calculated cell width std Y+WIDGET_OFFS_TMP_HI, r21
ldd r19, Y+WIDGET_OFFS_TMP_HI
ldd r12, Y+WIDGET_OFFS_WIDTH_LO ; default width
ldd r13, Y+WIDGET_OFFS_WIDTH_HI
ldd r17, Y+WIDGET_OFFS_PACK
andi r17, 3 ; WIDGET_PACK_HSELF0_BIT = 0, no shift necessary
push r18
push r19
rcall mLayoutPackCell ; R21:R20=relative pos (r17, r18, r19)
pop r19
pop r18
add r20, xl
adc r21, xh
std Y+WIDGET_OFFS_X_LO, r20 ; set new X
std Y+WIDGET_OFFS_X_HI, r21
std Y+WIDGET_OFFS_WIDTH_LO, r18 ; set new width
std Y+WIDGET_OFFS_WIDTH_HI, r19
add xl, r18 ; advance X
adc xh, r19
add xl, r22 ; add spacing
adc xh, r22
sub xh, r22
mLayoutCallbackPositionX_ret:
clc clc
ret ret
; @end ; @end
@@ -279,48 +258,131 @@ mLayoutCallbackPositionX_ret:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutCallbackPositionY ; @routine mLayoutCallbackSetYTmp
;
; @param Y widget
; @param r21:r20 TMP to set
; @param X Y to set
; @clobbers none
mLayoutCallbackSetYTmp:
std Y+WIDGET_OFFS_Y_LO, xl
std Y+WIDGET_OFFS_Y_HI, xh
std Y+WIDGET_OFFS_TMP_LO, r20
std Y+WIDGET_OFFS_TMP_HI, r21
clc
ret
; @end
; ---------------------------------------------------------------------------
; @routine mLayoutCallbackGridX
;
; @param Y widget
; @param r22 spacing between widgets
; @param X current X pos
; @clobbers r10-r13, r16-r21
mLayoutCallbackGridX:
ldd r20, Y+WIDGET_OFFS_TMP_LO
ldd r21, Y+WIDGET_OFFS_TMP_HI
std Y+WIDGET_OFFS_X_LO, xl ; set new X
std Y+WIDGET_OFFS_X_HI, xh
add xl, r20 ; add cell width
adc xh, r21
add xl, r22 ; add spacing
adc xh, r22
sub xh, r22
clc
ret
; @end
; ---------------------------------------------------------------------------
; @routine mLayoutCallbackPackX
;
; @param Y widget
; @param r22 spacing between widgets
; @clobbers r10-r13, r16-r21, X
mLayoutCallbackPackX:
ldd r10, Y+WIDGET_OFFS_TMP_LO ; calculated cell width
ldd r11, Y+WIDGET_OFFS_TMP_HI
ldd r12, Y+WIDGET_OFFS_WIDTH_LO ; default width
ldd r13, Y+WIDGET_OFFS_WIDTH_HI
ldd r17, Y+WIDGET_OFFS_PACK
andi r17, 3 ; WIDGET_PACK_HSELF0_BIT = 0, no shift necessary
rcall mLayoutPackCell ; R21:R20=relative pos, R19:R18=new size (r16, r17, r18, r19)
ldd xl, Y+WIDGET_OFFS_X_LO
ldd xh, Y+WIDGET_OFFS_X_HI
add xl, r20
adc xh, r21
std Y+WIDGET_OFFS_X_LO, xl
std Y+WIDGET_OFFS_X_HI, xh
std Y+WIDGET_OFFS_WIDTH_LO, r18
std Y+WIDGET_OFFS_WIDTH_HI, r19
ret
; @end
; ---------------------------------------------------------------------------
; @routine mLayoutCallbackGridY
; ;
; @param Y widget ; @param Y widget
; @param r22 spacing between widgets ; @param r22 spacing between widgets
; @param X current Y pos ; @param X current Y pos
; @clobbers r12, r13, r16-r21 ; @clobbers r10-r13, r16-r21
mLayoutCallbackPositionY: mLayoutCallbackGridY:
ldd r16, Y+OBJECT_OFFS_FLAGS ldd r20, Y+WIDGET_OFFS_TMP_LO
sbrs r16, WIDGET_FLAGS_VISIBLE_BIT ldd r21, Y+WIDGET_OFFS_TMP_HI
rjmp mLayoutCallbackPositionY_ret std Y+WIDGET_OFFS_Y_LO, xl ; set new Y
ldd r18, Y+WIDGET_OFFS_TMP_LO ; calculated cell width std Y+WIDGET_OFFS_Y_HI, xh
ldd r19, Y+WIDGET_OFFS_TMP_HI add xl, r20 ; add cell width
ldd r12, Y+WIDGET_OFFS_HEIGHT_LO ; default height adc xh, r21
add xl, r22 ; add spacing
adc xh, r22
sub xh, r22
clc
ret
; @end
; ---------------------------------------------------------------------------
; @routine mLayoutCallbackPackY
;
; @param Y widget
; @param r22 spacing between widgets
; @clobbers r10-r13, r16-r21, X
mLayoutCallbackPackY:
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 width
ldd r13, Y+WIDGET_OFFS_HEIGHT_HI ldd r13, Y+WIDGET_OFFS_HEIGHT_HI
ldd r17, Y+WIDGET_OFFS_PACK ldd r17, Y+WIDGET_OFFS_PACK
lsr r17 ; WIDGET_PACK_VSELF0_BIT = 2 -> shift 2 times right lsr r17 ; WIDGET_PACK_VSELF0_BIT = 2 -> shift 2 times right
lsr r17 lsr r17
andi r17, 3 andi r17, 3
push r18 rcall mLayoutPackCell ; R21:R20=relative pos, R19:R18=new size (r16, r17, r18, r19)
push r19 ldd xl, Y+WIDGET_OFFS_Y_LO
rcall mLayoutPackCell ; R21:R20=relative pos (r17, r18, r19) ldd xh, Y+WIDGET_OFFS_Y_HI
pop r19 add xl, r20
pop r18 adc xh, r21
add r20, xl std Y+WIDGET_OFFS_Y_LO, xl
adc r21, xh std Y+WIDGET_OFFS_Y_HI, xh
std Y+WIDGET_OFFS_Y_LO, r20 ; set new Y std Y+WIDGET_OFFS_HEIGHT_LO, r18
std Y+WIDGET_OFFS_Y_HI, r21 std Y+WIDGET_OFFS_HEIGHT_HI, r19
; 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 ret
; @end ; @end
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutSetupFirstContiguous ; @routine mLayoutSetupFirstContiguous
; ;
@@ -493,7 +555,7 @@ mLayoutCallbackGetMaxTmp_ret:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutCountChildrenMatchingPackContiguous ; @routine mLayoutCountMatchingPackContiguous
; ;
; @param Y object whose TMP value is to be added ; @param Y object whose TMP value is to be added
; @param r22 mask for WIDGET_OFFS_PACK ; @param r22 mask for WIDGET_OFFS_PACK
@@ -502,12 +564,12 @@ mLayoutCallbackGetMaxTmp_ret:
; @return r20 number of matching children ; @return r20 number of matching children
; @clobbers r18, r19 ; @clobbers r18, r19
mLayoutCountChildrenMatchingPackContiguous: mLayoutCountMatchingPackContiguous:
push yl push yl
push yh push yh
clr r20 clr r20
ldi zl, LOW(mLayoutCallbackCountChildrenMatchingPack) ldi zl, LOW(mLayoutCallbackCountMatchingPack)
ldi zh, HIGH(mLayoutCallbackCountChildrenMatchingPack) ldi zh, HIGH(mLayoutCallbackCountMatchingPack)
rcall mLayoutForEveryObjectContiguous ; (r18, r19, Y) rcall mLayoutForEveryObjectContiguous ; (r18, r19, Y)
pop yh pop yh
pop yl pop yl
@@ -530,8 +592,8 @@ mLayoutCountChildrenMatchingPackSkipped:
push yl push yl
push yh push yh
clr r20 clr r20
ldi zl, LOW(mLayoutCallbackCountChildrenMatchingPack) ldi zl, LOW(mLayoutCallbackCountMatchingPack)
ldi zh, HIGH(mLayoutCallbackCountChildrenMatchingPack) ldi zh, HIGH(mLayoutCallbackCountMatchingPack)
rcall mLayoutForEveryObjectSkipped ; (r18, r19, Y) rcall mLayoutForEveryObjectSkipped ; (r18, r19, Y)
pop yh pop yh
pop yl pop yl
@@ -541,7 +603,7 @@ mLayoutCountChildrenMatchingPackSkipped:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutCallbackCountChildrenMatchingPack ; @routine mLayoutCallbackCountMatchingPack
; ;
; @param Y object whose TMP value is to be added ; @param Y object whose TMP value is to be added
; @param r20 number of matching children so far ; @param r20 number of matching children so far
@@ -550,16 +612,16 @@ mLayoutCountChildrenMatchingPackSkipped:
; @return CFLAG clear (to not abort the loop function) ; @return CFLAG clear (to not abort the loop function)
; @clobbers r18 ; @clobbers r18
mLayoutCallbackCountChildrenMatchingPack: mLayoutCallbackCountMatchingPack:
ldd r18, Y+OBJECT_OFFS_FLAGS ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp mLayoutCallbackCountChildrenMatchingPack_ret rjmp mLayoutCallbackCountMatchingPack_ret
ldd r18, Y+WIDGET_OFFS_PACK ldd r18, Y+WIDGET_OFFS_PACK
eor r18, r23 eor r18, r23
and r18, r22 and r18, r22
brne mLayoutCallbackCountChildrenMatchingPack_ret brne mLayoutCallbackCountMatchingPack_ret
inc r20 inc r20
mLayoutCallbackCountChildrenMatchingPack_ret: mLayoutCallbackCountMatchingPack_ret:
clc clc
ret ret
; @end ; @end
@@ -567,7 +629,7 @@ mLayoutCallbackCountChildrenMatchingPack_ret:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutExpandChildrenMatchingPackContiguous ; @routine mLayoutExpandMatchingPackContiguous
; ;
; @param Y object whose TMP value is to be added ; @param Y object whose TMP value is to be added
; @param r21:r20 value to add to TMP ; @param r21:r20 value to add to TMP
@@ -576,12 +638,11 @@ mLayoutCallbackCountChildrenMatchingPack_ret:
; @param r25 number of widgets to handle ; @param r25 number of widgets to handle
; @clobbers r18, r19 ; @clobbers r18, r19
mLayoutExpandChildrenMatchingPackContiguous: mLayoutExpandMatchingPackContiguous:
push yl push yl
push yh push yh
clr r20 ldi zl, LOW(mLayoutCallbackExpandMatchingPack)
ldi zl, LOW(mLayoutCallbackExpandChildrenMatchingPack) ldi zh, HIGH(mLayoutCallbackExpandMatchingPack)
ldi zh, HIGH(mLayoutCallbackExpandChildrenMatchingPack)
rcall mLayoutForEveryObjectContiguous ; (r18, r19, Y) rcall mLayoutForEveryObjectContiguous ; (r18, r19, Y)
pop yh pop yh
pop yl pop yl
@@ -591,7 +652,7 @@ mLayoutExpandChildrenMatchingPackContiguous:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutExpandChildrenMatchingPackSkipped ; @routine mLayoutExpandMatchingPackSkipped
; ;
; @param Y object whose TMP value is to be added ; @param Y object whose TMP value is to be added
; @param r21:r20 value to add to TMP ; @param r21:r20 value to add to TMP
@@ -600,12 +661,11 @@ mLayoutExpandChildrenMatchingPackContiguous:
; @param r25 number of widgets to skip ; @param r25 number of widgets to skip
; @clobbers r18, r19 ; @clobbers r18, r19
mLayoutExpandChildrenMatchingPackSkipped: mLayoutExpandMatchingPackSkipped:
push yl push yl
push yh push yh
clr r20 ldi zl, LOW(mLayoutCallbackExpandMatchingPack)
ldi zl, LOW(mLayoutCallbackExpandChildrenMatchingPack) ldi zh, HIGH(mLayoutCallbackExpandMatchingPack)
ldi zh, HIGH(mLayoutCallbackExpandChildrenMatchingPack)
rcall mLayoutForEveryObjectSkipped ; (r18, r19, Y) rcall mLayoutForEveryObjectSkipped ; (r18, r19, Y)
pop yh pop yh
pop yl pop yl
@@ -615,7 +675,7 @@ mLayoutExpandChildrenMatchingPackSkipped:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine mLayoutCallbackExpandChildrenMatchingPack ; @routine mLayoutCallbackExpandMatchingPack
; ;
; @param Y object whose TMP value is to be added ; @param Y object whose TMP value is to be added
; @param r21:r20 space to add to expandable widgets ; @param r21:r20 space to add to expandable widgets
@@ -624,21 +684,21 @@ mLayoutExpandChildrenMatchingPackSkipped:
; @return CFLAG clear (to not abort the loop function) ; @return CFLAG clear (to not abort the loop function)
; @clobbers r18, r19 ; @clobbers r18, r19
mLayoutCallbackExpandChildrenMatchingPack: mLayoutCallbackExpandMatchingPack:
ldd r18, Y+OBJECT_OFFS_FLAGS ldd r18, Y+OBJECT_OFFS_FLAGS
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
rjmp mLayoutCallbackExpandChildrenMatchingPack_ret rjmp mLayoutCallbackExpandMatchingPack_ret
ldd r18, Y+WIDGET_OFFS_PACK ldd r18, Y+WIDGET_OFFS_PACK
eor r18, r23 eor r18, r23
and r18, r22 and r18, r22
brne mLayoutCallbackExpandChildrenMatchingPack_ret brne mLayoutCallbackExpandMatchingPack_ret
ldd r18, Y+WIDGET_OFFS_TMP_LO ldd r18, Y+WIDGET_OFFS_TMP_LO
ldd r19, Y+WIDGET_OFFS_TMP_HI ldd r19, Y+WIDGET_OFFS_TMP_HI
add r18, r20 add r18, r20
adc r19, r21 adc r19, r21
std Y+WIDGET_OFFS_TMP_LO, r18 std Y+WIDGET_OFFS_TMP_LO, r18
std Y+WIDGET_OFFS_TMP_HI, r19 std Y+WIDGET_OFFS_TMP_HI, r19
mLayoutCallbackExpandChildrenMatchingPack_ret: mLayoutCallbackExpandMatchingPack_ret:
clc clc
ret ret
; @end ; @end
@@ -809,7 +869,7 @@ mLayoutCallbackCopyTmpToHeight:
; @param r22 spacing between widgets ; @param r22 spacing between widgets
; @param r23 border at beginning and and ; @param r23 border at beginning and and
; @return r21:r20 total size in the given dimension including borders and inter-widget spacing ; @return r21:r20 total size in the given dimension including borders and inter-widget spacing
; @clobbers r18, r19, r25 ; @clobbers r18, r19
mLayoutSumContiguous: mLayoutSumContiguous:
push yl push yl
@@ -818,7 +878,7 @@ mLayoutSumContiguous:
clr r21 clr r21
ldi zl, LOW(mLayoutCallbackAddToSum) ldi zl, LOW(mLayoutCallbackAddToSum)
ldi zh, HIGH(mLayoutCallbackAddToSum) ldi zh, HIGH(mLayoutCallbackAddToSum)
rcall mLayoutForEveryObjectContiguous ; (r18, r19, r25, Y) rcall mLayoutForEveryObjectContiguous ; (r18, r19, Y)
sub r20, r22 ; undo last adding inter-widget space sub r20, r22 ; undo last adding inter-widget space
sbc r21, r22 sbc r21, r22
add r21, r22 add r21, r22
@@ -965,10 +1025,6 @@ mLayoutForEveryObjectContiguous_ret:
; @clobbers r18, r19, Y {any} ; @clobbers r18, r19, Y {any}
mLayoutForEveryObjectSkipped: mLayoutForEveryObjectSkipped:
tst r25
brne mLayoutForEveryObjectSkipped_loop
bigjmp DEBUG2
mLayoutForEveryObjectSkipped_loop: mLayoutForEveryObjectSkipped_loop:
push r25 push r25
push yl push yl
@@ -1017,42 +1073,51 @@ mLayoutGetBorders:
; @routine mLayoutPackCell ; @routine mLayoutPackCell
; ;
; @param Y address of widget ; @param Y address of widget
; @param r19:r18 size of target widget (i.e. width or height)
; @param r17 pack mode (see @ref WIDGET_PACK_BEGIN) ; @param r17 pack mode (see @ref WIDGET_PACK_BEGIN)
; @param R11:R10 size of cell area (i.e. width or height)
; @param R13:R12 size of object to pack (i.e. width or height) ; @param R13:R12 size of object to pack (i.e. width or height)
; @param r22 spacing (between widgets) ; @param r22 spacing (between widgets)
; @return R21:R20 pos ; @return R21:R20 pos
; @clobbers r17, r18, r19 ; @return R19:R18 new size of widget
; @clobbers r16, r17, r18, r19
mLayoutPackCell: mLayoutPackCell:
; preset clr r20 ; preset pos
clr r20
clr r21 clr r21
mov r18, r12 ; preset widget size
; subtract borders mov r19, r13
sub r18, r22 ; subtract spacing
sbc r19, r22 ; subtract borders from cell size
add r19, r22 clr r16
sub r10, r22 ; subtract spacing
sbc r11, r16
brcs mLayoutPackCell_ret
andi r17, 3 ; only 2 bits pack mode andi r17, 3 ; only 2 bits pack mode
cpi r17, WIDGET_PACK_FILLED
breq mLayoutPackCell_filled
cpi r17, WIDGET_PACK_END cpi r17, WIDGET_PACK_END
breq mLayoutPackCell_end breq mLayoutPackCell_end
cpi r17, WIDGET_PACK_CENTER cpi r17, WIDGET_PACK_CENTER
breq mLayoutPackCell_center breq mLayoutPackCell_center
rjmp mLayoutPackCell_ret ; begin/filled, align at begin rjmp mLayoutPackCell_ret ; begin/filled, align at begin
mLayoutPackCell_filled:
mov r18, r10 ; use full cell size (minus spacing)
mov r19, r11
rjmp mLayoutPackCell_ret
mLayoutPackCell_end: mLayoutPackCell_end:
sub r18, r12 sub r10, r12
sbc r19, r13 sbc r11, r13
add r20, r18 mov r20, r10
adc r21, r19 mov r21, r11
rjmp mLayoutPackCell_ret rjmp mLayoutPackCell_ret
mLayoutPackCell_center: mLayoutPackCell_center:
sub r18, r12 sub r10, r12
sbc r19, r13 sbc r11, r13
lsr r19 lsr r11
ror r18 ror r10
add r20, r18 mov r20, r10
adc r21, r19 mov r21, r11
rjmp mLayoutPackCell_ret rjmp mLayoutPackCell_ret
mLayoutPackCell_ret: mLayoutPackCell_ret:
ret ret

File diff suppressed because it is too large Load Diff