gui2: fixed problems with layouts
need to look into spread mode, too.
This commit is contained in:
@@ -253,49 +253,41 @@ test:
|
||||
sts guiApp, yl
|
||||
sts guiApp+1, yh
|
||||
|
||||
bigcall GuiApp_GetRootWindow
|
||||
brcc DEBUG_STOP
|
||||
push yl
|
||||
push yh
|
||||
mov xl, r18
|
||||
mov xh, r19
|
||||
ldi r16, 0 ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_TXT_LIVINGROOM)
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_LIVINGROOM)
|
||||
bigcall MainWindow_new
|
||||
bigcall MainWindow_GetContentWidget
|
||||
brcc DEBUG_STOP
|
||||
mov xl, yl ; X=MainWindow
|
||||
bigcall ClimateWin_new
|
||||
; rcall mkTestWindow
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
push xl ; mainWindow
|
||||
push xh
|
||||
mov xl, r18 ; contentWindow
|
||||
mov xh, r19
|
||||
|
||||
push xl
|
||||
push xh
|
||||
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | (1<<WIDGET_OPTS_INPUT_BIT) | (1<<WIDGET_OPTS_BORDER_BIT) ; OPTS
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, VALUE_ID_SENSOR_CO2_BASE
|
||||
ldi r21, C03_EEID_SENSOR_CO2
|
||||
ldi r22, SENSORWATCH_TYPE_CO2
|
||||
bigcall SensorWatch_new
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
pop xh
|
||||
pop xl
|
||||
pop yh
|
||||
pop yl
|
||||
brcc DEBUG_STOP
|
||||
brcc DEBUG_STOP2
|
||||
|
||||
bigcall GuiApp_EnterWindow
|
||||
push xl
|
||||
push xh
|
||||
bigcall GuiApp_EnterWindow
|
||||
pop xh
|
||||
pop xl
|
||||
brcc DEBUG_STOP3
|
||||
|
||||
push yl
|
||||
push yh
|
||||
mov yl, xl
|
||||
mov yh, xh
|
||||
ldi r16, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT) | (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
bigcall OBJ_AddFlagsUp
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
ret
|
||||
|
||||
|
||||
; ; debug
|
||||
; ldi r16, LOW(Debug_Style*2)
|
||||
; std Y+WIDGET_OFFS_STYLE_LO, r16
|
||||
; ldi r16, HIGH(Debug_Style*2)
|
||||
; std Y+WIDGET_OFFS_STYLE_HI, r16
|
||||
|
||||
|
||||
DEBUG_STOP:
|
||||
bigjmp DEBUG1
|
||||
@@ -309,6 +301,122 @@ DEBUG_STOP3:
|
||||
|
||||
|
||||
|
||||
mkTestWindow:
|
||||
bigcall GuiApp_GetRootWindow
|
||||
brcc mkTestWindow_ret
|
||||
mov xl, r18 ; use root window as parent for main window
|
||||
mov xh, r19
|
||||
ldi r16, 0 ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_TXT_LIVINGROOM) ; TODO: use "Room Climate"
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_LIVINGROOM)
|
||||
bigcall MainWindow_new
|
||||
brcc mkTestWindow_ret
|
||||
|
||||
; Y=MainWindow
|
||||
push yl
|
||||
push yh
|
||||
bigcall MainWindow_GetContentWidget ; r19:r18=content window
|
||||
brcc mkTestWindow_popRet
|
||||
mov xl, r18 ; use content window as parent
|
||||
mov xh, r19
|
||||
|
||||
push xl ; content window
|
||||
push xh
|
||||
rcall mkTestWidgets
|
||||
; rcall mkSimpleTestWidgets
|
||||
pop xh
|
||||
pop xl
|
||||
mkTestWindow_popRet:
|
||||
pop yh
|
||||
pop yl
|
||||
mkTestWindow_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine mkTestWidgets
|
||||
;
|
||||
; @param X pointer to MainWindow content window (becomes parent)
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
|
||||
mkTestWidgets:
|
||||
ldi r16, 0 ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
; ldi r20, HLAYOUT_MODE_SPREAD
|
||||
ldi r20, VLAYOUT_MODE_EXPAND
|
||||
bigcall VLayout_new
|
||||
brcc mkTestWidgets_ret
|
||||
|
||||
push yl
|
||||
push yh
|
||||
mov xl, yl ; use HLayout as parent
|
||||
mov xh, yh
|
||||
|
||||
push xl ; HLayout
|
||||
push xh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_IMG_HUMIDITY96)
|
||||
ldi r21, HIGH(RESSSOURCE_IMG_HUMIDITY96)
|
||||
bigcall ImageView_new
|
||||
pop xh
|
||||
pop xl
|
||||
brcc mkTestWidgets_popRet
|
||||
|
||||
push xl ; HLayout
|
||||
push xh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_IMG_CLOUD96)
|
||||
ldi r21, HIGH(RESSSOURCE_IMG_CLOUD96)
|
||||
bigcall ImageView_new
|
||||
pop xh
|
||||
pop xl
|
||||
brcc mkTestWidgets_popRet
|
||||
|
||||
mkTestWidgets_popRet:
|
||||
pop yh
|
||||
pop yl
|
||||
mkTestWidgets_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
mkSimpleTestWidgets:
|
||||
push xl ; Contentwindow
|
||||
push xh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_IMG_HUMIDITY96)
|
||||
ldi r21, HIGH(RESSSOURCE_IMG_HUMIDITY96)
|
||||
bigcall ImageView_new
|
||||
pop xh
|
||||
pop xl
|
||||
brcc mkSimpleTestWidgets_ret
|
||||
|
||||
push xl ; HLayout
|
||||
push xh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_IMG_CLOUD96)
|
||||
ldi r21, HIGH(RESSSOURCE_IMG_CLOUD96)
|
||||
bigcall ImageView_new
|
||||
pop xh
|
||||
pop xl
|
||||
brcc mkSimpleTestWidgets_ret
|
||||
|
||||
mkSimpleTestWidgets_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; includes
|
||||
|
||||
@@ -355,9 +463,9 @@ GUI2_MODULE_BEGIN:
|
||||
.include "modules/lcd2/gui2/base/valuelabel.asm"
|
||||
.include "modules/lcd2/gui2/aqhome/sensorwatch.asm"
|
||||
GUI2_MODULE_END:
|
||||
|
||||
.equ MODULE_SIZE_GUI2 = GUI2_MODULE_END-GUI2_MODULE_BEGIN
|
||||
|
||||
.include "w_climate.asm"
|
||||
|
||||
|
||||
.include "ressources.inc"
|
||||
|
||||
167
avr/devices/c03/test/w_climate.asm
Normal file
167
avr/devices/c03/test/w_climate.asm
Normal file
@@ -0,0 +1,167 @@
|
||||
; ***************************************************************************
|
||||
; 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_W_CLIMATE_ASM
|
||||
#define AQH_AVR_W_CLIMATE_ASM
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
.equ CLIMATEWIN_OFFS_BEGIN = MAINWINDOW_SIZE
|
||||
.equ CLIMATEWIN_SIZE = CLIMATEWIN_OFFS_BEGIN+0
|
||||
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; code
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine ClimateWin_new @global
|
||||
;
|
||||
; @param Y pointer to GUIAPP
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
|
||||
ClimateWin_new:
|
||||
bigcall GuiApp_GetRootWindow
|
||||
brcc ClimateWin_new_ret
|
||||
mov xl, r18 ; use root window as parent for main window
|
||||
mov xh, r19
|
||||
ldi r16, 0 ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_TXT_LIVINGROOM) ; TODO: use "Room Climate"
|
||||
ldi r21, HIGH(RESSSOURCE_TXT_LIVINGROOM)
|
||||
bigcall MainWindow_new
|
||||
brcc ClimateWin_new_ret
|
||||
|
||||
; Y=MainWindow
|
||||
push yl
|
||||
push yh
|
||||
bigcall MainWindow_GetContentWidget ; r19:r18=content window
|
||||
brcc ClimateWin_new_popRet
|
||||
mov xl, r18 ; use content window as parent
|
||||
mov xh, r19
|
||||
|
||||
push xl ; content window
|
||||
push xh
|
||||
rcall climateWinCreateSensorWatches
|
||||
pop xh
|
||||
pop xl
|
||||
; brcc ClimateWin_new_popRet
|
||||
|
||||
; TODO: create menu bar below
|
||||
|
||||
ClimateWin_new_popRet:
|
||||
pop yh
|
||||
pop yl
|
||||
ClimateWin_new_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine climateWinCreateSensorWatches
|
||||
;
|
||||
; @param X pointer to MainWindow content window (becomes parent)
|
||||
; @return CFLAG set of okay, cleared otherwise
|
||||
; @return Y address of newly created object
|
||||
|
||||
climateWinCreateSensorWatches:
|
||||
ldi r16, 0 ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
; ldi r20, HLAYOUT_MODE_SPREAD
|
||||
ldi r20, HLAYOUT_MODE_EXPAND
|
||||
bigcall HLayout_new
|
||||
brcc climateWinCreateSensorWatches_ret
|
||||
|
||||
mov xl, yl ; use HLayout as parent
|
||||
mov xh, yh
|
||||
|
||||
push xl ; HLayout
|
||||
push xh
|
||||
ldi r16, 0
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, LOW(RESSSOURCE_IMG_HUMIDITY96)
|
||||
ldi r21, HIGH(RESSSOURCE_IMG_HUMIDITY96)
|
||||
bigcall ImageView_new
|
||||
pop xh
|
||||
pop xl
|
||||
|
||||
; CO2 sensor watch
|
||||
push xl ; HLayout
|
||||
push xh
|
||||
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | (1<<WIDGET_OPTS_INPUT_BIT) ; OPTS
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, VALUE_ID_SENSOR_CO2_BASE
|
||||
ldi r21, C03_EEID_SENSOR_CO2
|
||||
ldi r22, SENSORWATCH_TYPE_CO2
|
||||
bigcall SensorWatch_new
|
||||
pop xh
|
||||
pop xl
|
||||
brcc climateWinCreateSensorWatches_ret
|
||||
|
||||
; temp sensor watch
|
||||
push xl ; HLayout
|
||||
push xh
|
||||
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | (1<<WIDGET_OPTS_INPUT_BIT) ; OPTS
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, VALUE_ID_SENSOR_TEMP_BASE
|
||||
ldi r21, C03_EEID_SENSOR_TEMP
|
||||
ldi r22, SENSORWATCH_TYPE_TEMP
|
||||
bigcall SensorWatch_new
|
||||
pop xh
|
||||
pop xl
|
||||
brcc climateWinCreateSensorWatches_ret
|
||||
|
||||
#if 0
|
||||
; humidity sensor watch
|
||||
push xl ; HLayout
|
||||
push xh
|
||||
ldi r16, (1<<OBJECT_OPTS_TIMER_BIT) | (1<<WIDGET_OPTS_INPUT_BIT) | (1<<WIDGET_OPTS_BORDER_BIT) ; OPTS
|
||||
ldi r17, (WIDGET_PACK_BEGIN<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, VALUE_ID_SENSOR_HUM_BASE
|
||||
ldi r21, C03_EEID_SENSOR_HUM
|
||||
ldi r22, SENSORWATCH_TYPE_HUM
|
||||
bigcall SensorWatch_new
|
||||
pop xh
|
||||
pop xl
|
||||
#endif
|
||||
|
||||
climateWinCreateSensorWatches_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
#if 0
|
||||
Debug_Style:
|
||||
.dw DISPLAY_COLOR_BLACK ; frontCol_norm
|
||||
; .dw DISPLAY_COLOR_LIGHTGREY ; backCol_norm
|
||||
.dw DISPLAY_COLOR_GREEN ; backCol_norm
|
||||
.dw DISPLAY_COLOR_BLACK ; borderCol_norm
|
||||
.dw DISPLAY_COLOR_WHITE ; shadowCol_norm
|
||||
|
||||
.dw DISPLAY_COLOR_WHITE ; frontCol_activated
|
||||
.dw DISPLAY_COLOR_NAVY ; backCol_activated
|
||||
.dw DISPLAY_COLOR_BLACK ; borderCol_activated
|
||||
.dw DISPLAY_COLOR_WHITE ; shadowCol_activated
|
||||
|
||||
.db 1, 1 ; outerBorderSize, innerBorderSize
|
||||
.dw ili9341Font12x16_1*2 ; font
|
||||
.db 12, 16 ; charWidth, charHeight
|
||||
# endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -106,6 +106,7 @@ SensorWatch_Init:
|
||||
push r21
|
||||
push r22
|
||||
; call base class
|
||||
ldi r20, VLAYOUT_MODE_EXPAND
|
||||
bigcall VLayout_Init
|
||||
pop r22
|
||||
pop r21
|
||||
@@ -309,7 +310,8 @@ SensorWatch_Descriptors:
|
||||
.dw RESSSOURCE_TXT_UNKNOWN_S, RESSSOURCE_IMG_CLOUD96, 0 ; unknown
|
||||
.dw RESSSOURCE_TXT_CO2_S, RESSSOURCE_IMG_CLOUD96, 0 ; co2
|
||||
.dw RESSSOURCE_TXT_TEMP_S, RESSSOURCE_IMG_TEMP96, 2 ; temp
|
||||
.dw RESSSOURCE_TXT_HUM_S, RESSSOURCE_IMG_HUMIDITY96, 0 ; hum
|
||||
; .dw RESSSOURCE_TXT_HUM_S, RESSSOURCE_IMG_HUMIDITY96, 0 ; hum
|
||||
.dw RESSSOURCE_TXT_TEMP_S, RESSSOURCE_IMG_HUMIDITY96, 0 ; hum
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -614,6 +614,7 @@ guiAppCheckSendGuiEvents:
|
||||
clr r17
|
||||
ldi r20, (1<<WIDGET_FLAGS_VISIBLE_BIT) | (1<<WIDGET_FLAGS_DIRTY_BIT)
|
||||
bigcall OBJ_TreeHandleSignalIfFlagsSet ; (any, !Y)
|
||||
|
||||
pop yh
|
||||
pop yl
|
||||
ldi r16, GUIAPP_GUITIMER
|
||||
|
||||
@@ -42,12 +42,15 @@
|
||||
; @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:
|
||||
ldi r24, LOW(HLAYOUT_SIZE)
|
||||
ldi r25, HIGH(HLAYOUT_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
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
|
||||
@@ -64,16 +67,18 @@ HLayout_new_ret:
|
||||
; @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
|
||||
push r21
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r21
|
||||
; 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
|
||||
@@ -94,6 +99,7 @@ HLayout_Init:
|
||||
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)
|
||||
@@ -214,7 +220,8 @@ hLayoutVertically:
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm r18, Z+
|
||||
lpm r19, Z
|
||||
; lpm r19, Z
|
||||
clr r19
|
||||
sub r22, r18
|
||||
sbc r23, r19
|
||||
sub r22, r18
|
||||
@@ -356,13 +363,19 @@ hLayoutPrepareSpread:
|
||||
|
||||
ldd r18, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r19, Y+WIDGET_OFFS_WIDTH_HI
|
||||
sub r18, r20
|
||||
sbc r19, r21
|
||||
sub r18, r20 ; width-usedWidth
|
||||
sbc r19, r21
|
||||
brcc hLayoutPrepareSpread_calcAdd
|
||||
clr r20
|
||||
clr r21
|
||||
rjmp hLayoutPrepareSpread_finish
|
||||
|
||||
hLayoutPrepareSpread_calcAdd:
|
||||
mov r20, r18
|
||||
mov r21, r19 ; remaining space
|
||||
|
||||
rcall LayoutCountVisibleChildren ; r16=number of visible child widgets (r17, r18, r19)
|
||||
inc r16
|
||||
inc r16 ; r16=number of spacings (begin->between->end)
|
||||
mov r22, r16
|
||||
push r22
|
||||
ldi r22, (1<<WIDGET_PACK_HSELF1_BIT) | \
|
||||
@@ -370,12 +383,13 @@ hLayoutPrepareSpread:
|
||||
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
|
||||
add r22, r16 ; r22=number of items to spread
|
||||
clr r23
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per element
|
||||
mov r20, r18
|
||||
mov r21, r19 ; r21:20=additional space per element
|
||||
mov r20, r16
|
||||
mov r21, r17 ; r21:20=additional space per element
|
||||
|
||||
hLayoutPrepareSpread_finish:
|
||||
; get and adjust spacing, setup start pos
|
||||
ldd zl, Y+WIDGET_OFFS_STYLE_LO
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
|
||||
@@ -98,7 +98,7 @@ Layout_SetDefaultHeights_ret:
|
||||
; Ignores invisible widgets.
|
||||
;
|
||||
; @param Y pointer to widget
|
||||
; @return r19:r18 total width of all child widgets plus space between
|
||||
; @return r19:r18 total size of all child widgets plus space between
|
||||
; @clobbers r16, r17, r18, r19, r20, r21, r22, r23, Z
|
||||
|
||||
Layout_SumTmpValues:
|
||||
@@ -119,7 +119,7 @@ Layout_SumTmpValues:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc Layout_SumTmpValues_loopEnd
|
||||
brcc Layout_SumTmpValues_finish
|
||||
Layout_SumTmpValues_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
@@ -139,10 +139,11 @@ Layout_SumTmpValues_next:
|
||||
Layout_SumTmpValues_loopEnd:
|
||||
mov r16, r20
|
||||
or r16, r21
|
||||
breq Layout_SumTmpValues_done
|
||||
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
|
||||
@@ -251,8 +252,8 @@ LayoutCountVisibleChildren:
|
||||
push yl
|
||||
push yh
|
||||
bigcall OBJ_GetFirstChild
|
||||
brcc LayoutCountVisibleChildren_done
|
||||
LayoutCountVisibleChildren_loop:
|
||||
brcc LayoutCountVisibleChildren_done
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
@@ -260,7 +261,7 @@ LayoutCountVisibleChildren_loop:
|
||||
inc r16
|
||||
LayoutCountVisibleChildren_next:
|
||||
rcall OBJ_GetNext
|
||||
rjmp LayoutCountVisibleChildren_loop
|
||||
brcs LayoutCountVisibleChildren_loop
|
||||
LayoutCountVisibleChildren_done:
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
@@ -69,6 +69,7 @@ MainWindow_Init:
|
||||
push r20
|
||||
push r21
|
||||
; call base class
|
||||
ldi r20, VLAYOUT_MODE_EXPAND
|
||||
bigcall VLayout_Init ; (r16, r17, X)
|
||||
pop r21
|
||||
pop r20
|
||||
@@ -86,6 +87,8 @@ MainWindow_Init:
|
||||
ldi r16, HIGH(MainWindow_DefaultStyle*2)
|
||||
std Y+WIDGET_OFFS_STYLE_HI, r16
|
||||
|
||||
bigcall Widget_SetFullScreen ; (R16)
|
||||
|
||||
; create sub widgets
|
||||
rcall mainWindowCreateTitleWidget
|
||||
rcall mainWindowCreateContentWidget
|
||||
@@ -202,6 +205,7 @@ mainWindowCreateContentWidget:
|
||||
mov xh, yh
|
||||
ldi r16, 0 ; OPTS
|
||||
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
|
||||
ldi r20, VLAYOUT_MODE_EXPAND
|
||||
bigcall VLayout_new
|
||||
brcc mainWindowCreateContentWidget_done
|
||||
; set style for title widget
|
||||
@@ -282,7 +286,7 @@ MainWindow_ContentStyle:
|
||||
.dw DISPLAY_COLOR_BLACK ; borderCol_activated
|
||||
.dw DISPLAY_COLOR_WHITE ; shadowCol_activated
|
||||
|
||||
.db 2, 2 ; outerBorderSize, innerBorderSize
|
||||
.db 1, 1 ; outerBorderSize, innerBorderSize
|
||||
.dw ili9341Font12x16_1*2 ; font
|
||||
.db 12, 16 ; charWidth, charHeight
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ RootWindow_OnLayout_done:
|
||||
ldd r17, Y+OBJECT_OFFS_FLAGS
|
||||
cbr r17, (1<<WIDGET_FLAGS_LAYOUT_BIT)
|
||||
std Y+OBJECT_OFFS_FLAGS, r17
|
||||
sec
|
||||
|
||||
sec
|
||||
ret
|
||||
; @end
|
||||
|
||||
@@ -42,12 +42,15 @@
|
||||
; @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:
|
||||
ldi r24, LOW(VLAYOUT_SIZE)
|
||||
ldi r25, HIGH(VLAYOUT_SIZE)
|
||||
bigcall Object_Alloc ; (!r16, !r17, !X)
|
||||
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
|
||||
@@ -64,16 +67,18 @@ VLayout_new_ret:
|
||||
; @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
|
||||
push r21
|
||||
; call base class
|
||||
bigcall Widget_Init ; (r16, r17, X)
|
||||
pop r21
|
||||
; 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
|
||||
@@ -115,21 +120,7 @@ VLayout_OnLayout:
|
||||
VLayout_OnGetDefaultWidth:
|
||||
rcall Layout_SetDefaultWidths
|
||||
rcall Layout_GetMaxTmp
|
||||
|
||||
; get outer border
|
||||
ldd zl, Y+WIDGET_OFFS_STYLE_LO
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm r16, Z
|
||||
clr r17
|
||||
sbiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
|
||||
add r18, r16 ; add outer border (top)
|
||||
adc r19, r17
|
||||
|
||||
add r18, r16 ; add outer border (bottom)
|
||||
adc r19, r17
|
||||
|
||||
bigcall Widget_AddOuterStyleBorders ; (r20, r21)
|
||||
sec
|
||||
ret
|
||||
|
||||
@@ -228,7 +219,8 @@ vLayoutHorizontally:
|
||||
ldd zh, Y+WIDGET_OFFS_STYLE_HI
|
||||
adiw zh:zl, WIDGET_STYLE_OFFS_OUTERBORDERSIZE
|
||||
lpm r18, Z+
|
||||
lpm r19, Z
|
||||
; lpm r19, Z
|
||||
clr r19
|
||||
sub r22, r18
|
||||
sbc r23, r19
|
||||
sub r22, r18
|
||||
@@ -244,14 +236,14 @@ vLayoutHorizontally_loop:
|
||||
mov yl, r18
|
||||
mov yh, r19
|
||||
|
||||
ldd r12, Y+WIDGET_OFFS_TMP_LO
|
||||
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
|
||||
mov r12, r22 ; TODO: need to check size, subtract borders!!!
|
||||
mov r13, r23
|
||||
vLayoutHorizontally_setWidth:
|
||||
std Y+WIDGET_OFFS_WIDTH_LO, r12
|
||||
@@ -261,7 +253,7 @@ vLayoutHorizontally_setWidth:
|
||||
ldd r17, Y+WIDGET_OFFS_PACK
|
||||
mov yl, xl ; use parent
|
||||
mov yh, xh
|
||||
rcall Widget_PackSelfX ; R5:R4=new pos (r17, r18, r19, r20, r21)
|
||||
rcall 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
|
||||
@@ -372,6 +364,11 @@ vLayoutPrepareSpread:
|
||||
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
|
||||
|
||||
@@ -387,9 +384,10 @@ vLayoutPrepareSpread:
|
||||
add r22, r16
|
||||
clr r23
|
||||
bigcall Utils_Divu16_16_16 ; r17:r16=space per element
|
||||
mov r20, r18
|
||||
mov r21, r19 ; r21:20=additional 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
|
||||
|
||||
@@ -523,7 +523,7 @@ Widget_OnDraw:
|
||||
sbrs r17, WIDGET_OPTS_BORDER_BIT
|
||||
rjmp Widget_OnDraw_ret
|
||||
bigcall Widget_DrawBorder
|
||||
|
||||
|
||||
Widget_OnDraw_ret:
|
||||
sec
|
||||
ret
|
||||
@@ -719,6 +719,17 @@ Widget_OnTouch_done:
|
||||
Widget_Clear:
|
||||
rcall Widget_LoadDimsForFullWidget ; (none)
|
||||
rcall Widget_MakeAbsPos ; (r16, r17, r18, r19)
|
||||
rcall Widget_ValidateDims ; (r16, r17)
|
||||
tst r16
|
||||
breq Widget_Clear_l1
|
||||
ldi r16, LOW(DISPLAY_COLOR_RED)
|
||||
mov r2, r16
|
||||
ldi r16, HIGH(DISPLAY_COLOR_RED)
|
||||
mov r3, r16
|
||||
bigcall Display_FillRect
|
||||
ret
|
||||
Widget_Clear_l1:
|
||||
|
||||
rcall Widget_SelectColors ; (R16)
|
||||
mov r2, r0 ; use background
|
||||
mov r3, r1
|
||||
@@ -927,6 +938,109 @@ Widget_MakeAbsPos_loopEnd:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_ValidateDims @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @param r5:r4 X0
|
||||
; @param r7:r6 Y0
|
||||
; @param r9:r8 X1/W
|
||||
; @param r11:r10 Y1/H
|
||||
; @return r16 1 if dims modified, 0 if dims where within display range
|
||||
; @clobbers r16, r17
|
||||
|
||||
Widget_ValidateDims:
|
||||
push r18
|
||||
clr r18
|
||||
ldi r16, LOW(DISPLAY_WIDTH) ; check X
|
||||
ldi r17, HIGH(DISPLAY_WIDTH)
|
||||
cp r4, r16
|
||||
cpc r5, r17
|
||||
brcs Widget_ValidateDims_width
|
||||
ldi r18, 1
|
||||
clr r4
|
||||
clr r5
|
||||
Widget_ValidateDims_width:
|
||||
sub r16, r4 ; calculate remaining width from pos on
|
||||
sbc r17, r5
|
||||
cp r16, r8
|
||||
cpc r17, r9
|
||||
brcc Widget_ValidateDims_y
|
||||
ldi r18, 1
|
||||
mov r8, r16
|
||||
mov r9, r17
|
||||
Widget_ValidateDims_y:
|
||||
ldi r16, LOW(DISPLAY_HEIGHT) ; check Y
|
||||
ldi r17, HIGH(DISPLAY_HEIGHT)
|
||||
cp r6, r16
|
||||
cpc r7, r17
|
||||
brcs Widget_ValidateDims_height
|
||||
ldi r18, 1
|
||||
clr r6
|
||||
clr r7
|
||||
Widget_ValidateDims_height:
|
||||
sub r16, r6 ; calculate remaining width from pos on
|
||||
sbc r17, r7
|
||||
cp r16, r10
|
||||
cpc r17, r11
|
||||
brcc Widget_ValidateDims_ret
|
||||
ldi r18, 1
|
||||
mov r10, r16
|
||||
mov r11, r17
|
||||
Widget_ValidateDims_ret:
|
||||
mov r16, r18
|
||||
pop r18
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_CheckDims @global
|
||||
;
|
||||
; @param Y address of widget
|
||||
; @clobbers r16, r17, r18, r19
|
||||
|
||||
Widget_CheckDims:
|
||||
ldi r18, LOW(DISPLAY_WIDTH) ; check X
|
||||
ldi r19, HIGH(DISPLAY_WIDTH)
|
||||
ldd r16, Y+WIDGET_OFFS_X_LO
|
||||
ldd r17, Y+WIDGET_OFFS_X_HI
|
||||
cp r16, r18
|
||||
cpc r17, r19
|
||||
brcc Widget_CheckDims_invalid
|
||||
sub r18, r16
|
||||
sbc r19, r17
|
||||
ldd r16, Y+WIDGET_OFFS_WIDTH_LO
|
||||
ldd r17, Y+WIDGET_OFFS_WIDTH_HI
|
||||
cp r18, r16
|
||||
cpc r19, r17
|
||||
brcs Widget_CheckDims_invalid
|
||||
|
||||
ldi r18, LOW(DISPLAY_HEIGHT) ; check Y
|
||||
ldi r19, HIGH(DISPLAY_HEIGHT)
|
||||
ldd r16, Y+WIDGET_OFFS_Y_LO
|
||||
ldd r17, Y+WIDGET_OFFS_Y_HI
|
||||
cp r16, r18
|
||||
cpc r17, r19
|
||||
brcc Widget_CheckDims_invalid
|
||||
sub r18, r16
|
||||
sbc r19, r17
|
||||
ldd r16, Y+WIDGET_OFFS_HEIGHT_LO
|
||||
ldd r17, Y+WIDGET_OFFS_HEIGHT_HI
|
||||
cp r18, r16
|
||||
cpc r19, r17
|
||||
brcs Widget_CheckDims_invalid
|
||||
; done, all okay so far
|
||||
sec
|
||||
rjmp Widget_CheckDims_ret
|
||||
Widget_CheckDims_invalid:
|
||||
clc
|
||||
Widget_CheckDims_ret:
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine Widget_SelectColors @global
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user