Fix clang-tidy: readability-non-const-parameter (4)
[geeqie.git] / src / image.h
1 /*
2  * Copyright (C) 2004 John Ellis
3  * Copyright (C) 2008 - 2016 The Geeqie Team
4  *
5  * Author: John Ellis
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef IMAGE_H
23 #define IMAGE_H
24
25 struct CollectInfo;
26 struct CollectionData;
27 struct FileData;
28 struct ImageLoader;
29
30 enum ImageState {
31         IMAGE_STATE_NONE        = 0,
32         IMAGE_STATE_IMAGE       = 1 << 0,
33         IMAGE_STATE_LOADING     = 1 << 1,
34         IMAGE_STATE_ERROR       = 1 << 2,
35         IMAGE_STATE_COLOR_ADJ   = 1 << 3,
36         IMAGE_STATE_ROTATE_AUTO = 1 << 4,
37         IMAGE_STATE_ROTATE_USER = 1 << 5,
38         IMAGE_STATE_DELAY_FLIP  = 1 << 6
39 };
40
41 struct ImageWindow
42 {
43         GtkWidget *widget;      /**< use this to add it and show it */
44         GtkWidget *pr;
45         GtkWidget *frame;
46
47         FileData *image_fd;
48
49         gboolean unknown;               /**< failed to load image */
50
51         ImageLoader *il;        /**< @FIXME image loader should probably go to FileData, but it must first support
52                                    sending callbacks to multiple ImageWindows in parallel */
53
54         gint has_frame;  /**< not boolean, see image_new() */
55
56         /* top level (not necessarily parent) window */
57         gboolean top_window_sync;       /**< resize top_window when image dimensions change */
58         GtkWidget *top_window;  /**< window that gets title, and window to resize when 'fitting' */
59         gchar *title;           /**< window title to display left of file name */
60         gchar *title_right;     /**< window title to display right of file name */
61         gboolean title_show_zoom;       /**< option to include zoom in window title */
62
63         gboolean completed;
64         ImageState state;       /**< mask of IMAGE_STATE_* flags about current image */
65
66         void (*func_update)(ImageWindow *imd, gpointer data);
67         void (*func_complete)(ImageWindow *imd, gint preload, gpointer data);
68         void (*func_state)(ImageWindow *imd, ImageState state, gpointer data);
69
70         using TileRequestFunc = gint (*)(ImageWindow *, gint, gint, gint, gint, GdkPixbuf *, gpointer);
71         TileRequestFunc func_tile_request;
72
73         using TileDisposeFunc = void (*)(ImageWindow *, gint, gint, gint, gint, GdkPixbuf *, gpointer);
74         TileDisposeFunc func_tile_dispose;
75
76         gpointer data_update;
77         gpointer data_complete;
78         gpointer data_state;
79         gpointer data_tile;
80
81         /* button, scroll functions */
82         void (*func_button)(ImageWindow *, GdkEventButton *event, gpointer);
83         void (*func_drag)(ImageWindow *, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer);
84         void (*func_scroll)(ImageWindow *, GdkEventScroll *event, gpointer);
85         void (*func_focus_in)(ImageWindow *, gpointer);
86
87         gpointer data_button;
88         gpointer data_drag;
89         gpointer data_scroll;
90         gpointer data_focus_in;
91
92         /**
93          * @headerfile func_scroll_notify
94          * scroll notification (for scroll bar implementation)
95          */
96         void (*func_scroll_notify)(ImageWindow *, gint x, gint y, gint width, gint height, gpointer);
97
98         gpointer data_scroll_notify;
99
100         /* collection info */
101         CollectionData *collection;
102         CollectInfo *collection_info;
103
104         /* color profiles */
105         gboolean color_profile_enable;
106         gint color_profile_input;
107         gboolean color_profile_use_image;
108         gint color_profile_from_image;
109         gpointer cm;
110
111         AlterType delay_alter_type;
112
113         FileData *read_ahead_fd;
114         ImageLoader *read_ahead_il;
115
116         gint prev_color_row;
117
118         gboolean auto_refresh;
119
120         gboolean delay_flip;
121         gint orientation;
122         gboolean desaturate;
123         gboolean overunderexposed;
124         gint user_stereo;
125
126         gboolean mouse_wheel_mode;
127 };
128
129 void image_set_frame(ImageWindow *imd, gboolean frame);
130 ImageWindow *image_new(gboolean frame);
131
132 /* additional setup */
133 void image_attach_window(ImageWindow *imd, GtkWidget *window,
134                          const gchar *title, const gchar *title_right, gboolean show_zoom);
135 void image_set_update_func(ImageWindow *imd,
136                            void (*func)(ImageWindow *imd, gpointer data),
137                            gpointer data);
138 void image_set_button_func(ImageWindow *imd,
139         void (*func)(ImageWindow *, GdkEventButton *event, gpointer),
140         gpointer data);
141 void image_set_drag_func(ImageWindow *imd,
142         void (*func)(ImageWindow *, GdkEventMotion *event, gdouble dx, gdouble dy, gpointer),
143         gpointer data);
144 void image_set_scroll_func(ImageWindow *imd,
145         void (*func)(ImageWindow *, GdkEventScroll *event, gpointer),
146         gpointer data);
147 void image_set_focus_in_func(ImageWindow *imd,
148         void (*func)(ImageWindow *, gpointer),
149         gpointer data);
150 void image_set_complete_func(ImageWindow *imd,
151                              void (*func)(ImageWindow *imd, gint preload, gpointer data),
152                              gpointer data);
153 void image_set_state_func(ImageWindow *imd,
154                           void (*func)(ImageWindow *imd, ImageState state, gpointer data),
155                           gpointer data);
156
157 void image_select(ImageWindow *imd, gboolean select);
158 void image_set_selectable(ImageWindow *imd, gboolean selectable);
159
160 void image_grab_focus(ImageWindow *imd);
161 /* path, name */
162 const gchar *image_get_path(ImageWindow *imd);
163 const gchar *image_get_name(ImageWindow *imd);
164 FileData *image_get_fd(ImageWindow *imd);
165
166 /**
167  * @headerfile image_set_fd
168  * merely changes path string, does not change the image!
169  */
170 void image_set_fd(ImageWindow *imd, FileData *fd);
171
172 /* load a new image */
173 void image_change_fd(ImageWindow *imd, FileData *fd, gdouble zoom);
174 void image_change_pixbuf(ImageWindow *imd, GdkPixbuf *pixbuf, gdouble zoom, gboolean lazy);
175 void image_change_from_collection(ImageWindow *imd, CollectionData *cd, CollectInfo *info, gdouble zoom);
176 CollectionData *image_get_collection(ImageWindow *imd, CollectInfo **info);
177 void image_copy_from_image(ImageWindow *imd, ImageWindow *source);
178 void image_move_from_image(ImageWindow *imd, ImageWindow *source);
179
180 gboolean image_get_image_size(ImageWindow *imd, gint *width, gint *height);
181 GdkPixbuf *image_get_pixbuf(ImageWindow *imd);
182
183 /* manipulation */
184 void image_area_changed(ImageWindow *imd, gint x, gint y, gint width, gint height);
185 void image_reload(ImageWindow *imd);
186 void image_scroll(ImageWindow *imd, gint x, gint y);
187 void image_scroll_to_point(ImageWindow *imd, gint x, gint y,
188                            gdouble x_align, gdouble y_align);
189 void image_get_scroll_center(ImageWindow *imd, gdouble *x, gdouble *y);
190 void image_set_scroll_center(ImageWindow *imd, gdouble x, gdouble y);
191 void image_alter_orientation(ImageWindow *imd, FileData *fd, AlterType type);
192 void image_set_desaturate(ImageWindow *imd, gboolean desaturate);
193 gboolean image_get_desaturate(ImageWindow *imd);
194 void image_set_overunderexposed(ImageWindow *imd, gboolean overunderexposed);
195 void image_set_ignore_alpha(ImageWindow *imd, gboolean ignore_alpha);
196
197 /* zoom */
198 void image_zoom_adjust(ImageWindow *imd, gdouble increment);
199 void image_zoom_adjust_at_point(ImageWindow *imd, gdouble increment, gint x, gint y);
200 void image_zoom_set_limits(ImageWindow *imd, gdouble min, gdouble max);
201 void image_zoom_set(ImageWindow *imd, gdouble zoom);
202 void image_zoom_set_fill_geometry(ImageWindow *imd, gboolean vertical);
203 gdouble image_zoom_get(ImageWindow *imd);
204 gdouble image_zoom_get_real(ImageWindow *imd);
205 gchar *image_zoom_get_as_text(ImageWindow *imd);
206 gdouble image_zoom_get_default(ImageWindow *imd);
207
208 /* stereo */
209 void image_stereo_set(ImageWindow *imd, gint stereo_mode);
210
211 StereoPixbufData image_stereo_pixbuf_get(ImageWindow *imd);
212 void image_stereo_pixbuf_set(ImageWindow *imd, StereoPixbufData stereo_mode);
213
214 /**
215  * @headerfile image_prebuffer_set
216  * read ahead, pass NULL to cancel
217  */
218 void image_prebuffer_set(ImageWindow *imd, FileData *fd);
219
220 /**
221  * @headerfile image_auto_refresh_enable
222  * auto refresh
223  */
224 void image_auto_refresh_enable(ImageWindow *imd, gboolean enable);
225
226 /**
227  * @headerfile image_top_window_set_sync
228  * allow top window to be resized ?
229  */
230 void image_top_window_set_sync(ImageWindow *imd, gboolean allow_sync);
231
232 /* background of image */
233 void image_background_set_color(ImageWindow *imd, GdkRGBA *color);
234 void image_background_set_color_from_options(ImageWindow *imd, gboolean fullscreen);
235
236 /* color profiles */
237 void image_color_profile_set(ImageWindow *imd,
238                              gint input_type,
239                              gboolean use_image);
240 gboolean image_color_profile_get(ImageWindow *imd,
241                              gint *input_type,
242                              gboolean *use_image);
243 void image_color_profile_set_use(ImageWindow *imd, gboolean enable);
244 gboolean image_color_profile_get_use(ImageWindow *imd);
245 gboolean image_color_profile_get_status(ImageWindow *imd, gchar **image_profile, gchar **screen_profile);
246
247 /**
248  * @headerfile image_set_delay_flip
249  * set delayed page flipping
250  */
251 void image_set_delay_flip(ImageWindow *imd, gint delay);
252
253 /**
254  * @headerfile image_to_root_window
255  * wallpaper util
256  */
257 void image_to_root_window(ImageWindow *imd, gboolean scaled);
258
259
260
261 void image_set_image_as_tiles(ImageWindow *imd, gint width, gint height,
262                               gint tile_width, gint tile_height, gint cache_size,
263                               ImageWindow::TileRequestFunc func_tile_request,
264                               ImageWindow::TileDisposeFunc func_tile_dispose,
265                               gpointer data,
266                               gdouble zoom);
267
268 /**
269  * @headerfile image_options_sync
270  * reset default options
271  */
272 void image_options_sync();
273
274 void image_get_rectangle(gint *x1, gint *y1, gint *x2, gint *y2);
275 void image_update_title(ImageWindow *imd);
276 #endif
277 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */