forked from KolibriOS/kolibrios
kiv: Add a button to switch scaling modes.
Two scaling modes (fit to the window, no scaling) were implemented some time ago. One can switch them with not obvious shortcuts 'w' and '=' (like in sxiv). This commit adds a button to the toolbar to do the same. Also, the window title now mentions the number of supported images in the current directory, not the total number of files in it. Align code to the kernel style guide. git-svn-id: svn://kolibrios.org@7860 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
78851ff66b
commit
5a520e0752
@ -152,6 +152,10 @@ still:
|
||||
jz button
|
||||
|
||||
mouse:
|
||||
mov eax, [need_scrollbar_v]
|
||||
add eax, [need_scrollbar_h]
|
||||
test eax, eax
|
||||
jz .done
|
||||
mov [pict_moved], 0
|
||||
|
||||
invoke scrollbar_vert_mouse, scroll_bar_data_vertical
|
||||
@ -518,6 +522,19 @@ button:
|
||||
jmp redraw_all
|
||||
|
||||
@@:
|
||||
cmp eax, 'scl'
|
||||
jnz .not_scl
|
||||
mov eax, LIBIMG_SCALE_NONE
|
||||
cmp [scale_mode], LIBIMG_SCALE_NONE
|
||||
jnz @f
|
||||
mov eax, LIBIMG_SCALE_FIT_MIN
|
||||
@@:
|
||||
call set_scale_mode
|
||||
jz @f
|
||||
call recalc_work
|
||||
@@:
|
||||
jmp redraw_all
|
||||
.not_scl:
|
||||
or esi, -1
|
||||
cmp eax, 'bck'
|
||||
jz next_or_prev_handler
|
||||
@ -968,8 +985,7 @@ proc find_last_name_component
|
||||
endp
|
||||
|
||||
|
||||
proc init_frame _img
|
||||
push ebx edx
|
||||
proc init_frame uses ebx edx, _img
|
||||
mov eax, [orig_image]
|
||||
cmp eax, [_img]
|
||||
jz .exit
|
||||
@ -997,7 +1013,6 @@ proc init_frame _img
|
||||
mov [pict.top], 0
|
||||
mov [pict.left], 0
|
||||
.exit:
|
||||
pop edx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
@ -1077,8 +1092,7 @@ proc draw_window
|
||||
endp
|
||||
|
||||
|
||||
proc draw_view
|
||||
push ebx esi edi
|
||||
proc draw_view uses ebx esi edi
|
||||
cmp [scale_mode], LIBIMG_SCALE_FIT_MIN
|
||||
jnz .scale_none
|
||||
mov ecx, [cur_frame]
|
||||
@ -1114,14 +1128,30 @@ proc draw_view
|
||||
push [view_abs_left] ; xpos
|
||||
invoke img.draw, [cur_frame]
|
||||
.done:
|
||||
pop edi esi ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
proc draw_scale_button
|
||||
pushad
|
||||
mcall 65, buttons+scalebtn*20, <20,20>, [scale_button_xy], 8, palette
|
||||
mov ebx, [scale_button_xy]
|
||||
add ebx, 0x00050006
|
||||
; print letter(s) corresponding to the current scaling mode
|
||||
mov edi, 2
|
||||
mov [scale_button_letter], 'x1'
|
||||
cmp [scale_mode], LIBIMG_SCALE_NONE
|
||||
jz @f
|
||||
add ebx, 0x00020001
|
||||
mov edi, 1
|
||||
mov [scale_button_letter], 'W'
|
||||
; cmp [scale_mode], LIBIMG_SCALE_FIT_MIN
|
||||
@@:
|
||||
mcall 4, , 0x800100ff, scale_button_letter
|
||||
popad
|
||||
ret
|
||||
endp
|
||||
|
||||
proc draw_toolbar
|
||||
push ebx esi edi
|
||||
|
||||
proc draw_toolbar uses ebx esi edi
|
||||
cmp [toolbar.height], 0
|
||||
jz .quit
|
||||
mov ebx, [toolbar_abs_left]
|
||||
@ -1154,6 +1184,8 @@ proc draw_toolbar
|
||||
mcall
|
||||
add ebx, ((5+25*2) SHL 16)+(5+25*2)
|
||||
mcall
|
||||
add ebx, ((5+25*1) SHL 16)+(5+25*1)
|
||||
mcall
|
||||
mov ebx, [toolbar_abs_left]
|
||||
add ebx, [toolbar.width]
|
||||
sub ebx, 25*5+10
|
||||
@ -1178,6 +1210,8 @@ proc draw_toolbar
|
||||
mcall , , , 'bgr'+40000000h
|
||||
add ebx, (0+25*1) SHL 16
|
||||
mcall , , , 'sld'+40000000h
|
||||
add ebx, (5+25*1) SHL 16
|
||||
mcall , , , 'scl'+40000000h
|
||||
mov ebx, [toolbar_abs_left]
|
||||
add ebx, [toolbar.width]
|
||||
sub ebx, 25*5+10
|
||||
@ -1209,6 +1243,10 @@ proc draw_toolbar
|
||||
mcall , buttons+bgrbtn *20
|
||||
add edx, ((0+25*1) SHL 16)+0
|
||||
mcall , buttons+slidebtn *20
|
||||
add edx, ((5+25*1) SHL 16)+0
|
||||
; mcall , buttons+scalebtn *20
|
||||
mov [scale_button_xy], edx
|
||||
call draw_scale_button
|
||||
mov edx, [client_abs_left]
|
||||
add edx, [client.width]
|
||||
sub edx, 25*5+4
|
||||
@ -1226,7 +1264,6 @@ proc draw_toolbar
|
||||
mcall , buttons+rot180btn*20
|
||||
|
||||
.quit:
|
||||
pop edi esi ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
@ -1539,29 +1576,6 @@ proc bin2dec
|
||||
endp
|
||||
|
||||
|
||||
proc is_root_dir _path
|
||||
push ecx esi
|
||||
|
||||
mov esi, [_path]
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
lodsb
|
||||
test al, al
|
||||
jz .done
|
||||
cmp al, '/'
|
||||
jnz @b
|
||||
inc ecx
|
||||
jmp @b
|
||||
.done:
|
||||
xor eax, eax
|
||||
cmp ecx, 3
|
||||
jz @f
|
||||
mov eax, -2
|
||||
@@:
|
||||
pop esi ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
; fills window_header with window title
|
||||
; window title is generated as '[k/n] <filename> - Kolibri Image Viewer'
|
||||
; n = total files in dir
|
||||
@ -1579,8 +1593,8 @@ proc generate_window_header
|
||||
call bin2dec
|
||||
mov byte[edi], '/'
|
||||
inc edi
|
||||
stdcall is_root_dir, path
|
||||
add eax, [files_num]
|
||||
mov eax, [directory_ptr]
|
||||
mov eax, [eax+4]
|
||||
call bin2dec
|
||||
mov word[edi], '] '
|
||||
add edi, 2
|
||||
@ -2145,6 +2159,8 @@ proc recalc_work
|
||||
jnz .recalc_canvas
|
||||
stdcall cmp_box, canvas, canvas_prev
|
||||
jnz .recalc_canvas
|
||||
cmp [bScaleModeChanged], 0
|
||||
jnz .recalc_canvas
|
||||
jmp .recalc_canvas_done
|
||||
.recalc_canvas:
|
||||
stdcall recalc_canvas
|
||||
@ -2173,7 +2189,7 @@ DATA
|
||||
|
||||
s_header db ' - Kolibri Image Viewer',0
|
||||
window_style dd 0x53FFFFFF
|
||||
window BOX 101, 144, 750, 600 ; left top width height
|
||||
window BOX 101, 144, 529, 324 ; left top width height
|
||||
window_prev BOX 0, 0, 0, 0
|
||||
window_save BOX 0, 0, 0, 0 ; restore after slide show
|
||||
client BOX 0, 0, 0, 0
|
||||
@ -2345,7 +2361,7 @@ virtual at 0
|
||||
file 'kivicons.bmp':0xA,4
|
||||
load offbits dword from 0
|
||||
end virtual
|
||||
numimages = 10
|
||||
numimages = 11
|
||||
openbtn = 0
|
||||
backbtn = 1
|
||||
forwardbtn = 2
|
||||
@ -2356,12 +2372,13 @@ rotcwbtn = 6
|
||||
rotccwbtn = 7
|
||||
rot180btn = 8
|
||||
slidebtn = 9
|
||||
scalebtn = 10
|
||||
|
||||
palette:
|
||||
file 'kivicons.bmp':0x36,offbits-0x36
|
||||
buttons:
|
||||
file 'kivicons.bmp':offbits
|
||||
repeat 10
|
||||
repeat 11
|
||||
y = %-1
|
||||
z = 20-%
|
||||
repeat numimages*5
|
||||
@ -2492,7 +2509,7 @@ readdir_fileinfo:
|
||||
dd 0
|
||||
readblocks dd 0
|
||||
directory_ptr dd 0
|
||||
curdir db 1024 dup (?)
|
||||
curdir rb 1024
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
I_END:
|
||||
@ -2520,6 +2537,8 @@ last_name_component rd 1
|
||||
toolbar.height_old rd 1
|
||||
|
||||
procinfo process_information
|
||||
scale_button_xy dd ?
|
||||
scale_button_letter dd ? ; i.e. 'x1',0
|
||||
align 16
|
||||
path rb 4096
|
||||
window_header rb 256
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.3 KiB |
Loading…
Reference in New Issue
Block a user