kfar: add mouse double click events, fix mouse in menu

git-svn-id: svn://kolibrios.org@9039 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2021-07-08 20:45:01 +00:00
parent 293a74db28
commit 90de905a60
2 changed files with 144 additions and 94 deletions

View File

@ -151,85 +151,93 @@ align 4
mov eax,SF_MOUSE_GET mov eax,SF_MOUSE_GET
mov ebx,SSF_WINDOW_POSITION mov ebx,SSF_WINDOW_POSITION
int 0x40 int 0x40
cmp ax, word[skinh] cmp ax, word[skinh]
jl .event jl .event
sub ax, word[skinh] sub ax, word[skinh]
xor dx,dx xor dx,dx
mov bx, font_height mov bx, font_height
div bx div bx
movzx edx,ax movzx edx,ax
shr eax,16 shr eax,16
sub eax, 5 ;window border sub eax, 5 ;window border
push edx push edx
xor dx,dx xor dx,dx
mov bx, font_width mov bx, font_width
div bx div bx
movzx eax,ax movzx eax,ax
pop edx pop edx
mov ebx, [esp+24h+8] ;DLGTEMPLATE* dlg mov ebx, [esp+24h+8] ;DLGTEMPLATE* dlg
cmp edx, [ebx+dlgtemplate.y] cmp dword[ebx+dlgtemplate.size], 0
jl .event jne .event ;¥á«¨ ¤¨ «®£®¢®¥ ®ª­® ­¥ áâ ­¤ àâ­®¥ (ᯨ᮪ §­ ç¥­¨©)
cmp eax, [ebx+dlgtemplate.x] cmp edx, [ebx+dlgtemplate.y]
jl .event jl .event
sub edx, [ebx+dlgtemplate.y] cmp eax, [ebx+dlgtemplate.x]
sub eax, [ebx+dlgtemplate.x] jl .event
cmp edx, [ebx+dlgtemplate.height] sub edx, [ebx+dlgtemplate.y]
jge .event sub eax, [ebx+dlgtemplate.x]
cmp eax, [ebx+dlgtemplate.width] cmp edx, [ebx+dlgtemplate.height]
jge .event jge .event
cmp eax, [ebx+dlgtemplate.width]
jge .event
add ebx, dlgtemplate.size+12 add ebx, dlgtemplate.size+12
mov ecx, [ebx-4] mov ecx, [ebx-4]
or ecx, ecx or ecx, ecx
jz .event jz .event
push ebx ecx push ebx ecx
.m_loop: .m_loop:
cmp [ebx+dlgitemtemplate.type], 2 ;button cmp [ebx+dlgitemtemplate.type], 2 ;button
je .m_comp je .m_comp
cmp [ebx+dlgitemtemplate.type], 3 ;edit cmp [ebx+dlgitemtemplate.type], 3 ;edit
je .m_comp je .m_comp
;cmp [ebx+dlgitemtemplate.type], 5 ;check ;cmp [ebx+dlgitemtemplate.type], 5 ;check
;je .m_comp ;je .m_comp
jmp .m_next jmp .m_next
align 4 align 4
.m_comp: .m_comp:
cmp [ebx+dlgitemtemplate.x1], eax cmp [ebx+dlgitemtemplate.x1], eax
jg .m_next jg .m_next
cmp [ebx+dlgitemtemplate.y1], edx cmp [ebx+dlgitemtemplate.y1], edx
jg .m_next jg .m_next
cmp [ebx+dlgitemtemplate.x2], eax cmp [ebx+dlgitemtemplate.x2], eax
jl .m_next jl .m_next
cmp [ebx+dlgitemtemplate.y2], edx cmp [ebx+dlgitemtemplate.y2], edx
jl .m_next jl .m_next
mov eax, [ebx+dlgitemtemplate.flags] cmp [ebx+dlgitemtemplate.type], 2 ;button
and eax, 4 jne @f
jnz .m_old_focus mov [esp+28+8], ebx ;save to eax
mov eax, ebx pop ecx ebx
jmp .m_new_focus jmp .exit
@@:
mov eax, [ebx+dlgitemtemplate.flags]
and eax, 4
jnz .m_old_focus
mov eax, ebx
jmp .m_new_focus
align 4 align 4
.m_next: .m_next:
add ebx, sizeof.DlgBtn add ebx, sizeof.DlgBtn
loop .m_loop loop .m_loop
.m_old_focus: .m_old_focus:
pop ecx ebx pop ecx ebx
jmp .event jmp .event
align 4 align 4
.m_new_focus: .m_new_focus:
pop ecx ebx pop ecx ebx
call DlgClearFocus call DlgClearFocus
or dword[eax+dlgitemtemplate.flags], 4 or dword[eax+dlgitemtemplate.flags], 4
sub ebx, dlgtemplate.size+12 sub ebx, dlgtemplate.size+12
push ebp push ebp
mov ebp, ebx mov ebp, ebx
call ManagerDlgProc.dodraw call ManagerDlgProc.dodraw
pop ebp pop ebp
call draw_image call draw_image
jmp .event jmp .event
align 4 align 4
.exit: .exit:
popad popad
@ -253,10 +261,10 @@ DlgClearFocus:
push ebx ecx push ebx ecx
@@: @@:
and byte [ebx+dlgitemtemplate.flags], not 4 and byte [ebx+dlgitemtemplate.flags], not 4
add ebx, sizeof.DlgBtn add ebx, sizeof.DlgBtn
loop @b loop @b
pop ecx ebx pop ecx ebx
ret ret
; int __stdcall ShowGenericBox(DLGTEMPLATE* dlg, void* DlgProc); ; int __stdcall ShowGenericBox(DLGTEMPLATE* dlg, void* DlgProc);
align 16 align 16
@ -438,6 +446,7 @@ draw_dialog_shadow:
ret ret
; void __stdcall DrawGenericBox(DLGDATA* dlg, void* DlgProc) ; void __stdcall DrawGenericBox(DLGDATA* dlg, void* DlgProc)
align 16
DrawGenericBox: DrawGenericBox:
pushad pushad
mov ebx, [esp+24h] mov ebx, [esp+24h]
@ -720,6 +729,7 @@ restore_console_data:
; int __stdcall menu(void* variants, const char* title, unsigned flags); ; int __stdcall menu(void* variants, const char* title, unsigned flags);
; variants 㪠§ë¢ ¥â ­  ⥪ã騩 í«¥¬¥­â ¢ ¤¢ãá¢ï§­®¬ «¨­¥©­®¬ ᯨ᪥ ; variants 㪠§ë¢ ¥â ­  ⥪ã騩 í«¥¬¥­â ¢ ¤¢ãá¢ï§­®¬ «¨­¥©­®¬ ᯨ᪥
align 16
menu: menu:
pop eax pop eax
push [cur_height] push [cur_height]
@ -734,11 +744,11 @@ menu_centered_in:
pushad pushad
mov ecx, 60 mov ecx, 60
; 40 bytes for dlgtemplate + additional: ; 40 bytes for dlgtemplate + additional:
; +40: dd cur_variant ; +40: dd cur_variant - [???]
; +44: dd num_variants ; +44: dd num_variants - ᪮«ìª® í«¥¬¥­â®¢ ¢« §¨â ¢ ®ª­®
; +48: dd begin_variant ; +48: dd begin_variant - [dd ..,..,???]
; +52: dd end_variant ; +52: dd end_variant - [dd ..,..,???]
; +56: dd cur_variant_idx ; +56: dd cur_variant_idx - ???
call xpgalloc call xpgalloc
test eax, eax test eax, eax
jnz @f jnz @f
@ -749,7 +759,7 @@ menu_centered_in:
@@: @@:
mov ebx, eax mov ebx, eax
mov eax, 1 mov eax, 1
test byte [esp+20h+28], 1 test byte [esp+20h+28], 1 ;unsigned flags
jz @f jz @f
mov al, 3 mov al, 3
@@: @@:
@ -760,7 +770,7 @@ menu_centered_in:
; <EFBFBD> å®¤¨¬ è¨à¨­ã ¨ ¢ëá®âã ®ª­  ; <EFBFBD> å®¤¨¬ è¨à¨­ã ¨ ¢ëá®âã ®ª­ 
xor eax, eax xor eax, eax
xor ecx, ecx xor ecx, ecx
mov esi, [esp+20h+20] mov esi, [esp+20h+20] ;void* variants
mov [ebx+40], esi mov [ebx+40], esi
mov dword [ebx+56], eax mov dword [ebx+56], eax
@@: @@:
@ -889,6 +899,7 @@ menu_centered_in:
popad popad
ret 28 ret 28
align 16
MenuDlgProc: MenuDlgProc:
mov eax, [esp+8] mov eax, [esp+8]
cmp al, 1 cmp al, 1

View File

@ -819,34 +819,39 @@ mouse:
mov eax,SF_MOUSE_GET mov eax,SF_MOUSE_GET
mov ebx,SSF_BUTTON_EXT mov ebx,SSF_BUTTON_EXT
int 0x40 int 0x40
mov byte[mousestate], 1
bt eax,24 ;left but. double click
jc @f
mov byte[mousestate], 0
bt eax,8 ;left but. down bt eax,8 ;left but. down
jnc event jc @f
jmp event
@@:
mov eax,SF_MOUSE_GET mov eax,SF_MOUSE_GET
mov ebx,SSF_WINDOW_POSITION mov ebx,SSF_WINDOW_POSITION
int 0x40 int 0x40
cmp ax, word[skinh] cmp ax, word[skinh]
jl event jl event
sub ax, word[skinh] sub ax, word[skinh]
xor dx,dx xor dx,dx
mov bx, font_height mov bx, font_height
div bx div bx
movzx edx,ax movzx edx,ax
dec edx ;¢¥àå­ïï à ¬ª  dec edx ;¢¥àå­ïï à ¬ª 
dec edx ;§ £®«®¢ª¨ dec edx ;§ £®«®¢ª¨
shr eax,16 shr eax,16
cmp edx, 0 cmp edx, 0
jl .no_ch_pos jl .no_ch_pos
mov ebx, [cur_height] mov ebx, [cur_height]
sub ebx, 3 sub ebx, 3
cmp edx, ebx cmp edx, ebx
je .on_panel je .on_panel
sub ebx, 7-3 sub ebx, 7-3
cmp edx, ebx cmp edx, ebx
jge .no_ch_pos jge .no_ch_pos
push edx eax push edx eax
mov ecx, [cur_width] mov ecx, [cur_width]
if font_width & 3 if font_width & 3
imul ecx, font_width imul ecx, font_width
@ -897,9 +902,14 @@ end if
cmp edx, 0 cmp edx, 0
jl @f jl @f
mov [ebp + PanelData.index], edx mov [ebp + PanelData.index], edx
cmp byte[mousestate], 0
je @f
call panels_OnKey.enter
jmp event
@@: @@:
call draw_panel call draw_panel
jmp event jmp event
align 4
.on_panel: .on_panel:
call get_keybar_ind call get_keybar_ind
lea eax, [panels_mouse+4*eax] lea eax, [panels_mouse+4*eax]
@ -908,7 +918,6 @@ end if
mov ebp, [active_panel] mov ebp, [active_panel]
mov ecx, [ebp + PanelData.index] mov ecx, [ebp + PanelData.index]
call dword[eax] call dword[eax]
@@:
jmp event jmp event
;input: ;input:
@ -958,7 +967,7 @@ get_keybar_ind:
inc edx inc edx
@@: @@:
cmp edx, edi cmp edx, edi
ja .ret ja .ret
cmp edx, [cur_width] cmp edx, [cur_width]
ja .ret ja .ret
cmp ecx, 12 cmp ecx, 12
@ -970,10 +979,18 @@ get_keybar_ind:
inc ecx inc ecx
jmp .l jmp .l
.ret: .ret:
lea eax, [esi+ecx-1] lea eax, [esi+ecx-1]
pop edi esi edx ecx ebx pop edi esi edx ecx ebx
ret ret
align 4
OnMouse_ctrl_f39:
sub eax, panels_mouse.ctrl+8
shr eax, 2
add eax, 0x3D
call panels_OnKey.ctrl_f39
ret
align 16 align 16
process_ctrl_keys: process_ctrl_keys:
cmp byte [esi], 0 cmp byte [esi], 0
@ -1106,6 +1123,7 @@ enum_associations_callback:
xor eax, eax xor eax, eax
ret 16 ret 16
align 4
enum_plugins_callback: enum_plugins_callback:
; LongBool __stdcall callback(f_name,sec_name,key_name,key_value); ; LongBool __stdcall callback(f_name,sec_name,key_name,key_value);
; [esp+4] = f_name, [esp+8] = sec_name, [esp+12] = key_name, [esp+16] = key_value ; [esp+4] = f_name, [esp+8] = sec_name, [esp+12] = key_name, [esp+16] = key_value
@ -3478,6 +3496,7 @@ close_plugin_panels:
jnz @b jnz @b
ret ret
align 4
close_plugin_panel: close_plugin_panel:
; close plugin and restore old directory ; close plugin and restore old directory
mov esi, [ebp + PanelData.parents] mov esi, [ebp + PanelData.parents]
@ -3515,6 +3534,7 @@ close_plugin_panel:
@@: @@:
pop ebx edx pop ebx edx
align 4
close_handle_if_unused: close_handle_if_unused:
; edx=hPlugin, ebx=hFile ; edx=hPlugin, ebx=hFile
push ebp push ebp
@ -3534,6 +3554,7 @@ close_handle_if_unused:
pop ebp pop ebp
ret ret
align 4
panels_IsHandleUsed: panels_IsHandleUsed:
; edx=hPlugin, ebx=hFile ; edx=hPlugin, ebx=hFile
mov ebp, panel1 mov ebp, panel1
@ -3570,6 +3591,7 @@ panels_IsHandleUsed:
inc esi inc esi
ret ret
align 4
panels_OnExit: panels_OnExit:
; close plugin panels ; close plugin panels
mov ebp, panel1 mov ebp, panel1
@ -3578,6 +3600,7 @@ panels_OnExit:
call close_plugin_panels call close_plugin_panels
ret ret
align 4
panels_OnRedraw: panels_OnRedraw:
or [cursor_x], -1 or [cursor_x], -1
or [cursor_y], -1 or [cursor_y], -1
@ -3590,6 +3613,7 @@ panels_OnRedraw:
call draw_panel call draw_panel
ret ret
align 4
init_console: init_console:
mov ecx, [console_data_ptr] mov ecx, [console_data_ptr]
call pgfree call pgfree
@ -3624,12 +3648,15 @@ init_console:
mov [panel2.height], eax mov [panel2.height], eax
ret ret
align 4
get_curfile_folder_entry: get_curfile_folder_entry:
mov ecx, [ebp + PanelData.index] mov ecx, [ebp + PanelData.index]
shl ecx, 2 shl ecx, 2
add ecx, [ebp + PanelData.files] add ecx, [ebp + PanelData.files]
mov ecx, [ecx] mov ecx, [ecx]
ret ret
align 4
get_curfile_name: get_curfile_name:
call get_curfile_folder_entry call get_curfile_folder_entry
add ecx, 40 add ecx, 40
@ -4970,6 +4997,7 @@ end if
sub ecx, edi sub ecx, edi
ret 8 ret 8
align 4
get_file_color: get_file_color:
mov ah, [esi + 6] mov ah, [esi + 6]
cmp ebp, [active_panel] cmp ebp, [active_panel]
@ -4989,6 +5017,7 @@ get_file_color:
@@: @@:
ret ret
align 4
draw_name_column: draw_name_column:
mov eax, [column_index] mov eax, [column_index]
mov [last_column_index], eax mov [last_column_index], eax
@ -5151,6 +5180,7 @@ draw_name_column:
draw_empty_column: draw_empty_column:
ret ret
align 4
draw_size_column: draw_size_column:
add edi, [column_width] add edi, [column_width]
add edi, [column_width] add edi, [column_width]
@ -5295,6 +5325,7 @@ end if
cld cld
ret ret
align 4
draw_date_column: draw_date_column:
mov ecx, [column_height] mov ecx, [column_height]
dec ecx dec ecx
@ -5361,6 +5392,7 @@ draw_date_column:
cld cld
ret ret
align 4
draw_time_column: draw_time_column:
mov ecx, [column_height] mov ecx, [column_height]
dec ecx dec ecx
@ -5445,6 +5477,7 @@ draw_time_column:
;@@: pop esi ;@@: pop esi
; ret ; ret
align 4
read_folder: read_folder:
mov eax, [ebp + PanelData.nfa] mov eax, [ebp + PanelData.nfa]
mov [dirinfo.size], eax mov [dirinfo.size], eax
@ -7530,8 +7563,12 @@ panels_mouse:
rd 4 rd 4
dd panels_OnKey.shift_f5 dd panels_OnKey.shift_f5
rd 7 rd 7
; Ctrl .ctrl:
rd 12 rd 2
repeat 9-3+1
dd OnMouse_ctrl_f39
end repeat
rd 3
; Ctrl+Shift ; Ctrl+Shift
rd 12 rd 12
; Alt ; Alt
@ -7929,6 +7966,8 @@ FolderShortcuts dd 0,0,0,0,0,0,0,0,0,0
bWasE0 db 0 bWasE0 db 0
ctrlstate db 0 ctrlstate db 0
mousestate db 0
align 4
MemForImage dd 0 MemForImage dd 0
restore_semicolon dd 0 restore_semicolon dd 0
bForHex db 0 bForHex db 0