Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9529 → Rev 9530

/programs/system/docky/trunk/docky.asm
15,13 → 15,15
include "NAME.INC"
 
@use_library \
mem.Alloc, \
mem.Free, \
mem.ReAlloc, \
dll.Load
mem.Alloc, mem.Free, mem.ReAlloc, dll.Load
;================================================================================
 
main:
; ==== Init ====
mcall SF_SYS_MISC, SSF_HEAP_INIT
mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors
call LOAD_ICONS
 
mcall SF_SYSTEM, SSF_GET_ACTIVE_WINDOW
mov [win.psid], eax
 
42,64 → 44,6
 
invoke ini.sections, ini_data.file_name, sections_callback
 
; ==== Load colors ====
mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, color
or dword[color.bg], 0x10000000
or dword[color.frame], 0x10000000
or dword[color.text], 0x80000000
 
; ==== Config LibIMG ====
mov dword[fi.p00], SSF_GET_INFO
mov dword[fi.p16], buf_128
mov dword[fi.p21], img_data.file_name
 
mcall SF_FILE, fi
 
mov edx, [buf_128 + 32]
imul edx, 10
 
stdcall mem.Alloc, edx
mov [img_data.rgb_object], eax
 
mov dword[fi.p00], SSF_READ_FILE
mov dword[fi.p12], edx
m2m dword[fi.p16], dword[img_data.rgb_object]
mov dword[fi.p21], img_data.file_name
 
mcall SF_FILE, fi
 
cmp ebx, 0xFFFFFFFF
je @f
 
stdcall dword[img.decode], dword[img_data.rgb_object], ebx, 0
mov dword[img_data.object], eax
 
; === ALPHA ===
mov edi, eax
add edi, 8
mov edi, [edi]
imul edi, 128
sub edi, 4
 
add eax, 24
mov eax, [eax]
.setalpha:
mov ebx, [eax + edi]
shr ebx, 24
cmp ebx, 0
jne .nonalpha
 
mov ecx, [color.bg]
mov [eax + edi], ecx
.nonalpha:
sub edi, 4
cmp edi, 0
jne .setalpha
 
; === CONVERTING TO BGR
stdcall dword[img.toRGB], dword[img_data.object], dword[img_data.rgb_object]
stdcall dword[img.destroy], dword[img_data.object]
 
; ==== Config window ====
mov eax, dword[dock_items.location]
and eax, 1b
159,8 → 103,8
mcall SF_GET_SCREEN_SIZE
shr eax, 16
.set_hw:
mov [win.width_opn], eax
mov [win.width_hdn], eax
mov [win.w_opn], eax
mov [win.w_hdn], eax
 
ret
 
168,7 → 112,7
.HORZ_X:
mcall SF_GET_SCREEN_SIZE
shr eax, 17
mov ecx, [win.width_opn]
mov ecx, [win.w_opn]
shr ecx, 1
sub eax, ecx
mov [win.x_opn], eax
178,8 → 122,8
 
;-------------------------------------------------------------------------------
.HORZ_HEIGHT:
mov dword[win.height_hdn], 3
mov dword[win.height_opn], BUTTON_SIZE
mov dword[win.h_hdn], 3
mov dword[win.h_opn], BUTTON_SIZE
 
ret
 
202,8 → 146,8
 
;-------------------------------------------------------------------------------
.VERT_WIDTH:
mov dword[win.width_opn], BUTTON_SIZE
mov dword[win.width_hdn], 3
mov dword[win.w_opn], BUTTON_SIZE
mov dword[win.w_hdn], 3
 
ret
 
237,8 → 181,8
mcall SF_GET_SCREEN_SIZE
and eax, 0xFFFF
.set_vh:
mov [win.height_opn], eax
mov [win.height_hdn], eax
mov [win.h_opn], eax
mov [win.h_hdn], eax
 
ret
 
248,7 → 192,7
and eax, 0xFFFF
shr eax, 1
 
mov esi, [win.height_opn]
mov esi, [win.h_opn]
shr esi, 1
sub eax, esi
 
259,14 → 203,14
 
;-------------------------------------------------------------------------------
.SETDEF:
mov eax, [win.width_hdn]
mov [win.width], eax
mov eax, [win.w_hdn]
mov [win.w], eax
 
mov eax, [win.x_hdn]
mov [win.x], eax
 
mov eax, [win.height_hdn]
mov [win.height], eax
mov eax, [win.h_hdn]
mov [win.h], eax
 
mov eax, [win.y_hdn]
mov [win.y], eax
274,14 → 218,14
cmp byte[dock_items.ashow],1
jne .not_ashow
 
mov eax, [win.width_opn]
mov [win.width], eax
mov eax, [win.w_opn]
mov [win.w], eax
 
mov eax, [win.x_opn]
mov [win.x], eax
 
mov eax, [win.height_opn]
mov [win.height], eax
mov eax, [win.h_opn]
mov [win.h], eax
 
mov eax, [win.y_opn]
mov [win.y], eax
300,7 → 244,6
call main_loop
;-------------------------------------------------------------------------------
exit:
stdcall mem.Free, [img_data.rgb_object]
mcall SF_SYSTEM, SSF_TERMINATE_THREAD, [nwin.sid]
mcall SF_TERMINATE_PROCESS
;-------------------------------------------------------------------------------
326,9 → 269,16
DRAW_WINDOW:
mcall SF_REDRAW, SSF_BEGIN_DRAW
 
mov esi, [color.bg]
push dword [sc.work]
mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors
pop eax
cmp dword [sc.work], eax
je @f
call LOAD_ICONS
@@:
mov esi, [sc.work]
or esi, 0x01000000
mcall SF_CREATE_WINDOW, <[win.x], [win.width]>, <[win.y], [win.height]>, [color.bg], , [color.frame]
mcall SF_CREATE_WINDOW, <[win.x], [win.w]>, <[win.y], [win.h]>, [sc.work], , [sc.work_dark]
 
xor edi, edi
@@:
338,7 → 288,7
push edi
mov eax, SF_DEFINE_BUTTON
mov edx, 0x60000002
mov esi, [color.bg]
mov esi, [sc.work]
imul edi, BUTTON_SIZE
add edi, 12
shl edi, 16
370,12 → 320,12
 
cmp byte[win.isvert], 1
je .vert_draw_sep
mcall , , <4, 36>, [color.frame]
mcall , , <4, 36>, [sc.work_dark]
jmp .end_inner_sep
.vert_draw_sep:
sub ebx, 12 shl 16
mov ecx, ebx
mcall , <4, 36>, , [color.frame]
mcall , <4, 36>, , [sc.work_dark]
.end_inner_sep:
pop ecx
pop ebx
397,10 → 347,12
imul ebx, edi, 4
add ebx, dock_items.icon
mov ebx, [ebx]
imul ebx, ICON_SIZE_BGR
add ebx, [img_data.rgb_object]
 
mcall SF_PUT_IMAGE, , <32, 32>
push edi
imul ebx, 32*32*4
add ebx, [icons_inactive]
mcall SF_PUT_IMAGE_EXT, , <32, 32>, , 32, 0, 0
pop edi
 
inc edi
jmp @b
426,7 → 378,7
; jmp exit
 
.button_dock:
mov edi, [win.button_index]
mov edi, [win.btn_index]
imul edi, 256
 
mov dword[fi.p00], SSF_START_APP
462,12 → 414,12
cmp edi, 0
jl wnd_hide
dec edi
cmp edi, [win.width]
cmp edi, [win.w]
jg wnd_hide
cmp esi, 0
jl wnd_hide
dec esi
cmp esi, [win.height]
cmp esi, [win.h]
jg wnd_hide
 
; ==== COUNT INDEX ====
497,33 → 449,33
mov eax, 100
 
.nxtcmp:
cmp [win.button_index], eax
cmp [win.btn_index], eax
je .nxt2
 
push dword[win.button_index]
push dword[win.btn_index]
pop dword[win.prev_index]
 
mov [win.button_index], eax
mov [win.btn_index], eax
 
; ==== DRAW SELECTION ====
call DRAW_SELECTION
 
.nxt2:
mov eax, [win.button_index]
mov eax, [win.btn_index]
imul eax, BUTTON_SIZE
cmp byte[win.isvert], 1
je .vert_name
add eax, [win.x]
mov [nwin.x], eax
mov byte[nwin.change_shape], 1
mcall SF_DRAW_RECT, <0, [win.width]>, <[win.height], 1>, [color.frame]
mov byte[nwin.swap_shape], 1
mcall SF_DRAW_RECT, <0, [win.w]>, <[win.h], 1>, [sc.work_dark]
jmp .vert_end
.vert_name:
add eax, [win.y]
add eax, 14
mov [nwin.y], eax
mov byte[nwin.change_shape], 1
mcall SF_DRAW_RECT, <[win.width], 1>, <0, [win.height]>, [color.frame]
mov byte[nwin.swap_shape], 1
mcall SF_DRAW_RECT, <[win.w], 1>, <0, [win.h]>, [sc.work_dark]
.vert_end:
 
; ==== OPEN/CLOSE WINDOW ====
541,22 → 493,14
 
mov byte[win.state], 1
 
mov eax, [win.width_opn]
mov [win.width], eax
m2m dword [win.x], dword [win.x_opn]
m2m dword [win.y], dword [win.y_opn]
m2m dword [win.w], dword [win.w_opn]
m2m dword [win.h], dword [win.h_opn]
 
mov eax, [win.x_opn]
mov [win.x], eax
 
mov eax, [win.height_opn]
mov [win.height], eax
 
mov eax, [win.y_opn]
mov [win.y], eax
 
 
cmp byte[dock_items.ashow],1
je .change_nothing
mcall SF_CHANGE_WINDOW, [win.x], [win.y], [win.width], [win.height]
mcall SF_CHANGE_WINDOW, [win.x], [win.y], [win.w], [win.h]
 
.change_nothing:
call DRAW_WINDOW
573,25 → 517,18
mcall SF_SYSTEM, SSF_FOCUS_WINDOW, [win.psid]
 
mov byte[win.state], 0
mov byte[win.button_index], -1
mov byte[win.btn_index], -1
 
cmp byte[dock_items.ashow],1
je .do_no_hide
 
mov eax, [win.width_hdn]
mov [win.width], eax
m2m dword [win.x], dword [win.x_hdn]
m2m dword [win.y], dword [win.y_hdn]
m2m dword [win.w], dword [win.w_hdn]
m2m dword [win.h], dword [win.h_hdn]
 
mov eax, [win.x_hdn]
mov [win.x], eax
mcall SF_CHANGE_WINDOW, [win.x], [win.y], [win.w], [win.h]
 
mov eax, [win.height_hdn]
mov [win.height], eax
 
mov eax, [win.y_hdn]
mov [win.y], eax
 
mcall SF_CHANGE_WINDOW, [win.x], [win.y], [win.width], [win.height]
 
.do_no_hide:
call DRAW_WINDOW
jmp main_loop
610,7 → 547,7
sub ecx, 0x000C0000
@@:
 
mcall SF_DRAW_RECT, , , [color.bg]
mcall SF_DRAW_RECT, , , [sc.work]
 
mov edx, ebx
shr ecx, 16
621,12 → 558,11
imul ebx, 4
add ebx, dock_items.icon
mov ebx, [ebx]
imul ebx, ICON_SIZE_BGR
add ebx, [img_data.rgb_object]
imul ebx, 32*32*4
add ebx, [icons_inactive]
mcall SF_PUT_IMAGE_EXT, , <32, 32>, , 32, 0, 0
 
mcall SF_PUT_IMAGE, , <32, 32>
 
mov ebx, [win.button_index]
mov ebx, [win.btn_index]
imul ebx, BUTTON_SIZE
add ebx, 14
shl ebx, 16
639,7 → 575,7
sub ecx, 0x000C0000
@@:
 
mcall SF_DRAW_RECT, , , [color.bt]
mcall SF_DRAW_RECT, , , [sc.work_button]
 
mov edx, ebx
shr ecx, 16
646,45 → 582,65
mov dx, cx
add edx, 0x00040004
 
mov ecx, [win.button_index]
imul ecx, 4
add ecx, dock_items.icon
mov ecx, [ecx]
imul ecx, ICON_SIZE_BGR
add ecx, [img_data.rgb_object]
mov ebx, [win.btn_index]
imul ebx, 4
add ebx, dock_items.icon
mov ebx, [ebx]
imul ebx, 32*32*4
add ebx, [icons_active]
mcall SF_PUT_IMAGE_EXT, , <32, 32>, , 32, 0, 0
 
mov ebx, sel_img
ret
;-------------------------------------------------------------------------------
proc icon32cpy uses ecx edx edi esi, dest:dword, src:dword, len:dword, bgcol:dword
mov edi, [dest]
mov esi, [src]
mov ecx, [len]
mov edx, [bgcol]
.loop:
m2m dword [edi], dword [esi]
cmp dword [edi], 0
jne @f
mov dword [edi], edx
@@:
add edi, 4
add esi, 4
sub ecx, 4
cmp ecx, 4
jg .loop
 
mov edi, 0
ret
endp
;-------------------------------------------------------------------------------
LOAD_ICONS:
mov esi, 0 ; esi is a counter of mem_open attempts
@@:
mov al, byte[ecx + 2]
shl eax, 8
mov al, byte[ecx + 1]
shl eax, 8
mov al, byte[ecx + 0]
; try to open shr memory, if failed then make 5 attempts more
mcall SF_SYS_MISC, SSF_MEM_OPEN,icons_resname ; 0 = SHM_READ
cmp eax,0
jne @f
inc esi
cmp esi,10
je exit
mcall SF_SLEEP, 70
jmp @b
@@:
mov [shr_icons_ptr], eax
mov [shr_icons_len], edx
 
or eax, 0x10000000
cmp eax, [color.bg]
jne .notbg
mov eax, [color.bt]
.notbg:
mcall SF_SYS_MISC, SSF_MEM_FREE, [icons_active]
mcall SF_SYS_MISC, SSF_MEM_ALLOC, [shr_icons_len]
mov [icons_active], eax
 
mov byte[ebx + 0], al
shr eax, 8
mov byte[ebx + 1], al
shr eax, 8
mov byte[ebx + 2], al
mcall SF_SYS_MISC, SSF_MEM_FREE, [icons_inactive]
mcall SF_SYS_MISC, SSF_MEM_ALLOC, [shr_icons_len]
mov [icons_inactive], eax
 
add ebx, 3
add ecx, 3
stdcall icon32cpy, [icons_inactive], [shr_icons_ptr], [shr_icons_len], [sc.work]
stdcall icon32cpy, [icons_active], [shr_icons_ptr], [shr_icons_len], [sc.work_button]
 
add edi, 3
mcall SF_SYS_MISC, SSF_MEM_CLOSE,icons_resname
 
cmp edi, 1024 * 3
jne @b
 
mcall SF_PUT_IMAGE, sel_img, <32, 32>
 
ret
;-------------------------------------------------------------------------------
proc sections_callback, _file_name, _section_name