1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef __GIMP_DISPLAY_SHELL_H__ 19 #define __GIMP_DISPLAY_SHELL_H__ 20 21 22 /* Apply to a float the same rounding mode used in the renderer */ 23 #define PROJ_ROUND(coord) ((gint) RINT (coord)) 24 #define PROJ_ROUND64(coord) ((gint64) RINT (coord)) 25 26 /* scale values */ 27 #define SCALEX(s,x) PROJ_ROUND ((x) * (s)->scale_x) 28 #define SCALEY(s,y) PROJ_ROUND ((y) * (s)->scale_y) 29 30 /* unscale values */ 31 #define UNSCALEX(s,x) ((gint) ((x) / (s)->scale_x)) 32 #define UNSCALEY(s,y) ((gint) ((y) / (s)->scale_y)) 33 /* (and float-returning versions) */ 34 #define FUNSCALEX(s,x) ((x) / (s)->scale_x) 35 #define FUNSCALEY(s,y) ((y) / (s)->scale_y) 36 37 38 #define GIMP_TYPE_DISPLAY_SHELL (gimp_display_shell_get_type ()) 39 #define GIMP_DISPLAY_SHELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShell)) 40 #define GIMP_DISPLAY_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass)) 41 #define GIMP_IS_DISPLAY_SHELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DISPLAY_SHELL)) 42 #define GIMP_IS_DISPLAY_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DISPLAY_SHELL)) 43 #define GIMP_DISPLAY_SHELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass)) 44 45 46 typedef struct _GimpDisplayShellClass GimpDisplayShellClass; 47 48 struct _GimpDisplayShell 49 { 50 GtkEventBox parent_instance; 51 52 GimpDisplay *display; 53 54 GimpUIManager *popup_manager; 55 GdkScreen *initial_screen; 56 gint initial_monitor; 57 58 GimpDisplayOptions *options; 59 GimpDisplayOptions *fullscreen_options; 60 GimpDisplayOptions *no_image_options; 61 62 GimpUnit unit; 63 64 gint offset_x; /* offset of display image */ 65 gint offset_y; 66 67 gdouble scale_x; /* horizontal scale factor */ 68 gdouble scale_y; /* vertical scale factor */ 69 70 gboolean flip_horizontally; 71 gboolean flip_vertically; 72 gdouble rotate_angle; 73 cairo_matrix_t *rotate_transform; 74 cairo_matrix_t *rotate_untransform; 75 76 gdouble monitor_xres; 77 gdouble monitor_yres; 78 gboolean dot_for_dot; /* ignore monitor resolution */ 79 80 GimpZoomModel *zoom; 81 82 gdouble last_scale; /* scale used when reverting zoom */ 83 guint last_scale_time; /* time when last_scale was set */ 84 gint last_offset_x; /* offsets used when reverting zoom */ 85 gint last_offset_y; 86 87 gdouble other_scale; /* scale factor entered in Zoom->Other*/ 88 89 gint disp_width; /* width of drawing area */ 90 gint disp_height; /* height of drawing area */ 91 92 gboolean proximity; /* is a device in proximity */ 93 94 gboolean show_image; /* whether to show the image */ 95 96 gboolean show_all; /* show the entire image */ 97 98 Selection *selection; /* Selection (marching ants) */ 99 gint64 selection_update; /* Last selection index update */ 100 101 GList *children; 102 103 GtkWidget *canvas; /* GimpCanvas widget */ 104 105 GtkAdjustment *hsbdata; /* adjustments */ 106 GtkAdjustment *vsbdata; 107 GtkWidget *hsb; /* scroll bars */ 108 GtkWidget *vsb; 109 110 GtkWidget *hrule; /* rulers */ 111 GtkWidget *vrule; 112 113 GtkWidget *origin; /* NW: origin */ 114 GtkWidget *quick_mask_button;/* SW: quick mask button */ 115 GtkWidget *zoom_button; /* NE: zoom toggle button */ 116 GtkWidget *nav_ebox; /* SE: navigation event box */ 117 118 GtkWidget *statusbar; /* statusbar */ 119 120 GimpCanvasItem *canvas_item; /* items drawn on the canvas */ 121 GimpCanvasItem *unrotated_item; /* unrotated items for e.g. cursor */ 122 GimpCanvasItem *passe_partout; /* item for the highlight */ 123 GimpCanvasItem *preview_items; /* item for previews */ 124 GimpCanvasItem *vectors; /* item proxy of vectors */ 125 GimpCanvasItem *grid; /* item proxy of the grid */ 126 GimpCanvasItem *guides; /* item proxies of guides */ 127 GimpCanvasItem *sample_points; /* item proxies of sample points */ 128 GimpCanvasItem *canvas_boundary; /* item for the cabvas boundary */ 129 GimpCanvasItem *layer_boundary; /* item for the layer boundary */ 130 GimpCanvasItem *tool_items; /* tools items, below the cursor */ 131 GimpCanvasItem *cursor; /* item for the software cursor */ 132 133 guint title_idle_id; /* title update idle ID */ 134 gchar *title; /* current title */ 135 gchar *status; /* current default statusbar content */ 136 137 gint icon_size; /* size of the icon pixbuf */ 138 gint icon_size_small; /* size of the icon's wilber pixbuf */ 139 guint icon_idle_id; /* ID of the idle-function */ 140 GdkPixbuf *icon; /* icon */ 141 142 guint fill_idle_id; /* display_shell_fill() idle ID */ 143 144 GimpHandedness cursor_handedness;/* Handedness for cursor display */ 145 GimpCursorType current_cursor; /* Currently installed main cursor */ 146 GimpToolCursorType tool_cursor; /* Current Tool cursor */ 147 GimpCursorModifier cursor_modifier; /* Cursor modifier (plus, minus, ...) */ 148 149 GimpCursorType override_cursor; /* Overriding cursor */ 150 gboolean using_override_cursor; 151 gboolean draw_cursor; /* should we draw software cursor ? */ 152 153 GtkWidget *close_dialog; /* close dialog */ 154 GtkWidget *scale_dialog; /* scale (zoom) dialog */ 155 GtkWidget *rotate_dialog; /* rotate dialog */ 156 GtkWidget *nav_popup; /* navigation popup */ 157 158 GimpColorConfig *color_config; /* color management settings */ 159 gboolean color_config_set; /* settings changed from defaults */ 160 161 GimpColorTransform *profile_transform; 162 GeglBuffer *profile_buffer; /* buffer for profile transform */ 163 guchar *profile_data; /* profile_buffer's pixels */ 164 gint profile_stride; /* profile_buffer's stride */ 165 166 GimpColorDisplayStack *filter_stack; /* color display conversion stuff */ 167 guint filter_idle_id; 168 169 GimpColorTransform *filter_transform; 170 const Babl *filter_format; /* filter_buffer's format */ 171 GeglBuffer *filter_buffer; /* buffer for display filters */ 172 guchar *filter_data; /* filter_buffer's pixels */ 173 gint filter_stride; /* filter_buffer's stride */ 174 175 GimpDisplayXfer *xfer; /* manages image buffer transfers */ 176 cairo_surface_t *mask_surface; /* buffer for rendering the mask */ 177 cairo_pattern_t *checkerboard; /* checkerboard pattern */ 178 179 gint paused_count; 180 181 GimpTreeHandler *vectors_freeze_handler; 182 GimpTreeHandler *vectors_thaw_handler; 183 GimpTreeHandler *vectors_visible_handler; 184 185 gboolean zoom_on_resize; 186 187 gboolean size_allocate_from_configure_event; 188 gboolean size_allocate_center_image; 189 190 /* the state of gimp_display_shell_tool_events() */ 191 gboolean pointer_grabbed; 192 guint32 pointer_grab_time; 193 194 gboolean keyboard_grabbed; 195 guint32 keyboard_grab_time; 196 197 gboolean inferior_ignore_mode; 198 199 /* Two states are possible when the shell is grabbed: it can be 200 * grabbed with space (or space+button1 which is the same state), 201 * then if space is released but button1 was still pressed, we wait 202 * for button1 to be released as well. 203 */ 204 gboolean space_release_pending; 205 gboolean button1_release_pending; 206 const gchar *space_shaded_tool; 207 208 gboolean scrolling; 209 gint scroll_start_x; 210 gint scroll_start_y; 211 gint scroll_last_x; 212 gint scroll_last_y; 213 gboolean rotating; 214 gdouble rotate_drag_angle; 215 gboolean scaling; 216 gpointer scroll_info; 217 gboolean layer_picking; 218 GimpLayer *picked_layer; 219 220 GeglBuffer *mask; 221 gint mask_offset_x; 222 gint mask_offset_y; 223 GimpRGB mask_color; 224 gboolean mask_inverted; 225 226 GimpMotionBuffer *motion_buffer; 227 228 GQueue *zoom_focus_pointer_queue; 229 230 gboolean blink; 231 guint blink_timeout_id; 232 }; 233 234 struct _GimpDisplayShellClass 235 { 236 GtkEventBoxClass parent_class; 237 238 void (* scaled) (GimpDisplayShell *shell); 239 void (* scrolled) (GimpDisplayShell *shell); 240 void (* rotated) (GimpDisplayShell *shell); 241 void (* reconnect) (GimpDisplayShell *shell); 242 }; 243 244 245 GType gimp_display_shell_get_type (void) G_GNUC_CONST; 246 247 GtkWidget * gimp_display_shell_new (GimpDisplay *display, 248 GimpUnit unit, 249 gdouble scale, 250 GimpUIManager *popup_manager, 251 GdkScreen *screen, 252 gint monitor); 253 254 void gimp_display_shell_add_overlay (GimpDisplayShell *shell, 255 GtkWidget *child, 256 gdouble image_x, 257 gdouble image_y, 258 GimpHandleAnchor anchor, 259 gint spacing_x, 260 gint spacing_y); 261 void gimp_display_shell_move_overlay (GimpDisplayShell *shell, 262 GtkWidget *child, 263 gdouble image_x, 264 gdouble image_y, 265 GimpHandleAnchor anchor, 266 gint spacing_x, 267 gint spacing_y); 268 269 GimpImageWindow * gimp_display_shell_get_window (GimpDisplayShell *shell); 270 GimpStatusbar * gimp_display_shell_get_statusbar (GimpDisplayShell *shell); 271 272 GimpColorConfig * gimp_display_shell_get_color_config 273 (GimpDisplayShell *shell); 274 275 void gimp_display_shell_present (GimpDisplayShell *shell); 276 277 void gimp_display_shell_reconnect (GimpDisplayShell *shell); 278 279 void gimp_display_shell_empty (GimpDisplayShell *shell); 280 void gimp_display_shell_fill (GimpDisplayShell *shell, 281 GimpImage *image, 282 GimpUnit unit, 283 gdouble scale); 284 285 void gimp_display_shell_scaled (GimpDisplayShell *shell); 286 void gimp_display_shell_scrolled (GimpDisplayShell *shell); 287 void gimp_display_shell_rotated (GimpDisplayShell *shell); 288 289 void gimp_display_shell_set_unit (GimpDisplayShell *shell, 290 GimpUnit unit); 291 GimpUnit gimp_display_shell_get_unit (GimpDisplayShell *shell); 292 293 gboolean gimp_display_shell_snap_coords (GimpDisplayShell *shell, 294 GimpCoords *coords, 295 gint snap_offset_x, 296 gint snap_offset_y, 297 gint snap_width, 298 gint snap_height); 299 300 gboolean gimp_display_shell_mask_bounds (GimpDisplayShell *shell, 301 gint *x, 302 gint *y, 303 gint *width, 304 gint *height); 305 306 void gimp_display_shell_set_show_image 307 (GimpDisplayShell *shell, 308 gboolean show_image); 309 310 void gimp_display_shell_set_show_all (GimpDisplayShell *shell, 311 gboolean show_all); 312 313 GimpPickable * gimp_display_shell_get_pickable (GimpDisplayShell *shell); 314 GimpPickable * gimp_display_shell_get_canvas_pickable 315 (GimpDisplayShell *shell); 316 GeglRectangle gimp_display_shell_get_bounding_box 317 (GimpDisplayShell *shell); 318 gboolean gimp_display_shell_get_infinite_canvas 319 (GimpDisplayShell *shell); 320 321 void gimp_display_shell_update_priority_rect 322 (GimpDisplayShell *shell); 323 324 void gimp_display_shell_flush (GimpDisplayShell *shell, 325 gboolean now); 326 327 void gimp_display_shell_pause (GimpDisplayShell *shell); 328 void gimp_display_shell_resume (GimpDisplayShell *shell); 329 330 void gimp_display_shell_set_highlight (GimpDisplayShell *shell, 331 const GdkRectangle *highlight, 332 double opacity); 333 void gimp_display_shell_set_mask (GimpDisplayShell *shell, 334 GeglBuffer *mask, 335 gint offset_x, 336 gint offset_y, 337 const GimpRGB *color, 338 gboolean inverted); 339 340 341 #endif /* __GIMP_DISPLAY_SHELL_H__ */ 342