Rename to ScrollReset.
static void layout_scroll_menu_cb(GtkWidget *widget, gpointer data)
{
- guint scroll_type;
-
if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return;
- scroll_type = GPOINTER_TO_UINT(data);
- options->image.scroll_reset_method = scroll_type;
+ options->image.scroll_reset_method = static_cast<ScrollReset>(GPOINTER_TO_UINT(data));
image_options_sync();
}
menu_item_add_divider(menu);
menu_item_add_radio(menu, _("Scroll to top left corner"),
- GUINT_TO_POINTER(SCROLL_RESET_TOPLEFT),
- options->image.scroll_reset_method == SCROLL_RESET_TOPLEFT,
- G_CALLBACK(layout_scroll_menu_cb),
- GUINT_TO_POINTER(SCROLL_RESET_TOPLEFT));
+ GUINT_TO_POINTER(ScrollReset::TOPLEFT),
+ options->image.scroll_reset_method == ScrollReset::TOPLEFT,
+ G_CALLBACK(layout_scroll_menu_cb),
+ GUINT_TO_POINTER(ScrollReset::TOPLEFT));
menu_item_add_radio(menu, _("Scroll to image center"),
- GUINT_TO_POINTER(SCROLL_RESET_CENTER),
- options->image.scroll_reset_method == SCROLL_RESET_CENTER,
- G_CALLBACK(layout_scroll_menu_cb),
- GUINT_TO_POINTER(SCROLL_RESET_CENTER));
+ GUINT_TO_POINTER(ScrollReset::CENTER),
+ options->image.scroll_reset_method == ScrollReset::CENTER,
+ G_CALLBACK(layout_scroll_menu_cb),
+ GUINT_TO_POINTER(ScrollReset::CENTER));
menu_item_add_radio(menu, _("Keep the region from previous image"),
- GUINT_TO_POINTER(SCROLL_RESET_NOCHANGE),
- options->image.scroll_reset_method == SCROLL_RESET_NOCHANGE,
- G_CALLBACK(layout_scroll_menu_cb),
- GUINT_TO_POINTER(SCROLL_RESET_NOCHANGE));
+ GUINT_TO_POINTER(ScrollReset::NOCHANGE),
+ options->image.scroll_reset_method == ScrollReset::NOCHANGE,
+ G_CALLBACK(layout_scroll_menu_cb),
+ GUINT_TO_POINTER(ScrollReset::NOCHANGE));
g_signal_connect(G_OBJECT(menu), "selection_done",
G_CALLBACK(layout_zoom_menu_hide_cb), NULL);
#define GQ_COLLECTION_EXT ".gqv"
-// @todo Merge with PixbufRendererScrollResetType ?
-#define SCROLL_RESET_TOPLEFT 0
-#define SCROLL_RESET_CENTER 1
-#define SCROLL_RESET_NOCHANGE 2
-
// @todo Deduplicate mousewheel_scrolls processing
#define MOUSEWHEEL_SCROLL_SIZE 20
options->image.max_autofit_size = 100;
options->image.max_enlargement_size = 900;
options->image.max_window_size = 90;
- options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
+ options->image.scroll_reset_method = ScrollReset::NOCHANGE;
options->image.tile_cache_max = 10;
options->image.image_cache_max = 128; /* 4 x 10MPix */
options->image.use_custom_border_color = FALSE;
/* image */
struct {
gboolean exif_rotate_enable;
- guint scroll_reset_method;
+ ScrollReset scroll_reset_method;
gboolean fit_window_to_image;
gboolean limit_window_size;
gint max_window_size;
FALSE,
static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)));
g_object_class_install_property(gobject_class,
- PROP_SCROLL_RESET,
- g_param_spec_uint("scroll_reset",
- "New image scroll reset",
- nullptr,
- PR_SCROLL_RESET_TOPLEFT,
- PR_SCROLL_RESET_NOCHANGE,
- PR_SCROLL_RESET_TOPLEFT,
- static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)));
+ PROP_SCROLL_RESET,
+ g_param_spec_uint("scroll_reset",
+ "New image scroll reset",
+ nullptr,
+ ScrollReset::TOPLEFT,
+ ScrollReset::NOCHANGE,
+ ScrollReset::TOPLEFT,
+ static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_WRITABLE)));
g_object_class_install_property(gobject_class,
PROP_DELAY_FLIP,
pr->scale = 1.0;
pr->aspect_ratio = 1.0;
- pr->scroll_reset = PR_SCROLL_RESET_TOPLEFT;
+ pr->scroll_reset = ScrollReset::TOPLEFT;
pr->scroller_id = 0;
pr->scroller_overlay = -1;
pr->zoom_expand = g_value_get_boolean(value);
break;
case PROP_SCROLL_RESET:
- pr->scroll_reset = static_cast<PixbufRendererScrollResetType>(g_value_get_uint(value));
+ pr->scroll_reset = static_cast<ScrollReset>(g_value_get_uint(value));
break;
case PROP_DELAY_FLIP:
pr->delay_flip = g_value_get_boolean(value);
{
switch (pr->scroll_reset)
{
- case PR_SCROLL_RESET_NOCHANGE:
+ case ScrollReset::NOCHANGE:
/* maintain old scroll position */
pr->x_scroll = (static_cast<gdouble>(pr->image_width) * old_center_x * pr->scale) - pr->vis_width / 2.0;
pr->y_scroll = (static_cast<gdouble>(pr->image_height) * old_center_y * pr->scale * pr->aspect_ratio) - pr->vis_height / 2.0;
break;
- case PR_SCROLL_RESET_CENTER:
+ case ScrollReset::CENTER:
/* center new image */
pr->x_scroll = (static_cast<gdouble>(pr->image_width) / 2.0 * pr->scale) - pr->vis_width / 2.0;
pr->y_scroll = (static_cast<gdouble>(pr->image_height) / 2.0 * pr->scale * pr->aspect_ratio) - pr->vis_height / 2.0;
break;
- case PR_SCROLL_RESET_TOPLEFT:
+ case ScrollReset::TOPLEFT:
default:
/* reset to upper left */
pr->x_scroll = 0;
void pixbuf_renderer_move(PixbufRenderer *pr, PixbufRenderer *source)
{
GObject *object;
- PixbufRendererScrollResetType scroll_reset;
+ ScrollReset scroll_reset;
g_return_if_fail(IS_PIXBUF_RENDERER(pr));
g_return_if_fail(IS_PIXBUF_RENDERER(source));
pr->y_mouse = source->y_mouse;
scroll_reset = pr->scroll_reset;
- pr->scroll_reset = PR_SCROLL_RESET_NOCHANGE;
+ pr->scroll_reset = ScrollReset::NOCHANGE;
pr->func_post_process = source->func_post_process;
pr->post_process_user_data = source->post_process_user_data;
void pixbuf_renderer_copy(PixbufRenderer *pr, PixbufRenderer *source)
{
GObject *object;
- PixbufRendererScrollResetType scroll_reset;
+ ScrollReset scroll_reset;
g_return_if_fail(IS_PIXBUF_RENDERER(pr));
g_return_if_fail(IS_PIXBUF_RENDERER(source));
pr->y_mouse = source->y_mouse;
scroll_reset = pr->scroll_reset;
- pr->scroll_reset = PR_SCROLL_RESET_NOCHANGE;
+ pr->scroll_reset = ScrollReset::NOCHANGE;
pr->orientation = source->orientation;
pr->stereo_data = source->stereo_data;
using PixbufRendererPostProcessFunc = void (*)(PixbufRenderer *, GdkPixbuf **, gint, gint, gint, gint, gpointer);
-enum PixbufRendererScrollResetType {
- PR_SCROLL_RESET_TOPLEFT = 0,
- PR_SCROLL_RESET_CENTER,
- PR_SCROLL_RESET_NOCHANGE,
- PR_SCROLL_RESET_COUNT,
-};
-
enum ImageRenderType {
TILE_RENDER_NONE = 0, /**< do nothing */
TILE_RENDER_AREA, /**< render an area of the tile */
gint y_scroll;
gdouble norm_center_x; /**< coordinates of viewport center in the image, in range 0.0 - 1.0 */
- gdouble norm_center_y; /**< these coordinates are used for PR_SCROLL_RESET_NOCHANGE and should be preserved over periods with NULL pixbuf */
+ gdouble norm_center_y; /**< these coordinates are used for ScrollReset::NOCHANGE and should be preserved over periods with NULL pixbuf */
gdouble subpixel_x_scroll; /**< subpixel scroll alignment, used to prevent accumulation of rounding errors */
gdouble subpixel_y_scroll;
gboolean zoom_2pass;
gboolean zoom_expand;
- PixbufRendererScrollResetType scroll_reset;
+ ScrollReset scroll_reset;
gboolean has_frame;
if (READ_BOOL(*options, image.limit_autofit_size)) continue;
if (READ_INT(*options, image.max_autofit_size)) continue;
if (READ_INT(*options, image.max_enlargement_size)) continue;
- if (READ_UINT_CLAMP(*options, image.scroll_reset_method, 0, PR_SCROLL_RESET_COUNT - 1)) continue;
+ if (READ_UINT_ENUM_CLAMP(*options, image.scroll_reset_method, 0, ScrollReset::COUNT - 1)) continue;
if (READ_INT(*options, image.tile_cache_max)) continue;
if (READ_INT(*options, image.image_cache_max)) continue;
if (READ_UINT_CLAMP(*options, image.zoom_quality, GDK_INTERP_NEAREST, GDK_INTERP_BILINEAR)) continue;
STEREO_PIXBUF_NONE = 3
};
+enum ScrollReset : guint {
+ TOPLEFT = 0,
+ CENTER = 1,
+ NOCHANGE = 2,
+ COUNT /**< Keep it last */
+};
+
using FileUtilDoneFunc = void (*)(gboolean, const gchar *, gpointer);
#define FILEDATA_MARKS_SIZE 10