fix button coord and size;

add 3d light effect;

git-svn-id: svn://kolibrios.org@4970 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Akyltist 2014-06-10 20:02:53 +00:00
parent c9402ee7c6
commit f16f70dcc9

View File

@ -39,6 +39,7 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
;> 7 (31) = 0 ;> 7 (31) = 0
;> 6 (30) = don't draw button ;> 6 (30) = don't draw button
;> 5 (29) = don't draw button frame when pressed ;> 5 (29) = don't draw button frame when pressed
;> 4 (28) = don't draw button 3d frame
;> esi = button color ;> esi = button color
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Undefine button: ;; Undefine button:
@ -86,9 +87,11 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
mov ax, dx mov ax, dx
stosw ; button id number: bits 0-15 stosw ; button id number: bits 0-15
mov eax, ebx mov eax, ebx
dec eax
rol eax, 16 rol eax, 16
stosd ; x start | x size stosd ; x start | x size
mov eax, ecx mov eax, ecx
dec eax
rol eax, 16 rol eax, 16
stosd ; y start | y size stosd ; y start | y size
mov eax, edx mov eax, edx
@ -100,114 +103,116 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
test edx, 0x40000000 test edx, 0x40000000
jnz .exit jnz .exit
; draw button body ; DRAW BODY -----------------------------
pushad pushad
call button._.button_calc_relativ
; calculate window-relative coordinates xor edi, edi ; for __sys_draw_line
movzx edi, cx ; set color
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 mov ecx, esi
; set coordinate
inc edx
; if gradient
cmp [buttontype], 0 cmp [buttontype], 0
je @f je .next_line
call button._.incecx2 call button._.incecx
align 4
; set button height counter .next_line:
@@:
mov edx, edi
.next_line:
call button._.button_dececx call button._.button_dececx
push edi
xor edi, edi
; call [draw_line]
call __sys_draw_line call __sys_draw_line
pop edi
add ebx, 0x00010001 add ebx, 0x00010001
dec edx dec edx
jnz .next_line jnz .next_line
popad popad
; draw button frame ; DRAW FRAME ----------------------------
pushad
call button._.button_calc_relativ
mov esi, common_colours
push ebx ecx mov edi, dword [esi+104]
call .top_border
mov edi, dword [esi+104]
call .bottom_border
mov edi, dword [esi+104]
call .right_border
mov edi, dword [esi+104]
call .left_border
popad
; calculate window-relative coordinates ; DRAW 3D SHADOW ------------------------
shr ebx, 16 test edx, 0x10000000
shr ecx, 16 jnz .exit
mov eax, [TASK_BASE]
add ebx, [eax - twdw + WDATA.box.left]
add ecx, [eax - twdw + WDATA.box.top]
; top border pushad
mov eax, ebx mov edi, edx
shl eax, 16 call button._.button_calc_relativ
mov ax, bx ; get color address
add ax, [esp + 4] mov esi, common_colours
test edi, 0x10000000
jnz @f
add eax, 0x10000
dec eax
inc ecx
dec edx
dec edx
align 4
@@:
mov edi, dword [esi+12]
call .top_border
mov edi, dword [esi+8]
call .bottom_border
mov edi, dword [esi+8]
call .right_border
mov edi, dword [esi+12]
call .left_border
popad
ret
align 4
.top_border:
mov ebx, ecx mov ebx, ecx
shl ebx, 16 shl ebx, 16
mov bx, cx mov bx , cx
push ebx mov ecx, edi
xor edi, edi xor edi, edi
mov ecx, esi
call button._.incecx
; call [draw_line]
call __sys_draw_line call __sys_draw_line
ret
; bottom border align 4
movzx edx, word[esp + 4 + 0] .bottom_border:
add ebx, edx add bx , dx
shl edx, 16 rol ebx, 16
add ebx, edx add bx , dx
mov ecx, esi mov ecx, edi
call button._.dececx xor edi, edi
; call [draw_line]
call __sys_draw_line call __sys_draw_line
ret
; left border align 4
pop ebx .right_border:
push edx push eax
mov edx, eax sub bx, dx
shr edx, 16 mov cx, ax
mov ax, dx shl eax, 16
mov edx, ebx mov ax, cx
shr edx, 16 mov ecx, edi
mov bx, dx xor edi, edi
add bx, [esp + 4 + 0]
pop edx
mov ecx, esi
call button._.incecx
; call [draw_line]
call __sys_draw_line call __sys_draw_line
pop eax
ret
; right border align 4
mov dx, [esp + 4] .left_border:
add ax, dx shr eax, 16
shl edx, 16 mov cx, ax
add eax, edx shl eax, 16
add ebx, 0x00010000 mov ax, cx
mov ecx, esi mov ecx, edi
call button._.dececx xor edi, edi
; call [draw_line]
call __sys_draw_line call __sys_draw_line
ret
pop ecx ebx align 4
.exit:
.exit:
ret ret
; FIXME: mutex needed ; FIXME: mutex needed
@ -269,8 +274,10 @@ sys_button_activate_handler: ;/////////////////////////////////////////////////
jz .exit jz .exit
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
push edi ; spam
xor edi, edi
call button._.negative_button call button._.negative_button
pop edi
.exit: .exit:
ret ret
@ -289,8 +296,11 @@ sys_button_deactivate_handler: ;///////////////////////////////////////////////
jz .exit jz .exit
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
push edi ; spam
xor edi, edi
inc edi
call button._.negative_button call button._.negative_button
pop edi
.exit: .exit:
ret ret
@ -373,69 +383,6 @@ button._.find_button: ;////////////////////////////////////////////////////////
pop edi esi edx ecx pop edi esi edx ecx
ret ret
;------------------------------------------------------------------------------
button._.dececx: ;/////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
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: ;/////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
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: ;////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
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: ;////////////////////////////////////////////////////// button._.button_dececx: ;//////////////////////////////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@ -446,9 +393,9 @@ button._.button_dececx: ;//////////////////////////////////////////////////////
push eax push eax
mov al, 1 mov al, 1
cmp edi, 20 ;cmp edi, 20
jg @f ;jg @f
mov al, 2 ;mov al, 2
@@: @@:
sub cl, al sub cl, al
@ -470,18 +417,60 @@ button._.button_dececx: ;//////////////////////////////////////////////////////
.finish: .finish:
ret ret
;------------------------------------------------------------------------------
button._.incecx: ;////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
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_calc_relativ: ;
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
movzx edx, cx
dec edx ; get height
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 + 20]
dec eax
mov bx, cx
shl ebx, 16
mov bx, cx
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
button._.negative_button: ;//////////////////////////////////////////////////// button._.negative_button: ;////////////////////////////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;? Invert system button border ;? Invert system button border
; edi - 0 activate, 1 - deactivate
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; if requested, do not display button border on press. ; if requested, do not display button border on press.
test ebx, 0x20000000 test ebx, 0x20000000
jnz .exit jnz .exit
pushad pushad
push ebx
xchg esi, eax xchg esi, eax
movzx ecx, [esi + SYS_BUTTON.pslot] movzx ecx, [esi + SYS_BUTTON.pslot]
@ -499,10 +488,58 @@ button._.negative_button: ;////////////////////////////////////////////////////
add ax, cx add ax, cx
add bx, dx add bx, dx
xor edx, edx
mov dx, [esi + SYS_BUTTON.id_lo]
cmp dx, 1
jne .no_close
sub eax, 0x00010001
dec ebx
mov esi, 0x01000000 mov esi, 0x01000000
call draw_rectangle.forced call draw_rectangle.forced
jmp .fade
align 4
.no_close:
cmp dx, 65535
jne .no_mini
sub eax, 0x00010001
dec ebx
mov esi, 0x01000000
call draw_rectangle.forced
jmp .fade
align 4
.no_mini:
add eax, 0x00010000
add ebx, 0x00010000
pop edx
test edx, 0x10000000
jnz .only_frame
mov edx, common_colours
mov esi, dword [edx+12]
cmp edi, 0
jne .shadow
mov esi, dword [edx+8]
align 4
.shadow:
call draw_rectangle.forced
align 4
.only_frame:
mov edx, common_colours
sub eax, 0x00010000
sub ebx, 0x00010000
mov esi, dword [edx+104]
cmp edi, 0
jne .draw
mov esi, dword [edx+112]
align 4
.draw:
call draw_rectangle.forced
popad popad
ret
.exit: align 4
.fade:
pop ebx
popad
align 4
.exit:
ret ret