[gthumb] image viewer: added ability to define the transparency style
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] image viewer: added ability to define the transparency style
- Date: Sun, 24 Nov 2019 12:28:05 +0000 (UTC)
commit e0399e29502f6b3c4d9673340653e7c51fe11796
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Nov 4 11:09:12 2019 +0100
image viewer: added ability to define the transparency style
gthumb/gth-image-viewer.c | 43 +++++++++++++++++++++++++++++++++++++++----
gthumb/gth-image-viewer.h | 12 ++++++++++++
2 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index fc0e022a..a6224841 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -40,7 +40,7 @@
#define MINIMUM_DELAY 10 /* When an animation frame has a 0 milli seconds
* delay use this delay instead. */
#define STEP_INCREMENT 20.0 /* Scroll increment. */
-#define BLACK_VALUE 0.2
+#define GRAY_VALUE 0.2
#define CHECKED_PATTERN_SIZE 20
@@ -113,7 +113,7 @@ struct _GthImageViewerPrivate {
gboolean skip_zoom_change;
gboolean update_image_after_zoom;
gboolean reset_scrollbars;
-
+ GthTransparencyStyle transparency_style;
GList *painters;
};
@@ -1576,6 +1576,7 @@ gth_image_viewer_init (GthImageViewer *self)
self->priv->cursor_void = NULL;
self->priv->reset_scrollbars = TRUE;
+ self->priv->transparency_style = GTH_TRANSPARENCY_STYLE_CHECKERED;
gth_image_viewer_set_tool (self, NULL);
@@ -2283,6 +2284,26 @@ gth_image_viewer_get_tool (GthImageViewer *self)
}
+void
+gth_image_viewer_set_transparency_style (GthImageViewer *self,
+ GthTransparencyStyle style)
+{
+ g_return_if_fail (GTH_IS_IMAGE_VIEWER (self));
+
+ self->priv->transparency_style = style;
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+
+GthTransparencyStyle
+gth_image_viewer_get_transparency_style (GthImageViewer *self)
+{
+ g_return_val_if_fail (GTH_IS_IMAGE_VIEWER (self), 0);
+
+ return self->priv->transparency_style;
+}
+
+
void
gth_image_viewer_scroll_to (GthImageViewer *self,
int x_offset,
@@ -2645,7 +2666,7 @@ gth_image_viewer_paint_background (GthImageViewer *self,
cairo_save (cr);
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
- cairo_set_source_rgb (cr, BLACK_VALUE, BLACK_VALUE, BLACK_VALUE);
+ cairo_set_source_rgb (cr, GRAY_VALUE, GRAY_VALUE, GRAY_VALUE);
cairo_rectangle (cr,
0,
0,
@@ -2685,7 +2706,21 @@ gth_image_viewer_paint_frame (GthImageViewer *self,
/* background */
- cairo_set_source (cr, self->priv->background_pattern);
+ switch (self->priv->transparency_style) {
+ case GTH_TRANSPARENCY_STYLE_CHECKERED:
+ cairo_set_source (cr, self->priv->background_pattern);
+ break;
+ case GTH_TRANSPARENCY_STYLE_WHITE:
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ break;
+ case GTH_TRANSPARENCY_STYLE_GRAY:
+ cairo_set_source_rgb (cr, GRAY_VALUE, GRAY_VALUE, GRAY_VALUE);
+ break;
+ case GTH_TRANSPARENCY_STYLE_BLACK:
+ cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ break;
+ }
+
cairo_rectangle (cr,
self->image_area.x,
self->image_area.y,
diff --git a/gthumb/gth-image-viewer.h b/gthumb/gth-image-viewer.h
index 9754b7fe..f04abcfc 100644
--- a/gthumb/gth-image-viewer.h
+++ b/gthumb/gth-image-viewer.h
@@ -77,6 +77,14 @@ typedef enum {
} GthZoomChange;
+typedef enum {
+ GTH_TRANSPARENCY_STYLE_CHECKERED,
+ GTH_TRANSPARENCY_STYLE_WHITE,
+ GTH_TRANSPARENCY_STYLE_GRAY,
+ GTH_TRANSPARENCY_STYLE_BLACK
+} GthTransparencyStyle;
+
+
struct _GthImageViewer
{
GtkWidget __parent;
@@ -224,6 +232,10 @@ void gth_image_viewer_set_tool (GthImageViewer
GthImageViewerTool *tool);
GthImageViewerTool *
gth_image_viewer_get_tool (GthImageViewer *viewer);
+void gth_image_viewer_set_transparency_style (GthImageViewer *viewer,
+ GthTransparencyStyle style);
+GthTransparencyStyle
+ gth_image_viewer_get_transparency_style (GthImageViewer *viewer);
/* Scrolling. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]