gui2: more work on layout code.

This commit is contained in:
Martin Preuss
2026-03-07 00:44:56 +01:00
parent 0af5aed2f6
commit 2cf4e414d2
5 changed files with 424 additions and 74 deletions

View File

@@ -16,7 +16,7 @@
; ***************************************************************************
; defines
.equ MAINWINDOW_OFFS_BEGIN = WIDGET_SIZE
.equ MAINWINDOW_OFFS_BEGIN = VLAYOUT_SIZE
; no data for now
.equ MAINWINDOW_SIZE = MAINWINDOW_OFFS_BEGIN+0
@@ -69,7 +69,7 @@ MainWindow_Init:
push r20
push r21
; call base class
bigcall Widget_Init ; (r16, r17, X)
bigcall VLayout_Init ; (r16, r17, X)
pop r21
pop r20
@@ -79,26 +79,29 @@ MainWindow_Init:
ldi r16, HIGH(MainWindow_DefaultSignalmap*2)
std Y+OBJECT_OFFS_SIGNALMAP_HI, r16
; move widget
clr r4
clr r5
clr r6
clr r7
bigcall Widget_Move ; (R16)
; set pos and size of widget to display size
clr r16
std Y+WIDGET_OFFS_X_LO, r16
std Y+WIDGET_OFFS_X_HI, r16
std Y+WIDGET_OFFS_Y_LO, r16
std Y+WIDGET_OFFS_Y_HI, r16
ldi r16, LOW(DISPLAY_WIDTH)
mov r8, r16
std Y+WIDGET_OFFS_WIDTH_LO, r16
ldi r16, HIGH(DISPLAY_WIDTH)
mov r9, r16
; resize widget
std Y+WIDGET_OFFS_WIDTH_HI, r16
ldi r16, LOW(DISPLAY_HEIGHT)
mov r10, r16
std Y+WIDGET_OFFS_HEIGHT_LO, r16
ldi r16, HIGH(DISPLAY_HEIGHT)
mov r11, r16
bigcall Widget_Resize ; (R16)
std Y+WIDGET_OFFS_HEIGHT_HI, r16
ldi r16, LOW(MainWindow_DefaultStyle)
std Y+WIDGET_OFFS_STYLE_LO, r16
ldi r16, HIGH(MainWindow_DefaultStyle)
std Y+WIDGET_OFFS_STYLE_HI, r16
; create sub widgets
rcall mainWindowCreateTitleWidget
rcall mainWindowCreateContentWidget
ret
; @end
@@ -148,28 +151,6 @@ MainWindow_OnGetDefaultHeight:
; ---------------------------------------------------------------------------
; @routine MainWindow_OnLayout @global
;
; @param Y address of widget
; @return CFLAG set if signal handled
; @clobbers any, !Y
MainWindow_OnLayout:
ldd r16, Y+OBJECT_OFFS_OPTS_LO
clr r4 ; X
clr r5
clr r6 ; Y
clr r7
; TODO
ret
; @end
; ---------------------------------------------------------------------------
; @routine mainWindowCreateTitleWidget
;
@@ -183,11 +164,11 @@ mainWindowCreateTitleWidget:
push yh
mov xl, yl
mov xh, yh
ldi r16, 0
ldi r16, (1<<WIDGET_OPTSLO_FILLX_BIT)
ldi r17, (WIDGET_XALIGN_LEFT<<WIDGET_OPTSHI_CONTENT_XALIGN0_BIT) | (WIDGET_YALIGN_CENTER<<WIDGET_OPTSHI_CONTENT_YALIGN0_BIT)
bigcall Label_new
; set style for title widget
brcc mainWindowCreateTitleWidget_done
; set style for title widget
ldi r16, LOW(MainWindow_TitleStyle*2)
std Y+WIDGET_OFFS_STYLE_LO, r16
ldi r16, HIGH(MainWindow_TitleStyle*2)
@@ -214,9 +195,16 @@ mainWindowCreateContentWidget:
push yh
mov xl, yl
mov xh, yh
ldi r16, 0 ; opts lo
ldi r16, (1<<WIDGET_OPTSLO_FILLX_BIT) | (1<<WIDGET_OPTSLO_FILLY_BIT)
ldi r17, 0 ; opts hi
bigcall Widget_new
brcc mainWindowCreateContentWidget_done
; set style for title widget
ldi r16, LOW(MainWindow_ContentStyle*2)
std Y+WIDGET_OFFS_STYLE_LO, r16
ldi r16, HIGH(MainWindow_ContentStyle*2)
std Y+WIDGET_OFFS_STYLE_HI, r16
mainWindowCreateContentWidget_done:
pop yh
pop yl
ret
@@ -231,9 +219,9 @@ mainWindowCreateContentWidget:
MainWindow_DefaultSignalmap:
; header
.dw Widget_DefaultSignalmap ; next table to use
.dw VLayout_DefaultSignalmap ; next table to use
; entries
.db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDrawNop), HIGH(Widget_OnDrawNop)
.db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDraw), HIGH(Widget_OnDraw)
.db WIDGET_VALUE_DEFAULT_WIDTH, WIDGET_SIGNAL_GETVALUE, LOW(MainWindow_OnGetDefaultWidth), HIGH(MainWindow_OnGetDefaultWidth)
.db WIDGET_VALUE_DEFAULT_HEIGHT, WIDGET_SIGNAL_GETVALUE, LOW(MainWindow_OnGetDefaultHeight), HIGH(MainWindow_OnGetDefaultHeight)
@@ -241,6 +229,22 @@ MainWindow_DefaultSignalmap:
MainWindow_DefaultStyle:
.dw DISPLAY_COLOR_BLACK ; frontCol_norm
.dw DISPLAY_COLOR_LIGHTGREY ; 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 0, 0 ; outerBorderSize, innerBorderSize
.dw ili9341Font12x16_1*2 ; font
.db 12, 16 ; charWidth, charHeight
MainWindow_TitleStyle:
.dw STYLE_WIN_TITLE_FOREGROUND ; frontCol_norm
@@ -259,6 +263,23 @@ MainWindow_TitleStyle:
MainWindow_ContentStyle:
.dw DISPLAY_COLOR_BLACK ; frontCol_norm
.dw DISPLAY_COLOR_LIGHTGREY ; 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 2, 1 ; outerBorderSize, innerBorderSize
.dw ili9341Font12x16_1*2 ; font
.db 12, 16 ; charWidth, charHeight
#endif