gui: more work on dialogs.

This commit is contained in:
Martin Preuss
2026-05-08 12:20:43 +02:00
parent b0d9c46d87
commit d149c5667f
3 changed files with 67 additions and 11 deletions

View File

@@ -66,6 +66,8 @@ CDialog_Init:
ldd zh, Y+CDIALOG_OFFS_CONFIG_HI
push yl ; main window
push yh
ldi r16, 0
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT)
bigcall CWidget_Create
pop yh
pop yl

View File

@@ -72,6 +72,8 @@
; @param Y pointer to target object for signals emitted by child widgets
; @param X pointer to window to become parent for the new widget
; @param Z pointer to dialog configuration
; @param r16 value for OBJECT_OFFS_OPTS
; @param r17 value for WIDGET_OFFS_PACK
; @return CFLAG set of okay, cleared otherwise
; @return Y pointer to created content widget
@@ -133,29 +135,30 @@ CWidget_CreateChildWidgets_ret:
; @param Y pointer to main window
; @param X pointer to content window of MainWindow (is a VLayout, becomes parent)
; @param Z pointer to dialog configuration
; @param r16 value for OBJECT_OFFS_OPTS
; @param r17 value for WIDGET_OFFS_PACK
; @return CFLAG set of okay, cleared otherwise
; @return Y pointer to created content widget
; @clobbers any, !Z
cWidgetMkMainWidget:
lpm r16, Z
cpi r16, CWIDGETCFG_MAINWIDGET_TYPE_NEXT
lpm r18, Z
cpi r18, CWIDGETCFG_MAINWIDGET_TYPE_NEXT
brcc cWidgetMkMainWidget_ret
dec r16
dec r18
clr r17
ldi r18, LOW(cWidgetMkMainWidget_table)
ldi r19, HIGH(cWidgetMkMainWidget_table)
add r18, r16
adc r19, r17
; determine location in calltable
clr r19
ldi r20, LOW(cWidgetMkMainWidget_table)
ldi r21, HIGH(cWidgetMkMainWidget_table)
add r18, r20
adc r19, r21
; prepare params, opts and pack
; prepare params
adiw zh:zl, CWIDGETCFG_OFFS_HEADER_PARAM1
lpm r20, Z+
lpm r21, Z
sbiw zh:zl, (CWIDGETCFG_OFFS_HEADER_PARAM1+1)
ldi r16, 0 ; OPTS
ldi r17, (WIDGET_PACK_FILLED<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_FILLED<<WIDGET_PACK_VSELF0_BIT) ; PACK
push zl
push zh

View File

@@ -70,8 +70,20 @@ Dialog_Init_ret:
Dialog_AddDefaultButtons:
bigcall MainWindow_GetContentWidget ; r19:r18=content window
brcc Dialog_AddDefaultButtons_ret
mov xl, r18 ; use content window as parent
mov xh, r19
ldi r16, 0 ; OPTS
ldi r17, (WIDGET_PACK_END<<WIDGET_PACK_HSELF0_BIT) | (WIDGET_PACK_END<<WIDGET_PACK_VSELF0_BIT) ; PACK
push zl
push zh
ldi zl, LOW(Dialog_ButtonsConfig*2)
ldi zh, HIGH(Dialog_ButtonsConfig*2)
bigcall CWidget_Create
pop zh
pop zl
ret
; create HLayout
push yl
@@ -188,6 +200,45 @@ Dialog_OnAbort:
; ***************************************************************************
; data in FLASH
Dialog_ButtonsConfig:
.db CWIDGETCFG_MAINWIDGET_TYPE_HLAYOUT, 0 ; TYPE, FLAGS
.dw (Dialog_HLayoutStyle*2) ; STYLE
.db HLAYOUT_MODE_EXPAND, 0 ; PARAM1, PARAM2
; ok button
.db CWIDGETCFG_WIDGET_TYPE_TEXTBUTTON, 0 ; TYPE, FLAGS
.db DIALOG_SEL_OKBUTTON, 0 ; SELECTOR, RESERVED
.db (1<<WIDGET_OPTS_BORDER_BIT), \
(WIDGET_PACK_END<<WIDGET_PACK_HSELF0_BIT) | \
(WIDGET_PACK_END<<WIDGET_PACK_VSELF0_BIT) | \
(WIDGET_PACK_CENTER<<WIDGET_PACK_HCONTENT0_BIT) | \
(WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT) ; OPTS, PACK
.dw (DefaultStyle_SpacyButton*2) ; STYLE
.dw RESSOURCE_TXT_DIALOGOK ; PARAM1, PARAM2 (text ressource)
.db DIALOG_SEL_OKBUTTON, BUTTON_MODE_NORMAL ; PARAM3, PARAM4
.dw 0, 0 ; MINVAL, MAXVAL
; abort button
.db CWIDGETCFG_WIDGET_TYPE_TEXTBUTTON, 0 ; TYPE, FLAGS
.db DIALOG_SEL_ABORTBUTTON, 0 ; SELECTOR, RESERVED
.db (1<<WIDGET_OPTS_BORDER_BIT), \
(WIDGET_PACK_END<<WIDGET_PACK_HSELF0_BIT) | \
(WIDGET_PACK_END<<WIDGET_PACK_VSELF0_BIT) | \
(WIDGET_PACK_CENTER<<WIDGET_PACK_HCONTENT0_BIT) | \
(WIDGET_PACK_CENTER<<WIDGET_PACK_VCONTENT0_BIT) ; OPTS, PACK
.dw (DefaultStyle_SpacyButton*2) ; STYLE
.dw RESSOURCE_TXT_DIALOGABORT ; PARAM1, PARAM2 (text ressource)
.db DIALOG_SEL_ABORTBUTTON, BUTTON_MODE_NORMAL ; PARAM3, PARAM4
.dw 0, 0 ; MINVAL, MAXVAL
; end of configuration
.dw 0
; @end
; ---------------------------------------------------------------------------
; @data Dialog_HLayoutStyle