Files
aqhomecontrol/avr/modules/lcd2/gui2/base/mainwindow.asm
2026-03-07 00:04:36 +01:00

265 lines
6.3 KiB
NASM

; ***************************************************************************
; 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_MAINWINDOW_ASM
#define AQH_AVR_GUI2_MAINWINDOW_ASM
; TODO: base on VLayout!
; ***************************************************************************
; defines
.equ MAINWINDOW_OFFS_BEGIN = WIDGET_SIZE
; no data for now
.equ MAINWINDOW_SIZE = MAINWINDOW_OFFS_BEGIN+0
; ***************************************************************************
; code
.cseg
; ---------------------------------------------------------------------------
; @routine MainWindow_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_LO
; @param r17 value for OBJECT_OFFS_OPTS_HI
; @param r21:r20 ressource id for title
; @clobbers any
MainWindow_new:
push r20
push r21
ldi r24, LOW(MAINWINDOW_SIZE)
ldi r25, HIGH(MAINWINDOW_SIZE)
bigcall Object_Alloc ; (!r16, !r17, !X)
pop r21
pop r20
brcc MainWindow_new_ret
rcall MainWindow_Init ; (r16, r17, X)
sec
MainWindow_new_ret:
ret
; @end
; ---------------------------------------------------------------------------
; @routine MainWindow_Init @global
;
; @param Y address of widget
; @param X parent widget (if any)
; @param r21:r20 ressource id for title
; @clobbers r16, r17, X
MainWindow_Init:
push r20
push r21
; call base class
bigcall Widget_Init ; (r16, r17, X)
pop r21
pop r20
; set default signal map
ldi r16, LOW(MainWindow_DefaultSignalmap*2)
std Y+OBJECT_OFFS_SIGNALMAP_LO, r16
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)
ldi r16, LOW(DISPLAY_WIDTH)
mov r8, r16
ldi r16, HIGH(DISPLAY_WIDTH)
mov r9, r16
; resize widget
ldi r16, LOW(DISPLAY_HEIGHT)
mov r10, r16
ldi r16, HIGH(DISPLAY_HEIGHT)
mov r11, r16
bigcall Widget_Resize ; (R16)
; create sub widgets
rcall mainWindowCreateTitleWidget
ret
; @end
; ***************************************************************************
; signal handlers
; ---------------------------------------------------------------------------
; @routine MainWindow_OnGetDefaultWidth @global
;
; @param Y address of widget
; @param r17 value requested
; @param xl param1
; @param xh param2
; @return CFLAG set if signal handled
; @return r19:r18 value
; @clobbers any, !Y
MainWindow_OnGetDefaultWidth:
ldi r18, LOW(DISPLAY_WIDTH)
ldi r19, HIGH(DISPLAY_WIDTH)
ret
; @end
; ---------------------------------------------------------------------------
; @routine MainWindow_OnGetDefaultHeight @global
;
; @param Y address of widget
; @param r17 value requested
; @param xl param1
; @param xh param2
; @return CFLAG set if signal handled
; @return r19:r18 value
; @clobbers any, !Y
MainWindow_OnGetDefaultHeight:
ldi r18, LOW(DISPLAY_HEIGHT)
ldi r19, HIGH(DISPLAY_HEIGHT)
ret
; @end
; ---------------------------------------------------------------------------
; @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
;
; @param Y address of main window widget
; @param r21:r20 ressource id for title
; @return CFLAG set of okay, cleared otherwise
mainWindowCreateTitleWidget:
; create title widget
push yl
push yh
mov xl, yl
mov xh, yh
ldi r16, 0
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
ldi r16, LOW(MainWindow_TitleStyle*2)
std Y+WIDGET_OFFS_STYLE_LO, r16
ldi r16, HIGH(MainWindow_TitleStyle*2)
std Y+WIDGET_OFFS_STYLE_HI, r16
sec
mainWindowCreateTitleWidget_done:
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine mainWindowCreateContentWidget
;
; @param Y address of main window widget
; @param r21:r20 ressource id for title
; @return CFLAG set of okay, cleared otherwise
mainWindowCreateContentWidget:
; create content widget
push yl
push yh
mov xl, yl
mov xh, yh
ldi r16, 0 ; opts lo
ldi r17, 0 ; opts hi
bigcall Widget_new
pop yh
pop yl
ret
; @end
; ***************************************************************************
; data in FLASH
MainWindow_DefaultSignalmap:
; header
.dw Widget_DefaultSignalmap ; next table to use
; entries
.db 0, WIDGET_SIGNAL_DRAW, LOW(Widget_OnDrawNop), HIGH(Widget_OnDrawNop)
.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)
.db 0, 0, 0, 0 ; end of table
MainWindow_TitleStyle:
.dw STYLE_WIN_TITLE_FOREGROUND ; frontCol_norm
.dw STYLE_WIN_TITLE_BACKGROUND ; 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, 1 ; outerBorderSize, innerBorderSize
.dw ili9341Font12x16_1*2 ; font
.db 12, 16 ; charWidth, charHeight
#endif