2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08: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
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-29 07:22:01 -08:00
|
|
|
|
1999-09-05 17:07:03 -07:00
|
|
|
#include "config.h"
|
2005-01-02 12:42:31 -08:00
|
|
|
|
2008-01-23 01:51:43 -08:00
|
|
|
#include <gegl.h>
|
2000-12-29 07:22:01 -08:00
|
|
|
#include <gtk/gtk.h>
|
2000-04-27 10:27:28 -07:00
|
|
|
|
2007-03-09 05:00:01 -08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-11-16 07:08:59 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "display-types.h"
|
2002-11-18 12:50:31 -08:00
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
#include "core/gimp.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpimage.h"
|
2005-09-19 05:44:06 -07:00
|
|
|
#include "core/gimpimage-quick-mask.h"
|
2001-02-21 04:18:09 -08:00
|
|
|
|
2012-04-10 03:09:37 -07:00
|
|
|
#include "widgets/gimpcairo-wilber.h"
|
2004-04-29 05:52:29 -07:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2001-05-25 09:04:54 -07:00
|
|
|
|
2010-09-29 13:12:01 -07:00
|
|
|
#include "gimpcanvasitem.h"
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "gimpdisplay.h"
|
2001-10-31 13:20:09 -08:00
|
|
|
#include "gimpdisplayshell.h"
|
2003-03-11 08:49:36 -08:00
|
|
|
#include "gimpdisplayshell-appearance.h"
|
2001-11-02 01:31:21 -08:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2004-02-06 16:16:52 -08:00
|
|
|
#include "gimpdisplayshell-draw.h"
|
2013-04-18 10:06:17 -07:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
2001-11-02 01:31:21 -08:00
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2016-01-05 09:02:59 -08:00
|
|
|
#include "gimpdisplayshell-scrollbars.h"
|
2001-11-10 15:03:22 -08:00
|
|
|
#include "gimpdisplayshell-selection.h"
|
2003-01-03 10:01:30 -08:00
|
|
|
#include "gimpdisplayshell-title.h"
|
2013-02-03 04:26:32 -08:00
|
|
|
#include "gimpdisplayxfer.h"
|
2009-09-25 16:19:27 -07:00
|
|
|
#include "gimpimagewindow.h"
|
2004-08-25 09:02:10 -07:00
|
|
|
#include "gimpnavigationeditor.h"
|
2001-09-25 16:23:09 -07:00
|
|
|
|
2015-03-11 23:37:32 -07:00
|
|
|
#include "git-version.h"
|
|
|
|
|
|
2014-03-07 02:32:24 -08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
2000-12-29 07:22:01 -08:00
|
|
|
|
2001-11-30 08:39:40 -08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
2011-02-22 22:13:45 -08:00
|
|
|
static void gimp_display_shell_vadjustment_changed (GtkAdjustment *adjustment,
|
2009-01-09 16:48:30 -08:00
|
|
|
GimpDisplayShell *shell);
|
2011-02-22 22:13:45 -08:00
|
|
|
static void gimp_display_shell_hadjustment_changed (GtkAdjustment *adjustment,
|
2009-01-09 16:48:30 -08:00
|
|
|
GimpDisplayShell *shell);
|
2011-02-22 22:13:45 -08:00
|
|
|
static gboolean gimp_display_shell_vscrollbar_change_value (GtkRange *range,
|
2009-01-09 16:48:30 -08:00
|
|
|
GtkScrollType scroll,
|
|
|
|
|
gdouble value,
|
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
|
|
2011-02-22 22:13:45 -08:00
|
|
|
static gboolean gimp_display_shell_hscrollbar_change_value (GtkRange *range,
|
2009-01-09 16:48:30 -08:00
|
|
|
GtkScrollType scroll,
|
|
|
|
|
gdouble value,
|
|
|
|
|
GimpDisplayShell *shell);
|
2008-03-19 12:19:37 -07:00
|
|
|
|
2013-04-18 02:56:43 -07:00
|
|
|
static void gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
|
2010-08-27 15:09:31 -07:00
|
|
|
cairo_t *cr);
|
2013-04-18 02:56:43 -07:00
|
|
|
static void gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell,
|
2010-08-27 15:09:31 -07:00
|
|
|
cairo_t *cr);
|
2002-03-19 05:14:25 -08:00
|
|
|
|
|
|
|
|
|
2001-11-30 08:39:40 -08:00
|
|
|
/* public functions */
|
2001-02-24 11:29:47 -08:00
|
|
|
|
2001-11-02 01:31:21 -08:00
|
|
|
void
|
|
|
|
|
gimp_display_shell_canvas_realize (GtkWidget *canvas,
|
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
|
{
|
2008-03-18 14:22:21 -07:00
|
|
|
GimpCanvasPaddingMode padding_mode;
|
|
|
|
|
GimpRGB padding_color;
|
2009-10-17 10:51:33 -07:00
|
|
|
GtkAllocation allocation;
|
2001-11-02 01:31:21 -08:00
|
|
|
|
2010-03-01 15:11:47 -08:00
|
|
|
gtk_widget_grab_focus (canvas);
|
2001-11-09 08:54:56 -08:00
|
|
|
|
2003-07-17 15:30:13 -07:00
|
|
|
gimp_display_shell_get_padding (shell, &padding_mode, &padding_color);
|
|
|
|
|
gimp_display_shell_set_padding (shell, padding_mode, &padding_color);
|
2001-11-16 07:08:59 -08:00
|
|
|
|
2009-10-17 10:51:33 -07:00
|
|
|
gtk_widget_get_allocation (canvas, &allocation);
|
|
|
|
|
|
2004-07-14 09:37:13 -07:00
|
|
|
gimp_display_shell_title_update (shell);
|
2001-11-09 08:54:56 -08:00
|
|
|
|
2009-10-17 10:51:33 -07:00
|
|
|
shell->disp_width = allocation.width;
|
|
|
|
|
shell->disp_height = allocation.height;
|
2001-11-02 01:31:21 -08:00
|
|
|
|
|
|
|
|
/* set up the scrollbar observers */
|
2010-06-18 14:00:11 -07:00
|
|
|
g_signal_connect (shell->hsbdata, "value-changed",
|
2011-02-22 22:13:45 -08:00
|
|
|
G_CALLBACK (gimp_display_shell_hadjustment_changed),
|
2001-11-02 01:31:21 -08:00
|
|
|
shell);
|
2010-06-18 14:00:11 -07:00
|
|
|
g_signal_connect (shell->vsbdata, "value-changed",
|
2011-02-22 22:13:45 -08:00
|
|
|
G_CALLBACK (gimp_display_shell_vadjustment_changed),
|
2001-11-02 01:31:21 -08:00
|
|
|
shell);
|
|
|
|
|
|
2008-07-12 07:48:09 -07:00
|
|
|
g_signal_connect (shell->hsb, "change-value",
|
2011-02-22 22:13:45 -08:00
|
|
|
G_CALLBACK (gimp_display_shell_hscrollbar_change_value),
|
2008-07-12 07:48:09 -07:00
|
|
|
shell);
|
|
|
|
|
|
|
|
|
|
g_signal_connect (shell->vsb, "change-value",
|
2011-02-22 22:13:45 -08:00
|
|
|
G_CALLBACK (gimp_display_shell_vscrollbar_change_value),
|
2008-07-12 07:48:09 -07:00
|
|
|
shell);
|
|
|
|
|
|
2002-01-25 10:34:33 -08:00
|
|
|
/* allow shrinking */
|
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
|
2013-01-30 01:50:54 -08:00
|
|
|
|
|
|
|
|
shell->xfer = gimp_display_xfer_realize (GTK_WIDGET(shell));
|
2018-01-16 12:48:48 -08:00
|
|
|
|
|
|
|
|
/* HACK: remove with GTK+ 3.x: this unconditionally maps the
|
|
|
|
|
* rulers, if configured to be hidden they are never visible to the
|
|
|
|
|
* user because they will be hidden again right away.
|
|
|
|
|
*
|
|
|
|
|
* For some obscure reason, having the rulers mapped once prevents
|
|
|
|
|
* crashes with tablets and on-canvas dialogs. See bug #784480 and
|
|
|
|
|
* all its duplicates.
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_show (shell->hrule);
|
|
|
|
|
gtk_widget_show (shell->vrule);
|
2001-11-02 01:31:21 -08:00
|
|
|
}
|
|
|
|
|
|
2018-04-03 13:36:17 -07:00
|
|
|
void
|
|
|
|
|
gimp_display_shell_canvas_realize_after (GtkWidget *canvas,
|
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
|
{
|
|
|
|
|
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
|
|
|
|
|
|
|
|
|
/* HACK: see above: must go with GTK+ 3.x too. Restore the rulers'
|
|
|
|
|
* intended visibility again.
|
|
|
|
|
*/
|
|
|
|
|
gimp_image_window_suspend_keep_pos (window);
|
|
|
|
|
gimp_display_shell_appearance_update (shell);
|
|
|
|
|
gimp_image_window_resume_keep_pos (window);
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-09 03:38:29 -08:00
|
|
|
void
|
|
|
|
|
gimp_display_shell_canvas_size_allocate (GtkWidget *widget,
|
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-08 11:14:51 -08:00
|
|
|
{
|
2003-10-06 04:25:59 -07:00
|
|
|
/* are we in destruction? */
|
2009-10-05 10:58:03 -07:00
|
|
|
if (! shell->display || ! gimp_display_get_shell (shell->display))
|
2004-11-09 03:38:29 -08:00
|
|
|
return;
|
2003-10-06 04:25:59 -07:00
|
|
|
|
2004-11-09 03:38:29 -08:00
|
|
|
if ((shell->disp_width != allocation->width) ||
|
|
|
|
|
(shell->disp_height != allocation->height))
|
2001-11-30 08:39:40 -08:00
|
|
|
{
|
2004-11-09 03:38:29 -08:00
|
|
|
if (shell->zoom_on_resize &&
|
|
|
|
|
shell->disp_width > 64 &&
|
|
|
|
|
shell->disp_height > 64 &&
|
|
|
|
|
allocation->width > 64 &&
|
|
|
|
|
allocation->height > 64)
|
2004-06-22 09:31:27 -07:00
|
|
|
{
|
2005-09-25 10:03:03 -07:00
|
|
|
gdouble scale = gimp_zoom_model_get_factor (shell->zoom);
|
2004-06-22 09:31:27 -07:00
|
|
|
gint offset_x;
|
|
|
|
|
gint offset_y;
|
|
|
|
|
|
2010-01-19 14:15:37 -08:00
|
|
|
/* FIXME: The code is a bit of a mess */
|
2008-08-17 00:29:48 -07:00
|
|
|
|
2004-06-22 09:31:27 -07:00
|
|
|
/* multiply the zoom_factor with the ratio of the new and
|
|
|
|
|
* old canvas diagonals
|
|
|
|
|
*/
|
2004-11-09 03:38:29 -08:00
|
|
|
scale *= (sqrt (SQR (allocation->width) +
|
|
|
|
|
SQR (allocation->height)) /
|
2004-06-22 09:31:27 -07: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 10:03:03 -07:00
|
|
|
gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, scale);
|
|
|
|
|
|
2004-06-22 09:31:27 -07:00
|
|
|
shell->offset_x = SCALEX (shell, offset_x);
|
|
|
|
|
shell->offset_y = SCALEY (shell, offset_y);
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-09 03:38:29 -08:00
|
|
|
shell->disp_width = allocation->width;
|
|
|
|
|
shell->disp_height = allocation->height;
|
2001-11-08 11:14:51 -08:00
|
|
|
|
2008-08-17 00:21:41 -07:00
|
|
|
/* When we size-allocate due to resize of the top level window,
|
2008-08-17 00:29:48 -07:00
|
|
|
* we want some additional logic. Don't apply it on
|
|
|
|
|
* zoom_on_resize though.
|
2008-08-17 00:21:41 -07:00
|
|
|
*/
|
2008-08-17 03:48:49 -07:00
|
|
|
if (shell->size_allocate_from_configure_event &&
|
|
|
|
|
! shell->zoom_on_resize)
|
2008-08-17 00:21:41 -07:00
|
|
|
{
|
2008-08-17 03:48:49 -07:00
|
|
|
gboolean center_horizontally;
|
|
|
|
|
gboolean center_vertically;
|
|
|
|
|
gint target_offset_x;
|
|
|
|
|
gint target_offset_y;
|
|
|
|
|
gint sw;
|
|
|
|
|
gint sh;
|
|
|
|
|
|
2013-04-18 10:06:17 -07:00
|
|
|
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
2008-08-17 03:48:49 -07:00
|
|
|
|
|
|
|
|
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 01:37:32 -07:00
|
|
|
|
2008-08-17 03:48:49 -07:00
|
|
|
if (! center_horizontally)
|
|
|
|
|
{
|
|
|
|
|
target_offset_x = MAX (shell->offset_x, 0);
|
|
|
|
|
}
|
2008-09-04 01:37:32 -07:00
|
|
|
|
2008-08-17 03:48:49 -07:00
|
|
|
if (! center_vertically)
|
|
|
|
|
{
|
|
|
|
|
target_offset_y = MAX (shell->offset_y, 0);
|
2008-08-17 00:29:48 -07:00
|
|
|
}
|
2008-09-04 01:37:32 -07:00
|
|
|
|
2008-08-17 03:48:49 -07:00
|
|
|
gimp_display_shell_scroll_set_offset (shell,
|
|
|
|
|
target_offset_x,
|
|
|
|
|
target_offset_y);
|
2008-08-17 00:21:41 -07:00
|
|
|
}
|
|
|
|
|
|
2008-08-14 07:41:29 -07:00
|
|
|
gimp_display_shell_scroll_clamp_and_update (shell);
|
2008-10-29 15:28:48 -07:00
|
|
|
gimp_display_shell_scaled (shell);
|
2008-08-14 07:41:29 -07:00
|
|
|
|
2008-08-17 03:48:49 -07:00
|
|
|
shell->size_allocate_from_configure_event = FALSE;
|
2001-11-30 08:39:40 -08:00
|
|
|
}
|
2018-06-27 15:52:08 -07:00
|
|
|
|
|
|
|
|
if (shell->size_allocate_center_image)
|
|
|
|
|
{
|
|
|
|
|
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
|
|
|
|
|
|
|
|
|
|
shell->size_allocate_center_image = FALSE;
|
|
|
|
|
}
|
2001-11-08 11:14:51 -08:00
|
|
|
}
|
|
|
|
|
|
2001-11-30 08:39:40 -08:00
|
|
|
gboolean
|
|
|
|
|
gimp_display_shell_canvas_expose (GtkWidget *widget,
|
|
|
|
|
GdkEventExpose *eevent,
|
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-08 11:14:51 -08:00
|
|
|
{
|
2003-10-06 04:25:59 -07:00
|
|
|
/* are we in destruction? */
|
2009-10-05 10:58:03 -07:00
|
|
|
if (! shell->display || ! gimp_display_get_shell (shell->display))
|
|
|
|
|
return TRUE;
|
2008-03-18 14:22:21 -07:00
|
|
|
|
2018-06-27 15:52:08 -07:00
|
|
|
/* we will scroll around in the next tick anyway, so we just can as
|
|
|
|
|
* well skip the drawing of this frame and wait for the next
|
|
|
|
|
*/
|
|
|
|
|
if (shell->size_allocate_center_image)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2009-10-18 13:19:29 -07:00
|
|
|
/* ignore events on overlays */
|
2010-05-01 09:02:42 -07:00
|
|
|
if (eevent->window == gtk_widget_get_window (widget))
|
2003-11-11 09:07:41 -08:00
|
|
|
{
|
2010-08-27 15:09:31 -07:00
|
|
|
cairo_t *cr;
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
{
|
2013-04-18 02:56:43 -07:00
|
|
|
gimp_display_shell_canvas_draw_image (shell, cr);
|
2010-05-01 09:02:42 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-04-18 02:56:43 -07:00
|
|
|
gimp_display_shell_canvas_draw_drop_zone (shell, cr);
|
2010-05-01 09:02:42 -07:00
|
|
|
}
|
2010-08-27 15:09:31 -07:00
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
2003-11-11 09:07:41 -08:00
|
|
|
}
|
2008-03-19 12:33:51 -07:00
|
|
|
|
2010-05-01 09:02:42 -07:00
|
|
|
return FALSE;
|
2001-11-30 08:39:40 -08:00
|
|
|
}
|
2001-11-08 11:14:51 -08:00
|
|
|
|
2001-08-19 04:21:48 -07:00
|
|
|
gboolean
|
2001-11-02 01:31:21 -08:00
|
|
|
gimp_display_shell_origin_button_press (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *event,
|
|
|
|
|
GimpDisplayShell *shell)
|
1998-06-09 02:20:46 -07:00
|
|
|
{
|
2008-03-18 14:22:21 -07:00
|
|
|
if (! shell->display->gimp->busy)
|
1998-06-09 02:20:46 -07:00
|
|
|
{
|
2011-09-18 15:45:36 -07:00
|
|
|
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
|
2004-11-09 03:38:29 -08:00
|
|
|
{
|
|
|
|
|
gboolean unused;
|
|
|
|
|
|
|
|
|
|
g_signal_emit_by_name (shell, "popup-menu", &unused);
|
|
|
|
|
}
|
1998-06-09 02:20:46 -07:00
|
|
|
}
|
|
|
|
|
|
2001-07-29 07:09:50 -07:00
|
|
|
/* Return TRUE to stop signal emission so the button doesn't grab the
|
2001-08-07 05:42:23 -07:00
|
|
|
* pointer away from us.
|
|
|
|
|
*/
|
2001-07-29 07:09:50 -07:00
|
|
|
return TRUE;
|
1998-06-09 02:20:46 -07:00
|
|
|
}
|
2001-11-16 07:08:59 -08:00
|
|
|
|
2001-11-30 06:41:56 -08:00
|
|
|
gboolean
|
2005-09-19 05:44:06 -07:00
|
|
|
gimp_display_shell_quick_mask_button_press (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 06:41:56 -08:00
|
|
|
{
|
2009-10-06 10:20:44 -07:00
|
|
|
if (! gimp_display_get_image (shell->display))
|
2008-03-18 14:22:21 -07:00
|
|
|
return TRUE;
|
|
|
|
|
|
2011-10-02 07:23:59 -07:00
|
|
|
if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
|
2001-11-30 06:41:56 -08:00
|
|
|
{
|
2009-09-29 11:32:26 -07:00
|
|
|
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
2009-09-23 07:58:03 -07:00
|
|
|
|
2009-09-29 11:32:26 -07:00
|
|
|
if (window)
|
2009-09-29 12:44:43 -07: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 06:41:56 -08:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2005-09-19 05:44:06 -07:00
|
|
|
gimp_display_shell_quick_mask_toggled (GtkWidget *widget,
|
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 06:41:56 -08:00
|
|
|
{
|
2009-10-06 10:20:44 -07:00
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
|
|
|
|
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
|
2009-07-15 05:29:43 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
if (active != gimp_image_get_quick_mask_state (image))
|
2004-02-14 07:37:23 -08:00
|
|
|
{
|
2016-09-30 16:06:02 -07:00
|
|
|
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
|
|
|
|
|
|
|
|
|
if (window)
|
|
|
|
|
{
|
|
|
|
|
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
2001-11-30 06:41:56 -08:00
|
|
|
|
2016-09-30 16:06:02 -07:00
|
|
|
gimp_ui_manager_toggle_action (manager,
|
|
|
|
|
"quick-mask", "quick-mask-toggle",
|
|
|
|
|
active);
|
|
|
|
|
}
|
2004-02-14 07:37:23 -08:00
|
|
|
}
|
2001-11-30 06:41:56 -08:00
|
|
|
}
|
2001-11-30 08:39:40 -08:00
|
|
|
|
2002-05-05 12:17:41 -07:00
|
|
|
gboolean
|
2011-02-22 22:13:45 -08:00
|
|
|
gimp_display_shell_navigation_button_press (GtkWidget *widget,
|
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
|
GimpDisplayShell *shell)
|
2002-05-05 12:17:41 -07:00
|
|
|
{
|
2009-10-06 10:20:44 -07:00
|
|
|
if (! gimp_display_get_image (shell->display))
|
2008-03-18 14:22:21 -07:00
|
|
|
return TRUE;
|
|
|
|
|
|
2011-09-18 15:45:36 -07:00
|
|
|
if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 1)
|
2002-05-05 12:17:41 -07:00
|
|
|
{
|
2004-08-25 09:02:10 -07:00
|
|
|
gimp_navigation_editor_popup (shell, widget, bevent->x, bevent->y);
|
2002-05-05 12:17:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-30 08:39:40 -08:00
|
|
|
|
2011-02-22 07:27:18 -08:00
|
|
|
/* private functions */
|
|
|
|
|
|
2001-11-30 08:39:40 -08:00
|
|
|
static void
|
2011-02-22 22:13:45 -08:00
|
|
|
gimp_display_shell_vadjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 08:39:40 -08:00
|
|
|
{
|
2011-02-22 22:13:45 -08:00
|
|
|
/* If we are panning with mouse, scrollbars are to be ignored or
|
|
|
|
|
* they will cause jitter in motion
|
2010-01-02 05:23:09 -08:00
|
|
|
*/
|
|
|
|
|
if (! shell->scrolling)
|
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
|
0,
|
|
|
|
|
gtk_adjustment_get_value (adjustment) -
|
|
|
|
|
shell->offset_y);
|
2001-11-30 08:39:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-02-22 22:13:45 -08:00
|
|
|
gimp_display_shell_hadjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 08:39:40 -08:00
|
|
|
{
|
2011-02-22 22:13:45 -08:00
|
|
|
/* If we are panning with mouse, scrollbars are to be ignored or
|
|
|
|
|
* they will cause jitter in motion
|
2010-01-02 05:23:09 -08:00
|
|
|
*/
|
|
|
|
|
if (! shell->scrolling)
|
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
|
gtk_adjustment_get_value (adjustment) -
|
|
|
|
|
shell->offset_x,
|
|
|
|
|
0);
|
2001-11-30 08:39:40 -08:00
|
|
|
}
|
|
|
|
|
|
2008-08-05 04:05:56 -07:00
|
|
|
static gboolean
|
2011-02-22 22:13:45 -08:00
|
|
|
gimp_display_shell_hscrollbar_change_value (GtkRange *range,
|
2008-08-05 04:05:56 -07: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 00:54:27 -07:00
|
|
|
g_object_freeze_notify (G_OBJECT (shell->hsbdata));
|
|
|
|
|
|
2016-01-05 09:02:59 -08:00
|
|
|
gimp_display_shell_scrollbars_setup_horizontal (shell, value);
|
2008-08-05 04:05:56 -07:00
|
|
|
|
2009-10-09 00:54:27 -07:00
|
|
|
g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
|
2008-08-05 04:05:56 -07:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2011-02-22 22:13:45 -08:00
|
|
|
gimp_display_shell_vscrollbar_change_value (GtkRange *range,
|
2008-08-05 04:05:56 -07: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 00:54:27 -07:00
|
|
|
g_object_freeze_notify (G_OBJECT (shell->vsbdata));
|
|
|
|
|
|
2016-01-05 09:02:59 -08:00
|
|
|
gimp_display_shell_scrollbars_setup_vertical (shell, value);
|
2008-08-05 04:05:56 -07:00
|
|
|
|
2009-10-09 00:54:27 -07:00
|
|
|
g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */
|
2008-08-05 04:05:56 -07:00
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-19 12:33:51 -07:00
|
|
|
static void
|
2013-04-18 02:56:43 -07:00
|
|
|
gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
|
|
|
|
|
cairo_t *cr)
|
2008-03-19 12:19:37 -07:00
|
|
|
{
|
2013-04-19 07:22:19 -07:00
|
|
|
cairo_rectangle_list_t *clip_rectangles;
|
|
|
|
|
cairo_rectangle_int_t image_rect;
|
2017-12-09 01:25:35 -08:00
|
|
|
cairo_matrix_t matrix;
|
2010-05-02 03:12:48 -07:00
|
|
|
|
|
|
|
|
image_rect.x = - shell->offset_x;
|
|
|
|
|
image_rect.y = - shell->offset_y;
|
2013-04-18 10:06:17 -07:00
|
|
|
gimp_display_shell_scale_get_image_size (shell,
|
|
|
|
|
&image_rect.width,
|
|
|
|
|
&image_rect.height);
|
2008-03-19 12:19:37 -07:00
|
|
|
|
|
|
|
|
|
2018-05-23 13:55:32 -07:00
|
|
|
/* the background has already been cleared by GdkWindow
|
2013-04-18 17:08:10 -07:00
|
|
|
*/
|
2013-04-18 02:56:43 -07:00
|
|
|
|
|
|
|
|
|
2018-05-23 13:55:32 -07:00
|
|
|
/* on top, draw the exposed part of the region that is inside the
|
2013-04-18 17:08:10 -07:00
|
|
|
* image
|
2010-05-02 03:12:48 -07:00
|
|
|
*/
|
|
|
|
|
|
2013-04-18 17:08:10 -07:00
|
|
|
cairo_save (cr);
|
2013-04-19 07:22:19 -07:00
|
|
|
clip_rectangles = cairo_copy_clip_rectangle_list (cr);
|
2017-12-09 01:25:35 -08:00
|
|
|
cairo_get_matrix (cr, &matrix);
|
2013-04-19 07:22:19 -07:00
|
|
|
|
|
|
|
|
if (shell->rotate_transform)
|
|
|
|
|
cairo_transform (cr, shell->rotate_transform);
|
2010-05-02 03:12:48 -07:00
|
|
|
|
2013-04-18 17:08:10 -07:00
|
|
|
cairo_rectangle (cr,
|
|
|
|
|
image_rect.x,
|
|
|
|
|
image_rect.y,
|
|
|
|
|
image_rect.width,
|
|
|
|
|
image_rect.height);
|
|
|
|
|
cairo_clip (cr);
|
2008-03-19 12:19:37 -07:00
|
|
|
|
2013-04-18 17:08:10 -07:00
|
|
|
if (gdk_cairo_get_clip_rectangle (cr, NULL))
|
2008-03-19 12:19:37 -07:00
|
|
|
{
|
2013-04-19 07:22:19 -07:00
|
|
|
gint i;
|
2013-04-18 17:08:10 -07:00
|
|
|
|
2010-09-28 12:10:03 -07:00
|
|
|
cairo_save (cr);
|
2013-04-20 01:47:13 -07:00
|
|
|
gimp_display_shell_draw_checkerboard (shell, cr);
|
2010-09-28 12:10:03 -07:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
2017-12-09 01:25:35 -08:00
|
|
|
cairo_set_matrix (cr, &matrix);
|
|
|
|
|
|
2013-04-18 17:08:10 -07:00
|
|
|
for (i = 0; i < clip_rectangles->num_rectangles; i++)
|
2013-04-18 02:56:43 -07:00
|
|
|
{
|
2013-04-18 17:08:10 -07:00
|
|
|
cairo_rectangle_t rect = clip_rectangles->rectangles[i];
|
2013-04-18 02:56:43 -07:00
|
|
|
|
|
|
|
|
gimp_display_shell_draw_image (shell, cr,
|
2013-04-18 17:08:10 -07:00
|
|
|
floor (rect.x),
|
|
|
|
|
floor (rect.y),
|
|
|
|
|
ceil (rect.width),
|
|
|
|
|
ceil (rect.height));
|
2013-04-18 02:56:43 -07:00
|
|
|
}
|
2010-05-02 03:12:48 -07:00
|
|
|
}
|
2008-03-19 12:19:37 -07:00
|
|
|
|
2013-04-19 07:22:19 -07:00
|
|
|
cairo_rectangle_list_destroy (clip_rectangles);
|
2013-04-18 17:08:10 -07:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
2010-05-02 03:12:48 -07:00
|
|
|
|
|
|
|
|
/* finally, draw all the remaining image window stuff on top
|
|
|
|
|
*/
|
2008-03-19 12:19:37 -07:00
|
|
|
|
2010-10-01 00:15:52 -07:00
|
|
|
/* draw canvas items */
|
2013-04-23 15:01:01 -07:00
|
|
|
cairo_save (cr);
|
|
|
|
|
|
2013-04-19 07:22:19 -07:00
|
|
|
if (shell->rotate_transform)
|
|
|
|
|
cairo_transform (cr, shell->rotate_transform);
|
|
|
|
|
|
2010-10-01 05:54:53 -07:00
|
|
|
gimp_canvas_item_draw (shell->canvas_item, cr);
|
2010-09-22 13:24:22 -07:00
|
|
|
|
2013-04-23 15:01:01 -07:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
|
|
gimp_canvas_item_draw (shell->unrotated_item, cr);
|
|
|
|
|
|
2008-03-19 12:19:37 -07:00
|
|
|
/* restart (and recalculate) the selection boundaries */
|
2010-10-09 11:23:05 -07:00
|
|
|
gimp_display_shell_selection_restart (shell);
|
2008-03-19 12:33:51 -07:00
|
|
|
}
|
2008-03-19 12:19:37 -07:00
|
|
|
|
2008-03-19 12:33:51 -07:00
|
|
|
static void
|
2013-04-18 02:56:43 -07:00
|
|
|
gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell,
|
|
|
|
|
cairo_t *cr)
|
2008-03-19 12:33:51 -07:00
|
|
|
{
|
2014-03-07 02:32:24 -08:00
|
|
|
cairo_save (cr);
|
|
|
|
|
|
2013-09-28 09:00:31 -07:00
|
|
|
gimp_cairo_draw_drop_wilber (shell->canvas, cr, shell->blink);
|
2014-03-07 02:32:24 -08:00
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
|
|
#ifdef GIMP_UNSTABLE
|
|
|
|
|
{
|
|
|
|
|
PangoLayout *layout;
|
2015-03-11 23:37:32 -07:00
|
|
|
gchar *msg;
|
2014-03-07 02:32:24 -08:00
|
|
|
GtkAllocation allocation;
|
|
|
|
|
gint width;
|
|
|
|
|
gint height;
|
|
|
|
|
gdouble scale;
|
|
|
|
|
|
2014-05-27 12:58:10 -07:00
|
|
|
layout = gtk_widget_create_pango_layout (shell->canvas, NULL);
|
2015-03-11 23:37:32 -07:00
|
|
|
|
|
|
|
|
msg = g_strdup_printf (_("<big>Unstable Development Version</big>\n\n"
|
|
|
|
|
"<small>commit <tt>%s</tt></small>\n\n"
|
2015-08-31 06:19:37 -07:00
|
|
|
"<small>Please test bugs against "
|
|
|
|
|
"latest git master branch\n"
|
|
|
|
|
"before reporting them.</small>"),
|
2017-03-21 19:54:11 -07:00
|
|
|
GIMP_GIT_VERSION_ABBREV);
|
2015-03-11 23:37:32 -07:00
|
|
|
pango_layout_set_markup (layout, msg, -1);
|
|
|
|
|
g_free (msg);
|
2014-03-07 02:32:24 -08:00
|
|
|
pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
|
|
|
|
|
|
|
|
|
|
pango_layout_get_pixel_size (layout, &width, &height);
|
|
|
|
|
gtk_widget_get_allocation (shell->canvas, &allocation);
|
|
|
|
|
|
|
|
|
|
scale = MIN (((gdouble) allocation.width / 2.0) / (gdouble) width,
|
|
|
|
|
((gdouble) allocation.height / 2.0) / (gdouble) height);
|
|
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
|
|
|
|
(allocation.width - (width * scale)) / 2,
|
|
|
|
|
(allocation.height - (height * scale)) / 2);
|
|
|
|
|
|
|
|
|
|
cairo_scale (cr, scale, scale);
|
|
|
|
|
|
|
|
|
|
pango_cairo_show_layout (cr, layout);
|
|
|
|
|
|
|
|
|
|
g_object_unref (layout);
|
|
|
|
|
}
|
|
|
|
|
#endif /* GIMP_UNSTABLE */
|
2008-03-19 12:19:37 -07:00
|
|
|
}
|