@@ -160,33 +160,23 @@ namespace pdfpc.Window {
160
160
161
161
Gtk . Orientation orientation = Gtk . Orientation . HORIZONTAL ;
162
162
bool tbox_inverse = false ;
163
- int tb_offset = (int ) (0.02 * presenter. window_h);
164
163
165
- int tbox_x = 0 , tbox_y = 0 ;
166
164
switch (Options . toolbox_direction) {
167
165
case Options . ToolboxDirection . LtoR :
168
166
orientation = Gtk . Orientation . HORIZONTAL ;
169
167
tbox_inverse = false ;
170
- tbox_x = (int ) (0.15 * presenter. window_w) + tb_offset;
171
- tbox_y = (int ) (0.70 * presenter. window_h) + tb_offset;
172
168
break ;
173
169
case Options . ToolboxDirection . RtoL :
174
170
orientation = Gtk . Orientation . HORIZONTAL ;
175
171
tbox_inverse = true ;
176
- tbox_x = (int ) (0.15 * presenter. window_w) - tb_offset;
177
- tbox_y = (int ) (0.70 * presenter. window_h) + tb_offset;
178
172
break ;
179
173
case Options . ToolboxDirection . TtoB :
180
174
orientation = Gtk . Orientation . VERTICAL ;
181
175
tbox_inverse = false ;
182
- tbox_x = 0 * presenter. window_w + tb_offset;
183
- tbox_y = 0 * presenter. window_h + tb_offset;
184
176
break ;
185
177
case Options . ToolboxDirection . BtoT :
186
178
orientation = Gtk . Orientation . VERTICAL ;
187
179
tbox_inverse = true ;
188
- tbox_x = 0 * presenter. window_w + tb_offset;
189
- tbox_y = 0 * presenter. window_h + tb_offset;
190
180
break ;
191
181
}
192
182
toolbox = new Gtk .Box (orientation, 0 );
@@ -222,7 +212,7 @@ namespace pdfpc.Window {
222
212
button_panel. set_homogeneous(true );
223
213
224
214
if (Options . toolbox_minimized) {
225
- button_panel. hide( );
215
+ button_panel. set_child_visible( false );
226
216
}
227
217
if (tbox_inverse) {
228
218
this . toolbox. pack_end(button_panel);
@@ -231,12 +221,8 @@ namespace pdfpc.Window {
231
221
}
232
222
233
223
tb. clicked. connect(() = > {
234
- var state = button_panel. visible;
235
- if (state) {
236
- button_panel. hide();
237
- } else {
238
- button_panel. show();
239
- }
224
+ var state = button_panel. get_child_visible();
225
+ button_panel. set_child_visible(! state);
240
226
});
241
227
242
228
tb = add_button(button_panel, tbox_inverse, " empty.svg" ,
@@ -301,6 +287,9 @@ namespace pdfpc.Window {
301
287
this . controller. queue_pen_surface_draws();
302
288
});
303
289
290
+ int tbox_x, tbox_y;
291
+ calculate_position(presenter. window_w, presenter. window_h,
292
+ out tbox_x, out tbox_y);
304
293
this . put(this . toolbox, tbox_x, tbox_y);
305
294
}
306
295
@@ -328,5 +317,39 @@ namespace pdfpc.Window {
328
317
scale_button. hide();
329
318
}
330
319
}
320
+
321
+ protected void calculate_position (int w , int h , out int x , out int y ) {
322
+ double fx = 0.0 , fy = 0.0 ;
323
+ double offset = 0.02 * h;
324
+
325
+ switch (Options . toolbox_direction) {
326
+ case Options . ToolboxDirection . LtoR :
327
+ fx = 0.15 * w + offset;
328
+ fy = 0.70 * h + offset;
329
+ break ;
330
+ case Options . ToolboxDirection . RtoL :
331
+ fx = 0.15 * w - offset;
332
+ fy = 0.70 * h + offset;
333
+ break ;
334
+ case Options . ToolboxDirection . TtoB :
335
+ fx = 0 * w + offset;
336
+ fy = 0 * h + offset;
337
+ break ;
338
+ case Options . ToolboxDirection . BtoT :
339
+ fx = 0 * w + offset;
340
+ fy = 0 * h + offset;
341
+ break ;
342
+ }
343
+
344
+ x = (int ) fx;
345
+ y = (int ) fy;
346
+ }
347
+
348
+ public void on_window_resize (int w , int h ) {
349
+ int x, y;
350
+ calculate_position(w, h, out x, out y);
351
+
352
+ this . move(this . toolbox, x, y);
353
+ }
331
354
}
332
355
}
0 commit comments