gimpdisplayshell.h 14.8 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
Elliot Lee's avatar
Elliot Lee committed
2 3
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
4
 * This program is free software: you can redistribute it and/or modify
Elliot Lee's avatar
Elliot Lee committed
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
Elliot Lee's avatar
Elliot Lee committed
7 8 9 10 11 12 13 14
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * 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/>.
Elliot Lee's avatar
Elliot Lee committed
16
 */
17

18 19
#ifndef __GIMP_DISPLAY_SHELL_H__
#define __GIMP_DISPLAY_SHELL_H__
Elliot Lee's avatar
Elliot Lee committed
20 21


22
/* Apply to a float the same rounding mode used in the renderer */
23 24
#define  PROJ_ROUND(coord)   ((gint) RINT (coord))
#define  PROJ_ROUND64(coord) ((gint64) RINT (coord))
25

26
/* scale values */
27 28
#define  SCALEX(s,x)      PROJ_ROUND ((x) * (s)->scale_x)
#define  SCALEY(s,y)      PROJ_ROUND ((y) * (s)->scale_y)
29 30

/* unscale values */
31 32
#define  UNSCALEX(s,x)    ((gint) ((x) / (s)->scale_x))
#define  UNSCALEY(s,y)    ((gint) ((y) / (s)->scale_y))
33
/* (and float-returning versions) */
34 35
#define  FUNSCALEX(s,x)   ((x) / (s)->scale_x)
#define  FUNSCALEY(s,y)   ((y) / (s)->scale_y)
36 37


38 39 40 41 42 43 44 45 46 47 48 49
#define GIMP_TYPE_DISPLAY_SHELL            (gimp_display_shell_get_type ())
#define GIMP_DISPLAY_SHELL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShell))
#define GIMP_DISPLAY_SHELL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass))
#define GIMP_IS_DISPLAY_SHELL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DISPLAY_SHELL))
#define GIMP_IS_DISPLAY_SHELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DISPLAY_SHELL))
#define GIMP_DISPLAY_SHELL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DISPLAY_SHELL, GimpDisplayShellClass))


typedef struct _GimpDisplayShellClass  GimpDisplayShellClass;

struct _GimpDisplayShell
{
50
  GtkEventBox        parent_instance;
51

Sven Neumann's avatar
Sven Neumann committed
52
  GimpDisplay       *display;
53

Sven Neumann's avatar
Sven Neumann committed
54
  GimpUIManager     *popup_manager;
55
  GdkMonitor        *initial_monitor;
56

57 58 59
  GimpDisplayOptions *options;
  GimpDisplayOptions *fullscreen_options;
  GimpDisplayOptions *no_image_options;
60

61
  GimpUnit           unit;
62

Sven Neumann's avatar
Sven Neumann committed
63 64
  gint               offset_x;         /*  offset of display image            */
  gint               offset_y;
65

Sven Neumann's avatar
Sven Neumann committed
66 67
  gdouble            scale_x;          /*  horizontal scale factor            */
  gdouble            scale_y;          /*  vertical scale factor              */
68

69 70
  gboolean           flip_horizontally;
  gboolean           flip_vertically;
71 72 73 74
  gdouble            rotate_angle;
  cairo_matrix_t    *rotate_transform;
  cairo_matrix_t    *rotate_untransform;

75 76 77 78 79 80
  gdouble            monitor_xres;
  gdouble            monitor_yres;
  gboolean           dot_for_dot;      /*  ignore monitor resolution          */

  GimpZoomModel     *zoom;

Sven Neumann's avatar
Sven Neumann committed
81 82 83 84
  gdouble            last_scale;       /*  scale used when reverting zoom     */
  guint              last_scale_time;  /*  time when last_scale was set       */
  gint               last_offset_x;    /*  offsets used when reverting zoom   */
  gint               last_offset_y;
85

86 87
  gdouble            other_scale;      /*  scale factor entered in Zoom->Other*/

Sven Neumann's avatar
Sven Neumann committed
88 89
  gint               disp_width;       /*  width of drawing area              */
  gint               disp_height;      /*  height of drawing area             */
90

Sven Neumann's avatar
Sven Neumann committed
91
  gboolean           proximity;        /*  is a device in proximity           */
92

Sven Neumann's avatar
Sven Neumann committed
93
  Selection         *selection;        /*  Selection (marching ants)          */
94

95 96
  GList             *children;

Sven Neumann's avatar
Sven Neumann committed
97
  GtkWidget         *canvas;           /*  GimpCanvas widget                  */
98

Sven Neumann's avatar
Sven Neumann committed
99 100 101 102
  GtkAdjustment     *hsbdata;          /*  adjustments                        */
  GtkAdjustment     *vsbdata;
  GtkWidget         *hsb;              /*  scroll bars                        */
  GtkWidget         *vsb;
103

Sven Neumann's avatar
Sven Neumann committed
104 105
  GtkWidget         *hrule;            /*  rulers                             */
  GtkWidget         *vrule;
106

Sven Neumann's avatar
Sven Neumann committed
107 108 109 110
  GtkWidget         *origin;           /*  NW: origin                         */
  GtkWidget         *quick_mask_button;/*  SW: quick mask button              */
  GtkWidget         *zoom_button;      /*  NE: zoom toggle button             */
  GtkWidget         *nav_ebox;         /*  SE: navigation event box           */
111

112 113
  GtkWidget         *statusbar;        /*  statusbar                          */

114
  GimpCanvasItem    *canvas_item;      /*  items drawn on the canvas          */
115
  GimpCanvasItem    *unrotated_item;   /*  unrotated items for e.g. cursor    */
116
  GimpCanvasItem    *passe_partout;    /*  item for the highlight             */
117
  GimpCanvasItem    *preview_items;    /*  item for previews                  */
118
  GimpCanvasItem    *vectors;          /*  item proxy of vectors              */
119
  GimpCanvasItem    *grid;             /*  item proxy of the grid             */
120
  GimpCanvasItem    *guides;           /*  item proxies of guides             */
121
  GimpCanvasItem    *sample_points;    /*  item proxies of sample points      */
122
  GimpCanvasItem    *layer_boundary;   /*  item for the layer boundary        */
123
  GimpCanvasItem    *tool_items;       /*  tools items, below the cursor      */
124
  GimpCanvasItem    *cursor;           /*  item for the software cursor       */
125

Sven Neumann's avatar
Sven Neumann committed
126
  guint              title_idle_id;    /*  title update idle ID               */
127 128 129
  gchar             *title;            /*  current title                      */
  gchar             *status;           /*  current default statusbar content  */

130 131
  gint               icon_size;        /*  size of the icon pixbuf            */
  gint               icon_size_small;  /*  size of the icon's wilber pixbuf   */
Sven Neumann's avatar
Sven Neumann committed
132
  guint              icon_idle_id;     /*  ID of the idle-function            */
133
  GdkPixbuf         *icon;             /*  icon                               */
134

Sven Neumann's avatar
Sven Neumann committed
135
  guint              fill_idle_id;     /*  display_shell_fill() idle ID       */
136

137
  GimpHandedness     cursor_handedness;/*  Handedness for cursor display      */
Sven Neumann's avatar
Sven Neumann committed
138 139 140
  GimpCursorType     current_cursor;   /*  Currently installed main cursor    */
  GimpToolCursorType tool_cursor;      /*  Current Tool cursor                */
  GimpCursorModifier cursor_modifier;  /*  Cursor modifier (plus, minus, ...) */
141

142
  GimpCursorType     override_cursor;  /*  Overriding cursor                  */
Sven Neumann's avatar
Sven Neumann committed
143 144
  gboolean           using_override_cursor;
  gboolean           draw_cursor;      /* should we draw software cursor ?    */
145

Sven Neumann's avatar
Sven Neumann committed
146 147
  GtkWidget         *close_dialog;     /*  close dialog                       */
  GtkWidget         *scale_dialog;     /*  scale (zoom) dialog                */
148
  GtkWidget         *rotate_dialog;    /*  rotate dialog                      */
Sven Neumann's avatar
Sven Neumann committed
149
  GtkWidget         *nav_popup;        /*  navigation popup                   */
150

151
  GimpColorConfig   *color_config;     /*  color management settings          */
152
  gboolean           color_config_set; /*  settings changed from defaults     */
153

154 155 156 157
  GimpColorTransform *profile_transform;
  GeglBuffer         *profile_buffer;  /*  buffer for profile transform       */
  guchar             *profile_data;    /*  profile_buffer's pixels            */
  gint                profile_stride;  /*  profile_buffer's stride            */
158

159
  GimpColorDisplayStack *filter_stack; /*  color display conversion stuff     */
160
  guint                  filter_idle_id;
161

162 163
  GimpColorTransform *filter_transform;
  const Babl         *filter_format;   /*  filter_buffer's format             */
164
  GimpColorProfile   *filter_profile;  /*  filter_format's profile            */
165 166 167
  GeglBuffer         *filter_buffer;   /*  buffer for display filters         */
  guchar             *filter_data;     /*  filter_buffer's pixels             */
  gint                filter_stride;   /*  filter_buffer's stride             */
168 169 170 171 172

  GimpDisplayXfer   *xfer;             /*  manages image buffer transfers     */
  cairo_surface_t   *mask_surface;     /*  buffer for rendering the mask      */
  cairo_pattern_t   *checkerboard;     /*  checkerboard pattern               */

Sven Neumann's avatar
Sven Neumann committed
173
  gint               paused_count;
174

175 176 177 178
  GimpTreeHandler   *vectors_freeze_handler;
  GimpTreeHandler   *vectors_thaw_handler;
  GimpTreeHandler   *vectors_visible_handler;

Sven Neumann's avatar
Sven Neumann committed
179
  gboolean           zoom_on_resize;
180

181
  gboolean           size_allocate_from_configure_event;
182
  gboolean           size_allocate_center_image;
183

184
  /*  the state of gimp_display_shell_tool_events()  */
185 186 187
  GdkDevice         *grab_pointer;
  GdkDevice         *grab_pointer_source;
  guint32            grab_pointer_time;
188

189 190 191
  GdkDevice         *grab_keyboard;
  GdkDevice         *grab_keyboard_source;
  guint32            grab_keyboard_time;
192

193 194 195 196 197
  /* Two states are possible when the shell is grabbed: it can be
   * grabbed with space (or space+button1 which is the same state),
   * then if space is released but button1 was still pressed, we wait
   * for button1 to be released as well.
   */
Sven Neumann's avatar
Sven Neumann committed
198
  gboolean           space_release_pending;
199
  gboolean           button1_release_pending;
Sven Neumann's avatar
Sven Neumann committed
200
  const gchar       *space_shaded_tool;
201

Sven Neumann's avatar
Sven Neumann committed
202
  gboolean           scrolling;
203 204
  gint               scroll_start_x;
  gint               scroll_start_y;
205 206
  gint               scroll_last_x;
  gint               scroll_last_y;
207 208
  gboolean           rotating;
  gdouble            rotate_drag_angle;
209
  gboolean           scaling;
210
  gpointer           scroll_info;
211 212
  gboolean           layer_picking;
  GimpLayer         *picked_layer;
213

214
  GeglBuffer        *mask;
215 216
  gint               mask_offset_x;
  gint               mask_offset_y;
217
  GimpRGB            mask_color;
218
  gboolean           mask_inverted;
219

220
  GimpMotionBuffer  *motion_buffer;
221

222
  GQueue            *zoom_focus_pointer_queue;
223 224 225

  gboolean           blink;
  guint              blink_timeout_id;
226 227 228 229
};

struct _GimpDisplayShellClass
{
230
  GtkEventBoxClass  parent_class;
231

232 233
  void (* scaled)    (GimpDisplayShell *shell);
  void (* scrolled)  (GimpDisplayShell *shell);
234
  void (* rotated)   (GimpDisplayShell *shell);
235
  void (* reconnect) (GimpDisplayShell *shell);
236 237 238
};


Michael Natterer's avatar
Michael Natterer committed
239
GType             gimp_display_shell_get_type      (void) G_GNUC_CONST;
Sven Neumann's avatar
Sven Neumann committed
240

Michael Natterer's avatar
Michael Natterer committed
241
GtkWidget       * gimp_display_shell_new           (GimpDisplay        *display,
Sven Neumann's avatar
Sven Neumann committed
242 243
                                                    GimpUnit            unit,
                                                    gdouble             scale,
244
                                                    GimpUIManager      *popup_manager,
245
                                                    GdkMonitor         *monitor);
Sven Neumann's avatar
Sven Neumann committed
246

247 248
void              gimp_display_shell_add_overlay   (GimpDisplayShell   *shell,
                                                    GtkWidget          *child,
249
                                                    gdouble             image_x,
250
                                                    gdouble             image_y,
251
                                                    GimpHandleAnchor    anchor,
252 253
                                                    gint                spacing_x,
                                                    gint                spacing_y);
254 255
void              gimp_display_shell_move_overlay  (GimpDisplayShell   *shell,
                                                    GtkWidget          *child,
256
                                                    gdouble             image_x,
257
                                                    gdouble             image_y,
258
                                                    GimpHandleAnchor    anchor,
259 260
                                                    gint                spacing_x,
                                                    gint                spacing_y);
261

262
GimpImageWindow * gimp_display_shell_get_window    (GimpDisplayShell   *shell);
263 264
GimpStatusbar   * gimp_display_shell_get_statusbar (GimpDisplayShell   *shell);

265 266 267
GimpColorConfig * gimp_display_shell_get_color_config
                                                   (GimpDisplayShell   *shell);

268 269
void              gimp_display_shell_present       (GimpDisplayShell   *shell);

Michael Natterer's avatar
Michael Natterer committed
270
void              gimp_display_shell_reconnect     (GimpDisplayShell   *shell);
Sven Neumann's avatar
Sven Neumann committed
271

Michael Natterer's avatar
Michael Natterer committed
272 273
void              gimp_display_shell_empty         (GimpDisplayShell   *shell);
void              gimp_display_shell_fill          (GimpDisplayShell   *shell,
274 275 276 277
                                                    GimpImage          *image,
                                                    GimpUnit            unit,
                                                    gdouble             scale);

Michael Natterer's avatar
Michael Natterer committed
278 279
void              gimp_display_shell_scaled        (GimpDisplayShell   *shell);
void              gimp_display_shell_scrolled      (GimpDisplayShell   *shell);
280
void              gimp_display_shell_rotated       (GimpDisplayShell   *shell);
Sven Neumann's avatar
Sven Neumann committed
281

Michael Natterer's avatar
Michael Natterer committed
282
void              gimp_display_shell_set_unit      (GimpDisplayShell   *shell,
Sven Neumann's avatar
Sven Neumann committed
283
                                                    GimpUnit            unit);
Michael Natterer's avatar
Michael Natterer committed
284
GimpUnit          gimp_display_shell_get_unit      (GimpDisplayShell   *shell);
Sven Neumann's avatar
Sven Neumann committed
285

Michael Natterer's avatar
Michael Natterer committed
286
gboolean          gimp_display_shell_snap_coords   (GimpDisplayShell   *shell,
Sven Neumann's avatar
Sven Neumann committed
287 288 289 290 291 292
                                                    GimpCoords         *coords,
                                                    gint                snap_offset_x,
                                                    gint                snap_offset_y,
                                                    gint                snap_width,
                                                    gint                snap_height);

Michael Natterer's avatar
Michael Natterer committed
293
gboolean          gimp_display_shell_mask_bounds   (GimpDisplayShell   *shell,
294 295 296 297
                                                    gint               *x,
                                                    gint               *y,
                                                    gint               *width,
                                                    gint               *height);
Sven Neumann's avatar
Sven Neumann committed
298

299
void              gimp_display_shell_flush         (GimpDisplayShell   *shell);
Sven Neumann's avatar
Sven Neumann committed
300

Michael Natterer's avatar
Michael Natterer committed
301 302
void              gimp_display_shell_pause         (GimpDisplayShell   *shell);
void              gimp_display_shell_resume        (GimpDisplayShell   *shell);
Sven Neumann's avatar
Sven Neumann committed
303

Michael Natterer's avatar
Michael Natterer committed
304
void              gimp_display_shell_set_highlight (GimpDisplayShell   *shell,
305 306
                                                    const GdkRectangle *highlight,
                                                    double              opacity);
Michael Natterer's avatar
Michael Natterer committed
307
void              gimp_display_shell_set_mask      (GimpDisplayShell   *shell,
308
                                                    GeglBuffer         *mask,
309 310
                                                    gint                offset_x,
                                                    gint                offset_y,
311 312
                                                    const GimpRGB      *color,
                                                    gboolean            inverted);
313

314 315

#endif /* __GIMP_DISPLAY_SHELL_H__ */