Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5984 → Rev 6078

/kernel/branches/Kolibri-acpi/gui/button.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
8,10 → 8,6
 
$Revision$
 
;==============================================================================
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
 
button.MAX_BUTTONS = 4095
 
struct SYS_BUTTON
25,12 → 21,11
dw ?
ends
 
align 4
;------------------------------------------------------------------------------
syscall_button: ;///// system function 8 //////////////////////////////////////
;------------------------------------------------------------------------------
;---------------------------------------------------------------
syscall_button: ;////////////// system function 8 //////////////
;---------------------------------------------------------------
;? Define/undefine GUI button object
;------------------------------------------------------------------------------
;---------------------------------------------------------------
;; Define button:
;> ebx = pack[16(x), 16(width)]
;> ecx = pack[16(y), 16(height)]
40,12 → 35,12
;> 6 (30) = don't draw button
;> 5 (29) = don't draw button frame when pressed
;> esi = button color
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;; Undefine button:
;> 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
74,13 → 69,12
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
; 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
94,18 → 88,52
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
and esi, 0xFFFFFF
xor edi, edi
push ebx ecx esi
dec cx
dec cx
cmp [buttontype], 1
jnz .draw
cmp cx, 65
jnc .draw
 
pushad
; calculate gradient data
mov eax, esi
shl eax, 8
mov edx, 3
.calculate:
rol eax, 8
shl al, 1
jnc @f
neg al
jnz @f
mov al, 64
@@:
cmp al, 65
jc @f
mov al, 64
@@:
div cl
shl ax, 8
dec edx
jnz .calculate
mov dl, cl
dec edx
shr edx, 1
shr eax, 8
mov edi, eax
mul edx
add esi, eax
 
; calculate window-relative coordinates
movzx edi, cx
.draw: ; calculate window-relative coordinates
movzx ebp, cx
dec ebp
shr ebx, 16
shr ecx, 16
mov eax, [TASK_BASE]
113,110 → 141,73
add ecx, [eax - twdw + WDATA.box.top]
mov eax, ebx
inc eax
shl eax, 16
mov ax, bx
add ax, word[esp + 16]
dec ax
mov edx, ebx
add dx, [esp+8]
dec edx
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
add ebx, 0x00010001
dec edx
 
shr ecx, 1
and cx, 7F7Fh
push esi
mov esi, edi
xor edi, edi
call hline ; top border
inc ebx
or ecx, 808080h
call hline ; top light line
pop ecx
inc ebx
.next_line:
call button._.button_dececx
push edi
xor edi, edi
; call [draw_line]
call __sys_draw_line
pop edi
add ebx, 0x00010001
dec edx
call hline ; button body
inc ebx
sub ecx, esi
dec ebp
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]
call __sys_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]
call __sys_draw_line
 
; left border
pop ebx
shr ecx, 2
and cx, 3F3Fh
mov ebp, ecx
shl ecx, 1
add ecx, ebp
call hline ; bottom dark line
inc ebx
sub ecx, ebp
call hline ; bottom border
pop ecx
shr ecx, 1
inc edx
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]
dec ebx
call __sys_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]
call __sys_draw_line
 
sub bx, [esp+4]
dec edx
inc ebx
cmp [buttontype], 0
jnz @f
dec edx
or ecx, 808080h
call vline ; left light line
inc edx
@@:
and ecx, 7F7F7Fh
dec eax
call vline ; left border
pop eax
call vline ; right border
cmp [buttontype], 0
jnz @f
mov ebp, ecx
shr ecx, 1
and cx, 7F7Fh
add ecx, ebp
dec eax
inc ebx
call vline ; right dark line
@@:
pop ecx ebx
 
.exit:
ret
 
; FIXME: mutex needed
syscall_button.remove_button:
.remove_button:
and edx, 0x00ffffff
mov edi, [BTN_ADDR]
mov ebx, [edi]
256,87 → 247,19
pop ebx
jmp .next_button
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
sys_button_activate_handler: ;/////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;---------------------------------------------------------------
sys_button_activate_handler:
sys_button_deactivate_handler:
;---------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
;> cl = mouse button mask this system button was pressed with
;------------------------------------------------------------------------------
call button._.find_button
or eax, eax
jz .exit
 
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
call button._.negative_button
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
sys_button_deactivate_handler: ;///////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
;> cl = mouse button mask this system button was pressed with
;------------------------------------------------------------------------------
call button._.find_button
or eax, eax
jz .exit
 
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
call button._.negative_button
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
sys_button_perform_handler: ;//////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
;> cl = mouse button mask this system button was pressed with
;------------------------------------------------------------------------------
shl eax, 8
mov al, cl
movzx ebx, byte[BTN_COUNT]
mov [BTN_BUFF + ebx * 4], eax
inc bl
mov [BTN_COUNT], bl
ret
 
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
 
;------------------------------------------------------------------------------
button._.find_button: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Find system button by specified process slot, id and coordinates
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)] or 0
;> ebx = pack[16(button x coord), 16(button y coord)]
;------------------------------------------------------------------------------
;< eax = pointer to SYS_BUTTON struct or 0
;------------------------------------------------------------------------------
;---------------------------------------------------------------
; find system button by specified process slot, id and coordinates
push ecx edx esi edi
 
mov edx, eax
shr edx, 24
and eax, 0x0ffffff
 
mov edi, [BTN_ADDR]
mov ecx, [edi]
imul esi, ecx, sizeof.SYS_BUTTON
343,11 → 266,9
add esi, edi
inc ecx
add esi, sizeof.SYS_BUTTON
 
.next_button:
dec ecx
jz .not_found
 
jz .popexit
add esi, -sizeof.SYS_BUTTON
 
; does it belong to our process?
367,147 → 288,58
cmp ebx, edi
jne .next_button
 
; okay, return it
mov eax, esi
jmp .exit
 
.not_found:
xor eax, eax
 
.exit:
pop edi esi edx ecx
ret
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
 
;------------------------------------------------------------------------------
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
; display button border on press?
bt ebx, 29
jc .exit
 
;------------------------------------------------------------------------------
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: ;//////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
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: ;////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Invert system button border
;------------------------------------------------------------------------------
; if requested, do not display button border on press.
test ebx, 0x20000000
jnz .exit
 
; invert system button border
pushad
 
xchg esi, eax
 
mov esi, eax
mov edi, ebx
movzx ecx, [esi + SYS_BUTTON.pslot]
shl ecx, 5
add ecx, window_data
 
mov eax, dword[esi + SYS_BUTTON.left]
mov ebx, dword[esi + SYS_BUTTON.top]
add eax, [ecx + WDATA.box.left]
add ebx, [ecx + WDATA.box.top]
push eax ebx
pop edx ecx
mov ecx, eax
mov edx, ebx
bt edi, 30
jc @f
inc ax
inc bx
dec cx
dec dx
@@:
rol eax, 16
rol ebx, 16
add ax, cx
add bx, dx
 
mov esi, 0x01000000
mov esi, 1000000h
call draw_rectangle.forced
 
popad
 
.exit:
ret
.popexit:
pop edi esi edx ecx
ret
 
;---------------------------------------------------------------
sys_button_perform_handler:
;---------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
;> cl = mouse button mask this system button was pressed with
;---------------------------------------------------------------
shl eax, 8
mov al, cl
movzx ebx, byte[BTN_COUNT]
mov [BTN_BUFF + ebx * 4], eax
inc bl
mov [BTN_COUNT], bl
ret
/kernel/branches/Kolibri-acpi/gui/font.inc
241,7 → 241,7
.drawPicture:
mov eax, -1
repz scasd
jcxz @f
jecxz @f
mov eax, edx
sub eax, ecx
push ecx
/kernel/branches/Kolibri-acpi/gui/skincode.inc
101,7 → 101,6
xor eax, eax
cld
rep stosd
 
mov ebx, [ebp+SKIN_HEADER.params]
add ebx, [skin_data]
mov eax, [ebx+SKIN_PARAMS.skin_height]
127,11 → 126,8
mov dword[_skinmargins+0], eax
mov eax, dword[ebx+SKIN_PARAMS.margin.bottom]
mov dword[_skinmargins+4], eax
 
mov ebx, [ebp+SKIN_HEADER.bitmaps]
add ebx, [skin_data]
;--------------------------------------
align 4
.lp1:
cmp dword[ebx], 0
je .end_bitmaps
142,11 → 138,8
xor eax, eax
mov edx, skin_active.left.data
or ecx, ecx
jnz @f
jnz .next_bitmap
mov edx, skin_inactive.left.data
;--------------------------------------
align 4
@@:
jmp .next_bitmap
;--------------------------------------
align 4
159,11 → 152,8
neg eax
mov edx, skin_active.oper.data
or ecx, ecx
jnz @f
jnz .next_bitmap
mov edx, skin_inactive.oper.data
;--------------------------------------
align 4
@@:
jmp .next_bitmap
;--------------------------------------
align 4
173,12 → 163,9
mov eax, [skin_active.left.width]
mov edx, skin_active.base.data
or ecx, ecx
jnz @f
jnz .next_bitmap
mov eax, [skin_inactive.left.width]
mov edx, skin_inactive.base.data
;--------------------------------------
align 4
@@:
jmp .next_bitmap
;--------------------------------------
align 4
202,8 → 189,6
.end_bitmaps:
mov ebx, [ebp+SKIN_HEADER.buttons]
add ebx, [skin_data]
;--------------------------------------
align 4
.lp2:
cmp dword[ebx], 0
je .end_buttons
245,13 → 230,10
;------------------------------------------------------------------------------
align 4
drawwindow_IV_caption:
 
mov ebp, skin_active
or al, al
jnz @f
mov ebp, skin_inactive
;--------------------------------------
align 4
@@:
mov esi, [esp+4]
mov eax, [esi+WDATA.box.width] ; window width
260,13 → 242,10
mov ecx, [ebp+SKIN_DATA.left.width]
shl ecx, 16
add ecx, [_skinh]
 
mov ebx, [ebp+SKIN_DATA.left.data]
or ebx, ebx
jz @f
call sys_putimage.forced
;--------------------------------------
align 4
@@:
mov esi, [esp+4]
mov eax, [esi+WDATA.box.width]
278,9 → 257,7
mov ecx, [ebp+SKIN_DATA.base.width]
jecxz .non_base
div ecx
 
inc eax
 
mov ebx, [ebp+SKIN_DATA.base.data]
mov ecx, [ebp+SKIN_DATA.base.width]
shl ecx, 16
288,8 → 265,6
mov edx, [ebp+SKIN_DATA.base.left]
sub edx, [ebp+SKIN_DATA.base.width]
shl edx, 16
;--------------------------------------
align 4
.baseskinloop:
shr edx, 16
add edx, [ebp+SKIN_DATA.base.width]
296,21 → 271,15
shl edx, 16
 
push eax ebx ecx edx
 
or ebx, ebx
jz @f
call sys_putimage.forced
;--------------------------------------
align 4
@@:
pop edx ecx ebx eax
 
dec eax
jnz .baseskinloop
;--------------------------------------
align 4
.non_base:
 
mov esi, [esp+4]
mov edx, [esi+WDATA.box.width]
sub edx, [ebp+SKIN_DATA.oper.width]
317,16 → 286,12
inc edx
shl edx, 16
mov ebx, [ebp+SKIN_DATA.oper.data]
 
mov ecx, [ebp+SKIN_DATA.oper.width]
shl ecx, 16
add ecx, [_skinh]
 
or ebx, ebx
jz @f
call sys_putimage.forced
;--------------------------------------
align 4
@@:
ret
;------------------------------------------------------------------------------
334,17 → 299,12
drawwindow_IV:
;param1 - aw_yes
pusha
 
push edx
 
mov edi, edx
 
mov ebp, skin_active
cmp byte [esp+32+4+4], 0
jne @f
mov ebp, skin_inactive
;--------------------------------------
align 4
@@:
mov eax, [edi+WDATA.box.left]
shl eax, 16
362,8 → 322,6
rol ebx, 16
call draw_rectangle
mov ecx, 3
;--------------------------------------
align 4
_dw3l:
add eax, 1*65536-1
add ebx, 0*65536-1
387,8 → 345,6
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
jnz @f
call draw_rectangle
;--------------------------------------
align 4
@@:
mov eax, [skin_data]
cmp [eax], dword 'SKIN'
400,7 → 356,6
inc ecx
mov edx, [_skinh]
mov edi, [common_colours+4]; standard grab color
; call [drawbar]
call vesa20_drawbar
jmp draw_clientbar
;--------------------------------------
408,11 → 363,8
@@:
mov al, [esp+32+4+4]
call drawwindow_IV_caption
;--------------------------------------
align 4
draw_clientbar:
mov esi, [esp]
 
mov edx, [esi+WDATA.box.top] ; WORK AREA
add edx, 21+5
mov ebx, [esi+WDATA.box.top]
428,10 → 380,7
mov edi, [esi+WDATA.cl_workarea]
test edi, 0x40000000
jnz _noinside2
; call [drawbar]
call vesa20_drawbar
;--------------------------------------
align 4
_noinside2:
mov eax, [skin_data]
cmp [eax], dword 'SKIN'
443,39 → 392,30
jge no_skin_add_button
inc eax
mov [edi], ax
 
shl eax, 4
add eax, edi
 
mov bx, [CURRENT_TASK]
mov [eax], bx
 
add eax, 2 ; save button id number
mov bx, 1
mov [eax], bx
add eax, 2 ; x start
mov word [eax+2], 1 ; button id
xor ebx, ebx
cmp [skin_btn_close.left], 0
jge _bCx_at_right
jge @f
mov ebx, [esp]
mov ebx, [ebx+WDATA.box.width]
inc ebx
;--------------------------------------
align 4
_bCx_at_right:
@@:
add ebx, [skin_btn_close.left]
mov [eax], bx
add eax, 2 ; x size
mov word [eax+4], bx ; x start
mov ebx, [skin_btn_close.width]
dec ebx
mov [eax], bx
add eax, 2 ; y start
mov word [eax+6], bx ; x size
mov ebx, [skin_btn_close.top]
mov [eax], bx
add eax, 2 ; y size
mov word [eax+8], bx ; y start
mov ebx, [skin_btn_close.height]
dec ebx
mov [eax], bx
mov word [eax+10], bx ; y size
bts word [eax+12], 14
;* minimize button
mov edi, [BTN_ADDR]
movzx eax, word [edi]
483,43 → 423,31
jge no_skin_add_button
inc eax
mov [edi], ax
 
shl eax, 4
add eax, edi
 
mov bx, [CURRENT_TASK]
mov [eax], bx
 
add eax, 2 ; save button id number
mov bx, 65535;999
mov [eax], bx
add eax, 2 ; x start
mov word [eax+2], -1 ; button id
xor ebx, ebx
cmp [skin_btn_minimize.left], 0
jge _bMx_at_right
jge @f
mov ebx, [esp]
mov ebx, [ebx+WDATA.box.width]
inc ebx
;--------------------------------------
align 4
_bMx_at_right:
@@:
add ebx, [skin_btn_minimize.left]
mov [eax], bx
add eax, 2 ; x size
mov word [eax+4], bx ; x start
mov ebx, [skin_btn_minimize.width]
dec ebx
mov [eax], bx
add eax, 2 ; y start
mov word [eax+6], bx ; x size
mov ebx, [skin_btn_minimize.top]
mov [eax], bx
add eax, 2 ; y size
mov word [eax+8], bx ; y start
mov ebx, [skin_btn_minimize.height]
dec ebx
mov [eax], bx
;--------------------------------------
align 4
mov word [eax+10], bx ; y size
bts word [eax+12], 14
no_skin_add_button:
pop edi
popa
ret 4
;------------------------------------------------------------------------------