Subversion Repositories Kolibri OS

Rev

Rev 8496 | Rev 8945 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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