Mercurial > hg > forks > geeqie
changeset 2794:780a9b685335
Ref #331: Overimposed custom composition rule lines
"Rule of thirds" guidelines are included as an additional item in the
overlay screen display feature.
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Sat, 14 Jul 2018 14:23:55 +0100 |
parents | 2feed80bcd34 |
children | 684ca84becd2 |
files | src/icons/Makefile.am src/icons/icon_guidelines.png src/image-overlay.c src/image-overlay.h src/layout_util.c src/options.h src/pixbuf_util.c src/pixbuf_util.h src/rcfile.c src/toolbar.c |
diffstat | 10 files changed, 105 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/icons/Makefile.am Sat Jul 07 19:50:31 2018 +0100 +++ b/src/icons/Makefile.am Sat Jul 14 14:23:55 2018 +0100 @@ -21,7 +21,8 @@ icon_book.png \ icon_config.png \ icon_tools.png \ - icon_view.png + icon_view.png \ + icon_guidelines.png ICONS_INLINE_PAIRS = \ folder_closed $(srcdir)/folder_closed.png \ @@ -41,7 +42,8 @@ icon_book $(srcdir)/icon_book.png \ icon_config $(srcdir)/icon_config.png \ icon_tools $(srcdir)/icon_tools.png \ - icon_view $(srcdir)/icon_view.png + icon_view $(srcdir)/icon_view.png \ + icon_guidelines $(srcdir)/icon_guidelines.png icons_inline.h: $(ICONS_INLINE) Makefile.in @sh -ec "echo '/* Auto generated file, do not edit */'; echo; \
--- a/src/image-overlay.c Sat Jul 07 19:50:31 2018 +0100 +++ b/src/image-overlay.c Sat Jul 14 14:23:55 2018 +0100 @@ -52,6 +52,7 @@ Histogram *histogram; OsdShowFlags show; + OverlayRendererFlags origin; gint ovl_info; @@ -215,10 +216,15 @@ } else { - if (show & OSD_SHOW_HISTOGRAM) + if (show & OSD_SHOW_GUIDELINES) { image_osd_set(imd, OSD_SHOW_NOTHING); } + else if (show & OSD_SHOW_HISTOGRAM) + { + image_osd_set(imd, OSD_SHOW_GUIDELINES); + image_osd_set(imd, show | ~OSD_SHOW_HISTOGRAM); + } else { image_osd_set(imd, show | OSD_SHOW_HISTOGRAM); @@ -793,6 +799,40 @@ return icon; } +static GdkPixbuf *image_osd_guidelines_render(OverlayStateData *osd) +{ + gint width, height; + GdkPixbuf *rectangles; + ImageWindow *imd = osd->imd; + + pixbuf_renderer_get_scaled_size((PixbufRenderer *)imd->pr, &width, &height); + + if (width && height) + { + rectangles = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); + if (rectangles) + { + pixbuf_set_rect_fill(rectangles, 0, 0, width, height, 255, 255, 255, 0); + pixbuf_set_rect(rectangles, 0, 0 + (height / 3), width, height / 3, + 0, 0, 0, 255, + 1, 1, 1, 1); + pixbuf_set_rect(rectangles, 0, 0 + (height / 3 + 1), width, height / 3 - 2, + 255, 255, 255, 255, + 1, 1, 1, 1); + + pixbuf_set_rect(rectangles, 0 + width / 3, 0 , width / 3, height, + 0, 0, 0, 255, + 1, 1, 1, 1); + pixbuf_set_rect(rectangles, 0 + width / 3 + 1, 0, width / 3 - 2, height, + 255, 255, 255, 255, + 1, 1, 1, 1); + return rectangles; + } + } + + return NULL; +} + static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y, OverlayRendererFlags flags) { @@ -876,7 +916,7 @@ { if (osd->ovl_info == 0) { - osd->ovl_info = image_overlay_add(osd->imd, pixbuf, osd->x, osd->y, OVL_RELATIVE); + osd->ovl_info = image_overlay_add(osd->imd, pixbuf, osd->x, osd->y, osd->origin); } else { @@ -902,19 +942,41 @@ with histogram we have to redraw also when loading is finished */ if (osd->changed_states & IMAGE_STATE_IMAGE || (osd->changed_states & IMAGE_STATE_LOADING && osd->show & OSD_SHOW_HISTOGRAM) || + (osd->changed_states & IMAGE_STATE_LOADING && osd->show & OSD_SHOW_GUIDELINES) || osd->notify & NOTIFY_HISTMAP) { GdkPixbuf *pixbuf; - pixbuf = image_osd_info_render(osd); - if (pixbuf) + if (osd->show & OSD_SHOW_GUIDELINES) { - image_osd_info_show(osd, pixbuf); - g_object_unref(pixbuf); + ImageWindow *imd = osd->imd; + osd->x = ((PixbufRenderer *)imd->pr)->x_offset; + osd->y = ((PixbufRenderer *)imd->pr)->y_offset; + osd->origin = OVL_NORMAL; + + pixbuf = image_osd_guidelines_render(osd); + if (pixbuf) + { + image_osd_info_show(osd, pixbuf); + g_object_unref(pixbuf); + } + + osd->x = options->image_overlay.x; + osd->y = options->image_overlay.y; + osd->origin = OVL_RELATIVE; } else { - image_osd_info_hide(osd); + pixbuf = image_osd_info_render(osd); + if (pixbuf) + { + image_osd_info_show(osd, pixbuf); + g_object_unref(pixbuf); + } + else + { + image_osd_info_hide(osd); + } } } } @@ -1088,6 +1150,7 @@ osd->show = OSD_SHOW_NOTHING; osd->x = options->image_overlay.x; osd->y = options->image_overlay.y; + osd->origin = OVL_RELATIVE; osd->histogram = histogram_new();
--- a/src/image-overlay.h Sat Jul 07 19:50:31 2018 +0100 +++ b/src/image-overlay.h Sat Jul 14 14:23:55 2018 +0100 @@ -37,7 +37,8 @@ OSD_SHOW_NOTHING = 0, OSD_SHOW_INFO = 1 << 0, OSD_SHOW_STATUS = 1 << 1, - OSD_SHOW_HISTOGRAM = 1 << 2 + OSD_SHOW_HISTOGRAM = 1 << 2, + OSD_SHOW_GUIDELINES = 1 << 3 } OsdShowFlags; void set_image_overlay_template_string(gchar **template_string, const gchar *value);
--- a/src/layout_util.c Sat Jul 07 19:50:31 2018 +0100 +++ b/src/layout_util.c Sat Jul 14 14:23:55 2018 +0100 @@ -928,6 +928,24 @@ } } +static void layout_menu_guidelines_cb(GtkToggleAction *action, gpointer data) +{ + LayoutWindow *lw = data; + + if (gtk_toggle_action_get_active(action)) + { + OsdShowFlags flags = image_osd_get(lw->image); + image_osd_set(lw->image, OSD_SHOW_INFO | OSD_SHOW_STATUS | OSD_SHOW_GUIDELINES); + layout_util_sync_views(lw); + } + else + { + OsdShowFlags flags = image_osd_get(lw->image); + if (flags & OSD_SHOW_GUIDELINES) + image_osd_set(lw->image, OSD_SHOW_NOTHING); + } +} + static void layout_menu_animate_cb(GtkToggleAction *action, gpointer data) { LayoutWindow *lw = data; @@ -1927,6 +1945,7 @@ { "Grayscale", NULL, N_("Toggle _grayscale"), "<shift>G", N_("Toggle grayscale"), CB(layout_menu_alter_desaturate_cb), FALSE}, { "ImageOverlay", NULL, N_("Image _Overlay"), NULL, N_("Image Overlay"), CB(layout_menu_overlay_cb), FALSE }, { "ImageHistogram", NULL, N_("_Show Histogram"), NULL, N_("Show Histogram"), CB(layout_menu_histogram_cb), FALSE }, + { "ImageGuidelines", PIXBUF_INLINE_ICON_GUIDELINES, N_("_Show Guidelines"), NULL, N_("Show Guidelines"), CB(layout_menu_guidelines_cb), FALSE }, { "RectangularSelection", NULL, N_("Rectangular Selection"), "<alt>R", N_("Rectangular Selection"), CB(layout_menu_rectangular_selection_cb), FALSE }, { "Animate", NULL, N_("GIF _animation"), "A", N_("Toggle GIF animation"), CB(layout_menu_animate_cb), FALSE }, { "ExifRotate", GTK_STOCK_ORIENTATION_PORTRAIT, N_("_Exif rotate"), "<alt>X", N_("Exif rotate"), CB(layout_menu_exif_rotate_cb), FALSE }, @@ -2162,6 +2181,7 @@ " </menu>" " <menu action='OverlayMenu'>" " <menuitem action='ImageOverlay'/>" +" <menuitem action='ImageGuidelines'/>" " <menuitem action='ImageHistogram'/>" " <menuitem action='ImageOverlayCycle'/>" " <separator/>" @@ -3018,6 +3038,9 @@ action = gtk_action_group_get_action(lw->action_group, "ImageHistogram"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), osd_flags & OSD_SHOW_HISTOGRAM); + action = gtk_action_group_get_action(lw->action_group, "ImageGuidelines"); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), osd_flags & OSD_SHOW_GUIDELINES); + action = gtk_action_group_get_action(lw->action_group, "ExifRotate"); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), options->image.exif_rotate_enable);
--- a/src/options.h Sat Jul 07 19:50:31 2018 +0100 +++ b/src/options.h Sat Jul 14 14:23:55 2018 +0100 @@ -35,6 +35,7 @@ gchar *image_l_click_video_editor; gboolean show_icon_names; gboolean show_star_rating; + gboolean show_guidelines; /* various */ gboolean tree_descend_subdirs;
--- a/src/pixbuf_util.c Sat Jul 07 19:50:31 2018 +0100 +++ b/src/pixbuf_util.c Sat Jul 14 14:23:55 2018 +0100 @@ -120,6 +120,7 @@ { PIXBUF_INLINE_ICON_CONFIG, icon_config }, { PIXBUF_INLINE_ICON_TOOLS, icon_tools }, { PIXBUF_INLINE_ICON_VIEW, icon_view }, + { PIXBUF_INLINE_ICON_GUIDELINES, icon_guidelines }, { NULL, NULL } };
--- a/src/pixbuf_util.h Sat Jul 07 19:50:31 2018 +0100 +++ b/src/pixbuf_util.h Sat Jul 14 14:23:55 2018 +0100 @@ -54,6 +54,7 @@ #define PIXBUF_INLINE_ICON_CONFIG "icon_config" #define PIXBUF_INLINE_ICON_TOOLS "icon_tools" #define PIXBUF_INLINE_ICON_VIEW "icon_view" +#define PIXBUF_INLINE_ICON_GUIDELINES "icon_guidelines" GdkPixbuf *pixbuf_copy_rotate_90(GdkPixbuf *src, gboolean counter_clockwise);
--- a/src/rcfile.c Sat Jul 07 19:50:31 2018 +0100 +++ b/src/rcfile.c Sat Jul 14 14:23:55 2018 +0100 @@ -307,6 +307,7 @@ /* General Options */ WRITE_NL(); WRITE_BOOL(*options, show_icon_names); WRITE_NL(); WRITE_BOOL(*options, show_star_rating); + WRITE_NL(); WRITE_BOOL(*options, show_guidelines); WRITE_SEPARATOR(); WRITE_NL(); WRITE_BOOL(*options, tree_descend_subdirs); @@ -644,6 +645,7 @@ /* General options */ if (READ_BOOL(*options, show_icon_names)) continue; if (READ_BOOL(*options, show_star_rating)) continue; + if (READ_BOOL(*options, show_guidelines)) continue; if (READ_BOOL(*options, tree_descend_subdirs)) continue; if (READ_BOOL(*options, view_dir_list_single_click_enter)) continue;
--- a/src/toolbar.c Sat Jul 07 19:50:31 2018 +0100 +++ b/src/toolbar.c Sat Jul 14 14:23:55 2018 +0100 @@ -111,6 +111,7 @@ {"ExifWin", N_("Exif window"), GTK_STOCK_FILE}, {"Thumbnails", N_("Show thumbnails"), PIXBUF_INLINE_ICON_THUMB}, {"ShowMarks", N_("Show marks"), GTK_STOCK_FILE}, + {"ImageGuidelines", N_("Show guidelines"), PIXBUF_INLINE_ICON_GUIDELINES}, {"FloatTools", N_("Float file list"), PIXBUF_INLINE_ICON_FLOAT}, {"SBar", N_("Info sidebar"), GTK_STOCK_FILE}, {"SBarSort", N_("Sort manager"), GTK_STOCK_FILE},