303 lines
8.4 KiB
NASM
303 lines
8.4 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
|
|
|
|
|
|
; ***************************************************************************
|
|
; defines
|
|
|
|
.equ MAINWINDOW_OFFS_BEGIN = VLAYOUT_SIZE
|
|
; no data for now
|
|
.equ MAINWINDOW_SIZE = MAINWINDOW_OFFS_BEGIN+0
|
|
|
|
|
|
; index of sub-windows
|
|
.equ MAINWINDOW_CHILDIDX_TITLE = 0
|
|
.equ MAINWINDOW_CHILDIDX_CONTENT = 1
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; 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
|
|
; @param r17 value for WIDGET_OFFS_PACK
|
|
; @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 r16 value for OBJECT_OFFS_OPTS
|
|
; @param r17 value for WIDGET_OFFS_PACK
|
|
; @param r21:r20 ressource id for title
|
|
; @clobbers r16, r17, X
|
|
|
|
MainWindow_Init:
|
|
push r20
|
|
push r21
|
|
; call base class
|
|
ldi r20, VLAYOUT_MODE_EXPAND
|
|
bigcall VLayout_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
|
|
|
|
; set style which has no spacing and no borders so needs no drawing because
|
|
; the children fill the screen completely
|
|
ldi r16, LOW(MainWindow_DefaultStyle*2)
|
|
std Y+WIDGET_OFFS_STYLE_LO, r16
|
|
ldi r16, HIGH(MainWindow_DefaultStyle*2)
|
|
std Y+WIDGET_OFFS_STYLE_HI, r16
|
|
|
|
bigcall Widget_SetFullScreen ; (R16)
|
|
|
|
; create sub widgets
|
|
rcall mainWindowCreateTitleWidget
|
|
rcall mainWindowCreateContentWidget
|
|
|
|
ret
|
|
; @end
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
; @routine MainWindow_GetContentWidget @global
|
|
;
|
|
; @param Y address of widget
|
|
; @param X parent widget (if any)
|
|
; @return CFLAG set, if found, cleared otherwise
|
|
; @return r19:r18 resulting object
|
|
; @clobbers r16
|
|
|
|
MainWindow_GetContentWidget:
|
|
ldi r16, MAINWINDOW_CHILDIDX_CONTENT
|
|
bigcall OBJ_GetChildAt
|
|
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 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_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_BEGIN<<WIDGET_PACK_VSELF0_BIT) | \
|
|
(WIDGET_PACK_BEGIN <<WIDGET_PACK_HCONTENT0_BIT) | (WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT)
|
|
bigcall Label_new
|
|
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)
|
|
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
|
|
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
|
|
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
|
|
; @end
|
|
|
|
|
|
|
|
|
|
|
|
; ***************************************************************************
|
|
; data in FLASH
|
|
|
|
MainWindow_DefaultSignalmap:
|
|
; header
|
|
.dw VLayout_DefaultSignalmap*2 ; 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_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
|
|
.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 2, 1 ; outerBorderSize, innerBorderSize
|
|
.dw ili9341Font12x16_1*2 ; font
|
|
.db 12, 16 ; charWidth, charHeight
|
|
|
|
|
|
|
|
; this is the defining style for most windows because normally
|
|
; the style of the parent will be propagated to newly created child widgets.
|
|
|
|
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
|
|
|