241 static float scale = 1.f;
244 GtkAllocation allocation;
245 gtk_widget_get_allocation(widget, &allocation);
246 static int width = 0;
248 gboolean changed = (
width != allocation.width) || (
height != allocation.height);
249 width = allocation.width;
250 height = allocation.height;
253 cairo_t *cr = cairo_create(cst);
254 GtkStyleContext *context = gtk_widget_get_style_context(widget);
255 gtk_render_background(context, cr, 0, 0, allocation.width, allocation.height);
261 if(
d->image_surface) cairo_surface_destroy(
d->image_surface);
277 scale = fminf(
width / (
float)wd,
height / (
float)ht);
278 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, wd);
279 cairo_surface_t *tmp_surface = cairo_image_surface_create_for_data(
data, CAIRO_FORMAT_RGB24, wd, ht, stride);
283 cairo_t *cri = cairo_create(
d->image_surface);
286 cairo_scale(cri, scale, scale);
287 cairo_translate(cri, -wd / 2., -ht / 2.);
288 cairo_set_source_surface(cri, tmp_surface, 0, 0);
290 cairo_surface_destroy(tmp_surface);
306 cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST);
307 cairo_set_source_surface(cr,
d->image_surface, 0, 0);
312 cairo_scale(cr, scale, scale);
313 cairo_translate(cr, -wd / 2., -ht / 2.);
318 double dx = line_width, dy = 0;
319 cairo_device_to_user_distance(cr, &dx, &dy);
327 cairo_rectangle(cr, 0, 0, wd, ht);
328 cairo_set_source_rgba(cr, 0, 0, 0, 0.5);
331 float boxw = 1, boxh = 1;
333 const float roi_w =
MIN(boxw * wd, wd);
334 const float roi_h =
MIN(boxh * ht, ht);
335 const float roi_x = dev->
roi.
x * wd - roi_w * 0.5f;
336 const float roi_y = dev->
roi.
y * ht - roi_h * 0.5f;
337 cairo_rectangle(cr, roi_x - 1, roi_y - 1, roi_w + 2, roi_h + 2);
340 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
343 cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
346 cairo_set_source_rgb(cr, 0., 0., 0.);
347 cairo_set_line_width(cr, line_width);
351 cairo_set_source_rgb(cr, 1., 1., 1.);
352 cairo_rectangle(cr, roi_x, roi_y, roi_w, roi_h);
358 cairo_set_source_rgb(cr, 1., 1., 1.);
359 cairo_set_line_width(cr, line_width);
360 cairo_rectangle(cr, 0.5, 0.5, wd - 1, ht - 1);
368 PangoRectangle logic;
370 pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
371 layout = pango_cairo_create_layout(cr);
373 pango_font_description_set_absolute_size(desc, fontsize * PANGO_SCALE);
374 pango_layout_set_font_description(layout, desc);
377 cairo_translate(cr, 0,
height);
378 cairo_set_source_rgba(cr, 1., 1., 1., 0.5);
379 cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND);
385 fit = g_strdup(_(
"Fit"));
394 pango_layout_set_text(layout, zoomline, -1);
396 pango_layout_get_pixel_extents(layout, NULL, &logic);
397 d->zoom_h = logic.height;
398 d->zoom_w = logic.width;
399 const double h =
d->zoom_h;
400 const double w =
d->zoom_w;
401 const int xp =
width - w - h - logic.x;
402 const int yp = - logic.height;
404 cairo_move_to(cr, xp, yp);
409 gtk_style_context_get(context, gtk_widget_get_state_flags(widget),
"background-color", &color, NULL);
411 gdk_cairo_set_source_rgba(cr, color);
412 pango_cairo_layout_path(cr, layout);
413 cairo_stroke_preserve(cr);
414 cairo_set_source_rgb(cr, 0.8, 0.8, 0.8);
419 gdk_rgba_free(color);
420 pango_font_description_free(desc);
421 g_object_unref(layout);
423 const float arrow_h = fontsize;
426 cairo_move_to(cr,
width - 0.95 * arrow_h, -0.9 * arrow_h - 2);
427 cairo_line_to(cr,
width - 0.05 * arrow_h, -0.9 * arrow_h - 2);
428 cairo_line_to(cr,
width - 0.5 * arrow_h, -0.1 * arrow_h - 2);
433 cairo_set_source_surface(crf, cst, 0, 0);
435 cairo_surface_destroy(cst);
546 GtkAllocation allocation;
547 gtk_widget_get_allocation(widget, &allocation);
548 int w = allocation.width;
549 int h = allocation.height;
554 GtkMenuShell *menu = GTK_MENU_SHELL(gtk_menu_new());
557 item = gtk_menu_item_new_with_label(_(
"Small"));
559 gtk_menu_shell_append(menu, item);
561 item = gtk_menu_item_new_with_label(_(
"Fit to screen"));
563 gtk_menu_shell_append(menu, item);
565 item = gtk_menu_item_new_with_label(_(
"25%"));
567 gtk_menu_shell_append(menu, item);
569 item = gtk_menu_item_new_with_label(_(
"33%"));
571 gtk_menu_shell_append(menu, item);
573 item = gtk_menu_item_new_with_label(_(
"50%"));
575 gtk_menu_shell_append(menu, item);
577 item = gtk_menu_item_new_with_label(_(
"100%"));
579 gtk_menu_shell_append(menu, item);
581 item = gtk_menu_item_new_with_label(_(
"200%"));
583 gtk_menu_shell_append(menu, item);
585 item = gtk_menu_item_new_with_label(_(
"400%"));
587 gtk_menu_shell_append(menu, item);
589 item = gtk_menu_item_new_with_label(_(
"800%"));
591 gtk_menu_shell_append(menu, item);
593 item = gtk_menu_item_new_with_label(_(
"1600%"));
595 gtk_menu_shell_append(menu, item);