Rev 7860 | Rev 7870 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5183 | hidnplayr | 1 | format binary as "" |
2 | |||
1004 | diamond | 3 | use32 |
4 | org 0x0 |
||
5 | |||
6 | db 'MENUET01' |
||
7656 | dunkaist | 7 | dd 0x01, START, I_END, E_END, stacktop, __params, sys_path |
1004 | diamond | 8 | |
9 | ;----------------------------------------------------------------------------- |
||
10 | |||
7656 | dunkaist | 11 | __DEBUG__ = 0 |
12 | __DEBUG_LEVEL__ = 1 |
||
1004 | diamond | 13 | |
7656 | dunkaist | 14 | LG_TRACE equ 1 |
1004 | diamond | 15 | |
7656 | dunkaist | 16 | include 'config.inc' |
17 | include 'proc32.inc' |
||
18 | include 'macros.inc' |
||
19 | include 'KOSfuncs.inc' |
||
20 | include 'dll.inc' |
||
21 | include 'debug-fdo.inc' |
||
22 | include 'libimg.inc' |
||
23 | |||
24 | |||
25 | KEY_MOVE_PIXELS = 50 |
||
26 | SCROLL_WIDTH_SIZE = 15 |
||
27 | AR_OFFSET = 10 |
||
28 | |||
7860 | dunkaist | 29 | MIN_WINDOW_WIDTH = 50+25*numimages |
7656 | dunkaist | 30 | MIN_WINDOW_HEIGHT = 100 |
31 | TOOLBAR_HEIGHT = 31 |
||
32 | CANVAS_PADDING = 5 |
||
1004 | diamond | 33 | ;----------------------------------------------------------------------------- |
34 | |||
35 | START: |
||
7656 | dunkaist | 36 | mcall SF_SYSTEM, SSF_MOUSE_SETTINGS, SSSF_SET_SPEED, 5 |
37 | mcall SF_SYSTEM, SSF_MOUSE_SETTINGS, SSSF_SET_SPEEDUP, 5 |
||
38 | mcall SF_SYS_MISC, SSF_HEAP_INIT |
||
39 | mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 ; set kbd mode to scancodes |
||
40 | mcall SF_SET_EVENTS_MASK, EVM_REDRAW or EVM_KEY or EVM_BUTTON or EVM_MOUSE or EVM_MOUSE_FILTER |
||
1004 | diamond | 41 | |
7656 | dunkaist | 42 | stdcall dll.Load, @IMPORT |
43 | or eax, eax |
||
44 | jnz exit |
||
1004 | diamond | 45 | |
7656 | dunkaist | 46 | invoke sort.START, 1 |
1016 | diamond | 47 | |
7656 | dunkaist | 48 | mov ecx, 1 ; for 15.4: 1 = tile |
49 | cmp word[__params], '\T' |
||
50 | jz set_bgr |
||
51 | inc ecx ; for 15.4: 2 = stretch |
||
52 | cmp word[__params], '\S' |
||
53 | jz set_bgr |
||
1004 | diamond | 54 | |
7656 | dunkaist | 55 | cmp byte[__params], 0 |
56 | jz @f |
||
57 | mov esi, __params |
||
58 | mov edi, path |
||
59 | mov ecx, 4096/4 |
||
60 | rep movsd |
||
61 | mov byte[edi-1], 0 |
||
7860 | dunkaist | 62 | @@: |
1594 | mario79 | 63 | ; OpenDialog initialisation |
7656 | dunkaist | 64 | push dword OpenDialog_data |
65 | call [OpenDialog_Init] |
||
1594 | mario79 | 66 | |
1427 | diamond | 67 | ; initialize keyboard handling |
7656 | dunkaist | 68 | invoke ini_get_shortcut, inifilename, aShortcuts, aNext, -1, next_mod |
69 | mov [next_key], eax |
||
70 | invoke ini_get_shortcut, inifilename, aShortcuts, aPrev, -1, prev_mod |
||
71 | mov [prev_key], eax |
||
72 | invoke ini_get_shortcut, inifilename, aShortcuts, aSlide, -1, slide_mod |
||
73 | mov [slide_key], eax |
||
74 | invoke ini_get_shortcut, inifilename, aShortcuts, aTglbar, -1, tglbar_mod |
||
75 | mov [tglbar_key], eax |
||
1427 | diamond | 76 | |
7656 | dunkaist | 77 | cmp byte[__params], 0 |
78 | jnz params_given |
||
1004 | diamond | 79 | |
7656 | dunkaist | 80 | mov [OpenDialog_data.draw_window], draw_window_fake |
81 | |||
1511 | mario79 | 82 | ; OpenDialog Open |
7656 | dunkaist | 83 | push dword OpenDialog_data |
84 | call [OpenDialog_Start] |
||
1470 | mario79 | 85 | |
7656 | dunkaist | 86 | cmp [OpenDialog_data.status], 1 |
87 | jnz exit |
||
1470 | mario79 | 88 | |
7656 | dunkaist | 89 | mov [OpenDialog_data.draw_window], draw_window |
1470 | mario79 | 90 | |
7656 | dunkaist | 91 | mov esi, path |
92 | mov edi, __params |
||
93 | mov ecx, 4096/4 |
||
94 | rep movsd |
||
95 | mov byte[edi-1], 0 |
||
96 | jmp params_given |
||
1004 | diamond | 97 | |
98 | set_bgr: |
||
7656 | dunkaist | 99 | mcall SF_BACKGROUND_SET, SSF_MODE_BG |
7860 | dunkaist | 100 | stdcall load_image, __params+4 |
7656 | dunkaist | 101 | jc exit |
102 | call set_as_bgr |
||
103 | jmp exit |
||
1004 | diamond | 104 | |
105 | params_given: |
||
7656 | dunkaist | 106 | mov esi, __params |
107 | push esi |
||
108 | call find_last_name_component |
||
109 | call load_directory |
||
1004 | diamond | 110 | |
7656 | dunkaist | 111 | pop eax |
112 | stdcall load_image, eax |
||
113 | jc exit |
||
1427 | diamond | 114 | |
1004 | diamond | 115 | ;----------------------------------------------------------------------------- |
116 | |||
7656 | dunkaist | 117 | redraw_all: |
118 | call draw_window |
||
1004 | diamond | 119 | |
120 | still: |
||
7656 | dunkaist | 121 | mov eax, [orig_image] |
7860 | dunkaist | 122 | test [eax+Image.Flags], Image.IsAnimated |
7656 | dunkaist | 123 | movi eax, SF_WAIT_EVENT |
124 | jz .wait_event |
||
125 | mcall SF_SYSTEM_GET, SSF_TIME_COUNT |
||
126 | mov edx, [cur_frame] |
||
127 | mov ebx, [cur_frame_time] |
||
7860 | dunkaist | 128 | add ebx, [edx+Image.Delay] |
7656 | dunkaist | 129 | sub ebx, eax |
7860 | dunkaist | 130 | cmp ebx, [edx+Image.Delay] |
7656 | dunkaist | 131 | jna @f |
132 | call red_update_frame |
||
133 | jmp still |
||
7860 | dunkaist | 134 | @@: |
7656 | dunkaist | 135 | test ebx, ebx |
136 | jnz @f |
||
137 | call red_update_frame |
||
138 | jmp still |
||
7860 | dunkaist | 139 | @@: |
7656 | dunkaist | 140 | movi eax, SF_WAIT_EVENT_TIMEOUT |
7860 | dunkaist | 141 | .wait_event: |
7656 | dunkaist | 142 | mcall |
143 | dec eax |
||
144 | jns @f |
||
145 | call red_update_frame |
||
146 | jmp still |
||
7860 | dunkaist | 147 | @@: |
7656 | dunkaist | 148 | jz redraw_all |
149 | dec eax |
||
150 | jz key |
||
151 | dec eax |
||
152 | jz button |
||
1004 | diamond | 153 | |
7656 | dunkaist | 154 | mouse: |
7860 | dunkaist | 155 | mov eax, [need_scrollbar_v] |
156 | add eax, [need_scrollbar_h] |
||
157 | test eax, eax |
||
158 | jz .done |
||
7656 | dunkaist | 159 | mov [pict_moved], 0 |
160 | |||
161 | invoke scrollbar_vert_mouse, scroll_bar_data_vertical |
||
162 | invoke scrollbar_hort_mouse, scroll_bar_data_horizontal |
||
163 | xor ecx, ecx |
||
164 | mov eax, [scroll_bar_data_vertical.position] |
||
165 | cmp [pict.top], eax |
||
166 | mov [pict.top], eax |
||
167 | setnz cl |
||
168 | mov eax, [scroll_bar_data_horizontal.position] |
||
169 | cmp [pict.left], eax |
||
170 | mov [pict.left], eax |
||
171 | setnz ch |
||
172 | test ecx, ecx |
||
173 | jz @f |
||
174 | call draw_view |
||
175 | call draw_onimage_decorations |
||
7860 | dunkaist | 176 | @@: |
7656 | dunkaist | 177 | |
178 | ; check for scroll |
||
179 | mcall SF_MOUSE_GET, SSF_SCROLL_DATA |
||
180 | test eax, eax |
||
181 | jz .no_scroll |
||
182 | movsx ecx, ax |
||
183 | shl ecx, 4 |
||
184 | sar eax, 16 |
||
185 | shl eax, 4 |
||
186 | stdcall move_pictport, eax, ecx |
||
187 | mov [pict_moved], eax |
||
188 | jmp .mouse_done |
||
7860 | dunkaist | 189 | .no_scroll: |
7656 | dunkaist | 190 | |
191 | ; get cursor coordinates in window |
||
192 | mcall SF_MOUSE_GET, SSF_WINDOW_POSITION |
||
193 | movsx ebx, ax |
||
194 | cmp ebx, 0 |
||
195 | jge @f |
||
196 | add eax, 0x10000 |
||
7860 | dunkaist | 197 | @@: |
7656 | dunkaist | 198 | mov ecx, [mouse_pos] |
199 | cmp eax, ecx |
||
200 | jz .no_mouse_move |
||
201 | mov [mouse_pos], eax |
||
202 | |||
203 | cmp [pict_drag], 1 |
||
204 | jnz .no_mouse_move |
||
205 | sar eax, 16 |
||
206 | movsx edx, cx |
||
207 | sar ecx, 16 |
||
208 | sub eax, ecx |
||
209 | sub ebx, edx |
||
210 | neg eax |
||
211 | neg ebx |
||
212 | stdcall move_pictport, eax, ebx |
||
213 | mov [pict_moved], eax |
||
214 | jmp .no_mouse_move |
||
7860 | dunkaist | 215 | .no_mouse_move: |
7656 | dunkaist | 216 | |
217 | ; check buttons |
||
218 | mcall SF_MOUSE_GET, SSF_BUTTON |
||
219 | mov ecx, eax |
||
220 | xor ecx, [mouse_buttons] |
||
221 | mov [mouse_buttons], eax |
||
222 | test ecx, 0x01 |
||
223 | jz .left_button_handled |
||
224 | test eax, 0x01 |
||
225 | jnz .left_button_down |
||
7860 | dunkaist | 226 | .left_button_up: |
7656 | dunkaist | 227 | mov [pict_drag], 0 |
228 | jmp .left_button_handled |
||
7860 | dunkaist | 229 | .left_button_down: |
7656 | dunkaist | 230 | mov ecx, [mouse_pos] |
231 | movzx edx, cx |
||
232 | sar ecx, 16 |
||
233 | mov ebx, [canvas_abs_top] |
||
234 | add ebx, [view.top] |
||
235 | cmp ebx, edx |
||
236 | jg .left_click_pict_done |
||
237 | add ebx, [view.height] |
||
238 | cmp ebx, edx |
||
239 | jl .left_click_pict_done |
||
240 | mov ebx, [canvas_abs_left] |
||
241 | add ebx, [view.left] |
||
242 | cmp ebx, ecx |
||
243 | jg .left_click_pict_done |
||
244 | add ebx, [view.width] |
||
245 | cmp ebx, ecx |
||
246 | jl .left_click_pict_done |
||
247 | mov [pict_drag], 1 |
||
248 | jmp .left_button_handled |
||
7860 | dunkaist | 249 | .left_click_pict_done: |
7656 | dunkaist | 250 | |
7860 | dunkaist | 251 | .left_button_handled: |
252 | .mouse_done: |
||
7656 | dunkaist | 253 | mov eax, [pict_moved] |
254 | test eax, eax |
||
255 | jz .done |
||
256 | stdcall update_scrollbars, eax |
||
257 | call draw_view |
||
258 | call draw_onimage_decorations |
||
7860 | dunkaist | 259 | .done: |
7656 | dunkaist | 260 | jmp still |
261 | |||
1080 | diamond | 262 | key: |
7656 | dunkaist | 263 | xor esi, esi |
1427 | diamond | 264 | keyloop: |
7656 | dunkaist | 265 | mcall SF_GET_KEY |
266 | test al, al |
||
267 | jnz keyloopdone |
||
268 | shr eax, 8 |
||
269 | mov ecx, eax |
||
270 | mcall SF_KEYBOARD, SSF_GET_CONTROL_KEYS |
||
271 | mov edx, next_mod |
||
272 | call check_shortcut |
||
273 | jz .next |
||
7860 | dunkaist | 274 | add edx, prev_mod-next_mod |
7656 | dunkaist | 275 | call check_shortcut |
276 | jz .prev |
||
7860 | dunkaist | 277 | add edx, slide_mod-prev_mod |
7656 | dunkaist | 278 | call check_shortcut |
279 | jz .slide |
||
7860 | dunkaist | 280 | add edx, tglbar_mod-slide_mod |
7656 | dunkaist | 281 | call check_shortcut |
282 | jz .tglbar |
||
283 | |||
284 | mov edx, scale_none_mod |
||
285 | call check_shortcut |
||
286 | jz .set_scale_none |
||
7860 | dunkaist | 287 | add edx, scale_fit_min_mod-scale_none_mod |
7656 | dunkaist | 288 | call check_shortcut |
289 | jz .set_scale_fit_min |
||
7860 | dunkaist | 290 | add edx, move_pictport_left_1_mod-scale_fit_min_mod |
7656 | dunkaist | 291 | call check_shortcut |
292 | jz .move_pictport_left |
||
7860 | dunkaist | 293 | add edx, move_pictport_left_2_mod-move_pictport_left_1_mod |
7656 | dunkaist | 294 | call check_shortcut |
295 | jz .move_pictport_left |
||
7860 | dunkaist | 296 | add edx, move_pictport_right_1_mod-move_pictport_left_2_mod |
7656 | dunkaist | 297 | call check_shortcut |
298 | jz .move_pictport_right |
||
7860 | dunkaist | 299 | add edx, move_pictport_right_2_mod-move_pictport_right_1_mod |
7656 | dunkaist | 300 | call check_shortcut |
301 | jz .move_pictport_right |
||
7860 | dunkaist | 302 | add edx, move_pictport_up_1_mod-move_pictport_right_2_mod |
7656 | dunkaist | 303 | call check_shortcut |
304 | jz .move_pictport_up |
||
7860 | dunkaist | 305 | add edx, move_pictport_up_2_mod-move_pictport_up_1_mod |
7656 | dunkaist | 306 | call check_shortcut |
307 | jz .move_pictport_up |
||
7860 | dunkaist | 308 | add edx, move_pictport_down_1_mod-move_pictport_up_2_mod |
7656 | dunkaist | 309 | call check_shortcut |
310 | jz .move_pictport_down |
||
7860 | dunkaist | 311 | add edx, move_pictport_down_2_mod-move_pictport_down_1_mod |
7656 | dunkaist | 312 | call check_shortcut |
313 | jz .move_pictport_down |
||
314 | |||
315 | cmp cl, 1 ; Esc |
||
316 | jz .esc |
||
317 | jmp keyloop |
||
7860 | dunkaist | 318 | .esc: |
7656 | dunkaist | 319 | test [bSlideShow], 1 |
320 | jz keyloop |
||
321 | jmp .slide |
||
7860 | dunkaist | 322 | .tglbar: |
7656 | dunkaist | 323 | bt [window_style], 25 |
324 | jnc @f |
||
325 | mov [bToggleToolbar], 1 |
||
326 | xor [bShowToolbar], 1 |
||
7860 | dunkaist | 327 | @@: |
7656 | dunkaist | 328 | jmp keyloop |
7860 | dunkaist | 329 | .slide: |
7656 | dunkaist | 330 | call slide_show |
331 | jmp keyloop |
||
7860 | dunkaist | 332 | .set_scale_none: |
7726 | dunkaist | 333 | mov eax, LIBIMG_SCALE_NONE |
334 | call set_scale_mode |
||
335 | jz @f |
||
7656 | dunkaist | 336 | call recalc_canvas |
7860 | dunkaist | 337 | @@: |
7656 | dunkaist | 338 | jmp keyloop |
7860 | dunkaist | 339 | .set_scale_fit_min: |
7726 | dunkaist | 340 | mov eax, LIBIMG_SCALE_FIT_MIN |
341 | call set_scale_mode |
||
342 | jz @f |
||
7656 | dunkaist | 343 | call recalc_work |
7860 | dunkaist | 344 | @@: |
7656 | dunkaist | 345 | jmp keyloop |
7860 | dunkaist | 346 | .move_pictport_left: |
7656 | dunkaist | 347 | stdcall move_pictport, -KEY_MOVE_PIXELS, 0 |
348 | stdcall update_scrollbars, eax |
||
349 | call draw_view |
||
350 | call draw_onimage_decorations |
||
351 | jmp keyloop |
||
7860 | dunkaist | 352 | .move_pictport_right: |
7656 | dunkaist | 353 | stdcall move_pictport, KEY_MOVE_PIXELS, 0 |
354 | stdcall update_scrollbars, eax |
||
355 | call draw_view |
||
356 | call draw_onimage_decorations |
||
357 | jmp keyloop |
||
7860 | dunkaist | 358 | .move_pictport_up: |
7656 | dunkaist | 359 | stdcall move_pictport, 0, -KEY_MOVE_PIXELS |
360 | stdcall update_scrollbars, eax |
||
361 | call draw_view |
||
362 | call draw_onimage_decorations |
||
363 | jmp keyloop |
||
7860 | dunkaist | 364 | .move_pictport_down: |
7656 | dunkaist | 365 | stdcall move_pictport, 0, KEY_MOVE_PIXELS |
366 | stdcall update_scrollbars, eax |
||
367 | call draw_view |
||
368 | call draw_onimage_decorations |
||
369 | jmp keyloop |
||
7860 | dunkaist | 370 | .prev: |
7656 | dunkaist | 371 | dec esi |
372 | jmp keyloop |
||
7860 | dunkaist | 373 | .next: |
7656 | dunkaist | 374 | inc esi |
375 | jmp keyloop |
||
1427 | diamond | 376 | keyloopdone: |
7656 | dunkaist | 377 | test esi, esi |
378 | jnz next_or_prev_handler |
||
379 | test [bToggleSlideShow], 1 |
||
380 | jnz redraw_all |
||
381 | test [bToggleToolbar], 1 |
||
382 | stdcall recalc_client |
||
383 | jnz redraw_all |
||
384 | test [bScaleModeChanged], 1 |
||
385 | mov [bScaleModeChanged], 0 |
||
386 | jnz redraw_all |
||
387 | test [bNewImage], 1 |
||
388 | mov [bNewImage], 0 |
||
389 | jnz redraw_all |
||
390 | jmp still |
||
1427 | diamond | 391 | next_or_prev_handler: |
7656 | dunkaist | 392 | call next_or_prev_image |
393 | jmp redraw_all |
||
1004 | diamond | 394 | |
1080 | diamond | 395 | red_update_frame: |
7656 | dunkaist | 396 | mov eax, [cur_frame] |
7860 | dunkaist | 397 | mov eax, [eax+Image.Next] |
7656 | dunkaist | 398 | test eax, eax |
399 | jnz @f |
||
400 | mov eax, [cur_image] |
||
7860 | dunkaist | 401 | @@: |
7656 | dunkaist | 402 | mov [cur_frame], eax |
403 | mcall SF_SYSTEM_GET, SSF_TIME_COUNT |
||
404 | mov [cur_frame_time], eax |
||
405 | call draw_view |
||
406 | ret |
||
1080 | diamond | 407 | |
408 | button: |
||
7656 | dunkaist | 409 | mcall SF_GET_BUTTON |
410 | shr eax, 8 |
||
1004 | diamond | 411 | |
7656 | dunkaist | 412 | ; flip horizontally |
413 | cmp eax, 'flh' |
||
414 | jnz .not_flh |
||
1004 | diamond | 415 | |
7656 | dunkaist | 416 | mov eax, [cur_image] |
417 | cmp eax, [orig_image] |
||
418 | jz @f |
||
419 | invoke img.flip, [cur_image], FLIP_HORIZONTAL |
||
7860 | dunkaist | 420 | @@: |
7656 | dunkaist | 421 | invoke img.flip, [orig_image], FLIP_HORIZONTAL |
422 | jmp redraw_all |
||
1004 | diamond | 423 | |
7656 | dunkaist | 424 | ; flip vertically |
7860 | dunkaist | 425 | .not_flh: |
7656 | dunkaist | 426 | cmp eax, 'flv' |
427 | jnz .not_flv |
||
1004 | diamond | 428 | |
7656 | dunkaist | 429 | mov eax, [cur_image] |
430 | cmp eax, [orig_image] |
||
431 | jz @f |
||
432 | invoke img.flip, [cur_image], FLIP_VERTICAL |
||
7860 | dunkaist | 433 | @@: |
7656 | dunkaist | 434 | invoke img.flip, [orig_image], FLIP_VERTICAL |
435 | jmp redraw_all |
||
1004 | diamond | 436 | |
7656 | dunkaist | 437 | ; flip both horizontally and vertically |
7860 | dunkaist | 438 | .not_flv: |
7656 | dunkaist | 439 | cmp eax, 'flb' |
440 | jnz .not_flb |
||
1004 | diamond | 441 | |
7656 | dunkaist | 442 | mov eax, [cur_image] |
443 | cmp eax, [orig_image] |
||
444 | jz @f |
||
445 | invoke img.flip, [cur_image], FLIP_BOTH |
||
7860 | dunkaist | 446 | @@: |
7656 | dunkaist | 447 | invoke img.flip, [orig_image], FLIP_BOTH |
448 | jmp redraw_all |
||
1004 | diamond | 449 | |
7656 | dunkaist | 450 | ; rotate left |
7860 | dunkaist | 451 | .not_flb: |
7656 | dunkaist | 452 | cmp eax, 'rtl' |
453 | jnz .not_rtl |
||
1004 | diamond | 454 | |
7656 | dunkaist | 455 | push ROTATE_90_CCW |
7860 | dunkaist | 456 | .rotate_common: |
7656 | dunkaist | 457 | mov eax, [cur_image] |
458 | cmp eax, [orig_image] |
||
459 | jz @f |
||
460 | invoke img.destroy, [cur_image] |
||
461 | mov [cur_image], 0 |
||
7860 | dunkaist | 462 | @@: |
7656 | dunkaist | 463 | invoke img.rotate, [orig_image] |
464 | jmp redraw_all |
||
1004 | diamond | 465 | |
7656 | dunkaist | 466 | ; rotate right |
7860 | dunkaist | 467 | .not_rtl: |
7656 | dunkaist | 468 | cmp eax, 'rtr' |
469 | jnz .not_rtr |
||
1004 | diamond | 470 | |
7656 | dunkaist | 471 | push ROTATE_90_CW |
472 | jmp .rotate_common |
||
1004 | diamond | 473 | |
7656 | dunkaist | 474 | ; open new file |
7860 | dunkaist | 475 | .not_rtr: |
7656 | dunkaist | 476 | cmp eax, 'opn' |
477 | jnz @f |
||
478 | |||
1511 | mario79 | 479 | ; OpenDialog Open |
7656 | dunkaist | 480 | push dword OpenDialog_data |
481 | call [OpenDialog_Start] |
||
1475 | diamond | 482 | |
7656 | dunkaist | 483 | cmp [OpenDialog_data.status], 1 |
484 | jnz still |
||
1004 | diamond | 485 | |
7656 | dunkaist | 486 | mov esi, path |
487 | mov edi, __params |
||
488 | push edi |
||
489 | mov ecx, 4096/4 |
||
490 | rep movsd |
||
491 | mov byte[edi-1], 0 |
||
1016 | diamond | 492 | |
7656 | dunkaist | 493 | pop esi |
494 | push esi |
||
495 | call find_last_name_component |
||
1016 | diamond | 496 | |
7656 | dunkaist | 497 | pop eax |
498 | push [cur_image] |
||
499 | stdcall load_image, eax |
||
500 | jc .restore_old |
||
501 | call free_directory |
||
502 | jmp redraw_all |
||
503 | |||
7860 | dunkaist | 504 | .restore_old: |
7656 | dunkaist | 505 | pop eax |
506 | jmp still |
||
507 | |||
508 | ; set background |
||
7860 | dunkaist | 509 | @@: |
7656 | dunkaist | 510 | cmp eax, 'bgr' |
511 | jnz @f |
||
1016 | diamond | 512 | |
7656 | dunkaist | 513 | mcall SF_BACKGROUND_SET, SSF_MODE_BG, 2 ; stretch by default |
514 | call set_as_bgr |
||
515 | jmp still |
||
3116 | dunkaist | 516 | |
7860 | dunkaist | 517 | @@: |
7656 | dunkaist | 518 | cmp eax, 'sld' |
519 | jnz @f |
||
3116 | dunkaist | 520 | |
7656 | dunkaist | 521 | call slide_show |
522 | jmp redraw_all |
||
1016 | diamond | 523 | |
7860 | dunkaist | 524 | @@: |
525 | cmp eax, 'scl' |
||
526 | jnz .not_scl |
||
527 | mov eax, LIBIMG_SCALE_NONE |
||
528 | cmp [scale_mode], LIBIMG_SCALE_NONE |
||
529 | jnz @f |
||
530 | mov eax, LIBIMG_SCALE_FIT_MIN |
||
531 | @@: |
||
532 | call set_scale_mode |
||
533 | jz @f |
||
534 | call recalc_work |
||
535 | @@: |
||
536 | jmp redraw_all |
||
537 | .not_scl: |
||
7656 | dunkaist | 538 | or esi, -1 |
539 | cmp eax, 'bck' |
||
540 | jz next_or_prev_handler |
||
541 | neg esi |
||
542 | cmp eax, 'fwd' |
||
543 | jz next_or_prev_handler |
||
1004 | diamond | 544 | |
7656 | dunkaist | 545 | cmp eax, 1 |
546 | jnz still |
||
1004 | diamond | 547 | |
7656 | dunkaist | 548 | exit: |
549 | mcall -1 |
||
1004 | diamond | 550 | |
551 | |||
7656 | dunkaist | 552 | proc load_image _filename |
553 | push ebx esi edi |
||
554 | invoke img.from_file, [_filename] |
||
555 | test eax, eax |
||
556 | jz .error |
||
557 | mov ebx, eax |
||
1004 | diamond | 558 | |
7860 | dunkaist | 559 | test [eax+Image.Flags], Image.IsAnimated |
7656 | dunkaist | 560 | jnz @f |
7860 | dunkaist | 561 | cmp [eax+Image.Next], 0 |
7656 | dunkaist | 562 | jz @f |
563 | stdcall merge_icons_to_single_img, eax |
||
564 | test eax, eax |
||
565 | jz .error_destroy |
||
7860 | dunkaist | 566 | @@: |
7656 | dunkaist | 567 | stdcall init_frame, eax |
568 | clc |
||
569 | jmp .exit |
||
1004 | diamond | 570 | |
7860 | dunkaist | 571 | .error_destroy: |
7656 | dunkaist | 572 | invoke img.destroy, ebx |
573 | xor eax, eax |
||
7860 | dunkaist | 574 | .error: |
7656 | dunkaist | 575 | stc |
7860 | dunkaist | 576 | .exit: |
7656 | dunkaist | 577 | pop edi esi ebx |
578 | ret |
||
579 | endp |
||
1004 | diamond | 580 | |
6804 | IgorA | 581 | |
7656 | dunkaist | 582 | ; in: eax -- pointer to image |
583 | ; out: fill pict structure |
||
584 | proc calculate_picture_size |
||
7860 | dunkaist | 585 | mov edx, [eax+Image.Width] |
586 | test [eax+Image.Flags], Image.IsAnimated |
||
7656 | dunkaist | 587 | jnz .not_in_row |
588 | push eax |
||
7860 | dunkaist | 589 | @@: |
590 | cmp [eax+Image.Next], 0 |
||
7656 | dunkaist | 591 | jz @f |
7860 | dunkaist | 592 | mov eax, [eax+Image.Next] |
593 | add edx, [eax+Image.Width] |
||
7656 | dunkaist | 594 | inc edx |
595 | jmp @b |
||
7860 | dunkaist | 596 | @@: |
7656 | dunkaist | 597 | pop eax |
7860 | dunkaist | 598 | .not_in_row: |
7656 | dunkaist | 599 | mov [pict.width], edx |
600 | add edx, 19 |
||
7860 | dunkaist | 601 | cmp edx, 50+25*numimages |
7656 | dunkaist | 602 | jae @f |
7860 | dunkaist | 603 | mov edx, 50+25*numimages |
604 | @@: |
||
605 | mov esi, [eax+Image.Height] |
||
606 | test [eax+Image.Flags], Image.IsAnimated |
||
7656 | dunkaist | 607 | jnz .max_equals_first |
608 | push eax |
||
7860 | dunkaist | 609 | @@: |
610 | cmp [eax+Image.Next], 0 |
||
7656 | dunkaist | 611 | jz @f |
7860 | dunkaist | 612 | mov eax, [eax+Image.Next] |
613 | cmp esi, [eax+Image.Height] |
||
7656 | dunkaist | 614 | jae @b |
7860 | dunkaist | 615 | mov esi, [eax+Image.Height] |
7656 | dunkaist | 616 | jmp @b |
7860 | dunkaist | 617 | @@: |
7656 | dunkaist | 618 | pop eax |
7860 | dunkaist | 619 | .max_equals_first: |
7656 | dunkaist | 620 | mov [pict.height], esi |
621 | ret |
||
6804 | IgorA | 622 | endp |
623 | |||
1004 | diamond | 624 | |
7656 | dunkaist | 625 | ; in: [orig_image] |
626 | proc set_as_bgr |
||
627 | mov esi, [orig_image] |
||
7860 | dunkaist | 628 | mov ecx, [esi+Image.Width] |
629 | mov edx, [esi+Image.Height] |
||
7656 | dunkaist | 630 | mcall SF_BACKGROUND_SET, SSF_SIZE_BG |
631 | mcall SF_BACKGROUND_SET, SSF_MAP_BG |
||
632 | test eax, eax |
||
633 | jz @f |
||
1004 | diamond | 634 | |
7656 | dunkaist | 635 | push eax |
636 | invoke img.to_rgb2, esi, eax |
||
637 | pop ecx |
||
638 | mcall SF_BACKGROUND_SET, SSF_UNMAP_BG |
||
1016 | diamond | 639 | |
7860 | dunkaist | 640 | @@: |
7656 | dunkaist | 641 | mcall SF_BACKGROUND_SET, SSF_REDRAW_BG |
642 | ; save to file eskin.ini |
||
643 | xor al, al |
||
644 | mov ecx, 1024 |
||
645 | mov edi, sys_path+2 |
||
646 | repne scasb |
||
647 | sub edi, sys_path+3 |
||
648 | invoke ini_set_str, inifileeskin, amain, aprogram, sys_path+2, edi |
||
649 | ; add param '\S__' |
||
650 | cmp word[__params], '\T' |
||
651 | jz @f |
||
652 | cmp word[__params], '\S' |
||
653 | je @f |
||
654 | mov esi, __params+4096-8 |
||
655 | mov edi, __params+4096-4 |
||
656 | mov ecx, 4096/4-1 |
||
657 | std |
||
658 | rep movsd |
||
659 | cld |
||
660 | mov dword[__params], '\S__' |
||
7860 | dunkaist | 661 | @@: |
7656 | dunkaist | 662 | xor al, al |
663 | mov ecx, 4096 |
||
664 | mov edi, __params |
||
665 | repne scasb |
||
666 | sub edi, __params+1 |
||
667 | invoke ini_set_str, inifileeskin, amain, aparam, __params, edi |
||
668 | ret |
||
669 | endp |
||
1016 | diamond | 670 | |
7656 | dunkaist | 671 | proc slide_show |
672 | push ebx esi edi |
||
673 | mov [bToggleSlideShow], 1 |
||
674 | btc [window_style], 25 |
||
675 | xor [bSlideShow], 1 |
||
676 | jnz .to_fullscreen |
||
677 | ; back from fullscreen |
||
678 | movzx eax, [bShowToolbarSave] |
||
679 | mov [bShowToolbar], al |
||
680 | mov [canvas_padding], CANVAS_PADDING |
||
681 | mov [bg_color], 0x00ffffff |
||
682 | mcall SF_CHANGE_WINDOW, [window_save.left], [window_save.top], [window_save.width], [window_save.height] |
||
683 | jmp .done |
||
7860 | dunkaist | 684 | .to_fullscreen: |
7656 | dunkaist | 685 | stdcall copy_box, window, window_save |
686 | movzx eax, [bShowToolbar] |
||
687 | mov [bShowToolbarSave], al |
||
688 | mov [bShowToolbar], 0 |
||
689 | mov [canvas_padding], 0 |
||
690 | mov [bg_color], 0x00000000 |
||
691 | mcall SF_GET_SCREEN_SIZE |
||
692 | mov edx, eax |
||
693 | shr edx, 16 |
||
694 | movzx eax, ax |
||
695 | mov esi, eax |
||
696 | mcall SF_CHANGE_WINDOW, 0, 0, , |
||
7726 | dunkaist | 697 | mov eax, LIBIMG_SCALE_FIT_MIN |
698 | call set_scale_mode |
||
1016 | diamond | 699 | |
7860 | dunkaist | 700 | .done: |
7656 | dunkaist | 701 | pop edi esi ebx |
702 | ret |
||
703 | endp |
||
7421 | leency | 704 | |
1016 | diamond | 705 | |
1427 | diamond | 706 | ; seek to ESI image files |
7860 | dunkaist | 707 | ; esi>0 means next file, esi<0-prev file |
7656 | dunkaist | 708 | proc next_or_prev_image |
709 | locals |
||
710 | files_cnt dd ? |
||
711 | file_idx dd ? |
||
712 | endl |
||
713 | push ebx esi edi |
||
714 | push esi |
||
715 | call load_directory |
||
716 | pop esi |
||
717 | mov eax, [directory_ptr] |
||
718 | mov eax, [eax+4] |
||
719 | mov [files_cnt], eax |
||
720 | cmp [directory_ptr], 0 |
||
721 | jz .ret |
||
722 | cmp [files_cnt], 0 ; number of files |
||
723 | jz .ret |
||
724 | mov eax, [cur_file_idx] |
||
725 | cmp eax, -1 |
||
726 | jnz @f |
||
727 | test esi, esi |
||
728 | jns @f |
||
729 | mov eax, [files_cnt] |
||
7860 | dunkaist | 730 | @@: |
7656 | dunkaist | 731 | add eax, esi |
7860 | dunkaist | 732 | @@: |
7656 | dunkaist | 733 | test eax, eax |
734 | jns @f |
||
735 | add eax, [files_cnt] |
||
736 | jmp @b |
||
7860 | dunkaist | 737 | @@: |
7656 | dunkaist | 738 | cmp eax, [files_cnt] |
739 | jb @f |
||
740 | sub eax, [files_cnt] |
||
741 | jmp @b |
||
7860 | dunkaist | 742 | @@: |
7656 | dunkaist | 743 | mov [file_idx], eax |
7860 | dunkaist | 744 | .scanloop: |
7656 | dunkaist | 745 | push eax esi |
746 | imul esi, eax, 304 |
||
747 | add esi, [directory_ptr] |
||
7860 | dunkaist | 748 | add esi, 32+40 |
7656 | dunkaist | 749 | mov edi, curdir |
7860 | dunkaist | 750 | @@: |
7656 | dunkaist | 751 | inc edi |
752 | cmp byte[edi-1], 0 |
||
753 | jnz @b |
||
754 | mov byte[edi-1], '/' |
||
7860 | dunkaist | 755 | @@: |
7656 | dunkaist | 756 | lodsb |
757 | stosb |
||
758 | test al, al |
||
759 | jnz @b |
||
760 | mov esi, curdir |
||
761 | push esi |
||
762 | mov edi, __params |
||
763 | mov ecx, 4096/4 |
||
764 | rep movsd |
||
765 | mov byte[edi-1], 0 |
||
766 | pop esi |
||
767 | stdcall load_image, curdir |
||
768 | pushfd |
||
7860 | dunkaist | 769 | @@: |
7656 | dunkaist | 770 | lodsb |
771 | test al, al |
||
772 | jnz @b |
||
7860 | dunkaist | 773 | @@: |
7656 | dunkaist | 774 | dec esi |
775 | cmp byte[esi], '/' |
||
776 | jnz @b |
||
777 | mov byte[esi], 0 |
||
778 | popfd |
||
779 | pop esi eax |
||
780 | jnc .loadedok |
||
781 | test esi, esi |
||
782 | js .try_prev |
||
7860 | dunkaist | 783 | .try_next: |
7656 | dunkaist | 784 | inc eax |
785 | cmp eax, [files_cnt] |
||
786 | jb @f |
||
787 | xor eax, eax |
||
7860 | dunkaist | 788 | @@: |
789 | .try_common: |
||
7656 | dunkaist | 790 | cmp eax, [file_idx] |
791 | jz .notfound |
||
792 | jmp .scanloop |
||
7860 | dunkaist | 793 | .try_prev: |
7656 | dunkaist | 794 | dec eax |
795 | jns @f |
||
796 | mov eax, [files_cnt] |
||
797 | dec eax |
||
7860 | dunkaist | 798 | @@: |
7656 | dunkaist | 799 | jmp .try_common |
7860 | dunkaist | 800 | .loadedok: |
7656 | dunkaist | 801 | mov [cur_file_idx], eax |
7860 | dunkaist | 802 | .ret: |
7656 | dunkaist | 803 | pop edi esi ebx |
804 | ret |
||
7860 | dunkaist | 805 | .notfound: |
7656 | dunkaist | 806 | pop edi esi ebx |
807 | ret |
||
808 | endp |
||
1016 | diamond | 809 | |
7656 | dunkaist | 810 | |
1016 | diamond | 811 | load_directory: |
7656 | dunkaist | 812 | cmp [directory_ptr], 0 |
813 | jnz .ret |
||
814 | mov esi, __params |
||
815 | mov edi, curdir |
||
816 | mov ecx, [last_name_component] |
||
817 | sub ecx, esi |
||
818 | dec ecx |
||
819 | js @f |
||
820 | rep movsb |
||
7860 | dunkaist | 821 | @@: |
7656 | dunkaist | 822 | mov byte[edi], 0 |
823 | mcall 68, 12, 0x1000 |
||
824 | test eax, eax |
||
825 | jz .ret |
||
826 | mov ebx, readdir_fileinfo |
||
7860 | dunkaist | 827 | mov dword[ebx+12], (0x1000-32) / 304 ; blocks to read |
7656 | dunkaist | 828 | mov dword[ebx+16], eax ; where to store |
829 | mcall 70 |
||
830 | cmp eax, 6 ; read ok, but there are more files |
||
831 | jz .dirok |
||
832 | test eax, eax |
||
833 | jnz free_directory |
||
834 | mov edx, [directory_ptr] |
||
835 | mov ecx, [edx+8] ; total number of files |
||
836 | mov [readblocks], ecx |
||
837 | imul ecx, 304 ; try to read entire dir, FIXME |
||
838 | add ecx, 32 ; plus header |
||
839 | mcall 68, 20 ; realloc |
||
840 | test eax, eax |
||
841 | jz free_directory |
||
842 | mov [directory_ptr], eax |
||
843 | mcall 70, readdir_fileinfo |
||
7860 | dunkaist | 844 | .dirok: |
7656 | dunkaist | 845 | cmp ebx, 0 |
846 | jle free_directory |
||
847 | mov eax, [directory_ptr] |
||
7860 | dunkaist | 848 | mov edi, [eax+8] ; total number of files |
7656 | dunkaist | 849 | mov [files_num], edi |
850 | add eax, 32 ; skip header |
||
851 | mov edi, eax |
||
852 | push 0 |
||
7860 | dunkaist | 853 | .dirskip: |
7656 | dunkaist | 854 | push eax |
855 | test byte[eax], 0x18 ; volume label or folder |
||
856 | jnz .nocopy |
||
857 | lea esi, [eax+40] ; name |
||
858 | mov ecx, esi |
||
7860 | dunkaist | 859 | @@: |
7656 | dunkaist | 860 | lodsb |
861 | test al, al |
||
862 | jnz @b |
||
7860 | dunkaist | 863 | @@: |
7656 | dunkaist | 864 | dec esi |
865 | cmp esi, ecx |
||
866 | jb .noext |
||
867 | cmp byte[esi], '.' |
||
868 | jnz @b |
||
869 | inc esi |
||
870 | mov ecx, [esi] |
||
871 | cmp byte[esi+3], 0 |
||
872 | jnz .not_3 |
||
873 | or ecx, 0x202020 |
||
874 | cmp ecx, 'jpg' |
||
875 | jz .copy |
||
876 | cmp ecx, 'bmp' |
||
877 | jz .copy |
||
878 | cmp ecx, 'gif' |
||
879 | jz .copy |
||
880 | cmp ecx, 'png' |
||
881 | jz .copy |
||
882 | cmp ecx, 'jpe' |
||
883 | jz .copy |
||
884 | cmp ecx, 'ico' |
||
885 | jz .copy |
||
886 | cmp ecx, 'cur' |
||
887 | jz .copy |
||
888 | cmp ecx, 'tga' |
||
889 | jz .copy |
||
890 | cmp ecx, 'pcx' |
||
891 | jz .copy |
||
892 | cmp ecx, 'xcf' |
||
893 | jz .copy |
||
894 | cmp ecx, 'pbm' |
||
895 | jz .copy |
||
896 | cmp ecx, 'pgm' |
||
897 | jz .copy |
||
898 | cmp ecx, 'pnm' |
||
899 | jz .copy |
||
900 | cmp ecx, 'ppm' |
||
901 | jz .copy |
||
902 | cmp ecx, 'tif' |
||
903 | jz .copy |
||
904 | cmp ecx, 'xbm' |
||
905 | jz .copy |
||
7860 | dunkaist | 906 | .not_3: |
7656 | dunkaist | 907 | cmp byte[esi+4], 0 |
908 | jnz .nocopy |
||
909 | or ecx, 0x20202020 |
||
910 | cmp ecx, 'tiff' |
||
911 | jz @f |
||
912 | cmp ecx, 'wbmp' |
||
913 | jz @f |
||
914 | cmp ecx, 'webp' |
||
915 | jz @f |
||
916 | cmp ecx, 'jpeg' |
||
917 | jnz .nocopy |
||
7860 | dunkaist | 918 | @@: |
7656 | dunkaist | 919 | cmp byte[esi+4], 0 |
920 | jnz .nocopy |
||
7860 | dunkaist | 921 | .copy: |
7656 | dunkaist | 922 | mov esi, [esp] |
923 | mov ecx, 304 / 4 |
||
924 | rep movsd |
||
925 | inc dword[esp+4] |
||
7860 | dunkaist | 926 | .nocopy: |
927 | .noext: |
||
7656 | dunkaist | 928 | pop eax |
929 | add eax, 304 |
||
930 | dec ebx |
||
931 | jnz .dirskip |
||
932 | mov eax, [directory_ptr] |
||
933 | pop ebx |
||
934 | mov [eax+4], ebx |
||
935 | test ebx, ebx |
||
936 | jz free_directory |
||
937 | push 0 ; sort mode |
||
938 | push ebx |
||
939 | add eax, 32 |
||
940 | push eax |
||
941 | call [SortDir] |
||
942 | xor eax, eax |
||
943 | mov edi, [directory_ptr] |
||
7860 | dunkaist | 944 | add edi, 32+40 ; name |
945 | .scan: |
||
7656 | dunkaist | 946 | mov esi, [last_name_component] |
947 | push edi |
||
948 | invoke strcmpi |
||
949 | pop edi |
||
950 | jz .found |
||
951 | inc eax |
||
952 | add edi, 304 |
||
953 | dec ebx |
||
954 | jnz .scan |
||
955 | or eax, -1 |
||
7860 | dunkaist | 956 | .found: |
7656 | dunkaist | 957 | mov [cur_file_idx], eax |
7860 | dunkaist | 958 | .ret: |
7656 | dunkaist | 959 | ret |
1016 | diamond | 960 | |
961 | free_directory: |
||
7656 | dunkaist | 962 | mcall 68, 13, [directory_ptr] |
963 | and [directory_ptr], 0 |
||
964 | ret |
||
1016 | diamond | 965 | |
7656 | dunkaist | 966 | |
1427 | diamond | 967 | ; in: esi->full name (e.g. /path/to/file.png) |
968 | ; out: [last_name_component]->last component (e.g. file.png) |
||
7656 | dunkaist | 969 | proc find_last_name_component |
970 | mov ecx, esi |
||
7860 | dunkaist | 971 | @@: |
7656 | dunkaist | 972 | lodsb |
973 | test al, al |
||
974 | jnz @b |
||
7860 | dunkaist | 975 | @@: |
7656 | dunkaist | 976 | dec esi |
977 | cmp esi, ecx |
||
978 | jb @f |
||
979 | cmp byte[esi], '/' |
||
980 | jnz @b |
||
7860 | dunkaist | 981 | @@: |
7656 | dunkaist | 982 | inc esi |
983 | mov [last_name_component], esi |
||
984 | ret |
||
985 | endp |
||
1427 | diamond | 986 | |
1080 | diamond | 987 | |
7860 | dunkaist | 988 | proc init_frame uses ebx edx, _img |
7656 | dunkaist | 989 | mov eax, [orig_image] |
990 | cmp eax, [_img] |
||
991 | jz .exit |
||
992 | test eax, eax |
||
993 | jz .freed |
||
994 | cmp eax, [cur_image] |
||
995 | jz @f |
||
996 | invoke img.destroy, [orig_image] |
||
7860 | dunkaist | 997 | @@: |
7656 | dunkaist | 998 | invoke img.destroy, [cur_image] |
7860 | dunkaist | 999 | .freed: |
3116 | dunkaist | 1000 | |
7656 | dunkaist | 1001 | mov [bNewImage], 1 |
1002 | mov eax, [_img] |
||
1003 | mov [orig_image], eax |
||
1004 | mov [cur_image], eax |
||
1005 | mov [cur_frame], eax |
||
7860 | dunkaist | 1006 | test byte[eax+Image.Flags], Image.IsAnimated |
7656 | dunkaist | 1007 | jz @f |
1008 | push ebx |
||
1009 | mcall SF_SYSTEM_GET, SSF_TIME_COUNT |
||
1010 | pop ebx |
||
1011 | mov [cur_frame_time], eax |
||
7860 | dunkaist | 1012 | @@: |
7656 | dunkaist | 1013 | mov [pict.top], 0 |
1014 | mov [pict.left], 0 |
||
7860 | dunkaist | 1015 | .exit: |
7656 | dunkaist | 1016 | ret |
1017 | endp |
||
1040 | diamond | 1018 | |
1019 | |||
7656 | dunkaist | 1020 | proc draw_window |
1021 | test [bFirstWinDraw], 1 |
||
1022 | jnz .min_size_ok |
||
1040 | diamond | 1023 | |
7656 | dunkaist | 1024 | mcall SF_THREAD_INFO, procinfo, -1 |
1025 | xor eax, eax |
||
1026 | mov edx, -1 |
||
1027 | mov esi, -1 |
||
1028 | cmp [procinfo.box.width], MIN_WINDOW_WIDTH |
||
1029 | ja @f |
||
1030 | mov edx, MIN_WINDOW_WIDTH |
||
1031 | inc eax |
||
7860 | dunkaist | 1032 | @@: |
7656 | dunkaist | 1033 | cmp [procinfo.box.height], MIN_WINDOW_HEIGHT |
1034 | ja @f |
||
1035 | mov esi, MIN_WINDOW_HEIGHT |
||
1036 | inc eax |
||
7860 | dunkaist | 1037 | @@: |
7656 | dunkaist | 1038 | test eax, eax |
1039 | jz @f |
||
1040 | mcall SF_CHANGE_WINDOW, -1, -1, , |
||
7860 | dunkaist | 1041 | @@: |
1004 | diamond | 1042 | |
7860 | dunkaist | 1043 | .min_size_ok: |
7656 | dunkaist | 1044 | test [bNewImage], 1 |
1045 | jz @f |
||
1046 | call generate_window_header |
||
7860 | dunkaist | 1047 | @@: |
7656 | dunkaist | 1048 | mcall SF_REDRAW, SSF_BEGIN_DRAW |
1049 | mov ecx, [window.top] |
||
1050 | shl ecx, 16 |
||
1051 | mov cx, word[window.height] |
||
1052 | mov ebx, [window.left] |
||
1053 | shl ebx, 16 |
||
1054 | mov bx, word[window.width] |
||
1055 | mcall 0, , , [window_style], 0, window_header |
||
1004 | diamond | 1056 | |
7656 | dunkaist | 1057 | mcall SF_THREAD_INFO, procinfo, -1 |
1058 | test [procinfo.wnd_state], 0x04 |
||
1059 | jnz .nodraw |
||
1004 | diamond | 1060 | |
7656 | dunkaist | 1061 | stdcall copy_box, window, window_prev |
1062 | stdcall copy_box, procinfo.box, window |
||
1063 | test [bFirstWinDraw], 1 |
||
1064 | jnz .recalc |
||
1065 | test [bToggleSlideShow], 1 |
||
1066 | jnz .recalc |
||
1067 | mov eax, [window.width] |
||
1068 | cmp eax, [window_prev.width] |
||
1069 | jnz .recalc |
||
1070 | mov eax, [window.height] |
||
1071 | cmp eax, [window_prev.height] |
||
1072 | jnz .recalc |
||
1073 | test [bNewImage], 1 |
||
1074 | jnz .recalc |
||
1075 | test [bToggleToolbar], 1 |
||
1076 | jnz .recalc |
||
1077 | jmp .recalc_done |
||
1004 | diamond | 1078 | |
7860 | dunkaist | 1079 | .recalc: |
7656 | dunkaist | 1080 | stdcall recalc_window |
7860 | dunkaist | 1081 | .recalc_done: |
1004 | diamond | 1082 | |
7656 | dunkaist | 1083 | stdcall draw_client |
7860 | dunkaist | 1084 | .nodraw: |
7656 | dunkaist | 1085 | mcall SF_REDRAW, SSF_END_DRAW |
1086 | mov [bFirstWinDraw], 0 |
||
1087 | mov [bNewImage], 0 |
||
1088 | mov [bToggleToolbar], 0 |
||
1089 | mov [bToggleSlideShow], 0 |
||
3116 | dunkaist | 1090 | |
7656 | dunkaist | 1091 | ret |
1092 | endp |
||
1004 | diamond | 1093 | |
1040 | diamond | 1094 | |
7860 | dunkaist | 1095 | proc draw_view uses ebx esi edi |
7656 | dunkaist | 1096 | cmp [scale_mode], LIBIMG_SCALE_FIT_MIN |
1097 | jnz .scale_none |
||
1098 | mov ecx, [cur_frame] |
||
7860 | dunkaist | 1099 | mov eax, [ecx+Image.Width] |
7656 | dunkaist | 1100 | cmp eax, [view.width] |
1101 | jnz .scale |
||
7860 | dunkaist | 1102 | mov eax, [ecx+Image.Height] |
7656 | dunkaist | 1103 | cmp eax, [view.height] |
1104 | jnz .scale |
||
1105 | jmp .draw |
||
7860 | dunkaist | 1106 | .scale: |
7656 | dunkaist | 1107 | mov eax, [orig_image] |
1108 | cmp eax, [cur_image] |
||
1109 | jz @f |
||
1110 | invoke img.destroy, [cur_image] |
||
1111 | mov eax, [orig_image] |
||
7860 | dunkaist | 1112 | @@: |
1113 | invoke img.scale, eax, 0, 0, [eax+Image.Width], [eax+Image.Height], 0, LIBIMG_SCALE_STRETCH, LIBIMG_INTER_DEFAULT, [view.width], [view.height] |
||
7656 | dunkaist | 1114 | test eax, eax |
1115 | ;FIXME |
||
1116 | mov [cur_image], eax |
||
1117 | mov [cur_frame], eax ; FIXME index |
||
1118 | jmp .draw |
||
1004 | diamond | 1119 | |
7860 | dunkaist | 1120 | .scale_none: |
1080 | diamond | 1121 | |
7860 | dunkaist | 1122 | .draw: |
7656 | dunkaist | 1123 | push [pict.top] |
1124 | push [pict.left] |
||
1125 | push [view.height] |
||
1126 | push [view.width] |
||
1127 | push [view_abs_top] ; ypos |
||
1128 | push [view_abs_left] ; xpos |
||
1129 | invoke img.draw, [cur_frame] |
||
7860 | dunkaist | 1130 | .done: |
7656 | dunkaist | 1131 | ret |
1132 | endp |
||
1004 | diamond | 1133 | |
7860 | dunkaist | 1134 | proc draw_scale_button |
1135 | pushad |
||
1136 | mcall 65, buttons+scalebtn*20, <20,20>, [scale_button_xy], 8, palette |
||
1137 | mov ebx, [scale_button_xy] |
||
1138 | add ebx, 0x00050006 |
||
1139 | ; print letter(s) corresponding to the current scaling mode |
||
1140 | mov edi, 2 |
||
1141 | mov [scale_button_letter], 'x1' |
||
1142 | cmp [scale_mode], LIBIMG_SCALE_NONE |
||
1143 | jz @f |
||
1144 | add ebx, 0x00020001 |
||
1145 | mov edi, 1 |
||
1146 | mov [scale_button_letter], 'W' |
||
1147 | ; cmp [scale_mode], LIBIMG_SCALE_FIT_MIN |
||
1148 | @@: |
||
7862 | dunkaist | 1149 | mcall 4, , 0x800000ff, scale_button_letter |
7860 | dunkaist | 1150 | popad |
1151 | ret |
||
1152 | endp |
||
7656 | dunkaist | 1153 | |
7860 | dunkaist | 1154 | proc draw_toolbar uses ebx esi edi |
7656 | dunkaist | 1155 | cmp [toolbar.height], 0 |
1156 | jz .quit |
||
1157 | mov ebx, [toolbar_abs_left] |
||
1158 | shl ebx, 16 |
||
1159 | add ebx, [toolbar.width] |
||
1160 | inc ebx |
||
1161 | mov ecx, [toolbar_abs_top] |
||
1162 | shl ecx, 16 |
||
1163 | add ecx, [toolbar.height] |
||
1164 | mcall 13, , , [bg_color] |
||
1165 | mov ebx, [toolbar_abs_left] |
||
1166 | shl ebx, 16 |
||
1167 | add ebx, [toolbar_abs_left] |
||
1168 | add ebx, [toolbar.width] |
||
1169 | mov ecx, [toolbar_abs_top] |
||
1170 | shl ecx, 16 |
||
1171 | add ecx, [toolbar_abs_top] |
||
7860 | dunkaist | 1172 | add ecx, (30 SHL 16)+30 |
7656 | dunkaist | 1173 | mcall 38, , , 0x007F7F7F |
1174 | mov ebx, [toolbar_abs_left] |
||
1175 | shl ebx, 16 |
||
1176 | add ebx, [toolbar_abs_left] |
||
7860 | dunkaist | 1177 | add ebx, ((5+25*1) SHL 16)+(5+25*1) |
7656 | dunkaist | 1178 | mov ecx, [toolbar_abs_top] |
1179 | shl ecx, 16 |
||
1180 | add ecx, [toolbar_abs_top] |
||
1181 | add ecx, [toolbar.height] |
||
1182 | mcall |
||
7860 | dunkaist | 1183 | add ebx, ((5+25*2) SHL 16)+(5+25*2) |
7656 | dunkaist | 1184 | mcall |
7860 | dunkaist | 1185 | add ebx, ((5+25*2) SHL 16)+(5+25*2) |
7656 | dunkaist | 1186 | mcall |
7860 | dunkaist | 1187 | add ebx, ((5+25*1) SHL 16)+(5+25*1) |
1188 | mcall |
||
7656 | dunkaist | 1189 | mov ebx, [toolbar_abs_left] |
1190 | add ebx, [toolbar.width] |
||
7860 | dunkaist | 1191 | sub ebx, 25*5+10 |
7656 | dunkaist | 1192 | shl ebx, 16 |
1193 | add ebx, [toolbar_abs_left] |
||
1194 | add ebx, [toolbar.width] |
||
7860 | dunkaist | 1195 | sub ebx, 25*5+10 |
7656 | dunkaist | 1196 | mcall |
1197 | |||
1198 | mov ebx, [toolbar_abs_left] |
||
1199 | shl ebx, 16 |
||
7860 | dunkaist | 1200 | add ebx, ((4+25*0) SHL 16)+21 |
7656 | dunkaist | 1201 | mov ecx, [toolbar_abs_top] |
1202 | shl ecx, 16 |
||
7860 | dunkaist | 1203 | add ecx, (4 SHL 16)+21 |
7656 | dunkaist | 1204 | mcall SF_DEFINE_BUTTON, , , 'opn'+40000000h |
7860 | dunkaist | 1205 | add ebx, (5+25*1) SHL 16 |
7656 | dunkaist | 1206 | mcall , , , 'bck'+40000000h |
7860 | dunkaist | 1207 | add ebx, (0+25*1) SHL 16 |
7656 | dunkaist | 1208 | mcall , , , 'fwd'+40000000h |
7860 | dunkaist | 1209 | add ebx, (5+25*1) SHL 16 |
7656 | dunkaist | 1210 | mcall , , , 'bgr'+40000000h |
7860 | dunkaist | 1211 | add ebx, (0+25*1) SHL 16 |
7656 | dunkaist | 1212 | mcall , , , 'sld'+40000000h |
7860 | dunkaist | 1213 | add ebx, (5+25*1) SHL 16 |
1214 | mcall , , , 'scl'+40000000h |
||
7656 | dunkaist | 1215 | mov ebx, [toolbar_abs_left] |
1216 | add ebx, [toolbar.width] |
||
7860 | dunkaist | 1217 | sub ebx, 25*5+10 |
7656 | dunkaist | 1218 | add ebx, 5 |
1219 | shl ebx, 16 |
||
1220 | mov bl, 21 |
||
1221 | mcall , , , 'flh'+40000000h |
||
1222 | add ebx, 25 SHL 16 |
||
1223 | mcall , , , 'flv'+40000000h |
||
1224 | add ebx, 30 SHL 16 |
||
1225 | mcall , , , 'rtr'+40000000h |
||
1226 | add ebx, 25 SHL 16 |
||
1227 | mcall , , , 'rtl'+40000000h |
||
1228 | add ebx, 25 SHL 16 |
||
1229 | mcall , , , 'flb'+40000000h |
||
1230 | |||
1231 | mov ebp, (numimages-1)*20 |
||
1232 | |||
1233 | mov edx, [toolbar_abs_left] |
||
1234 | shl edx, 16 |
||
1235 | add edx, [toolbar_abs_top] |
||
7860 | dunkaist | 1236 | add edx, ((5+25*0) SHL 16)+5 |
1237 | mcall 65, buttons+openbtn *20, <20, 20>, , 8, palette |
||
1238 | add edx, ((5+25*1) SHL 16)+0 |
||
1239 | mcall , buttons+backbtn *20 |
||
1240 | add edx, ((0+25*1) SHL 16)+0 |
||
1241 | mcall , buttons+forwardbtn*20 |
||
1242 | add edx, ((5+25*1) SHL 16)+0 |
||
1243 | mcall , buttons+bgrbtn *20 |
||
1244 | add edx, ((0+25*1) SHL 16)+0 |
||
1245 | mcall , buttons+slidebtn *20 |
||
1246 | add edx, ((5+25*1) SHL 16)+0 |
||
1247 | ; mcall , buttons+scalebtn *20 |
||
1248 | mov [scale_button_xy], edx |
||
1249 | call draw_scale_button |
||
7656 | dunkaist | 1250 | mov edx, [client_abs_left] |
1251 | add edx, [client.width] |
||
7860 | dunkaist | 1252 | sub edx, 25*5+4 |
7656 | dunkaist | 1253 | shl edx, 16 |
1254 | add edx, [client_abs_top] |
||
1255 | add edx, 5 |
||
1256 | mcall , buttons+fliphorzbtn*20 |
||
7860 | dunkaist | 1257 | add edx, 25*65536 |
7656 | dunkaist | 1258 | mcall , buttons+flipvertbtn*20 |
7860 | dunkaist | 1259 | add edx, 30*65536 |
7656 | dunkaist | 1260 | mcall , buttons+rotcwbtn*20 |
7860 | dunkaist | 1261 | add edx, 25*65536 |
7656 | dunkaist | 1262 | mcall , buttons+rotccwbtn*20 |
7860 | dunkaist | 1263 | add edx, 25*65536 |
7656 | dunkaist | 1264 | mcall , buttons+rot180btn*20 |
1265 | |||
7860 | dunkaist | 1266 | .quit: |
7656 | dunkaist | 1267 | ret |
1268 | endp |
||
1269 | |||
1270 | |||
1271 | proc draw_canvas |
||
1272 | push ebx esi edi |
||
1273 | |||
1274 | mov ebx, [canvas_abs_left] |
||
1275 | shl ebx, 16 |
||
1276 | add ebx, [canvas.width] |
||
1277 | mov ecx, [canvas_abs_top] |
||
1278 | shl ecx, 16 |
||
1279 | add ecx, [view.top] |
||
1280 | ;mov edx, 0xff0000 |
||
1281 | mcall 13, , , [bg_color] |
||
1282 | mcall 13 |
||
1283 | mov ecx, [view_abs_top] |
||
1284 | add ecx, [view.height] |
||
1285 | shl ecx, 16 |
||
1286 | add ecx, [canvas.height] |
||
1287 | sub ecx, [view.top] |
||
1288 | sub ecx, [view.height] |
||
1289 | ;mov edx, 0x00ff00 |
||
1290 | mcall 13, , , [bg_color] |
||
1291 | mcall 13 |
||
1292 | mov ebx, [canvas_abs_left] |
||
1293 | shl ebx, 16 |
||
1294 | add ebx, [view.left] |
||
1295 | mov ecx, [canvas_abs_top] |
||
1296 | shl ecx, 16 |
||
1297 | add ecx, [canvas.height] |
||
1298 | ;mov edx, 0x0000ff |
||
1299 | ;bg_color |
||
1300 | mcall |
||
1301 | mov ebx, [view_abs_left] |
||
1302 | add ebx, [view.width] |
||
1303 | shl ebx, 16 |
||
1304 | mov eax, [canvas.width] |
||
1305 | sub eax, [view.left] |
||
1306 | sub ebx, [view.width] |
||
1307 | add ebx, eax |
||
1308 | ;mov edx, 0xffff00 |
||
1309 | ;bg_color |
||
1310 | mcall 13 |
||
7860 | dunkaist | 1311 | @@: |
7656 | dunkaist | 1312 | |
1313 | call draw_view |
||
1314 | |||
1315 | pop edi esi ebx |
||
1316 | ret |
||
1317 | endp |
||
1318 | |||
1319 | |||
1320 | proc draw_client |
||
1321 | push ebx esi edi |
||
1322 | |||
1323 | test [bShowToolbar], 1 |
||
1324 | jz .toolbar_done |
||
1325 | call draw_toolbar |
||
7860 | dunkaist | 1326 | .toolbar_done: |
7656 | dunkaist | 1327 | call draw_work |
1328 | |||
1329 | pop edi esi ebx |
||
1330 | ret |
||
1331 | endp |
||
1332 | |||
1333 | |||
1334 | proc draw_work |
||
1335 | push ebx esi edi |
||
1336 | |||
1337 | mov ebx, [work_abs_left] |
||
1338 | shl ebx, 16 |
||
1339 | add ebx, [work.width] |
||
1340 | inc ebx |
||
1341 | mov ecx, [work_abs_top] |
||
1342 | shl ecx, 16 |
||
1343 | add ecx, [canvas.top] |
||
1344 | ; mcall 13, , , 0xff0000 |
||
1345 | mcall 13, , , [bg_color] |
||
1346 | mov eax, [canvas.height] |
||
1347 | ror ecx, 16 |
||
1348 | add ecx, eax |
||
1349 | add ecx, [canvas_padding] |
||
1350 | ror ecx, 16 |
||
1351 | ; mcall 13, , , 0x00ff00 |
||
1352 | mcall 13, , , [bg_color] |
||
1353 | ; mcall 13 |
||
1354 | |||
1355 | mov ebx, [work_abs_left] |
||
1356 | shl ebx, 16 |
||
1357 | add ebx, [canvas.left] |
||
1358 | mov ecx, [work_abs_top] |
||
1359 | add ecx, [canvas_padding] |
||
1360 | shl ecx, 16 |
||
1361 | add ecx, [canvas.height] |
||
1362 | ; mcall 13, , , 0x0000ff |
||
1363 | mcall 13, , , [bg_color] |
||
1364 | ; mcall |
||
1365 | mov eax, [canvas.width] |
||
1366 | ror ebx, 16 |
||
1367 | add ebx, eax |
||
1368 | add ebx, [canvas_padding] |
||
1369 | ror ebx, 16 |
||
1370 | ; mcall 13, , , 0xffff00 |
||
1371 | mcall 13, , , [bg_color] |
||
1372 | ; mcall 13 |
||
1373 | |||
1374 | call draw_canvas |
||
1375 | call draw_onimage_decorations |
||
1376 | |||
1377 | mov eax, 13 |
||
1378 | cmp [need_scrollbar_v], 1 |
||
1379 | jnz @f |
||
1380 | cmp [need_scrollbar_h], 1 |
||
1381 | jnz @f |
||
1382 | mov ebx, [work_abs_left] |
||
1383 | add ebx, [work.width] |
||
1384 | sub ebx, SCROLL_WIDTH_SIZE |
||
1385 | shl ebx, 16 |
||
1386 | add ebx, SCROLL_WIDTH_SIZE |
||
1387 | inc ebx |
||
1388 | mov ecx, [work_abs_top] |
||
1389 | add ecx, [work.height] |
||
1390 | sub ecx, SCROLL_WIDTH_SIZE |
||
1391 | shl ecx, 16 |
||
1392 | add ecx, SCROLL_WIDTH_SIZE |
||
1393 | inc ecx |
||
1394 | mov edx, [bg_color] |
||
1395 | ; mov edx, 0x00ffff |
||
1396 | mcall |
||
7860 | dunkaist | 1397 | @@: |
7656 | dunkaist | 1398 | |
1399 | cmp [need_scrollbar_v], 0 |
||
1400 | jz .v_scrollbar_done |
||
1401 | mov eax, [client.left] |
||
1402 | add eax, [client.width] |
||
1403 | sub eax, SCROLL_WIDTH_SIZE |
||
1404 | mov [scroll_bar_data_vertical.start_x], ax |
||
1405 | mov eax, [toolbar.height] |
||
1406 | add eax, [client.top] |
||
1407 | mov [scroll_bar_data_vertical.start_y], ax |
||
1408 | mov eax, [canvas.height] |
||
1409 | add eax, [canvas_padding] |
||
1410 | add eax, [canvas_padding] |
||
1411 | mov [scroll_bar_data_vertical.size_y], ax |
||
1412 | mov [scroll_bar_data_vertical.all_redraw], 1 |
||
1413 | invoke scrollbar_vert_draw, scroll_bar_data_vertical |
||
7860 | dunkaist | 1414 | .v_scrollbar_done: |
7656 | dunkaist | 1415 | |
1416 | cmp [need_scrollbar_h], 0 |
||
1417 | jz .h_scrollbar_done |
||
1418 | mov eax, [client.left] |
||
1419 | mov [scroll_bar_data_horizontal.start_x], ax |
||
1420 | mov eax, [client.top] |
||
1421 | add eax, [client.height] |
||
1422 | sub eax, SCROLL_WIDTH_SIZE |
||
1423 | mov [scroll_bar_data_horizontal.start_y], ax |
||
1424 | mov eax, [canvas.width] |
||
1425 | add eax, [canvas_padding] |
||
1426 | add eax, [canvas_padding] |
||
1427 | mov [scroll_bar_data_horizontal.size_x], ax |
||
1428 | mov [scroll_bar_data_horizontal.all_redraw], 1 |
||
1429 | invoke scrollbar_hort_draw, scroll_bar_data_horizontal |
||
7860 | dunkaist | 1430 | .h_scrollbar_done: |
7656 | dunkaist | 1431 | |
1432 | pop edi esi ebx |
||
1433 | ret |
||
1434 | endp |
||
1435 | |||
1436 | |||
1437 | proc draw_onimage_decorations |
||
1438 | bt [window_style], 25 |
||
1439 | jc @f |
||
1440 | ; draw fullscreen decorations on image |
||
1441 | call draw_filename |
||
1442 | call draw_fullscreen_controls |
||
7860 | dunkaist | 1443 | @@: |
7656 | dunkaist | 1444 | ret |
1445 | endp |
||
1446 | |||
1447 | |||
1448 | proc draw_filename |
||
1449 | push esi |
||
1450 | mcall 4, <100, 65>, 0x40ffffff, window_header, [window_header_len], 0x008800 |
||
1451 | pop esi |
||
1452 | ret |
||
1453 | endp |
||
1454 | |||
1455 | |||
1456 | proc draw_fullscreen_controls |
||
1457 | push esi |
||
1458 | mov ebx, [canvas.width] |
||
1459 | shr ebx, 1 |
||
1460 | add ebx, [canvas.left] |
||
1461 | sub ebx, 22 |
||
1462 | shl ebx, 16 |
||
1463 | add ebx, 20 |
||
1464 | mov ecx, [canvas.height] |
||
1465 | shr ecx, 3 |
||
1466 | neg ecx |
||
1467 | add ecx, [canvas.height] |
||
1468 | add ecx, [canvas.top] |
||
1469 | shl ecx, 16 |
||
1470 | add ecx, 20 |
||
1471 | mcall 8, , , 'bck'+40000000h |
||
1472 | add ebx, 25 SHL 16 |
||
1473 | mcall 8, , , 'fwd'+40000000h |
||
1474 | mov edx, [canvas.width] |
||
1475 | shr edx, 1 |
||
1476 | add edx, [canvas.left] |
||
1477 | sub edx, 22 |
||
1478 | shl edx, 16 |
||
1479 | add edx, [canvas.height] |
||
1480 | shr dx, 3 |
||
1481 | neg dx |
||
1482 | add dx, word[canvas.height] |
||
1483 | add edx, [canvas.top] |
||
7860 | dunkaist | 1484 | mcall 65, buttons+backbtn*20, <20, 20>, , 8, palette |
7656 | dunkaist | 1485 | add edx, 25 SHL 16 |
7860 | dunkaist | 1486 | mcall 65, buttons+forwardbtn*20, , , 8, |
7656 | dunkaist | 1487 | pop esi |
1488 | ret |
||
1489 | endp |
||
1490 | |||
1491 | |||
1492 | proc check_shortcut |
||
1570 | dunkaist | 1493 | ; in: cl = scancode (from sysfn 2), |
1494 | ; eax = state of modifiers (from sysfn 66.3), |
||
1495 | ; edx -> shortcut descriptor |
||
1496 | ; out: ZF set <=> fail |
||
7656 | dunkaist | 1497 | cmp cl, [edx+4] |
1498 | jnz .not |
||
1499 | push eax |
||
1500 | mov esi, [edx] |
||
1501 | and esi, 0xf |
||
1502 | and al, 3 |
||
1503 | call dword[check_modifier_table+esi*4] |
||
1504 | test al, al |
||
1505 | pop eax |
||
1506 | jnz .not |
||
1507 | push eax |
||
1508 | mov esi, [edx] |
||
1509 | shr esi, 4 |
||
1510 | and esi, 0xf |
||
1511 | shr al, 2 |
||
1512 | and al, 3 |
||
1513 | call dword[check_modifier_table+esi*4] |
||
1514 | test al, al |
||
1515 | pop eax |
||
1516 | jnz .not |
||
1517 | push eax |
||
1518 | mov esi, [edx] |
||
1519 | shr esi, 8 |
||
1520 | and esi, 0xf |
||
1521 | shr al, 4 |
||
1522 | and al, 3 |
||
1523 | call dword[check_modifier_table+esi*4] |
||
1524 | test al, al |
||
1525 | pop eax |
||
1526 | ; jnz .not |
||
7860 | dunkaist | 1527 | .not: |
7656 | dunkaist | 1528 | ret |
1529 | endp |
||
1427 | diamond | 1530 | |
7656 | dunkaist | 1531 | |
1427 | diamond | 1532 | check_modifier_0: |
7656 | dunkaist | 1533 | setnz al |
1534 | ret |
||
1427 | diamond | 1535 | check_modifier_1: |
7656 | dunkaist | 1536 | setp al |
1537 | ret |
||
1427 | diamond | 1538 | check_modifier_2: |
7656 | dunkaist | 1539 | cmp al, 3 |
1540 | setnz al |
||
1541 | ret |
||
1427 | diamond | 1542 | check_modifier_3: |
7656 | dunkaist | 1543 | cmp al, 1 |
1544 | setnz al |
||
1545 | ret |
||
1427 | diamond | 1546 | check_modifier_4: |
7656 | dunkaist | 1547 | cmp al, 2 |
1548 | setnz al |
||
1549 | ret |
||
1427 | diamond | 1550 | |
7656 | dunkaist | 1551 | ; >edi = destination string |
1552 | ; >eax = number |
||
1553 | proc bin2dec |
||
1554 | push ebx ecx edx esi |
||
1555 | |||
1556 | mov ebx, 10 |
||
1557 | xor ecx, ecx |
||
7860 | dunkaist | 1558 | @@: |
7656 | dunkaist | 1559 | xor edx, edx |
1560 | div ebx |
||
1561 | push edx |
||
1562 | inc ecx |
||
1563 | test eax, eax |
||
1564 | jnz @b |
||
1565 | |||
7860 | dunkaist | 1566 | @@: |
7656 | dunkaist | 1567 | pop eax |
1568 | add eax, '0' |
||
1569 | stosb |
||
1570 | inc [window_header_len] |
||
1571 | dec ecx |
||
1572 | jnz @b |
||
1573 | |||
1574 | pop esi edx ecx ebx |
||
1575 | ret |
||
1576 | endp |
||
1577 | |||
1578 | |||
1579 | ; fills window_header with window title |
||
1580 | ; window title is generated as '[k/n] |
||
1581 | ; n = total files in dir |
||
1582 | ; k = current file index |
||
1583 | proc generate_window_header |
||
1584 | push eax ebx esi edi |
||
1585 | mov esi, [last_name_component] |
||
1586 | mov edi, window_header |
||
1587 | mov [window_header_len], 4 ; [,/,], |
||
1588 | |||
1589 | mov byte[edi], '[' |
||
1590 | inc edi |
||
1591 | mov eax, [cur_file_idx] |
||
1592 | inc eax |
||
1593 | call bin2dec |
||
1594 | mov byte[edi], '/' |
||
1595 | inc edi |
||
7860 | dunkaist | 1596 | mov eax, [directory_ptr] |
1597 | mov eax, [eax+4] |
||
7656 | dunkaist | 1598 | call bin2dec |
1599 | mov word[edi], '] ' |
||
1600 | add edi, 2 |
||
1601 | |||
1602 | ; add filename |
||
7860 | dunkaist | 1603 | .next_symbol: |
7656 | dunkaist | 1604 | lodsb |
1605 | test al, al |
||
1606 | jz @f |
||
1607 | stosb |
||
1608 | inc [window_header_len] |
||
1609 | cmp edi, window_header+256 |
||
1610 | jb .next_symbol |
||
7860 | dunkaist | 1611 | .overflow: |
7656 | dunkaist | 1612 | mov dword[edi-4], '...' |
7860 | dunkaist | 1613 | .ret: |
7656 | dunkaist | 1614 | pop edi esi ebx eax |
1615 | ret |
||
7860 | dunkaist | 1616 | @@: |
7656 | dunkaist | 1617 | mov esi, s_header |
7860 | dunkaist | 1618 | @@: |
7656 | dunkaist | 1619 | lodsb |
1620 | stosb |
||
1621 | test al, al |
||
1622 | jz .ret |
||
1623 | cmp edi, window_header+256 |
||
1624 | jb @b |
||
1625 | jmp .overflow |
||
1626 | endp |
||
1627 | |||
1628 | |||
1629 | proc scale_none_calc |
||
1630 | push ebx |
||
1631 | |||
1632 | mov [scale_mode], LIBIMG_SCALE_NONE |
||
1633 | |||
1634 | mov eax, [orig_image] |
||
1635 | mov [cur_image], eax |
||
1636 | mov [cur_frame], eax |
||
1637 | mov ebx, eax |
||
1638 | |||
1639 | mov [need_scrollbar_v], 0 |
||
1640 | mov [need_scrollbar_h], 0 |
||
1641 | |||
7860 | dunkaist | 1642 | mov eax, [ebx+Image.Width] |
7656 | dunkaist | 1643 | cmp eax, [canvas.width] |
1644 | jbe @f |
||
1645 | sub [canvas.height], SCROLL_WIDTH_SIZE+1 |
||
1646 | mov [need_scrollbar_h], 1 |
||
7860 | dunkaist | 1647 | @@: |
1648 | mov eax, [ebx+Image.Height] |
||
7656 | dunkaist | 1649 | cmp eax, [canvas.height] |
1650 | jbe @f |
||
1651 | sub [canvas.width], SCROLL_WIDTH_SIZE+1 |
||
1652 | mov [need_scrollbar_v], 1 |
||
7860 | dunkaist | 1653 | @@: |
7656 | dunkaist | 1654 | cmp [need_scrollbar_h], 1 |
1655 | jz @f |
||
7860 | dunkaist | 1656 | mov eax, [ebx+Image.Width] |
7656 | dunkaist | 1657 | cmp eax, [canvas.width] |
1658 | jbe @f |
||
1659 | sub [canvas.height], SCROLL_WIDTH_SIZE+1 |
||
1660 | mov [need_scrollbar_h], 1 |
||
7860 | dunkaist | 1661 | @@: |
7656 | dunkaist | 1662 | |
1663 | |||
7860 | dunkaist | 1664 | mov eax, [ebx+Image.Width] |
7656 | dunkaist | 1665 | cmp eax, [canvas.width] |
1666 | jbe @f |
||
1667 | mov eax, [canvas.width] |
||
7860 | dunkaist | 1668 | @@: |
7656 | dunkaist | 1669 | mov [view.width], eax |
1670 | mov [pict.width], eax |
||
1671 | |||
7860 | dunkaist | 1672 | mov eax, [ebx+Image.Height] |
7656 | dunkaist | 1673 | cmp eax, [canvas.height] |
1674 | jbe @f |
||
1675 | mov eax, [canvas.height] |
||
7860 | dunkaist | 1676 | @@: |
7656 | dunkaist | 1677 | mov [view.height], eax |
1678 | mov [pict.height], eax |
||
1679 | |||
1680 | mov eax, [canvas.width] |
||
1681 | sub eax, [view.width] |
||
1682 | sar eax, 1 |
||
1683 | mov [view.left], eax |
||
1684 | mov eax, [canvas.height] |
||
1685 | sub eax, [view.height] |
||
1686 | sar eax, 1 |
||
1687 | mov [view.top], eax |
||
1688 | |||
7860 | dunkaist | 1689 | mov eax, [ebx+Image.Width] |
7656 | dunkaist | 1690 | sub eax, [pict.width] |
1691 | sar eax, 1 |
||
1692 | mov [pict.left], eax |
||
7860 | dunkaist | 1693 | mov eax, [ebx+Image.Height] |
7656 | dunkaist | 1694 | sub eax, [pict.height] |
1695 | sar eax, 1 |
||
1696 | mov [pict.top], eax |
||
1697 | |||
1698 | |||
7860 | dunkaist | 1699 | mov eax, [ebx+Image.Height] |
7656 | dunkaist | 1700 | mov [scroll_bar_data_vertical.max_area], eax |
1701 | mov eax, [pict.height] |
||
1702 | mov [scroll_bar_data_vertical.cur_area], eax |
||
1703 | mov eax, [pict.top] |
||
1704 | mov [scroll_bar_data_vertical.position], eax |
||
1705 | |||
7860 | dunkaist | 1706 | mov eax, [ebx+Image.Width] |
7656 | dunkaist | 1707 | mov [scroll_bar_data_horizontal.max_area], eax |
1708 | mov eax, [pict.width] |
||
1709 | mov [scroll_bar_data_horizontal.cur_area], eax |
||
1710 | mov eax, [pict.left] |
||
1711 | mov [scroll_bar_data_horizontal.position], eax |
||
1712 | |||
1713 | pop ebx |
||
1714 | ret |
||
1715 | endp |
||
1716 | |||
1717 | |||
1718 | proc scale_fit_min_calc |
||
1719 | push ebx |
||
1720 | |||
1721 | mov [need_scrollbar_v], 0 |
||
1722 | mov [need_scrollbar_h], 0 |
||
1723 | mov [scroll_bar_data_vertical.position], 0 |
||
1724 | mov [scroll_bar_data_horizontal.position], 0 |
||
1725 | |||
1726 | mov eax, [orig_image] |
||
7860 | dunkaist | 1727 | cmp [eax+Image.Type], Image.bpp24 |
7656 | dunkaist | 1728 | jz @f |
7860 | dunkaist | 1729 | cmp [eax+Image.Type], Image.bpp32 |
7656 | dunkaist | 1730 | jz @f |
7860 | dunkaist | 1731 | cmp [eax+Image.Type], Image.bpp8g |
7656 | dunkaist | 1732 | jz @f |
1733 | invoke img.convert, eax, 0, Image.bpp24, 0, 0 |
||
1734 | test eax, eax |
||
1735 | ; jz .error |
||
1736 | push eax |
||
1737 | invoke img.destroy, [orig_image] |
||
1738 | pop eax |
||
1739 | mov [orig_image], eax |
||
1740 | mov [cur_image], eax |
||
1741 | mov [cur_frame], eax |
||
7860 | dunkaist | 1742 | @@: |
7656 | dunkaist | 1743 | |
1744 | mov eax, [orig_image] |
||
7860 | dunkaist | 1745 | mov ecx, [eax+Image.Height] |
1746 | mov eax, [eax+Image.Width] |
||
7656 | dunkaist | 1747 | cmp eax, [canvas.width] |
1748 | ja .get_size |
||
1749 | cmp ecx, [canvas.height] |
||
1750 | ja .get_size |
||
1751 | jmp .got_size |
||
7860 | dunkaist | 1752 | .get_size: |
7656 | dunkaist | 1753 | invoke img.get_scaled_size, eax, ecx, LIBIMG_SCALE_FIT_MIN, [canvas.width], [canvas.height] |
7860 | dunkaist | 1754 | .got_size: |
7656 | dunkaist | 1755 | |
1756 | mov [pict.top], 0 |
||
1757 | mov [pict.left], 0 |
||
1758 | |||
1759 | cmp eax, [canvas.width] |
||
1760 | jbe @f |
||
1761 | mov eax, [canvas.width] |
||
7860 | dunkaist | 1762 | @@: |
7656 | dunkaist | 1763 | mov [view.width], eax |
1764 | mov [pict.width], eax |
||
1765 | neg eax |
||
1766 | add eax, [canvas.width] |
||
1767 | shr eax, 1 |
||
1768 | mov [view.left], eax |
||
1769 | |||
1770 | mov eax, ecx |
||
1771 | cmp eax, [canvas.height] |
||
1772 | jbe @f |
||
1773 | mov eax, [canvas.height] |
||
7860 | dunkaist | 1774 | @@: |
7656 | dunkaist | 1775 | mov [view.height], eax |
1776 | mov [pict.height], eax |
||
1777 | neg eax |
||
1778 | add eax, [canvas.height] |
||
1779 | shr eax, 1 |
||
1780 | mov [view.top], eax |
||
1781 | |||
1782 | |||
1783 | pop ebx |
||
1784 | ret |
||
1785 | endp |
||
1786 | |||
1787 | |||
7726 | dunkaist | 1788 | ; eax: new scaling mode |
1789 | ; z/Z - not/changed |
||
1790 | proc set_scale_mode |
||
1791 | cmp eax, [scale_mode] |
||
7656 | dunkaist | 1792 | mov [scale_mode], eax |
7726 | dunkaist | 1793 | setnz [bScaleModeChanged] |
7656 | dunkaist | 1794 | ret |
1795 | endp |
||
1796 | |||
1797 | proc move_pictport _dx, _dy |
||
1798 | locals |
||
1799 | new_left dd ? |
||
1800 | new_top dd ? |
||
1801 | endl |
||
1802 | push ebx ecx |
||
1803 | |||
1804 | mov ebx, [cur_image] |
||
7860 | dunkaist | 1805 | .x: |
7656 | dunkaist | 1806 | mov eax, [pict.left] |
1807 | add eax, [_dx] |
||
1808 | cmp eax, 0 |
||
1809 | jge @f |
||
1810 | mov [new_left], 0 |
||
1811 | jmp .xdone |
||
7860 | dunkaist | 1812 | @@: |
7656 | dunkaist | 1813 | mov ecx, eax |
1814 | add eax, [pict.width] |
||
7860 | dunkaist | 1815 | cmp eax, [ebx+Image.Width] |
7656 | dunkaist | 1816 | ja @f |
1817 | mov [new_left], ecx |
||
1818 | jmp .xdone |
||
7860 | dunkaist | 1819 | @@: |
1820 | mov eax, [ebx+Image.Width] |
||
7656 | dunkaist | 1821 | sub eax, [pict.width] |
1822 | mov [new_left], eax |
||
1823 | jmp .xdone |
||
7860 | dunkaist | 1824 | .xdone: |
7656 | dunkaist | 1825 | |
7860 | dunkaist | 1826 | .y: |
7656 | dunkaist | 1827 | mov eax, [pict.top] |
1828 | add eax, [_dy] |
||
1829 | cmp eax, 0 |
||
1830 | jge @f |
||
1831 | mov [new_top], 0 |
||
1832 | jmp .ydone |
||
7860 | dunkaist | 1833 | @@: |
7656 | dunkaist | 1834 | mov ecx, eax |
1835 | add eax, [pict.height] |
||
7860 | dunkaist | 1836 | cmp eax, [ebx+Image.Height] |
7656 | dunkaist | 1837 | ja @f |
1838 | mov [new_top], ecx |
||
1839 | jmp .ydone |
||
7860 | dunkaist | 1840 | @@: |
1841 | mov eax, [ebx+Image.Height] |
||
7656 | dunkaist | 1842 | sub eax, [pict.height] |
1843 | mov [new_top], eax |
||
1844 | jmp .ydone |
||
7860 | dunkaist | 1845 | .ydone: |
7656 | dunkaist | 1846 | |
1847 | xor eax, eax |
||
1848 | mov ecx, [new_left] |
||
1849 | mov edx, [new_top] |
||
1850 | |||
1851 | cmp ecx, [pict.left] |
||
1852 | setnz al |
||
1853 | shl eax, 8 |
||
1854 | |||
1855 | cmp edx, [pict.top] |
||
1856 | setnz al |
||
1857 | |||
1858 | mov [pict.left], ecx |
||
1859 | mov [pict.top], edx |
||
1860 | |||
1861 | pop ecx ebx |
||
1862 | ret |
||
1863 | endp |
||
1864 | |||
1865 | |||
1866 | proc update_scrollbars _xxhv |
||
1867 | mov eax, [_xxhv] |
||
1868 | |||
1869 | test ah, ah |
||
1870 | jz .no_h_scroll |
||
1871 | push eax |
||
1872 | mov [scroll_bar_data_horizontal.all_redraw], 0 |
||
1873 | mov eax, [pict.left] |
||
1874 | mov [scroll_bar_data_horizontal.position], eax |
||
1875 | invoke scrollbar_hort_draw, scroll_bar_data_horizontal |
||
1876 | pop eax |
||
7860 | dunkaist | 1877 | .no_h_scroll: |
7656 | dunkaist | 1878 | test al, al |
1879 | jz .no_v_scroll |
||
1880 | push eax |
||
1881 | mov [scroll_bar_data_vertical.all_redraw], 0 |
||
1882 | mov eax, [pict.top] |
||
1883 | mov [scroll_bar_data_vertical.position], eax |
||
1884 | invoke scrollbar_vert_draw, scroll_bar_data_vertical |
||
1885 | pop eax |
||
7860 | dunkaist | 1886 | .no_v_scroll: |
7656 | dunkaist | 1887 | |
1888 | ret |
||
1889 | endp |
||
1890 | |||
1891 | |||
1892 | proc merge_icons_to_single_img _img |
||
1893 | push ebx esi edi |
||
1894 | |||
1895 | mov edx, [_img] |
||
7860 | dunkaist | 1896 | mov eax, [edx+Image.Width] |
1897 | mov ecx, [edx+Image.Height] |
||
1898 | .next: |
||
1899 | cmp [edx+Image.Next], 0 |
||
7656 | dunkaist | 1900 | jz .got_sizes |
1901 | inc eax |
||
7860 | dunkaist | 1902 | mov edx, [edx+Image.Next] |
1903 | add eax, [edx+Image.Width] |
||
1904 | cmp ecx, [edx+Image.Height] |
||
7656 | dunkaist | 1905 | jae @f |
7860 | dunkaist | 1906 | mov ecx, [edx+Image.Height] |
1907 | @@: |
||
7656 | dunkaist | 1908 | jmp .next |
1909 | |||
7860 | dunkaist | 1910 | .got_sizes: |
7656 | dunkaist | 1911 | invoke img.create, eax, ecx, Image.bpp32 |
1912 | test eax, eax |
||
1913 | jz .error |
||
1914 | mov ebx, eax |
||
1915 | |||
1916 | mov eax, [bg_color] |
||
7860 | dunkaist | 1917 | mov edi, [ebx+Image.Data] |
1918 | mov ecx, [ebx+Image.Width] |
||
1919 | imul ecx, [ebx+Image.Height] |
||
7656 | dunkaist | 1920 | rep stosd |
1921 | |||
1922 | mov eax, [_img] |
||
7860 | dunkaist | 1923 | cmp [eax+Image.Type], Image.bpp32 |
7656 | dunkaist | 1924 | jz @f |
1925 | invoke img.convert, eax, 0, Image.bpp32, 0, 0 |
||
1926 | test eax, eax |
||
1927 | jz .error |
||
1928 | push eax |
||
1929 | invoke img.destroy, [_img] |
||
1930 | pop eax |
||
7860 | dunkaist | 1931 | @@: |
7656 | dunkaist | 1932 | mov esi, eax |
1933 | xor edi, edi |
||
7860 | dunkaist | 1934 | .next_img: |
7656 | dunkaist | 1935 | stdcall put_img_on_img, ebx, esi, edi, 0 |
7860 | dunkaist | 1936 | add edi, [esi+Image.Width] |
7656 | dunkaist | 1937 | inc edi |
7860 | dunkaist | 1938 | cmp [esi+Image.Next], 0 |
7656 | dunkaist | 1939 | jz @f |
7860 | dunkaist | 1940 | mov esi, [esi+Image.Next] |
7656 | dunkaist | 1941 | jmp .next_img |
7860 | dunkaist | 1942 | @@: |
7656 | dunkaist | 1943 | invoke img.destroy, esi |
1944 | mov eax, ebx |
||
1945 | jmp .quit |
||
1946 | |||
7860 | dunkaist | 1947 | .error: |
7656 | dunkaist | 1948 | xor eax, eax |
7860 | dunkaist | 1949 | .quit: |
7656 | dunkaist | 1950 | pop edi esi ebx |
1951 | ret |
||
1952 | endp |
||
1953 | |||
1954 | |||
1955 | proc put_img_on_img _bottom, _top, _x, _y |
||
1956 | locals |
||
1957 | img_height dd ? |
||
1958 | endl |
||
1959 | push ebx esi edi |
||
1960 | |||
1961 | mov ebx, [_bottom] |
||
1962 | mov edx, [_top] |
||
7860 | dunkaist | 1963 | mov eax, [edx+Image.Height] |
7656 | dunkaist | 1964 | mov [img_height], eax |
7860 | dunkaist | 1965 | mov esi, [edx+Image.Data] |
1966 | mov edi, [ebx+Image.Data] |
||
7656 | dunkaist | 1967 | mov eax, [_y] |
7860 | dunkaist | 1968 | imul eax, [ebx+Image.Width] |
7656 | dunkaist | 1969 | add eax, [_x] |
1970 | shl eax, 2 |
||
1971 | add edi, eax |
||
7860 | dunkaist | 1972 | .next_line: |
1973 | mov ecx, [edx+Image.Width] |
||
7656 | dunkaist | 1974 | rep movsd |
7860 | dunkaist | 1975 | mov eax, [ebx+Image.Width] |
1976 | sub eax, [edx+Image.Width] |
||
7656 | dunkaist | 1977 | shl eax, 2 |
1978 | add edi, eax |
||
1979 | dec [img_height] |
||
1980 | jnz .next_line |
||
1981 | |||
1982 | pop edi esi ebx |
||
1983 | ret |
||
1984 | endp |
||
1985 | |||
1986 | |||
1987 | proc copy_box _src, _dst |
||
1988 | pushad |
||
1989 | |||
1990 | mov esi, [_src] |
||
1991 | mov edi, [_dst] |
||
1992 | mov ecx, 4 |
||
1993 | rep movsd |
||
1994 | |||
1995 | popad |
||
1996 | ret |
||
1997 | endp |
||
1998 | |||
1999 | |||
2000 | proc cmp_box _a, _b |
||
2001 | pushad |
||
2002 | |||
2003 | mov esi, [_a] |
||
2004 | mov edi, [_b] |
||
2005 | mov ecx, 4 |
||
2006 | rep cmpsd |
||
2007 | |||
2008 | popad |
||
2009 | ret |
||
2010 | endp |
||
2011 | |||
2012 | |||
2013 | proc recalc_client |
||
2014 | stdcall copy_box, toolbar, toolbar_prev |
||
2015 | mov [toolbar.left], 0 |
||
2016 | mov [toolbar.top], 0 |
||
2017 | mov eax, [client.width] |
||
2018 | mov [toolbar.width], eax |
||
2019 | mov [toolbar.height], 0 |
||
2020 | cmp [bShowToolbar], 1 |
||
2021 | jnz @f |
||
2022 | mov [toolbar.height], TOOLBAR_HEIGHT |
||
7860 | dunkaist | 2023 | @@: |
7656 | dunkaist | 2024 | |
2025 | mov eax, [toolbar.top] |
||
2026 | add eax, [client_abs_top] |
||
2027 | mov [toolbar_abs_top], eax |
||
2028 | mov eax, [toolbar.left] |
||
2029 | add eax, [client_abs_left] |
||
2030 | mov [toolbar_abs_left], eax |
||
2031 | |||
2032 | test [bFirstWinDraw], 1 |
||
2033 | jnz .recalc_toolbar |
||
2034 | stdcall cmp_box, toolbar, toolbar_prev |
||
2035 | jnz .recalc_toolbar |
||
2036 | test [bNewImage], 1 |
||
2037 | jnz .recalc_toolbar |
||
2038 | jmp .recalc_toolbar_done |
||
7860 | dunkaist | 2039 | .recalc_toolbar: |
7656 | dunkaist | 2040 | stdcall recalc_toolbar |
7860 | dunkaist | 2041 | .recalc_toolbar_done: |
7656 | dunkaist | 2042 | |
2043 | stdcall copy_box, work, work_prev |
||
2044 | xor ecx, ecx |
||
2045 | test [bShowToolbar], 1 |
||
2046 | jz @f |
||
2047 | mov ecx, [toolbar.height] |
||
7860 | dunkaist | 2048 | @@: |
7656 | dunkaist | 2049 | mov eax, ecx |
2050 | mov [work.top], eax |
||
2051 | mov eax, [client.height] |
||
2052 | sub eax, ecx |
||
2053 | mov [work.height], eax |
||
2054 | mov [work.left], 0 |
||
2055 | mov eax, [client.width] |
||
2056 | mov [work.width], eax |
||
2057 | |||
2058 | mov eax, [work.top] |
||
2059 | add eax, [client_abs_top] |
||
2060 | mov [work_abs_top], eax |
||
2061 | mov eax, [work.left] |
||
2062 | add eax, [client_abs_left] |
||
2063 | mov [work_abs_left], eax |
||
2064 | |||
2065 | test [bFirstWinDraw], 1 |
||
2066 | jnz .recalc_work |
||
2067 | test [bNewImage], 1 |
||
2068 | jnz .recalc_work |
||
2069 | stdcall cmp_box, work, work_prev |
||
2070 | jnz .recalc_work |
||
2071 | jmp .recalc_work_done |
||
7860 | dunkaist | 2072 | .recalc_work: |
7656 | dunkaist | 2073 | stdcall recalc_work |
7860 | dunkaist | 2074 | .recalc_work_done: |
7656 | dunkaist | 2075 | |
2076 | ret |
||
2077 | endp |
||
2078 | |||
2079 | |||
2080 | proc recalc_toolbar |
||
2081 | |||
2082 | ret |
||
2083 | endp |
||
2084 | |||
2085 | |||
2086 | proc recalc_window |
||
2087 | stdcall copy_box, client, client_prev |
||
2088 | test [bSlideShow], 1 |
||
2089 | jz .no_slide_show |
||
7860 | dunkaist | 2090 | .slide_show: |
7656 | dunkaist | 2091 | mov [client.left], 0 |
2092 | mov [client.top], 0 |
||
2093 | mov eax, [procinfo.box.width] |
||
2094 | mov [client.width], eax |
||
2095 | mov eax, [procinfo.box.height] |
||
2096 | mov [client.height], eax |
||
2097 | jmp .calc_abs |
||
7860 | dunkaist | 2098 | .no_slide_show: |
7656 | dunkaist | 2099 | mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT |
2100 | mov [client.top], eax |
||
2101 | neg eax |
||
2102 | add eax, [procinfo.box.height] |
||
2103 | sub eax, 5 |
||
2104 | mov [client.height], eax |
||
2105 | mov [client.left], 5 |
||
2106 | mov eax, [procinfo.box.width] |
||
2107 | sub eax, 10 |
||
2108 | mov [client.width], eax |
||
2109 | |||
7860 | dunkaist | 2110 | .calc_abs: |
7656 | dunkaist | 2111 | mov eax, [client.top] |
2112 | mov [client_abs_top], eax |
||
2113 | mov eax, [client.left] |
||
2114 | mov [client_abs_left], eax |
||
2115 | |||
2116 | stdcall cmp_box, client, client_prev |
||
2117 | jnz .recalc_client |
||
2118 | test [bNewImage], 1 |
||
2119 | jnz .recalc_client |
||
2120 | test [bToggleToolbar], 1 |
||
2121 | jnz .recalc_client |
||
2122 | jmp .recalc_client_done |
||
7860 | dunkaist | 2123 | .recalc_client: |
7656 | dunkaist | 2124 | stdcall recalc_client |
7860 | dunkaist | 2125 | .recalc_client_done: |
7656 | dunkaist | 2126 | |
2127 | ret |
||
2128 | endp |
||
2129 | |||
2130 | |||
2131 | proc recalc_work |
||
2132 | stdcall copy_box, canvas, canvas_prev |
||
2133 | mov eax, [work.left] |
||
2134 | add eax, [canvas_padding] |
||
2135 | mov [canvas.left], eax |
||
2136 | mov eax, [work.width] |
||
2137 | sub eax, [canvas_padding] |
||
2138 | sub eax, [canvas_padding] |
||
2139 | inc eax |
||
2140 | mov [canvas.width], eax |
||
2141 | mov eax, [canvas_padding] |
||
2142 | mov [canvas.top], eax |
||
2143 | mov eax, [work.height] |
||
2144 | sub eax, [canvas_padding] |
||
2145 | sub eax, [canvas_padding] |
||
2146 | inc eax |
||
2147 | mov [canvas.height], eax |
||
2148 | |||
2149 | mov eax, [canvas.top] |
||
2150 | add eax, [work_abs_top] |
||
2151 | mov [canvas_abs_top], eax |
||
2152 | mov eax, [canvas.left] |
||
2153 | add eax, [work_abs_left] |
||
2154 | mov [canvas_abs_left], eax |
||
2155 | |||
2156 | test [bFirstWinDraw], 1 |
||
2157 | jnz .recalc_canvas |
||
2158 | test [bNewImage], 1 |
||
2159 | jnz .recalc_canvas |
||
2160 | stdcall cmp_box, canvas, canvas_prev |
||
2161 | jnz .recalc_canvas |
||
7860 | dunkaist | 2162 | cmp [bScaleModeChanged], 0 |
2163 | jnz .recalc_canvas |
||
7656 | dunkaist | 2164 | jmp .recalc_canvas_done |
7860 | dunkaist | 2165 | .recalc_canvas: |
7656 | dunkaist | 2166 | stdcall recalc_canvas |
7860 | dunkaist | 2167 | .recalc_canvas_done: |
7656 | dunkaist | 2168 | ret |
2169 | endp |
||
2170 | |||
2171 | |||
2172 | proc recalc_canvas |
||
2173 | stdcall copy_box, view, view_prev |
||
2174 | mov eax, [scale_mode] |
||
7860 | dunkaist | 2175 | call [scale_mode_calc+eax*4] |
7656 | dunkaist | 2176 | |
2177 | mov eax, [view.top] |
||
2178 | add eax, [canvas_abs_top] |
||
2179 | mov [view_abs_top], eax |
||
2180 | mov eax, [view.left] |
||
2181 | add eax, [canvas_abs_left] |
||
2182 | mov [view_abs_left], eax |
||
2183 | |||
2184 | ret |
||
2185 | endp |
||
2186 | |||
1004 | diamond | 2187 | ;----------------------------------------------------------------------------- |
7656 | dunkaist | 2188 | DATA |
1004 | diamond | 2189 | |
7656 | dunkaist | 2190 | s_header db ' - Kolibri Image Viewer',0 |
2191 | window_style dd 0x53FFFFFF |
||
7860 | dunkaist | 2192 | window BOX 101, 144, 529, 324 ; left top width height |
7656 | dunkaist | 2193 | window_prev BOX 0, 0, 0, 0 |
2194 | window_save BOX 0, 0, 0, 0 ; restore after slide show |
||
2195 | client BOX 0, 0, 0, 0 |
||
2196 | client_prev BOX 0, 0, 0, 0 |
||
2197 | client_abs_top dd ? |
||
2198 | client_abs_left dd ? |
||
2199 | toolbar BOX 0, 0, 0, 0 |
||
2200 | toolbar_prev BOX 0, 0, 0, 0 |
||
2201 | toolbar_abs_top dd ? |
||
2202 | toolbar_abs_left dd ? |
||
2203 | work BOX 0, 0, 0, 0 |
||
2204 | work_prev BOX 0, 0, 0, 0 |
||
2205 | work_abs_top dd ? |
||
2206 | work_abs_left dd ? |
||
2207 | canvas BOX 0, 0, 0, 0 |
||
2208 | canvas_prev BOX 0, 0, 0, 0 |
||
2209 | canvas_abs_top dd ? |
||
2210 | canvas_abs_left dd ? |
||
2211 | view BOX -1, -1, 0, 0 |
||
2212 | view_prev BOX -1, -1, 0, 0 |
||
2213 | view_abs_top dd ? |
||
2214 | view_abs_left dd ? |
||
2215 | pict BOX 0, 0, 0, 0 |
||
2216 | canvas_padding dd 5 |
||
2217 | bg_color dd 0x00ffffff |
||
2218 | scale_mode dd LIBIMG_SCALE_FIT_MIN |
||
2219 | pict_drag dd 0 |
||
2220 | scroll_v_drag dd 0 |
||
2221 | scroll_h_drag dd 0 |
||
1004 | diamond | 2222 | |
7656 | dunkaist | 2223 | mouse_buttons dd 0 |
2224 | mouse_pos dd 0 |
||
2225 | need_scrollbar_v dd 0 |
||
2226 | need_scrollbar_h dd 0 |
||
2227 | |||
2228 | pict_moved dd 0 |
||
2229 | |||
1004 | diamond | 2230 | ;----------------------------------------------------------------------------- |
7656 | dunkaist | 2231 | align 4 |
2232 | scroll_bar_data_vertical: |
||
2233 | .x: |
||
2234 | .size_x dw SCROLL_WIDTH_SIZE |
||
2235 | .start_x dw 1 |
||
2236 | .y: |
||
2237 | .size_y dw 100 |
||
2238 | .start_y dw 0 |
||
2239 | .btn_high dd SCROLL_WIDTH_SIZE |
||
2240 | .type dd 0 ;+12 |
||
2241 | .max_area dd 100 ;+16 |
||
2242 | .cur_area dd 10 ;+20 |
||
2243 | .position dd 0 ;+24 |
||
2244 | .bckg_col dd 0xAAAAAA ;+28 |
||
2245 | .frnt_col dd 0xCCCCCC ;+32 |
||
2246 | .line_col dd 0 ;+36 |
||
2247 | .redraw dd 0 ;+40 |
||
2248 | .delta dw 0 ;+44 |
||
2249 | .delta2 dw 0 ;+46 |
||
2250 | .run_x: |
||
2251 | .r_size_x dw 0 ;+48 |
||
2252 | .r_start_x dw 0 ;+50 |
||
2253 | .run_y: |
||
2254 | .r_size_y dw 0 ;+52 |
||
2255 | .r_start_y dw 0 ;+54 |
||
2256 | .m_pos dd 0 ;+56 |
||
2257 | .m_pos_2 dd 0 ;+60 |
||
2258 | .m_keys dd 0 ;+64 |
||
2259 | .run_size dd 0 ;+68 |
||
2260 | .position2 dd 0 ;+72 |
||
2261 | .work_size dd 0 ;+76 |
||
2262 | .all_redraw dd 0 ;+80 |
||
2263 | .ar_offset dd KEY_MOVE_PIXELS ;+84 |
||
1004 | diamond | 2264 | ;----------------------------------------------------------------------------- |
7656 | dunkaist | 2265 | align 4 |
2266 | scroll_bar_data_horizontal: |
||
2267 | .x: |
||
2268 | .size_x dw 0 ;+0 |
||
2269 | .start_x dw 0 ;+2 |
||
2270 | .y: |
||
2271 | .size_y dw SCROLL_WIDTH_SIZE ;+4 |
||
2272 | .start_y dw 0 ;+6 |
||
2273 | .btn_high dd SCROLL_WIDTH_SIZE ;+8 |
||
2274 | .type dd 0 ;+12 |
||
2275 | .max_area dd 50 ;+16 |
||
2276 | .cur_area dd 50 ;+20 |
||
2277 | .position dd 0 ;+24 |
||
2278 | .bckg_col dd 0xAAAAAA ;+28 |
||
2279 | .frnt_col dd 0xCCCCCC ;+32 |
||
2280 | .line_col dd 0 ;+36 |
||
2281 | .redraw dd 0 ;+40 |
||
2282 | .delta dw 0 ;+44 |
||
2283 | .delta2 dw 0 ;+46 |
||
2284 | .run_x: |
||
2285 | .r_size_x dw 0 ;+48 |
||
2286 | .r_start_x dw 0 ;+50 |
||
2287 | .run_y: |
||
2288 | .r_size_y dw 0 ;+52 |
||
2289 | .r_start_y dw 0 ;+54 |
||
2290 | .m_pos dd 0 ;+56 |
||
2291 | .m_pos_2 dd 0 ;+60 |
||
2292 | .m_keys dd 0 ;+64 |
||
2293 | .run_size dd 0 ;+68 |
||
2294 | .position2 dd 0 ;+72 |
||
2295 | .work_size dd 0 ;+76 |
||
2296 | .all_redraw dd 0 ;+80 |
||
2297 | .ar_offset dd KEY_MOVE_PIXELS ;+84 |
||
2298 | ;----------------------------------------------------------------------------- |
||
1004 | diamond | 2299 | align 4 |
2300 | @IMPORT: |
||
2301 | |||
7656 | dunkaist | 2302 | library \ |
2303 | libgfx , 'libgfx.obj' , \ |
||
2304 | libimg , 'libimg.obj' , \ |
||
2305 | libini , 'libini.obj' , \ |
||
2306 | sort , 'sort.obj' , \ |
||
2307 | proc_lib, 'proc_lib.obj', \ |
||
2308 | box_lib , 'box_lib.obj' |
||
1004 | diamond | 2309 | |
1511 | mario79 | 2310 | |
7656 | dunkaist | 2311 | import libgfx , \ |
2312 | libgfx.init , 'lib_init' , \ |
||
2313 | gfx.open , 'gfx_open' , \ |
||
2314 | gfx.close , 'gfx_close' , \ |
||
2315 | gfx.pen.color, 'gfx_pen_color', \ |
||
2316 | gfx.line , 'gfx_line' |
||
1004 | diamond | 2317 | |
7656 | dunkaist | 2318 | import libimg , \ |
2319 | libimg.init , 'lib_init' , \ |
||
2320 | img.from_file , 'img_from_file' , \ |
||
2321 | img.to_rgb2 , 'img_to_rgb2' , \ |
||
2322 | img.create , 'img_create' , \ |
||
2323 | img.flip , 'img_flip' , \ |
||
2324 | img.rotate , 'img_rotate' , \ |
||
2325 | img.destroy , 'img_destroy' , \ |
||
2326 | img.scale , 'img_scale' , \ |
||
2327 | img.get_scaled_size, 'img_get_scaled_size', \ |
||
2328 | img.convert , 'img_convert' , \ |
||
2329 | img.draw , 'img_draw' |
||
1004 | diamond | 2330 | |
7656 | dunkaist | 2331 | import libini , \ |
2332 | ini_get_shortcut, 'ini_get_shortcut', \ |
||
2333 | ini_set_str, 'ini_set_str' |
||
1004 | diamond | 2334 | |
7656 | dunkaist | 2335 | import sort ,\ |
2336 | sort.START, 'START' ,\ |
||
2337 | SortDir , 'SortDir',\ |
||
2338 | strcmpi , 'strcmpi' |
||
1427 | diamond | 2339 | |
7656 | dunkaist | 2340 | import proc_lib ,\ |
2341 | OpenDialog_Init , 'OpenDialog_init' ,\ |
||
2342 | OpenDialog_Start, 'OpenDialog_start' |
||
1016 | diamond | 2343 | |
7656 | dunkaist | 2344 | import box_lib ,\ |
2345 | scrollbar_vert_draw , 'scrollbar_v_draw' ,\ |
||
2346 | scrollbar_vert_mouse, 'scrollbar_v_mouse',\ |
||
2347 | scrollbar_hort_draw , 'scrollbar_h_draw' ,\ |
||
2348 | scrollbar_hort_mouse, 'scrollbar_h_mouse' |
||
1511 | mario79 | 2349 | |
7656 | dunkaist | 2350 | bFirstWinDraw db 1 |
2351 | bSlideShow db 0 |
||
2352 | bToggleSlideShow db 0 |
||
2353 | bShowToolbar db 1 |
||
2354 | bShowToolbarSave db 0 ; to restore state when return from slide show |
||
2355 | bToggleToolbar db 0 |
||
2356 | bScaleModeChanged db 0 |
||
2357 | bNewImage db 0 |
||
1004 | diamond | 2358 | ;----------------------------------------------------------------------------- |
2359 | |||
1016 | diamond | 2360 | virtual at 0 |
2361 | file 'kivicons.bmp':0xA,4 |
||
2362 | load offbits dword from 0 |
||
2363 | end virtual |
||
7860 | dunkaist | 2364 | numimages = 11 |
1016 | diamond | 2365 | openbtn = 0 |
2366 | backbtn = 1 |
||
2367 | forwardbtn = 2 |
||
2368 | bgrbtn = 3 |
||
2369 | fliphorzbtn = 4 |
||
2370 | flipvertbtn = 5 |
||
2371 | rotcwbtn = 6 |
||
2372 | rotccwbtn = 7 |
||
2373 | rot180btn = 8 |
||
3116 | dunkaist | 2374 | slidebtn = 9 |
7860 | dunkaist | 2375 | scalebtn = 10 |
1016 | diamond | 2376 | |
1004 | diamond | 2377 | palette: |
1570 | dunkaist | 2378 | file 'kivicons.bmp':0x36,offbits-0x36 |
1016 | diamond | 2379 | buttons: |
1570 | dunkaist | 2380 | file 'kivicons.bmp':offbits |
7862 | dunkaist | 2381 | repeat 10 |
7860 | dunkaist | 2382 | y = %-1 |
2383 | z = 20-% |
||
1016 | diamond | 2384 | repeat numimages*5 |
2385 | load a dword from $ - numimages*20*20 + numimages*20*y + (%-1)*4 |
||
2386 | load b dword from $ - numimages*20*20 + numimages*20*z + (%-1)*4 |
||
7656 | dunkaist | 2387 | store dword a at $ - numimages*20*20 + numimages*20*z + (%-1)*4 |
2388 | store dword b at $ - numimages*20*20 + numimages*20*y + (%-1)*4 |
||
1004 | diamond | 2389 | end repeat |
2390 | end repeat |
||
2391 | |||
7432 | leency | 2392 | inifilename db '/sys/settings/app.ini',0 |
2393 | aShortcuts db 'Kiv',0 |
||
1570 | dunkaist | 2394 | aNext db 'Next',0 |
2395 | aPrev db 'Prev',0 |
||
3116 | dunkaist | 2396 | aSlide db 'SlideShow',0 |
2397 | aTglbar db 'ToggleBar',0 |
||
1427 | diamond | 2398 | |
7421 | leency | 2399 | inifileeskin db '/sys/settings/eskin.ini',0 |
7660 | leency | 2400 | amain db 'bg',0 |
7421 | leency | 2401 | aprogram db 'program',0 |
2402 | aparam db 'param',0 |
||
2403 | |||
1427 | diamond | 2404 | align 4 |
2405 | check_modifier_table: |
||
1570 | dunkaist | 2406 | dd check_modifier_0 |
2407 | dd check_modifier_1 |
||
2408 | dd check_modifier_2 |
||
2409 | dd check_modifier_3 |
||
2410 | dd check_modifier_4 |
||
1427 | diamond | 2411 | |
1470 | mario79 | 2412 | ;--------------------------------------------------------------------- |
2413 | align 4 |
||
2414 | OpenDialog_data: |
||
7656 | dunkaist | 2415 | .type dd 0 |
2416 | .procinfo dd procinfo ; +4 |
||
2417 | .com_area_name dd communication_area_name ; +8 |
||
2418 | .com_area dd 0 ; +12 |
||
2419 | .opendir_path dd temp_dir_path ; +16 |
||
2420 | .dir_default_path dd communication_area_default_path ; +20 |
||
2421 | .start_path dd open_dialog_path ; +24 |
||
2422 | .draw_window dd draw_window ; +28 |
||
2423 | .status dd 0 ; +32 |
||
2424 | .openfile_path dd path ; openfile_path ; +36 |
||
2425 | .filename_area dd 0 ; +40 |
||
2426 | .filter_area dd Filter |
||
1582 | mario79 | 2427 | .x: |
7656 | dunkaist | 2428 | .x_size dw 420 ; +48 ; Window X size |
2429 | .x_start dw 10 ; +50 ; Window X position |
||
1582 | mario79 | 2430 | .y: |
7656 | dunkaist | 2431 | .y_size dw 320 ; +52 ; Window y size |
2432 | .y_start dw 10 ; +54 ; Window Y position |
||
1004 | diamond | 2433 | |
1470 | mario79 | 2434 | communication_area_name: |
1570 | dunkaist | 2435 | db 'FFFFFFFF_open_dialog',0 |
1701 | lrz | 2436 | |
1470 | mario79 | 2437 | open_dialog_path: |
1701 | lrz | 2438 | if __nightbuild eq yes |
2439 | db '/sys/MANAGERS/opendial',0 |
||
2440 | else |
||
1570 | dunkaist | 2441 | db '/sys/File Managers/opendial',0 |
1701 | lrz | 2442 | end if |
7656 | dunkaist | 2443 | communication_area_default_path: |
1570 | dunkaist | 2444 | db '/rd/1',0 |
1004 | diamond | 2445 | |
1470 | mario79 | 2446 | Filter: |
7860 | dunkaist | 2447 | dd Filter.end-Filter |
1470 | mario79 | 2448 | .1: |
2449 | db 'BMP',0 |
||
2450 | db 'GIF',0 |
||
2451 | db 'JPG',0 |
||
2452 | db 'JPEG',0 |
||
2453 | db 'JPE',0 |
||
2454 | db 'PNG',0 |
||
2455 | db 'ICO',0 |
||
2456 | db 'CUR',0 |
||
3116 | dunkaist | 2457 | db 'TGA',0 |
1570 | dunkaist | 2458 | db 'PCX',0 |
1922 | dunkaist | 2459 | db 'XCF',0 |
2389 | dunkaist | 2460 | db 'PBM',0 |
2461 | db 'PGM',0 |
||
2462 | db 'PNM',0 |
||
7656 | dunkaist | 2463 | db 'PPM',0 |
2389 | dunkaist | 2464 | db 'TIF',0 |
2465 | db 'TIFF',0 |
||
2394 | dunkaist | 2466 | db 'WBMP',0 |
7656 | dunkaist | 2467 | db 'WEBP',0 |
2468 | db 'XBM',0 |
||
1470 | mario79 | 2469 | .end: |
2470 | db 0 |
||
1004 | diamond | 2471 | |
1470 | mario79 | 2472 | draw_window_fake: |
1570 | dunkaist | 2473 | ret |
1470 | mario79 | 2474 | ;------------------------------------------------------------------------------ |
7656 | dunkaist | 2475 | scale_mode_calc dd scale_none_calc, 0, 0, 0, scale_fit_min_calc |
2476 | |||
2477 | scale_none_mod dd 0 |
||
2478 | scale_none_key dd 13 ; '=' |
||
2479 | scale_fit_min_mod dd 0 |
||
2480 | scale_fit_min_key dd 17 ; 'w' |
||
2481 | |||
2482 | move_pictport_left_1_mod dd 0 |
||
2483 | move_pictport_left_1_key dd 35 ; 'h' |
||
2484 | move_pictport_left_2_mod dd 0 |
||
2485 | move_pictport_left_2_key dd 75 ; arrow left |
||
2486 | |||
2487 | move_pictport_right_1_mod dd 0 |
||
2488 | move_pictport_right_1_key dd 38 ; 'l' |
||
2489 | move_pictport_right_2_mod dd 0 |
||
2490 | move_pictport_right_2_key dd 77 ; arrow right |
||
2491 | |||
2492 | move_pictport_up_1_mod dd 0 |
||
2493 | move_pictport_up_1_key dd 37 ; 'k' |
||
2494 | move_pictport_up_2_mod dd 0 |
||
2495 | move_pictport_up_2_key dd 72 ; arrow up |
||
2496 | |||
2497 | move_pictport_down_1_mod dd 0 |
||
2498 | move_pictport_down_1_key dd 36 ; 'j' |
||
2499 | move_pictport_down_2_mod dd 0 |
||
2500 | move_pictport_down_2_key dd 80 ; arrow down |
||
2501 | |||
2502 | ;shift_left_down_mod |
||
2503 | |||
2504 | ;include_debug_strings |
||
2505 | |||
1016 | diamond | 2506 | readdir_fileinfo: |
1570 | dunkaist | 2507 | dd 1 |
2508 | dd 0 |
||
2509 | dd 0 |
||
2510 | readblocks dd 0 |
||
7860 | dunkaist | 2511 | directory_ptr dd 0 |
2512 | curdir rb 1024 |
||
1470 | mario79 | 2513 | ;------------------------------------------------------------------------------ |
7656 | dunkaist | 2514 | |
1004 | diamond | 2515 | I_END: |
1016 | diamond | 2516 | align 4 |
7656 | dunkaist | 2517 | img_data_len rd 1 |
2518 | fh rd 1 |
||
2519 | orig_image rd 1 |
||
2520 | cur_image rd 1 |
||
2521 | files_num rd 1 |
||
2522 | cur_file_idx rd 1 |
||
2523 | cur_frame_time rd 1 |
||
2524 | cur_frame rd 1 |
||
1004 | diamond | 2525 | |
7656 | dunkaist | 2526 | next_mod rd 1 |
2527 | next_key rd 1 |
||
2528 | prev_mod rd 1 |
||
2529 | prev_key rd 1 |
||
2530 | slide_mod rd 1 |
||
2531 | slide_key rd 1 |
||
2532 | tglbar_mod rd 1 |
||
2533 | tglbar_key rd 1 |
||
1004 | diamond | 2534 | |
3116 | dunkaist | 2535 | |
7656 | dunkaist | 2536 | last_name_component rd 1 |
2537 | toolbar.height_old rd 1 |
||
2538 | |||
2539 | procinfo process_information |
||
7860 | dunkaist | 2540 | scale_button_xy dd ? |
2541 | scale_button_letter dd ? ; i.e. 'x1',0 |
||
7421 | leency | 2542 | align 16 |
7656 | dunkaist | 2543 | path rb 4096 |
2544 | window_header rb 256 |
||
2545 | window_header_len rd 1 |
||
2546 | __params rb 4096 |
||
1470 | mario79 | 2547 | ;--------------------------------------------------------------------- |
7421 | leency | 2548 | sys_path rb 1024 |
7656 | dunkaist | 2549 | temp_dir_path: |
1470 | mario79 | 2550 | rb 4096 |
2551 | ;--------------------------------------------------------------------- |
||
1570 | dunkaist | 2552 | rb 4096 |
1470 | mario79 | 2553 | stacktop: |
2554 | ;--------------------------------------------------------------------- |
||
7656 | dunkaist | 2555 | E_END:=>20,>100,>20,>20,20>0-prev> |