gui2: removed old layout modules.
This commit is contained in:
@@ -1,507 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2026 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI2_HLAYOUT_ASM
|
||||
#define AQH_AVR_GUI2_HLAYOUT_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ HLAYOUT_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ HLAYOUT_OFFS_MODE = HLAYOUT_OFFS_BEGIN+0
|
||||
.equ HLAYOUT_SIZE = HLAYOUT_OFFS_BEGIN+1
|
||||
|
||||
|
||||
; values for HLAYOUT_OFFS_MODE
|
||||
.equ HLAYOUT_MODE_EXPAND = 0
|
||||
.equ HLAYOUT_MODE_SPREAD = 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (HLAYOUT_MODE_EXPAND, HLAYOUT_MODE_SPREAD)
|
||||
; @clobbers any
|
||||
|
||||
HLayout_new:
|
||||
push r20
|
||||
ldi r24, LOW(HLAYOUT_SIZE)
|
||||
ldi r25, HIGH(HLAYOUT_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r20
|
||||
brcc HLayout_new_ret
|
||||
rcall HLayout_Init ; (r16, r17, X)
|
||||
sec
|
||||
HLayout_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (HLAYOUT_MODE_EXPAND, HLAYOUT_MODE_SPREAD)
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
HLayout_Init:
|
||||
push r20
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r20
|
||||
|
||||
; set widget-specific data
|
||||
std Y+HLAYOUT_OFFS_MODE, r20
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(HLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(HLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_OnLayout
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout_OnLayout:
|
||||
rcall hLayoutHorizontally
|
||||
rcall hLayoutVertically
|
||||
|
||||
; force re-drawing of this widget, clear layout bit
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
cbr r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_OnGetDefaultHeight
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout_OnGetDefaultHeight:
|
||||
rcall Layout_SetDefaultHeights
|
||||
rcall Layout_GetMaxTmp
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine HLayout_OnGetDefaultWidth
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
HLayout_OnGetDefaultWidth:
|
||||
rcall Layout_SetDefaultWidths
|
||||
rcall Layout_SumTmpValues ; r19:r18=default width
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutSetX
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers r16, r17, r18, r19, r20, r21, r22, r23, Z
|
||||
|
||||
hLayoutSetX:
|
||||
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
|
||||
clr r23
|
||||
sbiw zh:zl, WIDGET_STYLE_OFFS_SPACING
|
||||
; get outer border
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm r20, Z
|
||||
clr r21
|
||||
sbiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc hLayoutSetX_loopEnd
|
||||
hLayoutSetX_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r16, WIDGET_FLAGS_VISIBLE_BIT
|
||||
rjmp hLayoutSetX_next
|
||||
; set Y
|
||||
std Y+WIDGET_OFFS_X_LO, r20
|
||||
std Y+WIDGET_OFFS_X_HI, r21
|
||||
; set width
|
||||
ldd r16, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r17, Y+WIDGET_OFFS_TMP_HI
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r16
|
||||
std Y+WIDGET_OFFS_WIDTH_HI, r17
|
||||
; advance r21:r20
|
||||
add r20, r16 ; add widget size
|
||||
adc r21, r17
|
||||
add r20, r22 ; add spacing
|
||||
adc r21, r23
|
||||
|
||||
; force direct children to re-layout and re-draw
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
ori r16, (1<<WIDGET_FLAGS_DIRTY_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
hLayoutSetX_next:
|
||||
rcall OBJ_GetNext
|
||||
brcs hLayoutSetX_loop
|
||||
hLayoutSetX_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutVertically
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
hLayoutVertically:
|
||||
bigcall Layout_SetDefaultHeights ; (any, !Y)
|
||||
; calc usable height of host widget
|
||||
ldd r22, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r23, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
ldd zl, Y+WIDGET_OFFS_STYLE_LO
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm r18, Z+
|
||||
; lpm r19, Z
|
||||
clr r19
|
||||
sub r22, r18
|
||||
sbc r23, r19
|
||||
sub r22, r18
|
||||
sbc r23, r19
|
||||
; r23:r22=width of host widget
|
||||
push yl
|
||||
push yh
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
hLayoutVertically_loop:
|
||||
brcc hLayoutVertically_loopEnd
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
|
||||
ldd r12, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r13, Y+WIDGET_OFFS_TMP_HI
|
||||
|
||||
ldd r17, Y+WIDGET_OFFS_PACK
|
||||
andi r17, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT)
|
||||
cpi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT)
|
||||
brne hLayoutVertically_setHeight
|
||||
mov r12, r22
|
||||
mov r13, r23
|
||||
hLayoutVertically_setHeight:
|
||||
std Y+WIDGET_OFFS_HEIGHT_LO, r12
|
||||
std Y+WIDGET_OFFS_HEIGHT_HI, r13
|
||||
push yl
|
||||
push yh
|
||||
ldd r17, Y+WIDGET_OFFS_PACK
|
||||
mov yl, xl ; use parent
|
||||
mov yh, xh
|
||||
rcall Widget_PackSelfY ; R7:R6=new pos (r17, r18, r19, r20, r21)
|
||||
pop yh
|
||||
pop yl
|
||||
std Y+WIDGET_OFFS_Y_LO, r6
|
||||
std Y+WIDGET_OFFS_Y_HI, r7
|
||||
rcall OBJ_GetNext
|
||||
rjmp hLayoutVertically_loop
|
||||
hLayoutVertically_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutHorizontally
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
hLayoutHorizontally:
|
||||
ldd r16, Y+HLAYOUT_OFFS_MODE
|
||||
cpi r16, HLAYOUT_MODE_SPREAD
|
||||
breq hLayoutHorizontally_spread
|
||||
rjmp hLayoutExpand
|
||||
hLayoutHorizontally_spread:
|
||||
rjmp hLayoutSpread
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutExpand
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
hLayoutExpand:
|
||||
rcall Layout_SetDefaultWidths
|
||||
rcall Layout_SumTmpValues ; r19:r18=width+borders
|
||||
|
||||
ldd r22, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r23, Y+WIDGET_OFFS_WIDTH_HI
|
||||
sub r22, r18
|
||||
sbc r23, r19 ; r23:r22=(height-usedSpace)=unusedSpace
|
||||
breq hLayoutExpand_setX
|
||||
brcs hLayoutExpand_setX
|
||||
|
||||
; r23:r22=remaining space to distribute
|
||||
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 LayoutCountChildrenWithPackMode ; r16=number of expandable child widgets
|
||||
pop r23
|
||||
pop r22
|
||||
tst r16
|
||||
breq hLayoutExpand_setX
|
||||
|
||||
; calc space to add to each expandable child widget and add it
|
||||
mov r20, r22
|
||||
mov r21, r23
|
||||
mov r22, r16
|
||||
clr r23
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per expandable child widget
|
||||
mov r20, r16
|
||||
mov r21, r17
|
||||
|
||||
ldi r22, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) ; value
|
||||
bigcall LayoutIncTmpOnMatchingPack
|
||||
|
||||
hLayoutExpand_setX:
|
||||
rcall hLayoutSetX
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutExpand
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
hLayoutSpread:
|
||||
rcall hLayoutPrepareSpread ; (any, !Y)
|
||||
rcall hLayoutFinalizeSpread ; (r18, r19, X)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutPrepareSpread
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return X startpos
|
||||
; @return r21:r20 extra space (in pixels)
|
||||
; @return r25:r24 spacing (including extra space)
|
||||
; @clobbers any, !Y
|
||||
|
||||
hLayoutPrepareSpread:
|
||||
rcall Layout_SetDefaultWidths ; (any, !Y)
|
||||
rcall hLayoutCalcSpreadValue ; r21:r20=spread value (r16, r17, r18, r19, r20, r21, r22, r23, Z)
|
||||
|
||||
; get and adjust spacing, setup start pos
|
||||
ldd zl, Y+WIDGET_OFFS_STYLE_LO
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm xl, Z+ ; border
|
||||
clr xh
|
||||
lpm r24, Z ; spacing
|
||||
clr r25
|
||||
|
||||
add r24, r20 ; add extra space to spacing
|
||||
adc r25, r21
|
||||
|
||||
add xl, r20 ; add extra space to border
|
||||
adc xh, r21
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutCalcSpreadValue
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r21:r20 spread value to add to spacings and expandable children
|
||||
; @clobbers r16, r17, r18, r19, r20, r21, r22, r23, Z
|
||||
|
||||
hLayoutCalcSpreadValue:
|
||||
; calc used width
|
||||
rcall Layout_SumTmpValues ; r21:r20=width+borders
|
||||
ldd r18, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r19, Y+WIDGET_OFFS_WIDTH_HI
|
||||
sub r18, r20 ; width-usedWidth
|
||||
sbc r19, r21
|
||||
brcc hLayoutCalcSpreadValue_calcAdd
|
||||
clr r20
|
||||
clr r21
|
||||
rjmp hLayoutCalcSpreadValue_ret
|
||||
|
||||
; r19:r18=remaining space
|
||||
hLayoutCalcSpreadValue_calcAdd:
|
||||
mov r20, r18
|
||||
mov r21, r19 ; remaining space
|
||||
|
||||
rcall LayoutCountVisibleChildren ; r16=number of visible child widgets (r17, r18, r19)
|
||||
inc r16 ; r16=number of spacings (begin->between->end)
|
||||
mov r22, r16
|
||||
push r22
|
||||
ldi r22, (1<<WIDGET_PACK_HSELF1_BIT) | \
|
||||
(1<<WIDGET_PACK_HSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) ; value
|
||||
rcall LayoutCountChildrenWithPackMode ; r16=number of expandable children (r17, r18, r19)
|
||||
pop r22
|
||||
add r22, r16 ; r22=number of items to spread
|
||||
tst r22
|
||||
brne hLayoutCalcSpreadValue_div
|
||||
clr r20
|
||||
clr r21
|
||||
rjmp hLayoutCalcSpreadValue_ret
|
||||
|
||||
hLayoutCalcSpreadValue_div:
|
||||
clr r23
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per element
|
||||
mov r20, r16
|
||||
mov r21, r17 ; r21:20=additional space per element
|
||||
hLayoutCalcSpreadValue_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine hLayoutFinalizeSpread
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X startpos
|
||||
; @param r21:r20 extra space (in pixels)
|
||||
; @param r25:r24 spacing (including extra space)
|
||||
; @clobbers r18, r19, X
|
||||
|
||||
hLayoutFinalizeSpread:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc hLayoutFinalizeSpread_done
|
||||
hLayoutFinalizeSpread_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r17, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
|
||||
rjmp hLayoutFinalizeSpread_next
|
||||
|
||||
; determine final width of child widget
|
||||
ldd r18, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r19, Y+WIDGET_OFFS_TMP_HI
|
||||
ldd r16, Y+WIDGET_OFFS_PACK
|
||||
andi r16, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT)
|
||||
cpi r16, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT)
|
||||
brne hLayoutFinalizeSpread_setWidth
|
||||
add r18, r20 ; add extra space
|
||||
adc r19, r21
|
||||
hLayoutFinalizeSpread_setWidth:
|
||||
; store width
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r18
|
||||
std Y+WIDGET_OFFS_WIDTH_HI, r19
|
||||
; store pos
|
||||
std Y+WIDGET_OFFS_X_LO, xl
|
||||
std Y+WIDGET_OFFS_X_HI, xh
|
||||
; advance pos
|
||||
add xl, r18 ; add width to current pos
|
||||
adc xh, r19
|
||||
add xl, r24 ; add spacing to current pos
|
||||
adc xh, r25
|
||||
hLayoutFinalizeSpread_next:
|
||||
rcall OBJ_GetNext ; r19:r18=object (none)
|
||||
brcs hLayoutFinalizeSpread_loop
|
||||
hLayoutFinalizeSpread_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
HLayout_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_LAYOUT, LOW(HLayout_OnLayout), HIGH(HLayout_OnLayout)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(HLayout_OnGetDefaultWidth), HIGH(HLayout_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(HLayout_OnGetDefaultHeight), HIGH(HLayout_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2026 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI2_LAYOUT_ASM
|
||||
#define AQH_AVR_GUI2_LAYOUT_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Layout_SetDefaultWidths
|
||||
;
|
||||
; Set default width in WIDGET_OFFS_TMP_LO/HI of child widgets
|
||||
; Ignores invisible widgets.
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
Layout_SetDefaultWidths:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc Layout_SetDefaultWidths_ret
|
||||
Layout_SetDefaultWidths_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r18, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
|
||||
rjmp Layout_SetDefaultWidths_next
|
||||
bigcall Widget_GetDefaultWidth
|
||||
std Y+WIDGET_OFFS_TMP_LO, r18
|
||||
std Y+WIDGET_OFFS_TMP_HI, r19
|
||||
Layout_SetDefaultWidths_next:
|
||||
rcall OBJ_GetNext
|
||||
brcs Layout_SetDefaultWidths_loop
|
||||
Layout_SetDefaultWidths_ret:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Layout_SetDefaultHeights
|
||||
;
|
||||
; Set default height in WIDGET_OFFS_TMP_LO/HI of child widgets
|
||||
; Ignores invisible widgets.
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
Layout_SetDefaultHeights:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc Layout_SetDefaultHeights_ret
|
||||
Layout_SetDefaultHeights_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r18, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
|
||||
rjmp Layout_SetDefaultHeights_next
|
||||
bigcall Widget_GetDefaultHeight
|
||||
std Y+WIDGET_OFFS_TMP_LO, r18
|
||||
std Y+WIDGET_OFFS_TMP_HI, r19
|
||||
Layout_SetDefaultHeights_next:
|
||||
rcall OBJ_GetNext
|
||||
brcs Layout_SetDefaultHeights_loop
|
||||
Layout_SetDefaultHeights_ret:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Layout_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
|
||||
|
||||
Layout_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 Layout_SumTmpValues_finish
|
||||
Layout_SumTmpValues_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r18, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
|
||||
rjmp Layout_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
|
||||
Layout_SumTmpValues_next:
|
||||
rcall OBJ_GetNext
|
||||
brcs Layout_SumTmpValues_loop
|
||||
Layout_SumTmpValues_loopEnd:
|
||||
mov r16, r20
|
||||
or r16, r21
|
||||
breq Layout_SumTmpValues_finish
|
||||
sub r20, r22 ; sub last spacing
|
||||
sbc r21, r22
|
||||
add r21, r22
|
||||
Layout_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
|
||||
Layout_SumTmpValues_done:
|
||||
mov r18, r20
|
||||
mov r19, r21
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Layout_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
|
||||
|
||||
Layout_GetMaxTmp:
|
||||
clr r20
|
||||
clr r21
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
Layout_GetMaxTmp_loop:
|
||||
brcc Layout_GetMaxTmp_ret
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r18, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r18, WIDGET_FLAGS_VISIBLE_BIT
|
||||
rjmp Layout_GetMaxTmp_next
|
||||
ldd r18, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r19, Y+WIDGET_OFFS_TMP_HI
|
||||
; max
|
||||
cp r20, r18
|
||||
cpc r21, r19
|
||||
brcc Layout_GetMaxTmp_next
|
||||
mov r20, r18
|
||||
mov r21, r19
|
||||
Layout_GetMaxTmp_next:
|
||||
rcall OBJ_GetNext
|
||||
rjmp Layout_GetMaxTmp_loop
|
||||
Layout_GetMaxTmp_ret:
|
||||
mov r18, r20
|
||||
mov r19, r21
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine LayoutCountChildrenWithPackMode
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param r22 mask for WIDGET_OFFS_PACK
|
||||
; @param r23 value for WIDGET_OFFS_PACK
|
||||
; @return r16 number of matching children
|
||||
; @clobbers r17, r18, r19
|
||||
|
||||
LayoutCountChildrenWithPackMode:
|
||||
clr r16
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
LayoutCountChildrenWithPackMode_loop:
|
||||
brcc LayoutCountChildrenWithPackMode_done
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r17, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
|
||||
rjmp LayoutCountChildrenWithPackMode_next
|
||||
ldd r17, Y+WIDGET_OFFS_PACK
|
||||
eor r17, r23
|
||||
and r17, r22
|
||||
brne LayoutCountChildrenWithPackMode_next
|
||||
inc r16
|
||||
LayoutCountChildrenWithPackMode_next:
|
||||
rcall OBJ_GetNext
|
||||
rjmp LayoutCountChildrenWithPackMode_loop
|
||||
LayoutCountChildrenWithPackMode_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine LayoutCountVisibleChildren
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r16 number of matching children
|
||||
; @clobbers r17, r18, r19
|
||||
|
||||
LayoutCountVisibleChildren:
|
||||
clr r16
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc LayoutCountVisibleChildren_done
|
||||
LayoutCountVisibleChildren_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
sbrc r17, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
|
||||
inc r16
|
||||
LayoutCountVisibleChildren_next:
|
||||
rcall OBJ_GetNext
|
||||
brcs LayoutCountVisibleChildren_loop
|
||||
LayoutCountVisibleChildren_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine LayoutIncTmpOnMatchingPack
|
||||
;
|
||||
; Ignores invisible widgets.
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param R21:R20 value to add to tmp value of expandable widgets
|
||||
; @param r22 mask for WIDGET_OFFS_PACK
|
||||
; @param r23 value for WIDGET_OFFS_PACK
|
||||
; @clobbers r16, r18, r19
|
||||
|
||||
LayoutIncTmpOnMatchingPack:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc LayoutIncTmpOnMatchingPack_done
|
||||
LayoutIncTmpOnMatchingPack_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r16, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
|
||||
rjmp LayoutIncTmpOnMatchingPack_next
|
||||
ldd r16, Y+WIDGET_OFFS_PACK
|
||||
eor r16, r23
|
||||
and r16, r22
|
||||
brne LayoutIncTmpOnMatchingPack_next
|
||||
ldd r18, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r19, Y+WIDGET_OFFS_TMP_HI
|
||||
add r18, r20
|
||||
adc r19, r21
|
||||
std Y+WIDGET_OFFS_TMP_LO, r18
|
||||
std Y+WIDGET_OFFS_TMP_HI, r19
|
||||
LayoutIncTmpOnMatchingPack_next:
|
||||
rcall OBJ_GetNext
|
||||
brcs LayoutIncTmpOnMatchingPack_loop
|
||||
LayoutIncTmpOnMatchingPack_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,641 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2026 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI2_MLAYOUT_COLUMN_ASM
|
||||
#define AQH_AVR_GUI2_MLAYOUT_COLUMN_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MLayout_OnGetDefaultWidth_ColumnMode @global
|
||||
;
|
||||
; @param Y widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
MLayout_OnGetDefaultWidth_ColumnMode:
|
||||
; DEBUG
|
||||
ldi r18, 10
|
||||
clr r19
|
||||
sec
|
||||
ret
|
||||
|
||||
rcall mLayoutSetDefaultWidthToTmp ; (any, !Y)
|
||||
rcall mLayoutGetBorders ; r22=spacing, r23=border
|
||||
push yl
|
||||
push yh
|
||||
rcall MLayout_GetFirstChildToY
|
||||
rcall mLayoutSumContiguous ; r21:r20 needed minimum row width (r18, r19, r25)
|
||||
pop yh
|
||||
pop yl
|
||||
mov r18, r20
|
||||
mov r19, r21
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MLayout_OnGetDefaultHeight_ColumnMode @global
|
||||
;
|
||||
; @param Y widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
MLayout_OnGetDefaultHeight_ColumnMode:
|
||||
; DEBUG
|
||||
ldi r18, 10
|
||||
clr r19
|
||||
sec
|
||||
ret
|
||||
|
||||
bigcall OBJ_GetFirstChild
|
||||
push yl
|
||||
push yh
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
rcall mLayoutSetDefaultHeightToTmp ; (any, !Y)
|
||||
rcall mLayoutGetBorders ; r22=spacing, r23=border
|
||||
rcall mLayoutSumSkipped ; r21:r20 needed minimum row width (r18, r19, r25)
|
||||
mov r18, r20
|
||||
mov r19, r21
|
||||
pop yh
|
||||
pop yl
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine MLayout_LayoutColumnMode @global
|
||||
;
|
||||
; @param Y widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
MLayout_Layout_ColumnMode:
|
||||
rcall mLayoutColumnLayoutHorizontally
|
||||
rcall mLayoutColumnLayoutVertically
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnLayoutHorizontally
|
||||
;
|
||||
; @param Y widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
mLayoutColumnLayoutHorizontally:
|
||||
rcall mLayoutGetBorders ; r22=spacing, r23=border
|
||||
ldd r25, Y+MLAYOUT_OFFS_COLSORROWS
|
||||
|
||||
push yl
|
||||
push yh
|
||||
rcall MLayout_GetFirstChildToY ; (none)
|
||||
push r22
|
||||
push r23
|
||||
push r25
|
||||
clr r25
|
||||
rcall mLayoutSetDefaultWidthToTmp ; (any, !Y)
|
||||
clr r25
|
||||
rcall mLayoutCopyTmpToWidth ; (r18, r19, Z)
|
||||
pop r25
|
||||
pop r23
|
||||
pop r22
|
||||
|
||||
|
||||
; prepare first row
|
||||
rcall mLayoutSetupFirstContiguous ; set max column widths to first row (r18, r19, Z)
|
||||
rcall mLayoutColumnExpandColumns ; (r16-r23)
|
||||
rcall mLayoutColumnGridX
|
||||
rcall mLayoutColumnCopyXTmpFromFirstRow
|
||||
rcall mLayoutColumnPackX ; (r10-r13, r16-r21, X)
|
||||
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
mLayoutColumnLayoutVertically:
|
||||
rcall mLayoutGetBorders ; r22=spacing, r23=border
|
||||
ldd r25, Y+MLAYOUT_OFFS_COLSORROWS
|
||||
|
||||
push yl
|
||||
push yh
|
||||
rcall MLayout_GetFirstChildToY ; (none)
|
||||
push r22
|
||||
push r23
|
||||
push r25
|
||||
clr r25
|
||||
rcall mLayoutSetDefaultHeightToTmp ; (any, !Y)
|
||||
clr r25
|
||||
rcall mLayoutCopyTmpToHeight ; (r18, r19, Z)
|
||||
pop r25
|
||||
pop r23
|
||||
pop r22
|
||||
|
||||
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)
|
||||
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCopyXTmpFromFirstRow
|
||||
;
|
||||
; @param Y widget
|
||||
; @param R25 widgets per row/column
|
||||
; @clobbers r18-r21, Z
|
||||
|
||||
mLayoutColumnCopyXTmpFromFirstRow:
|
||||
M_MLAYOUT_FOREVERY_CONT mLayoutCallbackColumnCopyRow
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutCallbackColumnCopyRow
|
||||
;
|
||||
; @param Y widget
|
||||
; @clobbers r18, r19, r20, r21
|
||||
|
||||
mLayoutCallbackColumnCopyRow:
|
||||
push zl
|
||||
push zh
|
||||
rcall mLayoutColumnCopyXTmpAcrossColumn ; (r18, r19, r20, r21, X, Z)
|
||||
pop zh
|
||||
pop zl
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCopyXTmpAcrossColumn
|
||||
;
|
||||
; @param Y widget
|
||||
; @param R25 widgets per row/column
|
||||
; @clobbers r18, r19, r20, r21, X, Z
|
||||
|
||||
mLayoutColumnCopyXTmpAcrossColumn:
|
||||
push yl
|
||||
push yh
|
||||
ldd r20, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r21, Y+WIDGET_OFFS_TMP_HI
|
||||
ldd xl, Y+WIDGET_OFFS_X_LO
|
||||
ldd xh, Y+WIDGET_OFFS_X_HI
|
||||
ldi zl, LOW(mLayoutCallbackSetXTmp)
|
||||
ldi zh, HIGH(mLayoutCallbackSetXTmp)
|
||||
rcall mLayoutForEveryObjectSkipped ; (r18, r19, Y)
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCopyTmpFromFirstColumn
|
||||
;
|
||||
; @param Y widget
|
||||
; @param R25 widgets per row/column
|
||||
; @clobbers r18-r21, Z
|
||||
|
||||
mLayoutColumnCopyTmpFromFirstColumn:
|
||||
push yl
|
||||
push yh
|
||||
ldi zl, LOW(mLayoutCallbackColumnCopyColumn)
|
||||
ldi zh, HIGH(mLayoutCallbackColumnCopyColumn)
|
||||
rcall mLayoutForEveryObjectSkipped ; (r18-r21, Y)
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutCallbackColumnCopyColumn
|
||||
;
|
||||
; @param Y widget
|
||||
; @param R25 widgets per row/column
|
||||
; @clobbers r18, r19, r20, r21
|
||||
|
||||
mLayoutCallbackColumnCopyColumn:
|
||||
push zl
|
||||
push zh
|
||||
rcall mLayoutColumnCopyYTmpAcrossRow ; (r18, r19, r20, r21, Z)
|
||||
pop zh
|
||||
pop zl
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCopyTmpAcrossRow
|
||||
;
|
||||
; @param Y widget
|
||||
; @param R25 widgets per row/column
|
||||
; @clobbers r18, r19, r20, r21, Z
|
||||
|
||||
mLayoutColumnCopyYTmpAcrossRow:
|
||||
push yl
|
||||
push yh
|
||||
ldd r20, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r21, Y+WIDGET_OFFS_TMP_HI
|
||||
ldd xl, Y+WIDGET_OFFS_Y_LO
|
||||
ldd xh, Y+WIDGET_OFFS_Y_HI
|
||||
ldi zl, LOW(mLayoutCallbackSetYTmp)
|
||||
ldi zh, HIGH(mLayoutCallbackSetYTmp)
|
||||
rcall mLayoutForEveryObjectContiguous ; (r18, r19, Y)
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnGridX
|
||||
;
|
||||
; 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, Z
|
||||
|
||||
mLayoutColumnGridX:
|
||||
mov xl, r23 ; start at border
|
||||
clr xh
|
||||
push yl
|
||||
push yh
|
||||
ldi zl, LOW(mLayoutCallbackGridX)
|
||||
ldi zh, HIGH(mLayoutCallbackGridX)
|
||||
rcall mLayoutForEveryObjectContiguous ; (r12, r13, r16-r21, Y)
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @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:
|
||||
push r25
|
||||
clr r25
|
||||
M_MLAYOUT_FOREVERY_CONT mLayoutCallbackPackX ; (r10-r13, r16-r21, X)
|
||||
pop r25
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnGridY
|
||||
;
|
||||
; 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, X, Z
|
||||
|
||||
mLayoutColumnGridY:
|
||||
mov xl, r23 ; start at border
|
||||
clr xh
|
||||
push yl
|
||||
push yh
|
||||
ldi zl, LOW(mLayoutCallbackGridY)
|
||||
ldi zh, HIGH(mLayoutCallbackGridY)
|
||||
rcall mLayoutForEveryObjectSkipped ; (r12, r13, r16-r21, Y)
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @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
|
||||
;
|
||||
; Calculate additional space per expandable widget in a row.
|
||||
;
|
||||
; @param Y first widget of current row
|
||||
; @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-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
|
||||
|
||||
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
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCalcAddSpacePerColumn
|
||||
;
|
||||
; 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-r21
|
||||
|
||||
mLayoutColumnCalcAddSpacePerColumn:
|
||||
push r22
|
||||
push r23
|
||||
rcall mLayoutColumnCalcAdditionalSpaceContiguous ; r21:r20=additional space (R18, R19)
|
||||
brcc mLayoutColumnCalcAddSpacePerColumn_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 mLayoutColumnCalcAddSpacePerColumn_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 mLayoutColumnCalcAddSpacePerColumn_ret
|
||||
mLayoutColumnCalcAddSpacePerColumn_none:
|
||||
clr r20
|
||||
clr r21
|
||||
clc
|
||||
mLayoutColumnCalcAddSpacePerColumn_ret:
|
||||
pop r23
|
||||
pop r22
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCalcAdditionalSpaceContiguous
|
||||
;
|
||||
; 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
|
||||
|
||||
mLayoutColumnCalcAdditionalSpaceContiguous:
|
||||
push r18
|
||||
push r19
|
||||
rcall mLayoutSumContiguous ; r21:r20 needed minimum row width (r18, r19)
|
||||
pop r19
|
||||
pop r18
|
||||
sub r18, r20
|
||||
sbc r19, r21
|
||||
brcs mLayoutColumnCalcAdditionalSpaceContiguous_none
|
||||
breq mLayoutColumnCalcAdditionalSpaceContiguous_none
|
||||
mov r20, r18
|
||||
mov r21, r19
|
||||
sec
|
||||
rjmp mLayoutColumnCalcAdditionalSpaceContiguous_ret
|
||||
mLayoutColumnCalcAdditionalSpaceContiguous_none:
|
||||
clr r20
|
||||
clr r21
|
||||
clc
|
||||
mLayoutColumnCalcAdditionalSpaceContiguous_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnExpandRows
|
||||
;
|
||||
; Calculate additional space per expandable widget in a column.
|
||||
;
|
||||
; @param Y first widget of current row
|
||||
; @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-r21
|
||||
|
||||
mLayoutColumnExpandRows:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetParent
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r18, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r19, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
rcall mLayoutColumnCalcAddSpacePerRow ; r21:r20=additional space (r16-r23)
|
||||
brcc mLayoutColumnExpandRows_ret
|
||||
|
||||
push r22
|
||||
push r23
|
||||
ldi r22, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; value
|
||||
rcall mLayoutExpandMatchingPackSkipped ; (r18, r19)
|
||||
pop r23
|
||||
pop r22
|
||||
|
||||
mLayoutColumnExpandRows_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCalcAddSpacePerRow
|
||||
;
|
||||
; Calculate additional space per expandable widget in a column.
|
||||
;
|
||||
; @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-r21
|
||||
|
||||
mLayoutColumnCalcAddSpacePerRow:
|
||||
push r22
|
||||
push r23
|
||||
rcall mLayoutColumnCalcAdditionalSpaceSkipped ; r21:r20=additional space (R18, R19)
|
||||
brcc mLayoutColumnCalcAddSpacePerRow_ret
|
||||
push r20
|
||||
push r21
|
||||
ldi r22, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; value
|
||||
rcall mLayoutCountMatchingPackContiguous ; r20=num of matching items (r18, r19)
|
||||
mov r22, r20
|
||||
clr r23
|
||||
pop r21
|
||||
pop r20
|
||||
tst r22
|
||||
breq mLayoutColumnCalcAddSpacePerRow_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 mLayoutColumnCalcAddSpacePerRow_ret
|
||||
mLayoutColumnCalcAddSpacePerRow_none:
|
||||
clr r20
|
||||
clr r21
|
||||
clc
|
||||
mLayoutColumnCalcAddSpacePerRow_ret:
|
||||
pop r23
|
||||
pop r22
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mLayoutColumnCalcAdditionalSpaceSkipped
|
||||
;
|
||||
; 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
|
||||
|
||||
mLayoutColumnCalcAdditionalSpaceSkipped:
|
||||
push r18
|
||||
push r19
|
||||
rcall mLayoutSumSkipped ; r21:r20 needed minimum row width (r18, r19)
|
||||
pop r19
|
||||
pop r18
|
||||
sub r18, r20
|
||||
sbc r19, r21
|
||||
brcs mLayoutColumnCalcAdditionalSpaceSkipped_none
|
||||
breq mLayoutColumnCalcAdditionalSpaceSkipped_none
|
||||
mov r20, r18
|
||||
mov r21, r19
|
||||
sec
|
||||
rjmp mLayoutColumnCalcAdditionalSpaceSkipped_ret
|
||||
mLayoutColumnCalcAdditionalSpaceSkipped_none:
|
||||
clr r20
|
||||
clr r21
|
||||
clc
|
||||
mLayoutColumnCalcAdditionalSpaceSkipped_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,481 +0,0 @@
|
||||
; ***************************************************************************
|
||||
; copyright : (C) 2026 by Martin Preuss
|
||||
; email : martin@libchipcard.de
|
||||
;
|
||||
; ***************************************************************************
|
||||
; * This file is part of the project "AqHome". *
|
||||
; * Please see toplevel file COPYING of that project for license details. *
|
||||
; ***************************************************************************
|
||||
|
||||
#ifndef AQH_AVR_GUI2_VLAYOUT_ASM
|
||||
#define AQH_AVR_GUI2_VLAYOUT_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ VLAYOUT_OFFS_BEGIN = WIDGET_SIZE
|
||||
.equ VLAYOUT_OFFS_MODE = VLAYOUT_OFFS_BEGIN+0
|
||||
.equ VLAYOUT_SIZE = VLAYOUT_OFFS_BEGIN+1
|
||||
|
||||
|
||||
; values for VLAYOUT_OFFS_MODE
|
||||
.equ VLAYOUT_MODE_EXPAND = 0
|
||||
.equ VLAYOUT_MODE_SPREAD = 1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_new @global
|
||||
;
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
; @param X parent widget
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (VLAYOUT_MODE_EXPAND, VLAYOUT_MODE_SPREAD)
|
||||
; @clobbers any
|
||||
|
||||
VLayout_new:
|
||||
push r20
|
||||
ldi r24, LOW(VLAYOUT_SIZE)
|
||||
ldi r25, HIGH(VLAYOUT_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
pop r20
|
||||
brcc VLayout_new_ret
|
||||
rcall VLayout_Init ; (r16, r17, X)
|
||||
sec
|
||||
VLayout_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_Init @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param X parent widget (if any)
|
||||
; @param r16 value for OBJECT_OFFS_OPTS
|
||||
; @param r17 value for WIDGET_OFFS_PACK
|
||||
; @param r20 layout mode (VLAYOUT_MODE_EXPAND, VLAYOUT_MODE_SPREAD)
|
||||
; @clobbers r16, r17, X
|
||||
|
||||
VLayout_Init:
|
||||
push r20
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r20
|
||||
|
||||
; set widget-specific data
|
||||
std Y+VLAYOUT_OFFS_MODE, r20
|
||||
|
||||
; set default signal map
|
||||
ldi r16, LOW(VLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
|
||||
ldi r16, HIGH(VLayout_DefaultSignalmap*2)
|
||||
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_OnLayout
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
VLayout_OnLayout:
|
||||
rcall vLayoutVertically
|
||||
rcall vLayoutHorizontally
|
||||
; force re-drawing of this widget, clear layout bit
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbr r16, (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
cbr r16, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_OnGetDefaultWidth
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
VLayout_OnGetDefaultWidth:
|
||||
rcall Layout_SetDefaultWidths
|
||||
rcall Layout_GetMaxTmp
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine VLayout_OnGetDefaultHeight
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 value
|
||||
; @clobbers any, !Y
|
||||
|
||||
VLayout_OnGetDefaultHeight:
|
||||
rcall Layout_SetDefaultHeights
|
||||
rcall Layout_SumTmpValues ; r19:r18=default width
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutSetY
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers r16, r17, r18, r19, r20, r21, r22, r23, Z
|
||||
|
||||
vLayoutSetY:
|
||||
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
|
||||
clr r23
|
||||
sbiw zh:zl, WIDGET_STYLE_OFFS_SPACING
|
||||
; get outer border
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm r20, Z
|
||||
clr r21
|
||||
sbiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc vLayoutSetY_loopEnd
|
||||
vLayoutSetY_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r16, WIDGET_FLAGS_VISIBLE_BIT
|
||||
rjmp vLayoutSetY_next
|
||||
; set Y
|
||||
std Y+WIDGET_OFFS_Y_LO, r20
|
||||
std Y+WIDGET_OFFS_Y_HI, r21
|
||||
; set width
|
||||
ldd r16, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r17, Y+WIDGET_OFFS_TMP_HI
|
||||
std Y+WIDGET_OFFS_HEIGHT_LO, r16
|
||||
std Y+WIDGET_OFFS_HEIGHT_HI, r17
|
||||
; advance r21:r20
|
||||
add r20, r16 ; add widget size
|
||||
adc r21, r17
|
||||
add r20, r22 ; add spacing
|
||||
adc r21, r23
|
||||
|
||||
; force direct children to re-layout and re-draw
|
||||
ldd r16, Y+OBJECT_OFFS_FLAGS
|
||||
ori r16, (1<<WIDGET_FLAGS_DIRTY_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r16
|
||||
vLayoutSetY_next:
|
||||
rcall OBJ_GetNext
|
||||
brcs vLayoutSetY_loop
|
||||
vLayoutSetY_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutHorizontally
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
vLayoutHorizontally:
|
||||
bigcall Layout_SetDefaultWidths ; (any, !Y)
|
||||
; calc usable width of host widget
|
||||
ldd r22, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r23, Y+WIDGET_OFFS_WIDTH_HI
|
||||
ldd zl, Y+WIDGET_OFFS_STYLE_LO
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm r18, Z+
|
||||
; lpm r19, Z
|
||||
clr r19
|
||||
sub r22, r18
|
||||
sbc r23, r19
|
||||
sub r22, r18
|
||||
sbc r23, r19
|
||||
; r23:r22=width of host widget
|
||||
push yl
|
||||
push yh
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
vLayoutHorizontally_loop:
|
||||
brcc vLayoutHorizontally_loopEnd
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
|
||||
ldd r12, Y+WIDGET_OFFS_TMP_LO ; default width
|
||||
ldd r13, Y+WIDGET_OFFS_TMP_HI
|
||||
|
||||
ldd r17, Y+WIDGET_OFFS_PACK
|
||||
andi r17, (1<<WIDGET_PACK_HSELF1_BIT) | (1<<WIDGET_PACK_HSELF0_BIT)
|
||||
cpi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT)
|
||||
brne vLayoutHorizontally_setWidth
|
||||
mov r12, r22 ; TODO: need to check size, subtract borders!!!
|
||||
mov r13, r23
|
||||
vLayoutHorizontally_setWidth:
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r12
|
||||
std Y+WIDGET_OFFS_WIDTH_HI, r13
|
||||
push yl
|
||||
push yh
|
||||
ldd r17, Y+WIDGET_OFFS_PACK
|
||||
mov yl, xl ; use parent
|
||||
mov yh, xh
|
||||
bigcall Widget_PackSelfX ; R5:R4=new pos (r17, r18, r19, r20, r21) !! TODO: ERROR when FILLED !!
|
||||
pop yh
|
||||
pop yl
|
||||
std Y+WIDGET_OFFS_X_LO, r4
|
||||
std Y+WIDGET_OFFS_X_HI, r5
|
||||
rcall OBJ_GetNext
|
||||
rjmp vLayoutHorizontally_loop
|
||||
vLayoutHorizontally_loopEnd:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutVertically
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
vLayoutVertically:
|
||||
ldd r16, Y+VLAYOUT_OFFS_MODE
|
||||
cpi r16, VLAYOUT_MODE_SPREAD
|
||||
breq vLayoutVertically_spread
|
||||
rjmp vLayoutExpand
|
||||
vLayoutVertically_spread:
|
||||
rjmp vLayoutSpread
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutExpand
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
vLayoutExpand:
|
||||
rcall Layout_SetDefaultHeights
|
||||
rcall Layout_SumTmpValues ; r19:r18=width+borders
|
||||
|
||||
ldd r22, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r23, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
sub r22, r18
|
||||
sbc r23, r19 ; r23:r22=(height-usedSpace)=unusedSpace
|
||||
breq vLayoutExpand_setY
|
||||
brcs vLayoutExpand_setY
|
||||
|
||||
; r23:r22=remaining space to distribute
|
||||
push r22
|
||||
push r23
|
||||
ldi r22, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; value
|
||||
rcall LayoutCountChildrenWithPackMode ; r16=number of expandable child widgets
|
||||
pop r23
|
||||
pop r22
|
||||
tst r16
|
||||
breq vLayoutExpand_setY
|
||||
|
||||
; calc space to add to each expandable child widget and add it
|
||||
mov r20, r22
|
||||
mov r21, r23
|
||||
mov r22, r16
|
||||
clr r23
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per expandable child widget
|
||||
mov r20, r16
|
||||
mov r21, r17
|
||||
|
||||
ldi r22, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; value
|
||||
bigcall LayoutIncTmpOnMatchingPack
|
||||
|
||||
vLayoutExpand_setY:
|
||||
rcall vLayoutSetY
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutExpand
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @clobbers any, !Y
|
||||
|
||||
vLayoutSpread:
|
||||
rcall vLayoutPrepareSpread ; (any, !Y)
|
||||
rcall vLayoutFinalizeSpread ; (r18, r19, X)
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutPrepareSpread
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return X startpos
|
||||
; @return r21:r20 extra space (in pixels)
|
||||
; @return r25:r24 spacing (including extra space)
|
||||
; @clobbers any, !Y
|
||||
|
||||
vLayoutPrepareSpread:
|
||||
rcall Layout_SetDefaultHeights ; (any, !Y)
|
||||
rcall Layout_SumTmpValues ; r21:r20=width+borders
|
||||
|
||||
ldd r18, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r19, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
sub r18, r20
|
||||
sbc r19, r21
|
||||
brcc vLayoutPrepareSpread_calcAdd
|
||||
clr r20
|
||||
clr r21
|
||||
rjmp vLayoutPrepareSpread_finish
|
||||
vLayoutPrepareSpread_calcAdd:
|
||||
mov r20, r18
|
||||
mov r21, r19 ; remaining space
|
||||
|
||||
rcall LayoutCountVisibleChildren ; r16=number of visible child widgets (r17, r18, r19)
|
||||
inc r16
|
||||
mov r22, r16
|
||||
push r22
|
||||
ldi r22, (1<<WIDGET_PACK_VSELF1_BIT) | \
|
||||
(1<<WIDGET_PACK_VSELF0_BIT) ; mask
|
||||
ldi r23, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; value
|
||||
rcall LayoutCountChildrenWithPackMode ; r16=number of expandable children (r17, r18, r19)
|
||||
pop r22
|
||||
add r22, r16
|
||||
clr r23
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per element
|
||||
mov r20, r16
|
||||
mov r21, r17 ; r21:20=additional space per element
|
||||
|
||||
vLayoutPrepareSpread_finish:
|
||||
; get and adjust spacing, setup start pos
|
||||
ldd zl, Y+WIDGET_OFFS_STYLE_LO
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm xl, Z+ ; border
|
||||
clr xh
|
||||
lpm r24, Z ; spacing
|
||||
clr r25
|
||||
|
||||
add r24, r20 ; add extra space to spacing
|
||||
adc r25, r21
|
||||
|
||||
add xl, r20 ; add extra space to border
|
||||
adc xh, r21
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine vLayoutFinalizeSpread
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @param X startpos
|
||||
; @param r21:r20 extra space (in pixels)
|
||||
; @param r25:r24 spacing (including extra space)
|
||||
; @clobbers r18, r19, X
|
||||
|
||||
vLayoutFinalizeSpread:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc vLayoutFinalizeSpread_done
|
||||
vLayoutFinalizeSpread_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
sbrs r17, WIDGET_FLAGS_VISIBLE_BIT ; skip invisible widgets
|
||||
rjmp vLayoutFinalizeSpread_next
|
||||
; store pos
|
||||
std Y+WIDGET_OFFS_Y_LO, xl
|
||||
std Y+WIDGET_OFFS_Y_HI, xh
|
||||
; determine final height of child widget
|
||||
ldd r18, Y+WIDGET_OFFS_TMP_LO
|
||||
ldd r19, Y+WIDGET_OFFS_TMP_HI
|
||||
ldd r16, Y+WIDGET_OFFS_PACK
|
||||
andi r16, (1<<WIDGET_PACK_VSELF1_BIT) | (1<<WIDGET_PACK_VSELF0_BIT)
|
||||
cpi r16, (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT)
|
||||
brne vLayoutFinalizeSpread_setHeight
|
||||
add r18, r20 ; add extra space
|
||||
adc r19, r21
|
||||
vLayoutFinalizeSpread_setHeight:
|
||||
std Y+WIDGET_OFFS_HEIGHT_LO, r18
|
||||
std Y+WIDGET_OFFS_HEIGHT_HI, r19
|
||||
; advance pos
|
||||
add xl, r18 ; add height to current pos
|
||||
adc xh, r19
|
||||
add xl, r24 ; add spacing to current pos
|
||||
adc xh, r25
|
||||
vLayoutFinalizeSpread_next:
|
||||
rcall OBJ_GetNext ; r19:r18=object (none)
|
||||
brcs vLayoutFinalizeSpread_loop
|
||||
vLayoutFinalizeSpread_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; data in FLASH
|
||||
|
||||
VLayout_DefaultSignalmap:
|
||||
; header
|
||||
.dw Widget_DefaultSignalmap*2 ; next table to use
|
||||
; entries
|
||||
.db 0, WIDGET_SIGNAL_LAYOUT, LOW(VLayout_OnLayout), HIGH(VLayout_OnLayout)
|
||||
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(VLayout_OnGetDefaultWidth), HIGH(VLayout_OnGetDefaultWidth)
|
||||
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(VLayout_OnGetDefaultHeight), HIGH(VLayout_OnGetDefaultHeight)
|
||||
|
||||
.db 0, 0, 0, 0 ; end of table
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user