From 7872f731985c86313b0a724103b0c1dae8ce3ca2 Mon Sep 17 00:00:00 2001 From: "Mihail Semenyako (mike.dld)" Date: Sun, 27 Dec 2009 18:37:14 +0000 Subject: [PATCH] * gui/button.inc refactoring * only 16 ID bits were checked on button delete, 24 now * negative button frame draw speed up git-svn-id: svn://kolibrios.org@1334 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/syscall.inc | 2 +- kernel/trunk/gui/button.inc | 1261 ++++++++++++++++----------------- kernel/trunk/kernel.asm | 2 +- 3 files changed, 620 insertions(+), 645 deletions(-) diff --git a/kernel/trunk/core/syscall.inc b/kernel/trunk/core/syscall.inc index 3bb000f189..d4c6611fd5 100644 --- a/kernel/trunk/core/syscall.inc +++ b/kernel/trunk/core/syscall.inc @@ -190,7 +190,7 @@ iglobal dd delay_hs ; 5-DelayHs dd syscall_openramdiskfile ; 6-OpenRamdiskFile dd syscall_putimage ; 7-PutImage - dd sys_button ; 8-DefineButton + dd syscall_button ; 8-DefineButton dd sys_cpuusage ; 9-GetProcessInfo dd sys_waitforevent ; 10-WaitForEvent dd sys_getevent ; 11-CheckForEvent diff --git a/kernel/trunk/gui/button.inc b/kernel/trunk/gui/button.inc index ad5e13f68c..63f3b797e5 100644 --- a/kernel/trunk/gui/button.inc +++ b/kernel/trunk/gui/button.inc @@ -1,643 +1,618 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; -;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; -;; Distributed under terms of the GNU General Public License ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -$Revision$ - - -max_buttons=4095 -dececx: - push edx - push ecx - - mov edx,2 - .loop: - - cmp byte [esp+edx],0x20 - jae @f - mov [esp+edx],byte 0x20 - @@: - sub [esp+edx],byte 0x20 - - dec edx - jns .loop - - pop ecx - pop edx - ret - -incecx: - push edx - push ecx - - mov edx,2 - .loop: - - cmp byte [esp+edx],0xdf - jbe @f - mov [esp+edx],byte 0xdf - @@: - add [esp+edx],byte 0x20 - - dec edx - jns .loop - pop ecx - pop edx - ret - -incecx2: - push edx - push ecx - - mov edx,2 - .loop: - - cmp byte [esp+edx],0xeb - jbe @f - mov [esp+edx],byte 0xeb - @@: - add [esp+edx],byte 0x14 - - dec edx - jns .loop - pop ecx - pop edx - ret - -drawbuttonframes: - - push esi - push edi - push eax - push ebx - push ecx - push edx - - shr ebx,16 - shr ecx,16 - mov eax,[TASK_BASE] - - add ebx,[eax-twdw + WDATA.box.left] - add ecx,[eax-twdw + WDATA.box.top] - mov eax, ebx - shl eax, 16 - mov ax, bx - add ax, word [esp+8] - mov ebx, ecx - shl ebx, 16 - mov bx, cx - push ebx - xor edi, edi - mov ecx, esi - call incecx - call [draw_line] - - movzx edx,word [esp+4+4] - add ebx,edx - shl edx,16 - add ebx,edx - mov ecx,esi - call dececx - call [draw_line] - - pop ebx - push edx - mov edx,eax - shr edx,16 - mov ax,dx - mov edx,ebx - shr edx,16 - mov bx,dx - mov dx,[esp+4+4] - add bx,dx - pop edx - mov ecx,esi - call incecx - call [draw_line] - - mov dx,[esp+8] - add ax,dx - shl edx,16 - add eax,edx - add ebx,1*65536 - mov ecx,esi - call dececx - call [draw_line] - - pop edx - pop ecx - pop ebx - pop eax - pop edi - pop esi - - ret - -button_dececx: - - cmp [buttontype],dword 1 - jne .finish -; je bdece -; ret -; bdece: - push eax - mov eax,0x01 - cmp edi,20 - jg @f - mov eax,0x02 - @@: - test ecx,0xff - jz @f - sub ecx,eax - @@: - shl eax,8 - test ecx,0xff00 - jz @f - sub ecx,eax - @@: - shl eax,8 - test ecx,0xff0000 - jz @f - sub ecx,eax - @@: - pop eax - .finish: - ret - - -sys_button: - - mov eax, [current_slot] - rol ebx, 16 - add bx, word [eax+APPDATA.wnd_clientbox.left] - rol ebx, 16 - rol ecx, 16 - add cx, word [eax+APPDATA.wnd_clientbox.top] - rol ecx, 16 -.forced: - - test edx, 0x80000000 - jnz remove_button - - or bx, bx - jle noaddbutt - or cx, cx - jle noaddbutt - - test edx, 0x40000000 - jnz button_no_draw - - pushad ; button body - movzx edi, cx - shr ebx, 16 - shr ecx, 16 - mov eax, [TASK_BASE] - add ebx, [eax-twdw + WDATA.box.left] - add ecx, [eax-twdw + WDATA.box.top] - mov eax, ebx - shl eax, 16 - mov ax, bx - add ax, word [esp+16] - mov ebx, ecx - shl ebx, 16 - mov bx, cx - mov ecx, esi - cmp [buttontype], 0 - je @f - call incecx2 -@@: - mov edx, edi - -.newline: - call button_dececx - push edi - xor edi, edi - call [draw_line] - pop edi - add ebx, 1*65536+1 ; [ y start | y end ] - dec edx - jnz .newline - popad - - call drawbuttonframes - -button_no_draw: - - mov edi, [BTN_ADDR] - movzx eax, word [edi] - cmp eax, max_buttons - jge noaddbutt - inc eax - mov [edi], ax - - shl eax, 4 - add edi, eax - - mov ax, [CURRENT_TASK] - stosw - mov ax, dx - stosw ; button id number: bits 0-15 - mov eax, ebx - rol eax, 16 - stosd ; x start | x size - mov eax, ecx - rol eax, 16 - stosd ; y start | y size - mov eax, edx - shr eax, 16 - stosw ; button id number: bits 16-31 - -noaddbutt: - - ret - - -remove_button: - - and edx, 0x7fffffff - -rnewba2: - - mov edi, [BTN_ADDR] - mov eax, edi - movzx ebx, word [edi] - inc ebx - -rnewba: - - dec ebx - jz rnmba - - add eax, 0x10 - - mov cx, [CURRENT_TASK] - cmp cx, [eax] - jnz rnewba - cmp dx, [eax+2] - jnz rnewba - - lea ecx, [ebx+1] - shl ecx, 4 - mov ebx, eax - add eax, 0x10 - call memmove - dec dword [edi] - jmp rnewba2 - -rnmba: - - ret - -find_pressed_button_frames: - - pushad - - movzx ebx,word [eax+0] - shl ebx,5 - add ebx,window_data - mov ecx, [ebx+ WDATA.box.left] ; window x start - movzx edx,word [eax+4] ; button x start - add ecx,edx - push ecx - - mov dx,[eax+6] ; button x size - add cx,dx - mov esi,ecx - inc esi - mov ecx, [ebx+WDATA.box.top] ; window y start - mov dx,[eax+8] ; button y start - add ecx,edx - mov ebx,ecx - mov dx,[eax+10] ; button y size - add dx,cx - inc dx - - pop eax - - ; eax x beginning - ; ebx y beginning - ; esi x end - ; edx y end - ; ecx color - - mov [pressed_button_eax],eax - mov [pressed_button_ebx],ebx - mov [pressed_button_ecx],ecx - mov [pressed_button_edx],edx - mov [pressed_button_esi],esi - - popad - ret - -uglobal - pressed_button_eax dd 0 - pressed_button_ebx dd 0 - pressed_button_ecx dd 0 - pressed_button_edx dd 0 - pressed_button_esi dd 0 -endg - -; negative button image - -negativebutton: - ; If requested, do not display button - ; boarder on press. - test ebx,0x20000000 - jz draw_negative_button - ret - draw_negative_button: - - pushad - - mov eax,[pressed_button_eax] - mov ebx,[pressed_button_ebx] - mov ecx,[pressed_button_ecx] - mov edx,[pressed_button_edx] - mov esi,[pressed_button_esi] - mov ecx,0x01000000 - - dec edx - push edx - inc edx - dec esi - push esi - inc esi - - push eax - push ebx - push ecx - push edx - push edi - - call [_display.disable_mouse] - - bdbnewline: - mov edi,1 ; force - cmp eax,[esp+16] - jz bneg - cmp eax,[esp+20] - jz bneg - cmp ebx,[esp+12] - jz bneg - cmp ebx,[esp+24] - jnz nbneg -; jz bneg -; jmp nbneg - - bneg: - - call [putpixel] - - nbneg: - - inc eax - cmp eax,esi - jnz bdbnewline - mov eax,[esp+16] - inc ebx - cmp ebx,edx - jnz bdbnewline - - add esp,28 - - popad - - ret - -; check buttons - - -; 0000 word process number -; 0002 word button id number : bits 0-15 -; 0004 word x start -; 0006 word x size -; 0008 word y start -; 000A word y size -; 000C word button id number : bits 16-31 -; -; button table in 0x10 increments -; -; first at 0x10 - -align 4 -checkbuttons: - - cmp [BTN_DOWN],byte 0 ; mouse buttons pressed - jnz @f -;..................................... start 1/5 : modified by vhanla ............................. - mov [bPressedMouseXY_B],0 -;..................................... end 1/5 : modified by vhanla ............................. - ret - @@: - pushad - - xor esi, esi - mov edi, [BTN_ADDR] - movzx edx, word [edi] - test edx, edx - jne @f - popad - ret - - @@: -;..................................... start 2/5 : modified by vhanla ............................. - ;here i catch the coordinates when the mouse's button is clicked - push ax - cmp [bPressedMouseXY_B],0;FALSE - jnz @f - mov [bPressedMouseXY_B],1;TRUE - it was already clicked - mov ax,[MOUSE_X] - mov [mx],ax - mov ax,[MOUSE_Y] - mov [my],ax - @@: - pop ax - ;and it is only refreshed after the mouse's button release -;..................................... end 2/5 : modified by vhanla ............................. - - push esi - inc edx - push edx - - buttonnewcheck: - - pop edx - pop esi - inc esi - cmp edx,esi - jge bch - - popad ; no button pressed - ret - - bch: - - push esi - push edx - mov eax,esi - shl eax,4 - add eax,edi - - ; check that button is at top of windowing stack - - movzx ebx,word [eax] - movzx ecx,word [WIN_STACK + ebx * 2] - cmp ecx,[TASK_COUNT] - jne buttonnewcheck - - ; check that button start is inside window x/y end - - movzx ebx,word [eax+0] - shl ebx,5 - - test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED - jnz buttonnewcheck - -; add ebx,window_data -; mov ecx,[window_data+ebx+8] ; window end X - movzx edx,word [eax+4] ; button start X - cmp edx, [window_data+ebx+WDATA.box.width] ;ecx - jge buttonnewcheck - -; mov ecx,[window_data+ebx+12] ; window end Y - movzx edx, word [eax+8] ; button start Y - cmp edx, [window_data+ebx+WDATA.box.height] ;ecx - jge buttonnewcheck - - ; check coordinates - ; mouse x >= button x ? - movzx ebx,word [eax+0] - shl ebx,5 - add ebx,window_data - mov ecx, [ebx+WDATA.box.left] ; window x start - movzx edx,word [eax+4] ; button x start - add edx,ecx -;..................................... start 3/5 : modified by vhanla ............................. - mov cx,[mx] ;mov cx,[MOUSE_X] -;..................................... end 3/5 : modified by vhanla ............................. - cmp edx,ecx - jg buttonnewcheck - - movzx ebx,word [eax+6] ; button x size - add edx,ebx - cmp ecx,edx - jg buttonnewcheck - - ; mouse y >= button y ? - movzx ebx,word [eax+0] - shl ebx,5 - add ebx,window_data - mov ecx, [ebx+WDATA.box.top] ; window y start - movzx edx,word [eax+8] ; button y start - add edx,ecx -;..................................... start 4/5 : modified by vhanla ............................. - mov cx,[my] ;mov cx,[MOUSE_Y] -;..................................... start 4/5 : modified by vhanla ............................. - cmp edx,ecx - jg buttonnewcheck - - movzx ebx,word [eax+10] ; button y size - add edx,ebx - cmp ecx,edx - jg buttonnewcheck - - ; mouse on button - - pop edx - pop esi - - mov bx,[eax+0xc] ; button id : bits 16-31 - shl ebx,16 - mov bx,[eax+2] ; button id : bits 00-16 - push ebx - - mov [MOUSE_DOWN],byte 1 ; no mouse down checks - call find_pressed_button_frames - call negativebutton - - pushad -; // Alver 22.06.2008 // { - push eax - mov al, byte [BTN_DOWN] - mov byte [btn_down_determ], al - pop eax -; } \\ Alver \\ - - cbwaitmouseup: - - call checkidle - - call [draw_pointer] - - pushad - call stack_handler - popad - - cmp [BTN_DOWN],byte 0 ; mouse buttons pressed ? - jnz cbwaitmouseup - popad - - call negativebutton - mov [MOUSE_BACKGROUND],byte 0 ; no mouse background - mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse -;..................................... start 5/5 : modified by vhanla ............................. - ; check coordinates -iglobal - mx dw 0x0 ; keeps the x mouse's position when it was clicked - my dw 0x0 ; keeps the y mouse's position when it was clicked - bPressedMouseXY_B db 0x0 - btn_down_determ db 0x0 ; << // Alver 22.06.2008// << -endg - - pusha - ; mouse x >= button x ? - movzx ebx,word [eax+0] - shl ebx,5 - add ebx,window_data - mov ecx, [ebx+WDATA.box.left] ; window x start - movzx edx,word [eax+4] ; button x start - add edx,ecx - mov cx,[MOUSE_X] - cmp edx,ecx - jg no_on_button ;if we release the pointer out of the button area - - movzx ebx,word [eax+6] ; button x size - add edx,ebx - cmp ecx,edx - jg no_on_button - - ; mouse y >= button y ? - movzx ebx,word [eax+0] - shl ebx,5 - add ebx,window_data - mov ecx, [ebx+WDATA.box.top] ; window y start - movzx edx,word [eax+8] ; button y start - add edx,ecx - mov cx,[MOUSE_Y] - cmp edx,ecx - jg no_on_button - - movzx ebx,word [eax+10] ; button y size - add edx,ebx - cmp ecx,edx - jg no_on_button - popa - mov [BTN_COUNT],byte 1 ; no of buttons in buffer - pop ebx - mov [BTN_BUFF],ebx ; lets put the button id in buffer - push ebx - pusha - jmp yes_on_button -no_on_button: - mov [BTN_COUNT],byte 0 ; no of buttons in buffer -yes_on_button: - mov [MOUSE_DOWN],byte 0 ; mouse down -> do not draw - popa - pop ebx - popa - ret - -;..................................... end 5/5 : modified by vhanla ................................ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; +;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +$Revision$ + + +button._.MAX_BUTTONS = 4095 + + +;============================================================================== +;///// public functions /////////////////////////////////////////////////////// +;============================================================================== + +struc SYS_BUTTON +{ + .pslot dw ? + .id_lo dw ? + .left dw ? + .width dw ? + .top dw ? + .height dw ? + .id_hi dw ? + .sizeof: +} +virtual at 0 + SYS_BUTTON SYS_BUTTON +end virtual + +iglobal + mx dw 0x0 ; keeps the x mouse's position when it was clicked + my dw 0x0 ; keeps the y mouse's position when it was clicked + bPressedMouseXY_B db 0x0 + btn_down_determ db 0x0 +endg + +align 4 +;------------------------------------------------------------------------------ +syscall_button: ;///// system function 8 ////////////////////////////////////// +;------------------------------------------------------------------------------ +; Define/undefine GUI button object +;------------------------------------------------------------------------------ +; Define button arguments: +; ebx = pack[16(x), 16(width)] +; ecx = pack[16(y), 16(height)] +; edx = pack[8(flags), 24(button identifier)] +; flags bits: +; 7 (31) = 0 +; 6 (30) = don't draw button +; 5 (29) = don't draw button frame when pressed +; esi = button color +; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +; Undefine button arguments: +; edx = pack[8(flags), 24(button identifier)] +; flags bits: +; 7 (31) = 1 +;------------------------------------------------------------------------------ + ; do we actually need to undefine the button? + test edx, 0x80000000 + jnz .remove_button + + ; do we have free button slots available? + mov edi, [BTN_ADDR] + mov eax, [edi] + cmp eax, button._.MAX_BUTTONS + jge .exit + + ; does it have positive size? (otherwise it doesn't have sense) + or bx, bx + jle .exit + or cx, cx + jle .exit + + ; make coordinates clientbox-relative + push eax + mov eax, [current_slot] + rol ebx, 16 + add bx, word[eax + APPDATA.wnd_clientbox.left] + rol ebx, 16 + rol ecx, 16 + add cx, word[eax + APPDATA.wnd_clientbox.top] + rol ecx, 16 + pop eax + + ; basic checks passed, define the button + push ebx ecx edx + inc eax + mov [edi], ax + shl eax, 4 + add edi, eax + ; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it + ; if you change something + mov ax, [CURRENT_TASK] + stosw + mov ax, dx + stosw ; button id number: bits 0-15 + mov eax, ebx + rol eax, 16 + stosd ; x start | x size + mov eax, ecx + rol eax, 16 + stosd ; y start | y size + mov eax, edx + shr eax, 16 + stosw ; button id number: bits 16-31 + pop edx ecx ebx + + ; do we also need to draw the button? + test edx, 0x40000000 + jnz .exit + + ; draw button body + + pushad + + ; calculate window-relative coordinates + movzx edi, cx + shr ebx, 16 + shr ecx, 16 + mov eax, [TASK_BASE] + add ebx, [eax - twdw + WDATA.box.left] + add ecx, [eax - twdw + WDATA.box.top] + mov eax, ebx + shl eax, 16 + mov ax, bx + add ax, word[esp + 16] + mov ebx, ecx + shl ebx, 16 + mov bx, cx + + ; calculate initial color + mov ecx, esi + cmp [buttontype], 0 + je @f + call button._.incecx2 + + ; set button height counter + @@: mov edx, edi + + .next_line: + call button._.button_dececx + push edi + xor edi, edi + call [draw_line] + pop edi + add ebx, 0x00010001 + dec edx + jnz .next_line + + popad + + ; draw button frame + + push ebx ecx + + ; calculate window-relative coordinates + shr ebx, 16 + shr ecx, 16 + mov eax, [TASK_BASE] + add ebx, [eax - twdw + WDATA.box.left] + add ecx, [eax - twdw + WDATA.box.top] + + ; top border + mov eax, ebx + shl eax, 16 + mov ax, bx + add ax, [esp + 4] + mov ebx, ecx + shl ebx, 16 + mov bx, cx + push ebx + xor edi, edi + mov ecx, esi + call button._.incecx + call [draw_line] + + ; bottom border + movzx edx, word[esp + 4 + 0] + add ebx, edx + shl edx, 16 + add ebx, edx + mov ecx, esi + call button._.dececx + call [draw_line] + + ; left border + pop ebx + push edx + mov edx, eax + shr edx, 16 + mov ax, dx + mov edx, ebx + shr edx, 16 + mov bx, dx + add bx, [esp + 4 + 0] + pop edx + mov ecx, esi + call button._.incecx + call [draw_line] + + ; right border + mov dx, [esp + 4] + add ax, dx + shl edx, 16 + add eax, edx + add ebx, 0x00010000 + mov ecx, esi + call button._.dececx + call [draw_line] + + pop ecx ebx + + .exit: + ret + +; FIXME: mutex needed +syscall_button.remove_button: + and edx, 0x00ffffff + mov edi, [BTN_ADDR] + mov ebx, [edi] + inc ebx + imul esi, ebx, SYS_BUTTON.sizeof + add esi, edi + xor ecx, ecx + add ecx, -SYS_BUTTON.sizeof + + .next_button: + dec ebx + jz .exit + + add ecx, SYS_BUTTON.sizeof + add esi, -SYS_BUTTON.sizeof + + ; does it belong to our process? + mov ax, [CURRENT_TASK] + cmp ax, [esi + SYS_BUTTON.pslot] + jne .next_button + + ; does the identifier match? + mov eax, dword[esi + SYS_BUTTON.id_hi - 2] + mov ax, [esi + SYS_BUTTON.id_lo] + and eax, 0x00ffffff + cmp edx, eax + jne .next_button + + ; okay, undefine it + mov ebx, esi + lea eax, [esi + SYS_BUTTON.sizeof] + call memmove + dec dword[edi] + add ecx, -SYS_BUTTON.sizeof + jmp .next_button + + .exit: + ret + +align 4 +;------------------------------------------------------------------------------ +check_buttons: ;/////////////////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +; +;------------------------------------------------------------------------------ + cmp byte[BTN_DOWN], 0 ; mouse buttons pressed + jnz @f + mov [bPressedMouseXY_B], 0 + ret + + @@: pushad + xor esi, esi + mov edi, [BTN_ADDR] + mov edx, [edi] + test edx, edx + jne @f + popad + ret + + ;here i catch the coordinates when the mouse's button is clicked + @@: push ax + cmp [bPressedMouseXY_B], 0 ; FALSE + jnz @f + mov [bPressedMouseXY_B], 1 ; TRUE - it was already clicked + mov ax, [MOUSE_X] + mov [mx], ax + mov ax, [MOUSE_Y] + mov [my], ax + @@: pop ax + ;and it is only refreshed after the mouse's button release + + push esi + inc edx + push edx + + .buttonnewcheck: + pop edx + pop esi + inc esi + cmp edx, esi + jge .bch + + popad + ret + + .bch: + push esi + push edx + mov eax, esi + shl eax, 4 + add eax, edi + + ; check that button is at top of windowing stack + movzx ebx, [eax + SYS_BUTTON.pslot] + movzx ecx, word[WIN_STACK + ebx * 2] + cmp ecx, [TASK_COUNT] + jne .buttonnewcheck + + ; check that button start is inside window x/y end + shl ebx, 5 + + test [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED + jnz .buttonnewcheck + + movzx edx, [eax + SYS_BUTTON.left] + cmp edx, [window_data + ebx + WDATA.box.width] ;ecx + jge .buttonnewcheck + + movzx edx, [eax + SYS_BUTTON.top] + cmp edx, [window_data + ebx + WDATA.box.height] ;ecx + jge .buttonnewcheck + + ; check coordinates + + ; mouse x >= button x ? + add ebx, window_data + mov ecx, [ebx + WDATA.box.left] + movzx edx, [eax + SYS_BUTTON.left] + add edx, ecx + mov cx, [mx] ;mov cx,[MOUSE_X] + cmp edx, ecx + jg .buttonnewcheck + + movzx ebx, [eax + SYS_BUTTON.width] + add edx, ebx + cmp ecx, edx + jg .buttonnewcheck + + ; mouse y >= button y ? + movzx ebx, [eax + SYS_BUTTON.pslot] + shl ebx, 5 + add ebx, window_data + mov ecx, [ebx + WDATA.box.top] + movzx edx, [eax + SYS_BUTTON.top] + add edx, ecx + mov cx, [my] ;mov cx,[MOUSE_Y] + cmp edx, ecx + jg .buttonnewcheck + + movzx ebx, [eax + SYS_BUTTON.height] + add edx, ebx + cmp ecx, edx + jg .buttonnewcheck + + ; mouse on button + + pop edx + pop esi + + mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] ; button id : bits 16-31 + mov bx, [eax + SYS_BUTTON.id_lo] ; button id : bits 00-16 + push ebx + + mov byte[MOUSE_DOWN], 1 ; no mouse down checks + call button._.negative_button + + pushad + push eax + mov al, [BTN_DOWN] + mov byte[btn_down_determ], al + pop eax + + .cbwaitmouseup: + call checkidle + call [draw_pointer] + + pushad + call stack_handler + popad + + cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ? + jnz .cbwaitmouseup + popad + + call button._.negative_button + mov byte[MOUSE_BACKGROUND], 0 ; no mouse background + mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse + + ; check coordinates + pusha + + ; mouse x >= button x ? + movzx ebx, [eax + SYS_BUTTON.pslot] + shl ebx, 5 + add ebx, window_data + mov ecx, [ebx + WDATA.box.left] + movzx edx, [eax + SYS_BUTTON.left] + add edx, ecx + mov cx, [MOUSE_X] + cmp edx, ecx + jg .no_on_button ;if we release the pointer out of the button area + + movzx ebx, [eax + SYS_BUTTON.width] + add edx, ebx + cmp ecx, edx + jg .no_on_button + + ; mouse y >= button y ? + movzx ebx, [eax + SYS_BUTTON.pslot] + shl ebx, 5 + add ebx, window_data + mov ecx, [ebx + WDATA.box.top] + movzx edx, [eax + SYS_BUTTON.top] + add edx, ecx + mov cx, [MOUSE_Y] + cmp edx, ecx + jg .no_on_button + + movzx ebx, [eax + SYS_BUTTON.height] + add edx, ebx + cmp ecx, edx + jg .no_on_button + + popa + + mov byte[BTN_COUNT], 1 ; no of buttons in buffer + pop ebx + mov [BTN_BUFF], ebx ; lets put the button id in buffer + push ebx + pusha + jmp .yes_on_button + + .no_on_button: + mov byte[BTN_COUNT], 0 ; no of buttons in buffer + + .yes_on_button: + mov byte[MOUSE_DOWN], 0 ; mouse down -> do not draw + popa + pop ebx + popa + ret + +;============================================================================== +;///// private functions ////////////////////////////////////////////////////// +;============================================================================== + +;------------------------------------------------------------------------------ +button._.dececx: ;///////////////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +; +;------------------------------------------------------------------------------ + sub cl, 0x20 + jnc @f + xor cl, cl + @@: sub ch, 0x20 + jnc @f + xor ch, ch + @@: rol ecx, 16 + sub cl, 0x20 + jnc @f + xor cl, cl + @@: rol ecx, 16 + ret + +;------------------------------------------------------------------------------ +button._.incecx: ;///////////////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +; +;------------------------------------------------------------------------------ + add cl, 0x20 + jnc @f + or cl, -1 + @@: add ch, 0x20 + jnc @f + or ch, -1 + @@: rol ecx, 16 + add cl, 0x20 + jnc @f + or cl, -1 + @@: rol ecx, 16 + ret + +;------------------------------------------------------------------------------ +button._.incecx2: ;//////////////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +; +;------------------------------------------------------------------------------ + add cl, 0x14 + jnc @f + or cl, -1 + @@: add ch, 0x14 + jnc @f + or ch, -1 + @@: rol ecx, 16 + add cl, 0x14 + jnc @f + or cl, -1 + @@: rol ecx, 16 + ret + +;------------------------------------------------------------------------------ +button._.button_dececx: ;////////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +; +;------------------------------------------------------------------------------ + cmp [buttontype], 1 + jne .finish + + push eax + mov al, 1 + cmp edi, 20 + jg @f + mov al, 2 + + @@: sub cl, al + jnc @f + xor cl, cl + @@: sub ch, al + jnc @f + xor ch, ch + @@: rol ecx, 16 + sub cl, al + jnc @f + xor cl, cl + @@: rol ecx, 16 + + pop eax + + .finish: + ret + +;------------------------------------------------------------------------------ +button._.negative_button: ;//////////////////////////////////////////////////// +;------------------------------------------------------------------------------ +; +;------------------------------------------------------------------------------ + ; If requested, do not display button border on press. + test ebx, 0x20000000 + jz .draw_negative_button + ret + + .draw_negative_button: + pushad + + mov ebx, dword[eax + SYS_BUTTON.left] + mov ecx, dword[eax + SYS_BUTTON.top] + rol ebx, 16 + rol ecx, 16 + push ebx ecx + + ; calculate window-relative coordinates + shr ebx, 16 + shr ecx, 16 + movzx eax, word[eax + SYS_BUTTON.pslot] + shl eax, 5 + add eax, window_data + add ebx, [eax + WDATA.box.left] + add ecx, [eax + WDATA.box.top] + + xor edi, edi + inc edi + + ; top border + mov eax, ebx + shl eax, 16 + mov ax, bx + add ax, [esp + 4] + mov ebx, ecx + shl ebx, 16 + mov bx, cx + push ebx + mov ecx, 0x01000000 + call [draw_line] + + ; bottom border + movzx edx, word[esp + 4 + 0] + add ebx, edx + shl edx, 16 + add ebx, edx + call [draw_line] + + ; left border + pop ebx + push edx + mov edx, eax + shr edx, 16 + mov ax, dx + mov edx, ebx + shr edx, 16 + mov bx, dx + add bx, [esp + 4 + 0] + pop edx + add ebx, 0x00010000 + dec bx + call [draw_line] + + ; right border + mov dx, [esp + 4] + add ax, dx + shl edx, 16 + add eax, edx + call [draw_line] + + pop ecx ebx + + popad + ret diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index a13129271d..a782c37b60 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -1035,7 +1035,7 @@ boot_log: align 32 osloop: call [draw_pointer] - call checkbuttons + call check_buttons call checkwindows ; call check_window_move_request call checkmisc