end: use blue checkbox, code refactoring, UI/UX improvements

git-svn-id: svn://kolibrios.org@9456 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2021-12-22 11:32:12 +00:00
parent 5a5ad5a64e
commit 770f4559be
2 changed files with 174 additions and 238 deletions

View File

@ -1,69 +1,68 @@
empty_label: db ' ',0 WIN_W = 440
WIN_H = 200
BOT_PANEL_H = 70
;---------------------------------------------------------------------
CANCEL_BUTTON_ID = 1+BT_HIDE
HOME_BUTTON_ID = 2
REBOOT_BUTTON_ID = 3
POWEROFF_BUTTON_ID = 4
CHECKBOX_BUTTON_ID = 5+BT_HIDE
;---------------------------------------------------------------------
TEXT_HOME: db 'Home',0 TEXT_HOME: db 'Home',0
TEXT_ENTER: db 'Enter',0 TEXT_ENTER: db 'Enter',0
TEXT_END: db 'End',0 TEXT_END: db 'End',0
TEXT_CANCEL: db 'x',0 TEXT_CANCEL: db 'x',0
;---------------------------------------------------------------------
strlen_var dd 0
if lang eq ru if lang eq ru
TEXT_TITLE: db '<27>╞骭平言 <20>碲',0 TEXT_WTITLE: db '<27>╞骭平言 <20>碲',0
TEXT_RDSAVE1: db '‘®åà ­¨âì ¨§¬¥­¥­¨ï, ᤥ« ­­ë¥ ¢',0 TEXT_RDSAVE1: db '‘®åà ­¨âì ¨§¬¥­¥­¨ï, ᤥ« ­­ë¥ ¢',0
TEXT_RDSAVE2: db '¯à®æ¥áᥠࠡ®âë ¢ á¨á⥬¥ (Ctrl+S)',0 TEXT_RDSAVE2: db '¯à®æ¥áᥠࠡ®âë ¢ á¨á⥬¥ (Ctrl+S)',0
TEXT_KERNEL: db 'Ÿ¤à®',0 TEXT_KERNEL: db 'Ÿ¤à®',0
TEXT_REBOOT: db '<27>¥à¥§ £à㧪 ',0 TEXT_REBOOT: db '<27>¥à¥§ £à㧪 ',0
TEXT_OFF: db '‚몫î祭¨¥',0 TEXT_OFF: db '‚몫î祭¨¥',0
TEXT_SAVING: db '䴴樈<E4B4B4>平言 恣<><E681A3>...',0
else if lang eq ge else if lang eq ge
TEXT_TITLE: db 'Shutdown computer',0 TEXT_WTITLE: db 'Shutdown computer',0
TEXT_RDSAVE1: db 'Save all changes that were done',0 TEXT_RDSAVE1: db 'Save all changes that were done',0
TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0 TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0
TEXT_KERNEL: db 'Kernel',0 TEXT_KERNEL: db 'Kernel',0
TEXT_REBOOT: db 'Neustart',0 TEXT_REBOOT: db 'Neustart',0
TEXT_OFF: db 'Beenden',0 TEXT_OFF: db 'Beenden',0
TEXT_SAVING: db 'Saving RAM-drive...',0
else if lang eq it else if lang eq it
TEXT_TITLE: db 'Shutdown computer',0 TEXT_WTITLE: db 'Shutdown computer',0
TEXT_RDSAVE1: db 'Save all changes that were done',0 TEXT_RDSAVE1: db 'Save all changes that were done',0
TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0 TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0
TEXT_KERNEL: db 'Kernel',0 TEXT_KERNEL: db 'Kernel',0
TEXT_REBOOT: db 'Riavvio',0 TEXT_REBOOT: db 'Riavvio',0
TEXT_OFF: db 'Spegni',0 TEXT_OFF: db 'Spegni',0
TEXT_SAVING: db 'Saving RAM-drive...',0
else else
TEXT_TITLE: db 'Shutdown computer',0 TEXT_WTITLE: db 'Shutdown computer',0
TEXT_RDSAVE1: db 'Save all changes that were done',0 TEXT_RDSAVE1: db 'Save all changes that were done',0
TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0 TEXT_RDSAVE2: db 'during system work (Ctrl+S)',0
TEXT_KERNEL: db 'Kernel',0 TEXT_KERNEL: db 'Kernel',0
TEXT_REBOOT: db 'Reboot',0 TEXT_REBOOT: db 'Reboot',0
TEXT_OFF: db 'Power off',0 TEXT_OFF: db 'Power off',0
TEXT_SAVING: db 'Saving RAM-drive...',0
end if end if
;---------------------------------------------------------------------
rdsave: rdsave:
dd SSF_START_APP,0,hide,0,0 dd SSF_START_APP,0,hide,0,0
db '/sys/rdsave',0 db '/sys/rdsave',0
hide db 'h',0
asettings db 'settings',0
aautosave db 'autosave',0
ini_file db '/sys/settings/rdsave.ini',0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;Lib_DATA ;Lib_DATA
system_dir_Boxlib db '/sys/lib/box_lib.obj',0
system_dir_libini db '/sys/lib/libini.obj',0 system_dir_libini db '/sys/lib/libini.obj',0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
l_libs_start: l_libs_start:
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, Box_lib_import
library02 l_libs system_dir_libini+9, library_path, system_dir_libini, libini_import library02 l_libs system_dir_libini+9, library_path, system_dir_libini, libini_import
end_l_libs: end_l_libs:
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
Box_lib_import:
init_checkbox dd aInit_checkbox
check_box_draw dd aCheck_box_draw
check_box_mouse dd aCheck_box_mouse
;version_ch2 dd aVersion_ch2
dd 0,0
aInit_checkbox db 'init_checkbox2',0
aCheck_box_draw db 'check_box_draw2',0
aCheck_box_mouse db 'check_box_mouse2',0
;aVersion_ch2 db 'version_ch2',0
;---------------------------------------------------------------------
align 4
libini_import: libini_import:
init_lib dd a_init init_lib dd a_init
ini_get_int dd aini_get_int ini_get_int dd aini_get_int
@ -73,36 +72,6 @@ a_init db 'lib_init',0
aini_get_int db 'ini_get_int',0 aini_get_int db 'ini_get_int',0
aini_set_int db 'ini_set_int',0 aini_set_int db 'ini_set_int',0
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
checkbox_sharedname db 'CHECKBOX',0
check1 check_box2 32 shl 16 +15, 70 shl 16 +15,6,0xffffff,0x757575,0x00CC00, empty_label, ch_flag_middle checkbox_img dd ?
;---------------------------------------------------------------------
hide db 'h',0
asettings db 'settings',0
aautosave db 'autosave',0
ini_file db '/sys/settings/rdsave.ini',0
If fade=1
color21 dd 0x01505890
color22 dd 0xbfbfbf
color23 dd 0xa49fa1
color24 dd 0x590011
color25 dd 0x593700
color26 dd 0x373737
color27 dd 0x003700
color28 dd 0x90bfbfbf
else
if lang eq ru
label7:
db '䴴樈<E4B4B4>平言 恣<><E681A3>...',0
else
label7:
db 'Saving RAM-drive...',0
end if
end if

View File

@ -1,9 +1,6 @@
; END ; END
; KolibriOS Team 2005-2021 ; KolibriOS Team 2005-2021
fade equ 0
use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à  use32 ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
org 0x0 ;  ¤à¥á æ¨ï á ­ã«ï org 0x0 ;  ¤à¥á æ¨ï á ­ã«ï
@ -14,7 +11,7 @@ dd IM_END ; ࠧ
dd I_END ; ª®«¨ç¥á⢮ ¯ ¬ï⨠dd I_END ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
dd stacktop ;  ¤à¥á ¢¥à設ë á⥪  dd stacktop ;  ¤à¥á ¢¥à設ë á⥪ 
dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢ dd 0x0 ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢
dd cur_dir_path dd 0x0
include 'lang.inc' include 'lang.inc'
include '../../../macros.inc' include '../../../macros.inc'
@ -22,66 +19,39 @@ include '../../../proc32.inc'
include '../../../dll.inc' include '../../../dll.inc'
include '../../../KOSfuncs.inc' include '../../../KOSfuncs.inc'
include '../../../load_lib.mac' include '../../../load_lib.mac'
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
include '../../../gui_patterns.inc' include '../../../gui_patterns.inc'
include "../../../string.inc" include '../../../string.inc'
WIN_W equ 440
WIN_H equ 200
BOT_PANEL_H equ 70
CANCEL_BUTTON_ID equ 1+BT_HIDE
HOME_BUTTON_ID equ 2
REBOOT_BUTTON_ID equ 3
POWEROFF_BUTTON_ID equ 4
@use_library @use_library
align 4
START: START:
mcall SF_SYS_MISC, SSF_HEAP_INIT
mcall SF_SYS_MISC, SSF_MEM_OPEN, checkbox_sharedname
mov [checkbox_img], eax
load_libraries l_libs_start,end_l_libs
load_libraries l_libs_start,end_l_libs
inc eax inc eax
test eax,eax test eax,eax
jz close jz close
stdcall [init_checkbox], check1 stdcall dll.Init,[init_lib]
stdcall dll.Init,[init_lib] invoke ini_get_int,ini_file,asettings,aautosave,0
invoke ini_get_int,ini_file,asettings,aautosave,0
mov [autosave],eax mov [autosave],eax
dec eax
jnz @f
bts dword [check1.flags],1
@@:
mcall SF_SET_EVENTS_MASK,0x80000027
redraw: redraw:
call draw_window call draw_window
still: still:
mov al,SF_WAIT_EVENT mcall SF_WAIT_EVENT ;wait here for event
mcall ;wait here for event
dec eax dec eax
jz redraw jz redraw
dec eax dec eax
jz key jz key
dec eax dec eax
jz button jz button
stdcall [check_box_mouse], check1
bt dword [check1.flags],1
jnc @f
mov [autosave],1
jmp still
@@:
mov [autosave],0
jmp still jmp still
key: key:
mov al,SF_GET_KEY mcall SF_GET_KEY ;get key code
mcall ;get key code
mov al,ah mov al,ah
cmp al,13 cmp al,13
je restart je restart
@ -121,27 +91,11 @@ restart_kernel:
push 4 push 4
mcall_and_close: mcall_and_close:
if fade=1
; === FADE IN ===
mov eax, color1
@@:
mov ebx, [eax + 32]
mov [eax], ebx
add eax, 4
cmp eax, color21
jne @b
call draw_window
end if
invoke ini_set_int,ini_file,asettings,aautosave,[autosave] invoke ini_set_int,ini_file,asettings,aautosave,[autosave]
cmp [autosave],1 cmp [autosave],1
jne no_save jne no_save
if fade=0 mcall SF_DRAW_TEXT,<55,108>,0x90FF990A,TEXT_SAVING
mov al,SF_DRAW_TEXT
mcall ,<50,120> ,0x800000cc,label7
end if
mcall SF_FILE,rdsave mcall SF_FILE,rdsave
test eax,eax test eax,eax
@ -168,21 +122,20 @@ no_save:
ret ret
checkbox: checkbox:
btc dword [check1.flags],1 cmp [autosave],1
jc .1 je .1
mov [autosave],1 mov [autosave],1
jmp .draw jmp .draw
.1: .1:
mov [autosave],0 mov [autosave],0
.draw: .draw:
stdcall [check_box_draw], check1 call draw_checkbox_flag
jmp still jmp still
draw_window: draw_window:
mcall SF_REDRAW,SSF_BEGIN_DRAW mcall SF_REDRAW,SSF_BEGIN_DRAW
mov al,SF_GET_SCREEN_SIZE mcall SF_GET_SCREEN_SIZE
mcall ;get screen max x & max y
movzx ecx,ax movzx ecx,ax
shr eax,17 shr eax,17
shl eax,16 shl eax,16
@ -196,66 +149,80 @@ draw_window:
mcall ;define and draw window mcall ;define and draw window
DrawWideRectangle 0, 0, WIN_W, WIN_H, 2, 0xA3A7AA DrawWideRectangle 0, 0, WIN_W, WIN_H, 2, 0xA3A7AA
DrawBar 2, 2, WIN_W-4, WIN_H-BOT_PANEL_H-2, 0x202020 mcall SF_DRAW_RECT, <2,WIN_W-4>, <2,WIN_H-BOT_PANEL_H-2>, 0x202020
DrawBar 2, WIN_H-BOT_PANEL_H-2, WIN_W-4, BOT_PANEL_H, 0x4B4B4B mcall SF_DRAW_RECT, <2,WIN_W-4>, <WIN_H-BOT_PANEL_H-2,BOT_PANEL_H>, 0x4B4B4B
WriteText 30, 27, 10010001b, 0xFFFfff, TEXT_TITLE
WriteText 55, 70, 10010000b, 0xFFFfff, TEXT_RDSAVE1
WriteText 55, 86, 10010000b, 0xFFFfff, TEXT_RDSAVE2
DefineButton WIN_W-33, 2, 32, 20, CANCEL_BUTTON_ID, 0 mcall SF_DRAW_TEXT, <30,27>, 0x91FFFfff, TEXT_WTITLE
WriteText WIN_W-23, 5, 10000001b, 0xFFFfff, TEXT_CANCEL mcall SF_DRAW_TEXT, <55,70>, 0x90FFFfff, TEXT_RDSAVE1
mcall SF_DRAW_TEXT, <55,86>, 0x90FFFfff, TEXT_RDSAVE2
mcall SF_DRAW_TEXT, <WIN_W-23,5>, 0x81FFFfff, TEXT_CANCEL
stdcall [check_box_draw], check1 mcall SF_DEFINE_BUTTON, <WIN_W-35,32>, <2,22>, CANCEL_BUTTON_ID
mcall SF_DEFINE_BUTTON, <32,14>, <70,14>, CHECKBOX_BUTTON_ID
mcall SF_DEFINE_BUTTON, <47,WIN_W-47>, <68,34>, CHECKBOX_BUTTON_ID+BT_NOFRAME
;DefineButton WIN_W-33, 2, 32, 20, CANCEL_BUTTON_ID, 0
;DefineButton 32, 70, 14, 14, CHECKBOX_BUTTON_ID, 0
;DefineButton 47, 68, WIN_W-47, 34, CHECKBOX_BUTTON_ID+BT_NOFRAME, 0
DrawRectangle3D 32, 70, 14, 14, 0x606060, 0xAFAFAF
call draw_checkbox_flag
macro EndButton x, bgcol, id, but_text, hotkey_text stdcall EndButton, 20, 0x4E91C5, HOME_BUTTON_ID, TEXT_KERNEL, TEXT_HOME
{ stdcall EndButton, 160, 0x55C891, REBOOT_BUTTON_ID, TEXT_REBOOT, TEXT_ENTER
buty equ WIN_H-60 stdcall EndButton, 300, 0xC75C54, POWEROFF_BUTTON_ID, TEXT_OFF, TEXT_END
butw equ 116
buth equ 43 mcall SF_REDRAW,SSF_END_DRAW
DrawWideRectangle x-3, buty-3, butw+6, buth+6, 3, 0x202020 ret
DefineButton x, buty, butw-1, buth-1, id, bgcol
; WriteTextBold -strlen(but_text)*8 + butw / 2 + x, buty+8, 10010000b, 0xFFFfff, but_text proc EndButton x, bgcol, id, but_text, hotkey_text
; WriteText -strlen(but_text)*6 + butw / 2 + x, buty+26, 10000000b, 0xFFFfff, hotkey_text BUTY = WIN_H-60
stdcall string.length, but_text BUTW = 116
mov ebx,eax mov ebx,[x]
imul ebx,4 sub ebx,3
neg ebx mcall SF_DRAW_RECT, <ebx,BUTW+6>, <BUTY-3,43+6>, 0x202020
add ebx,butw / 2 + x mcall SF_DEFINE_BUTTON, <[x],BUTW>, <BUTY,43-1>, [id], [bgcol]
shl ebx,16 ; -strlen(but_text)*8 + BUTW / 2 + x, BUTY+8
add ebx,buty+8 stdcall string.length, [but_text]
mcall SF_DRAW_TEXT, , 10010000b shl 24 + 0xFFFfff, but_text neg eax
lea ebx,[eax*4+BUTW/2]
add ebx,[x]
mcall SF_DRAW_TEXT, <ebx,BUTY+8>, 0x90FFFfff, [but_text]
add ebx,1 shl 16 add ebx,1 shl 16
mcall mcall
stdcall string.length, hotkey_text stdcall string.length, [hotkey_text]
mov ebx,eax neg eax
imul ebx,3 lea ebx,[eax*3+BUTW/2]
neg ebx add ebx,[x]
add ebx,butw / 2 + x
shl ebx,16 shl ebx,16
add ebx,buty+26 add ebx,BUTY+26
mcall SF_DRAW_TEXT, , 10000000b shl 24 + 0xFFFfff, hotkey_text mcall SF_DRAW_TEXT, , 0x80FFFfff, [hotkey_text]
} ret
endp
EndButton 20, 0x4E91C5, HOME_BUTTON_ID, TEXT_KERNEL, TEXT_HOME draw_checkbox_flag:
EndButton 160, 0x55C891, REBOOT_BUTTON_ID, TEXT_REBOOT, TEXT_ENTER cmp [autosave],0
EndButton 300, 0xC75C54, POWEROFF_BUTTON_ID, TEXT_OFF, TEXT_END je .flag_unset
cmp [checkbox_img],0
mov al,SF_REDRAW je .flag_set_but_no_checkbox_img
mcall ,SSF_END_DRAW .flag_set:
mcall SF_PUT_IMAGE, [checkbox_img], <13,13>, <33,71>
ret
.flag_set_but_no_checkbox_img:
mcall SF_DRAW_RECT, <33,13>, <71,13>, 0xffffff
mcall SF_DRAW_RECT, <34,11>, <72,11>, 0x58C33C
ret
.flag_unset:
DrawRectangle3D 33, 71, 12, 12, 0xDDDddd, 0xffffff
mcall SF_DRAW_RECT, <34,12>, <72,12>, 0xFFFfff
ret ret
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
;data
include 'data.inc' include 'data.inc'
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
IM_END: IM_END:
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 4 align 4
proc_info rb 1024 proc_info rb 1024
autosave rd 1 autosave rd 1
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
cur_dir_path rb 4096
library_path rb 4096 library_path rb 4096
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
align 32 align 32