2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 22:05:25 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 22:05:25 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 22:05:25 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-29 15:22:01 +00:00
|
|
|
|
1999-09-06 00:07:03 +00:00
|
|
|
#include "config.h"
|
2005-01-02 20:42:31 +00:00
|
|
|
|
2008-01-23 09:51:43 +00:00
|
|
|
#include <gegl.h>
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2007-03-09 13:00:01 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-11-16 15:08:59 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display-types.h"
|
2002-11-18 20:50:31 +00:00
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
2005-09-19 12:44:06 +00:00
|
|
|
#include "core/gimpimage-quick-mask.h"
|
2001-02-21 12:18:09 +00:00
|
|
|
|
2012-04-10 12:09:37 +02:00
|
|
|
#include "widgets/gimpcairo-wilber.h"
|
2004-04-29 12:52:29 +00:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2001-05-25 16:04:54 +00:00
|
|
|
|
2010-09-29 22:12:01 +02:00
|
|
|
#include "gimpcanvasitem.h"
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "gimpdisplay.h"
|
2001-10-31 21:20:09 +00:00
|
|
|
#include "gimpdisplayshell.h"
|
2003-03-11 16:49:36 +00:00
|
|
|
#include "gimpdisplayshell-appearance.h"
|
2001-11-02 09:31:21 +00:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2004-02-07 00:16:52 +00:00
|
|
|
#include "gimpdisplayshell-draw.h"
|
2001-11-02 09:31:21 +00:00
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2001-11-10 23:03:22 +00:00
|
|
|
#include "gimpdisplayshell-selection.h"
|
2003-01-03 18:01:30 +00:00
|
|
|
#include "gimpdisplayshell-title.h"
|
2009-09-26 01:19:27 +02:00
|
|
|
#include "gimpimagewindow.h"
|
2004-08-25 16:02:10 +00:00
|
|
|
#include "gimpnavigationeditor.h"
|
2001-09-25 23:23:09 +00:00
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2001-11-30 16:39:40 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2011-02-23 07:13:45 +01:00
|
|
|
static void gimp_display_shell_vadjustment_changed (GtkAdjustment *adjustment,
|
2009-01-10 00:48:30 +00:00
|
|
|
GimpDisplayShell *shell);
|
2011-02-23 07:13:45 +01:00
|
|
|
static void gimp_display_shell_hadjustment_changed (GtkAdjustment *adjustment,
|
2009-01-10 00:48:30 +00:00
|
|
|
GimpDisplayShell *shell);
|
2011-02-23 07:13:45 +01:00
|
|
|
static gboolean gimp_display_shell_vscrollbar_change_value (GtkRange *range,
|
2009-01-10 00:48:30 +00:00
|
|
|
GtkScrollType scroll,
|
|
|
|
gdouble value,
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
|
2011-02-23 07:13:45 +01:00
|
|
|
static gboolean gimp_display_shell_hscrollbar_change_value (GtkRange *range,
|
2009-01-10 00:48:30 +00:00
|
|
|
GtkScrollType scroll,
|
|
|
|
gdouble value,
|
|
|
|
GimpDisplayShell *shell);
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2009-01-10 00:48:30 +00:00
|
|
|
static void gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell,
|
2010-08-28 00:09:31 +02:00
|
|
|
GdkEventExpose *eevent,
|
|
|
|
cairo_t *cr);
|
2009-01-10 00:48:30 +00:00
|
|
|
static void gimp_display_shell_canvas_expose_drop_zone (GimpDisplayShell *shell,
|
2010-08-28 00:09:31 +02:00
|
|
|
GdkEventExpose *eevent,
|
|
|
|
cairo_t *cr);
|
2002-03-19 13:14:25 +00:00
|
|
|
|
|
|
|
|
2001-11-30 16:39:40 +00:00
|
|
|
/* public functions */
|
2001-02-24 19:29:47 +00:00
|
|
|
|
2001-11-02 09:31:21 +00:00
|
|
|
void
|
|
|
|
gimp_display_shell_canvas_realize (GtkWidget *canvas,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
2008-03-18 21:22:21 +00:00
|
|
|
GimpCanvasPaddingMode padding_mode;
|
|
|
|
GimpRGB padding_color;
|
2009-10-17 19:51:33 +02:00
|
|
|
GtkAllocation allocation;
|
2001-11-02 09:31:21 +00:00
|
|
|
|
2010-03-02 00:11:47 +01:00
|
|
|
gtk_widget_grab_focus (canvas);
|
2001-11-09 16:54:56 +00:00
|
|
|
|
2003-07-17 22:30:13 +00:00
|
|
|
gimp_display_shell_get_padding (shell, &padding_mode, &padding_color);
|
|
|
|
gimp_display_shell_set_padding (shell, padding_mode, &padding_color);
|
2001-11-16 15:08:59 +00:00
|
|
|
|
2009-10-17 19:51:33 +02:00
|
|
|
gtk_widget_get_allocation (canvas, &allocation);
|
|
|
|
|
2004-07-14 16:37:13 +00:00
|
|
|
gimp_display_shell_title_update (shell);
|
2001-11-09 16:54:56 +00:00
|
|
|
|
2009-10-17 19:51:33 +02:00
|
|
|
shell->disp_width = allocation.width;
|
|
|
|
shell->disp_height = allocation.height;
|
2001-11-02 09:31:21 +00:00
|
|
|
|
|
|
|
/* set up the scrollbar observers */
|
2010-06-18 23:00:11 +02:00
|
|
|
g_signal_connect (shell->hsbdata, "value-changed",
|
2011-02-23 07:13:45 +01:00
|
|
|
G_CALLBACK (gimp_display_shell_hadjustment_changed),
|
2001-11-02 09:31:21 +00:00
|
|
|
shell);
|
2010-06-18 23:00:11 +02:00
|
|
|
g_signal_connect (shell->vsbdata, "value-changed",
|
2011-02-23 07:13:45 +01:00
|
|
|
G_CALLBACK (gimp_display_shell_vadjustment_changed),
|
2001-11-02 09:31:21 +00:00
|
|
|
shell);
|
|
|
|
|
2008-07-12 14:48:09 +00:00
|
|
|
g_signal_connect (shell->hsb, "change-value",
|
2011-02-23 07:13:45 +01:00
|
|
|
G_CALLBACK (gimp_display_shell_hscrollbar_change_value),
|
2008-07-12 14:48:09 +00:00
|
|
|
shell);
|
|
|
|
|
|
|
|
g_signal_connect (shell->vsb, "change-value",
|
2011-02-23 07:13:45 +01:00
|
|
|
G_CALLBACK (gimp_display_shell_vscrollbar_change_value),
|
2008-07-12 14:48:09 +00:00
|
|
|
shell);
|
|
|
|
|
2002-01-25 18:34:33 +00:00
|
|
|
/* allow shrinking */
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
|
2001-11-02 09:31:21 +00:00
|
|
|
}
|
|
|
|
|
2004-11-09 11:38:29 +00:00
|
|
|
void
|
|
|
|
gimp_display_shell_canvas_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-08 19:14:51 +00:00
|
|
|
{
|
2003-10-06 11:25:59 +00:00
|
|
|
/* are we in destruction? */
|
2009-10-05 19:58:03 +02:00
|
|
|
if (! shell->display || ! gimp_display_get_shell (shell->display))
|
2004-11-09 11:38:29 +00:00
|
|
|
return;
|
2003-10-06 11:25:59 +00:00
|
|
|
|
2004-11-09 11:38:29 +00:00
|
|
|
if ((shell->disp_width != allocation->width) ||
|
|
|
|
(shell->disp_height != allocation->height))
|
2001-11-30 16:39:40 +00:00
|
|
|
{
|
2004-11-09 11:38:29 +00:00
|
|
|
if (shell->zoom_on_resize &&
|
|
|
|
shell->disp_width > 64 &&
|
|
|
|
shell->disp_height > 64 &&
|
|
|
|
allocation->width > 64 &&
|
|
|
|
allocation->height > 64)
|
2004-06-22 16:31:27 +00:00
|
|
|
{
|
2005-09-25 17:03:03 +00:00
|
|
|
gdouble scale = gimp_zoom_model_get_factor (shell->zoom);
|
2004-06-22 16:31:27 +00:00
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
|
2010-01-19 23:15:37 +01:00
|
|
|
/* FIXME: The code is a bit of a mess */
|
2008-08-17 07:29:48 +00:00
|
|
|
|
2004-06-22 16:31:27 +00:00
|
|
|
/* multiply the zoom_factor with the ratio of the new and
|
|
|
|
* old canvas diagonals
|
|
|
|
*/
|
2004-11-09 11:38:29 +00:00
|
|
|
scale *= (sqrt (SQR (allocation->width) +
|
|
|
|
SQR (allocation->height)) /
|
2004-06-22 16:31:27 +00:00
|
|
|
sqrt (SQR (shell->disp_width) +
|
|
|
|
SQR (shell->disp_height)));
|
|
|
|
|
|
|
|
offset_x = UNSCALEX (shell, shell->offset_x);
|
|
|
|
offset_y = UNSCALEX (shell, shell->offset_y);
|
|
|
|
|
2005-09-25 17:03:03 +00:00
|
|
|
gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, scale);
|
|
|
|
|
2004-06-22 16:31:27 +00:00
|
|
|
shell->offset_x = SCALEX (shell, offset_x);
|
|
|
|
shell->offset_y = SCALEY (shell, offset_y);
|
|
|
|
}
|
|
|
|
|
2004-11-09 11:38:29 +00:00
|
|
|
shell->disp_width = allocation->width;
|
|
|
|
shell->disp_height = allocation->height;
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2008-08-17 07:21:41 +00:00
|
|
|
/* When we size-allocate due to resize of the top level window,
|
2008-08-17 07:29:48 +00:00
|
|
|
* we want some additional logic. Don't apply it on
|
|
|
|
* zoom_on_resize though.
|
2008-08-17 07:21:41 +00:00
|
|
|
*/
|
2008-08-17 10:48:49 +00:00
|
|
|
if (shell->size_allocate_from_configure_event &&
|
|
|
|
! shell->zoom_on_resize)
|
2008-08-17 07:21:41 +00:00
|
|
|
{
|
2008-08-17 10:48:49 +00:00
|
|
|
gboolean center_horizontally;
|
|
|
|
gboolean center_vertically;
|
|
|
|
gint target_offset_x;
|
|
|
|
gint target_offset_y;
|
|
|
|
gint sw;
|
|
|
|
gint sh;
|
|
|
|
|
|
|
|
gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
|
|
|
|
|
|
|
|
center_horizontally = sw <= shell->disp_width;
|
|
|
|
center_vertically = sh <= shell->disp_height;
|
|
|
|
|
|
|
|
gimp_display_shell_scroll_center_image (shell,
|
|
|
|
center_horizontally,
|
|
|
|
center_vertically);
|
|
|
|
|
|
|
|
/* This is basically the best we can do before we get an
|
|
|
|
* API for storing the image offset at the start of an
|
|
|
|
* image window resize using the mouse
|
|
|
|
*/
|
|
|
|
target_offset_x = shell->offset_x;
|
|
|
|
target_offset_y = shell->offset_y;
|
2008-09-04 08:37:32 +00:00
|
|
|
|
2008-08-17 10:48:49 +00:00
|
|
|
if (! center_horizontally)
|
|
|
|
{
|
|
|
|
target_offset_x = MAX (shell->offset_x, 0);
|
|
|
|
}
|
2008-09-04 08:37:32 +00:00
|
|
|
|
2008-08-17 10:48:49 +00:00
|
|
|
if (! center_vertically)
|
|
|
|
{
|
|
|
|
target_offset_y = MAX (shell->offset_y, 0);
|
2008-08-17 07:29:48 +00:00
|
|
|
}
|
2008-09-04 08:37:32 +00:00
|
|
|
|
2008-08-17 10:48:49 +00:00
|
|
|
gimp_display_shell_scroll_set_offset (shell,
|
|
|
|
target_offset_x,
|
|
|
|
target_offset_y);
|
2008-08-17 07:21:41 +00:00
|
|
|
}
|
|
|
|
|
2008-08-14 14:41:29 +00:00
|
|
|
gimp_display_shell_scroll_clamp_and_update (shell);
|
2008-10-29 22:28:48 +00:00
|
|
|
gimp_display_shell_scaled (shell);
|
2008-08-14 14:41:29 +00:00
|
|
|
|
2008-08-17 10:48:49 +00:00
|
|
|
/* Reset */
|
|
|
|
shell->size_allocate_from_configure_event = FALSE;
|
2001-11-30 16:39:40 +00:00
|
|
|
}
|
2001-11-08 19:14:51 +00:00
|
|
|
}
|
|
|
|
|
2010-05-10 20:57:45 +02:00
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_is_double_buffered (GimpDisplayShell *shell)
|
|
|
|
{
|
2010-09-23 00:11:18 +02:00
|
|
|
return TRUE; /* FIXME: repair this after cairo tool drawing is done */
|
|
|
|
|
2010-05-10 20:57:45 +02:00
|
|
|
/* always double-buffer if there are overlay children or a
|
2010-09-17 23:12:42 +02:00
|
|
|
* transform preview, or they will flicker badly. Also double
|
|
|
|
* buffer when we are editing paths.
|
2010-05-10 20:57:45 +02:00
|
|
|
*/
|
2011-02-23 05:21:06 +01:00
|
|
|
#if 0
|
2010-09-17 23:12:42 +02:00
|
|
|
if (GIMP_OVERLAY_BOX (shell->canvas)->children ||
|
|
|
|
gimp_display_shell_get_show_transform (shell) ||
|
|
|
|
GIMP_IS_VECTOR_TOOL (tool_manager_get_active (shell->display->gimp)))
|
2010-05-10 20:57:45 +02:00
|
|
|
return TRUE;
|
2011-02-23 05:21:06 +01:00
|
|
|
#endif
|
2010-05-10 20:57:45 +02:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-30 16:39:40 +00:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *eevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-08 19:14:51 +00:00
|
|
|
{
|
2003-10-06 11:25:59 +00:00
|
|
|
/* are we in destruction? */
|
2009-10-05 19:58:03 +02:00
|
|
|
if (! shell->display || ! gimp_display_get_shell (shell->display))
|
|
|
|
return TRUE;
|
2008-03-18 21:22:21 +00:00
|
|
|
|
2009-10-18 22:19:29 +02:00
|
|
|
/* ignore events on overlays */
|
2010-05-01 18:02:42 +02:00
|
|
|
if (eevent->window == gtk_widget_get_window (widget))
|
2003-11-11 17:07:41 +00:00
|
|
|
{
|
2010-08-28 00:09:31 +02:00
|
|
|
cairo_t *cr;
|
|
|
|
|
2010-05-01 18:02:42 +02:00
|
|
|
if (gimp_display_get_image (shell->display))
|
|
|
|
{
|
2010-05-10 20:57:45 +02:00
|
|
|
if (gimp_display_shell_is_double_buffered (shell))
|
2010-05-02 12:12:48 +02:00
|
|
|
gdk_window_begin_paint_region (eevent->window, eevent->region);
|
2010-08-28 00:09:31 +02:00
|
|
|
}
|
2010-05-02 12:12:48 +02:00
|
|
|
|
2010-08-28 11:44:11 +02:00
|
|
|
/* create the cairo_t after enabling double buffering, or we
|
|
|
|
* will get the wrong window destination surface
|
|
|
|
*/
|
2010-08-28 00:09:31 +02:00
|
|
|
cr = gdk_cairo_create (gtk_widget_get_window (shell->canvas));
|
|
|
|
gdk_cairo_region (cr, eevent->region);
|
|
|
|
cairo_clip (cr);
|
|
|
|
|
|
|
|
if (gimp_display_get_image (shell->display))
|
|
|
|
{
|
|
|
|
gimp_display_shell_canvas_expose_image (shell, eevent, cr);
|
2010-05-01 18:02:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-28 00:09:31 +02:00
|
|
|
gimp_display_shell_canvas_expose_drop_zone (shell, eevent, cr);
|
2010-05-01 18:02:42 +02:00
|
|
|
}
|
2010-08-28 00:09:31 +02:00
|
|
|
|
|
|
|
cairo_destroy (cr);
|
2003-11-11 17:07:41 +00:00
|
|
|
}
|
2008-03-19 19:33:51 +00:00
|
|
|
|
2010-05-01 18:02:42 +02:00
|
|
|
return FALSE;
|
2001-11-30 16:39:40 +00:00
|
|
|
}
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
gboolean
|
|
|
|
gimp_display_shell_canvas_expose_after (GtkWidget *widget,
|
|
|
|
GdkEventExpose *eevent,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
/* are we in destruction? */
|
|
|
|
if (! shell->display || ! gimp_display_get_shell (shell->display))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ignore events on overlays */
|
|
|
|
if (eevent->window == gtk_widget_get_window (widget))
|
|
|
|
{
|
|
|
|
if (gimp_display_get_image (shell->display))
|
|
|
|
{
|
2010-05-10 20:57:45 +02:00
|
|
|
if (gimp_display_shell_is_double_buffered (shell))
|
2010-05-02 12:12:48 +02:00
|
|
|
gdk_window_end_paint (eevent->window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-08-19 11:21:48 +00:00
|
|
|
gboolean
|
2001-11-02 09:31:21 +00:00
|
|
|
gimp_display_shell_origin_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1998-06-09 09:20:46 +00:00
|
|
|
{
|
2008-03-18 21:22:21 +00:00
|
|
|
if (! shell->display->gimp->busy)
|
1998-06-09 09:20:46 +00:00
|
|
|
{
|
2011-09-19 00:45:36 +02:00
|
|
|
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
|
2004-11-09 11:38:29 +00:00
|
|
|
{
|
|
|
|
gboolean unused;
|
|
|
|
|
|
|
|
g_signal_emit_by_name (shell, "popup-menu", &unused);
|
|
|
|
}
|
1998-06-09 09:20:46 +00:00
|
|
|
}
|
|
|
|
|
2001-07-29 14:09:50 +00:00
|
|
|
/* Return TRUE to stop signal emission so the button doesn't grab the
|
2001-08-07 12:42:23 +00:00
|
|
|
* pointer away from us.
|
|
|
|
*/
|
2001-07-29 14:09:50 +00:00
|
|
|
return TRUE;
|
1998-06-09 09:20:46 +00:00
|
|
|
}
|
2001-11-16 15:08:59 +00:00
|
|
|
|
2001-11-30 14:41:56 +00:00
|
|
|
gboolean
|
2005-09-19 12:44:06 +00:00
|
|
|
gimp_display_shell_quick_mask_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 14:41:56 +00:00
|
|
|
{
|
2009-10-06 19:20:44 +02:00
|
|
|
if (! gimp_display_get_image (shell->display))
|
2008-03-18 21:22:21 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2011-10-02 16:23:59 +02:00
|
|
|
if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
|
2001-11-30 14:41:56 +00:00
|
|
|
{
|
2009-09-29 20:32:26 +02:00
|
|
|
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
2009-09-23 16:58:03 +02:00
|
|
|
|
2009-09-29 20:32:26 +02:00
|
|
|
if (window)
|
2009-09-29 21:44:43 +02:00
|
|
|
{
|
|
|
|
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
|
|
|
|
|
|
|
gimp_ui_manager_ui_popup (manager,
|
|
|
|
"/quick-mask-popup",
|
|
|
|
GTK_WIDGET (shell),
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
}
|
2001-11-30 14:41:56 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-09-19 12:44:06 +00:00
|
|
|
gimp_display_shell_quick_mask_toggled (GtkWidget *widget,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 14:41:56 +00:00
|
|
|
{
|
2009-10-06 19:20:44 +02:00
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
|
|
|
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
|
2009-07-15 14:29:43 +02:00
|
|
|
|
2009-10-06 19:20:44 +02:00
|
|
|
if (active != gimp_image_get_quick_mask_state (image))
|
2004-02-14 15:37:23 +00:00
|
|
|
{
|
2009-10-06 19:20:44 +02:00
|
|
|
gimp_image_set_quick_mask_state (image, active);
|
2001-11-30 14:41:56 +00:00
|
|
|
|
2009-10-06 19:20:44 +02:00
|
|
|
gimp_image_flush (image);
|
2004-02-14 15:37:23 +00:00
|
|
|
}
|
2001-11-30 14:41:56 +00:00
|
|
|
}
|
2001-11-30 16:39:40 +00:00
|
|
|
|
2002-05-05 19:17:41 +00:00
|
|
|
gboolean
|
2011-02-23 07:13:45 +01:00
|
|
|
gimp_display_shell_navigation_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell)
|
2002-05-05 19:17:41 +00:00
|
|
|
{
|
2009-10-06 19:20:44 +02:00
|
|
|
if (! gimp_display_get_image (shell->display))
|
2008-03-18 21:22:21 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2011-09-19 00:45:36 +02:00
|
|
|
if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 1)
|
2002-05-05 19:17:41 +00:00
|
|
|
{
|
2004-08-25 16:02:10 +00:00
|
|
|
gimp_navigation_editor_popup (shell, widget, bevent->x, bevent->y);
|
2002-05-05 19:17:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-11-30 16:39:40 +00:00
|
|
|
|
2011-02-22 16:27:18 +01:00
|
|
|
/* private functions */
|
|
|
|
|
2001-11-30 16:39:40 +00:00
|
|
|
static void
|
2011-02-23 07:13:45 +01:00
|
|
|
gimp_display_shell_vadjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 16:39:40 +00:00
|
|
|
{
|
2011-02-23 07:13:45 +01:00
|
|
|
/* If we are panning with mouse, scrollbars are to be ignored or
|
|
|
|
* they will cause jitter in motion
|
2010-01-02 15:23:09 +02:00
|
|
|
*/
|
|
|
|
if (! shell->scrolling)
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
0,
|
|
|
|
gtk_adjustment_get_value (adjustment) -
|
|
|
|
shell->offset_y);
|
2001-11-30 16:39:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-23 07:13:45 +01:00
|
|
|
gimp_display_shell_hadjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 16:39:40 +00:00
|
|
|
{
|
2011-02-23 07:13:45 +01:00
|
|
|
/* If we are panning with mouse, scrollbars are to be ignored or
|
|
|
|
* they will cause jitter in motion
|
2010-01-02 15:23:09 +02:00
|
|
|
*/
|
|
|
|
if (! shell->scrolling)
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
gtk_adjustment_get_value (adjustment) -
|
|
|
|
shell->offset_x,
|
|
|
|
0);
|
2001-11-30 16:39:40 +00:00
|
|
|
}
|
|
|
|
|
2008-08-05 11:05:56 +00:00
|
|
|
static gboolean
|
2011-02-23 07:13:45 +01:00
|
|
|
gimp_display_shell_hscrollbar_change_value (GtkRange *range,
|
2008-08-05 11:05:56 +00:00
|
|
|
GtkScrollType scroll,
|
|
|
|
gdouble value,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
if (! shell->display)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if ((scroll == GTK_SCROLL_JUMP) ||
|
|
|
|
(scroll == GTK_SCROLL_PAGE_BACKWARD) ||
|
|
|
|
(scroll == GTK_SCROLL_PAGE_FORWARD))
|
|
|
|
return FALSE;
|
|
|
|
|
2009-10-09 09:54:27 +02:00
|
|
|
g_object_freeze_notify (G_OBJECT (shell->hsbdata));
|
|
|
|
|
2008-08-10 09:08:11 +00:00
|
|
|
gimp_display_shell_scroll_setup_hscrollbar (shell, value);
|
2008-08-05 11:05:56 +00:00
|
|
|
|
2009-10-09 09:54:27 +02:00
|
|
|
g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
|
2008-08-05 11:05:56 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-02-23 07:13:45 +01:00
|
|
|
gimp_display_shell_vscrollbar_change_value (GtkRange *range,
|
2008-08-05 11:05:56 +00:00
|
|
|
GtkScrollType scroll,
|
|
|
|
gdouble value,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
if (! shell->display)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if ((scroll == GTK_SCROLL_JUMP) ||
|
|
|
|
(scroll == GTK_SCROLL_PAGE_BACKWARD) ||
|
|
|
|
(scroll == GTK_SCROLL_PAGE_FORWARD))
|
|
|
|
return FALSE;
|
|
|
|
|
2009-10-09 09:54:27 +02:00
|
|
|
g_object_freeze_notify (G_OBJECT (shell->vsbdata));
|
|
|
|
|
2008-08-10 09:08:11 +00:00
|
|
|
gimp_display_shell_scroll_setup_vscrollbar (shell, value);
|
2008-08-05 11:05:56 +00:00
|
|
|
|
2009-10-09 09:54:27 +02:00
|
|
|
g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */
|
2008-08-05 11:05:56 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-19 19:33:51 +00:00
|
|
|
static void
|
2008-03-19 19:19:37 +00:00
|
|
|
gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell,
|
2010-08-28 00:09:31 +02:00
|
|
|
GdkEventExpose *eevent,
|
|
|
|
cairo_t *cr)
|
2008-03-19 19:19:37 +00:00
|
|
|
{
|
2010-05-02 12:12:48 +02:00
|
|
|
GdkRegion *clear_region;
|
|
|
|
GdkRegion *image_region;
|
|
|
|
GdkRectangle image_rect;
|
2008-03-19 19:19:37 +00:00
|
|
|
GdkRectangle *rects;
|
|
|
|
gint n_rects;
|
|
|
|
gint i;
|
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
/* first, clear the exposed part of the region that is outside the
|
|
|
|
* image, which is the exposed region minus the image rectangle
|
2008-03-19 19:19:37 +00:00
|
|
|
*/
|
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
clear_region = gdk_region_copy (eevent->region);
|
|
|
|
|
|
|
|
image_rect.x = - shell->offset_x;
|
|
|
|
image_rect.y = - shell->offset_y;
|
|
|
|
gimp_display_shell_draw_get_scaled_image_size (shell,
|
|
|
|
&image_rect.width,
|
|
|
|
&image_rect.height);
|
|
|
|
image_region = gdk_region_rectangle (&image_rect);
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
gdk_region_subtract (clear_region, image_region);
|
|
|
|
gdk_region_destroy (image_region);
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
if (! gdk_region_empty (clear_region))
|
|
|
|
{
|
|
|
|
gdk_region_get_rectangles (clear_region, &rects, &n_rects);
|
|
|
|
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
gdk_window_clear_area (gtk_widget_get_window (shell->canvas),
|
|
|
|
rects[i].x,
|
|
|
|
rects[i].y,
|
|
|
|
rects[i].width,
|
|
|
|
rects[i].height);
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
g_free (rects);
|
2008-03-19 19:19:37 +00:00
|
|
|
}
|
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
/* then, draw the exposed part of the region that is inside the
|
|
|
|
* image, which is the exposed region minus the region used for
|
|
|
|
* clearing above
|
|
|
|
*/
|
|
|
|
|
|
|
|
image_region = gdk_region_copy (eevent->region);
|
|
|
|
|
|
|
|
gdk_region_subtract (image_region, clear_region);
|
|
|
|
gdk_region_destroy (clear_region);
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
if (! gdk_region_empty (image_region))
|
2008-03-19 19:19:37 +00:00
|
|
|
{
|
2010-09-28 21:10:03 +02:00
|
|
|
cairo_save (cr);
|
|
|
|
gimp_display_shell_draw_checkerboard (shell, cr,
|
|
|
|
image_rect.x,
|
|
|
|
image_rect.y,
|
|
|
|
image_rect.width,
|
|
|
|
image_rect.height);
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-08-27 19:32:16 +02:00
|
|
|
cairo_save (cr);
|
2010-09-28 22:04:07 +02:00
|
|
|
gdk_region_get_rectangles (image_region, &rects, &n_rects);
|
2010-08-27 19:32:16 +02:00
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
for (i = 0; i < n_rects; i++)
|
2010-09-29 20:58:13 +02:00
|
|
|
gimp_display_shell_draw_image (shell, cr,
|
|
|
|
rects[i].x,
|
|
|
|
rects[i].y,
|
|
|
|
rects[i].width,
|
|
|
|
rects[i].height);
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-09-28 22:04:07 +02:00
|
|
|
g_free (rects);
|
2010-08-27 19:32:16 +02:00
|
|
|
cairo_restore (cr);
|
2010-05-02 12:12:48 +02:00
|
|
|
}
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-05-02 12:12:48 +02:00
|
|
|
gdk_region_destroy (image_region);
|
|
|
|
|
|
|
|
/* finally, draw all the remaining image window stuff on top
|
|
|
|
*/
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2010-10-01 09:15:52 +02:00
|
|
|
/* draw canvas items */
|
2010-10-01 14:54:53 +02:00
|
|
|
gimp_canvas_item_draw (shell->canvas_item, cr);
|
2010-09-22 22:24:22 +02:00
|
|
|
|
2008-03-19 19:19:37 +00:00
|
|
|
/* restart (and recalculate) the selection boundaries */
|
2010-10-09 20:23:05 +02:00
|
|
|
gimp_display_shell_selection_restart (shell);
|
2008-03-19 19:33:51 +00:00
|
|
|
}
|
2008-03-19 19:19:37 +00:00
|
|
|
|
2008-03-19 19:33:51 +00:00
|
|
|
static void
|
|
|
|
gimp_display_shell_canvas_expose_drop_zone (GimpDisplayShell *shell,
|
2010-08-28 00:09:31 +02:00
|
|
|
GdkEventExpose *eevent,
|
|
|
|
cairo_t *cr)
|
2008-03-19 19:33:51 +00:00
|
|
|
{
|
2010-05-02 12:12:48 +02:00
|
|
|
GdkRectangle *rects;
|
|
|
|
gint n_rects;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
gdk_region_get_rectangles (eevent->region, &rects, &n_rects);
|
|
|
|
|
|
|
|
for (i = 0; i < n_rects; i++)
|
|
|
|
{
|
|
|
|
gdk_window_clear_area (gtk_widget_get_window (shell->canvas),
|
|
|
|
rects[i].x,
|
|
|
|
rects[i].y,
|
|
|
|
rects[i].width,
|
|
|
|
rects[i].height);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (rects);
|
2008-03-19 19:33:51 +00:00
|
|
|
|
2010-08-28 15:30:02 +02:00
|
|
|
gimp_cairo_draw_drop_wilber (shell->canvas, cr);
|
2008-03-19 19:19:37 +00:00
|
|
|
}
|