2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06: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-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-09-06 08:07:03 +08:00
|
|
|
#include "config.h"
|
2005-01-03 04:42:31 +08:00
|
|
|
|
2008-01-23 17:51:43 +08:00
|
|
|
#include <gegl.h>
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-11-16 23:08:59 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2005-09-19 20:44:06 +08:00
|
|
|
#include "core/gimpimage-quick-mask.h"
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2012-04-10 18:09:37 +08:00
|
|
|
#include "widgets/gimpcairo-wilber.h"
|
2004-04-29 20:52:29 +08:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
|
2010-09-30 04:12:01 +08:00
|
|
|
#include "gimpcanvasitem.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "gimpdisplayshell.h"
|
2003-03-12 00:49:36 +08:00
|
|
|
#include "gimpdisplayshell-appearance.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2004-02-07 08:16:52 +08:00
|
|
|
#include "gimpdisplayshell-draw.h"
|
2019-07-16 05:24:35 +08:00
|
|
|
#include "gimpdisplayshell-render.h"
|
2013-04-19 01:06:17 +08:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-scroll.h"
|
2016-01-06 01:02:59 +08:00
|
|
|
#include "gimpdisplayshell-scrollbars.h"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "gimpdisplayshell-selection.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-title.h"
|
2009-09-26 07:19:27 +08:00
|
|
|
#include "gimpimagewindow.h"
|
2004-08-26 00:02:10 +08:00
|
|
|
#include "gimpnavigationeditor.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2015-03-12 14:37:32 +08:00
|
|
|
#include "git-version.h"
|
|
|
|
|
2014-03-07 18:32:24 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2011-02-23 14:13:45 +08:00
|
|
|
static void gimp_display_shell_vadjustment_changed (GtkAdjustment *adjustment,
|
2009-01-10 08:48:30 +08:00
|
|
|
GimpDisplayShell *shell);
|
2011-02-23 14:13:45 +08:00
|
|
|
static void gimp_display_shell_hadjustment_changed (GtkAdjustment *adjustment,
|
2009-01-10 08:48:30 +08:00
|
|
|
GimpDisplayShell *shell);
|
2011-02-23 14:13:45 +08:00
|
|
|
static gboolean gimp_display_shell_vscrollbar_change_value (GtkRange *range,
|
2009-01-10 08:48:30 +08:00
|
|
|
GtkScrollType scroll,
|
|
|
|
gdouble value,
|
|
|
|
GimpDisplayShell *shell);
|
|
|
|
|
2011-02-23 14:13:45 +08:00
|
|
|
static gboolean gimp_display_shell_hscrollbar_change_value (GtkRange *range,
|
2009-01-10 08:48:30 +08:00
|
|
|
GtkScrollType scroll,
|
|
|
|
gdouble value,
|
|
|
|
GimpDisplayShell *shell);
|
2008-03-20 03:19:37 +08:00
|
|
|
|
2013-04-18 17:56:43 +08:00
|
|
|
static void gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
|
2010-08-28 06:09:31 +08:00
|
|
|
cairo_t *cr);
|
2013-04-18 17:56:43 +08:00
|
|
|
static void gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell,
|
2010-08-28 06:09:31 +08:00
|
|
|
cairo_t *cr);
|
2002-03-19 21:14:25 +08:00
|
|
|
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
/* public functions */
|
2001-02-25 03:29:47 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_canvas_realize (GtkWidget *canvas,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
2019-07-16 05:24:35 +08:00
|
|
|
GimpCanvasPaddingMode padding_mode;
|
|
|
|
GimpRGB padding_color;
|
|
|
|
GtkAllocation allocation;
|
2001-11-02 17:31:21 +08:00
|
|
|
|
2010-03-02 07:11:47 +08:00
|
|
|
gtk_widget_grab_focus (canvas);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2003-07-18 06:30:13 +08:00
|
|
|
gimp_display_shell_get_padding (shell, &padding_mode, &padding_color);
|
|
|
|
gimp_display_shell_set_padding (shell, padding_mode, &padding_color);
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2009-10-18 01:51:33 +08:00
|
|
|
gtk_widget_get_allocation (canvas, &allocation);
|
|
|
|
|
2004-07-15 00:37:13 +08:00
|
|
|
gimp_display_shell_title_update (shell);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2009-10-18 01:51:33 +08:00
|
|
|
shell->disp_width = allocation.width;
|
|
|
|
shell->disp_height = allocation.height;
|
2001-11-02 17:31:21 +08:00
|
|
|
|
|
|
|
/* set up the scrollbar observers */
|
2010-06-19 05:00:11 +08:00
|
|
|
g_signal_connect (shell->hsbdata, "value-changed",
|
2011-02-23 14:13:45 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_hadjustment_changed),
|
2001-11-02 17:31:21 +08:00
|
|
|
shell);
|
2010-06-19 05:00:11 +08:00
|
|
|
g_signal_connect (shell->vsbdata, "value-changed",
|
2011-02-23 14:13:45 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_vadjustment_changed),
|
2001-11-02 17:31:21 +08:00
|
|
|
shell);
|
|
|
|
|
2008-07-12 22:48:09 +08:00
|
|
|
g_signal_connect (shell->hsb, "change-value",
|
2011-02-23 14:13:45 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_hscrollbar_change_value),
|
2008-07-12 22:48:09 +08:00
|
|
|
shell);
|
|
|
|
|
|
|
|
g_signal_connect (shell->vsb, "change-value",
|
2011-02-23 14:13:45 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_vscrollbar_change_value),
|
2008-07-12 22:48:09 +08:00
|
|
|
shell);
|
|
|
|
|
2002-01-26 02:34:33 +08:00
|
|
|
/* allow shrinking */
|
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (shell), 0, 0);
|
2001-11-02 17:31:21 +08:00
|
|
|
}
|
|
|
|
|
2019-07-22 00:13:53 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gint prev_width;
|
|
|
|
gint prev_height;
|
|
|
|
} TickClosure;
|
|
|
|
|
2018-06-28 06:52:08 +08:00
|
|
|
static gboolean
|
2019-07-22 00:13:53 +08:00
|
|
|
gimp_display_shell_canvas_tick (GtkWidget *widget,
|
|
|
|
GdkFrameClock *frame_clock,
|
|
|
|
TickClosure *tick)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2019-07-22 00:13:53 +08:00
|
|
|
GimpDisplayShell *shell = tick->shell;
|
|
|
|
GtkAllocation allocation;
|
2018-06-28 06:52:08 +08:00
|
|
|
|
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
2003-10-06 19:25:59 +08:00
|
|
|
|
2019-07-22 00:13:53 +08:00
|
|
|
if ((tick->prev_width != allocation.width) ||
|
|
|
|
(tick->prev_height != allocation.height))
|
2001-12-01 00:39:40 +08:00
|
|
|
{
|
2004-11-09 19:38:29 +08:00
|
|
|
if (shell->zoom_on_resize &&
|
2019-07-22 00:13:53 +08:00
|
|
|
tick->prev_width > 64 &&
|
|
|
|
tick->prev_height > 64 &&
|
|
|
|
allocation.width > 64 &&
|
|
|
|
allocation.height > 64)
|
2004-06-23 00:31:27 +08:00
|
|
|
{
|
2005-09-26 01:03:03 +08:00
|
|
|
gdouble scale = gimp_zoom_model_get_factor (shell->zoom);
|
2004-06-23 00:31:27 +08:00
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
|
|
|
|
2010-01-20 06:15:37 +08:00
|
|
|
/* FIXME: The code is a bit of a mess */
|
2008-08-17 15:29:48 +08:00
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
/* multiply the zoom_factor with the ratio of the new and
|
|
|
|
* old canvas diagonals
|
|
|
|
*/
|
2018-06-28 06:52:08 +08:00
|
|
|
scale *= (sqrt (SQR (allocation.width) +
|
|
|
|
SQR (allocation.height)) /
|
2019-07-22 00:13:53 +08:00
|
|
|
sqrt (SQR (tick->prev_width) +
|
|
|
|
SQR (tick->prev_height)));
|
2004-06-23 00:31:27 +08:00
|
|
|
|
|
|
|
offset_x = UNSCALEX (shell, shell->offset_x);
|
|
|
|
offset_y = UNSCALEX (shell, shell->offset_y);
|
|
|
|
|
2005-09-26 01:03:03 +08:00
|
|
|
gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, scale);
|
|
|
|
|
2004-06-23 00:31:27 +08:00
|
|
|
shell->offset_x = SCALEX (shell, offset_x);
|
|
|
|
shell->offset_y = SCALEY (shell, offset_y);
|
|
|
|
}
|
|
|
|
|
2008-08-17 15:21:41 +08:00
|
|
|
/* When we size-allocate due to resize of the top level window,
|
2008-08-17 15:29:48 +08:00
|
|
|
* we want some additional logic. Don't apply it on
|
|
|
|
* zoom_on_resize though.
|
2008-08-17 15:21:41 +08:00
|
|
|
*/
|
2008-08-17 18:48:49 +08:00
|
|
|
if (shell->size_allocate_from_configure_event &&
|
|
|
|
! shell->zoom_on_resize)
|
2008-08-17 15:21:41 +08:00
|
|
|
{
|
2008-08-17 18:48:49 +08:00
|
|
|
gboolean center_horizontally;
|
|
|
|
gboolean center_vertically;
|
|
|
|
gint target_offset_x;
|
|
|
|
gint target_offset_y;
|
|
|
|
gint sw;
|
|
|
|
gint sh;
|
|
|
|
|
2013-04-19 01:06:17 +08:00
|
|
|
gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
|
2008-08-17 18:48:49 +08: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 16:37:32 +08:00
|
|
|
|
2008-08-17 18:48:49 +08:00
|
|
|
if (! center_horizontally)
|
|
|
|
{
|
|
|
|
target_offset_x = MAX (shell->offset_x, 0);
|
|
|
|
}
|
2008-09-04 16:37:32 +08:00
|
|
|
|
2008-08-17 18:48:49 +08:00
|
|
|
if (! center_vertically)
|
|
|
|
{
|
|
|
|
target_offset_y = MAX (shell->offset_y, 0);
|
2008-08-17 15:29:48 +08:00
|
|
|
}
|
2008-09-04 16:37:32 +08:00
|
|
|
|
2008-08-17 18:48:49 +08:00
|
|
|
gimp_display_shell_scroll_set_offset (shell,
|
|
|
|
target_offset_x,
|
|
|
|
target_offset_y);
|
2008-08-17 15:21:41 +08:00
|
|
|
}
|
|
|
|
|
2008-08-14 22:41:29 +08:00
|
|
|
gimp_display_shell_scroll_clamp_and_update (shell);
|
2008-10-30 06:28:48 +08:00
|
|
|
gimp_display_shell_scaled (shell);
|
2008-08-14 22:41:29 +08:00
|
|
|
|
2008-08-17 18:48:49 +08:00
|
|
|
shell->size_allocate_from_configure_event = FALSE;
|
2001-12-01 00:39:40 +08:00
|
|
|
}
|
2018-05-30 03:09:44 +08:00
|
|
|
|
2018-06-28 06:52:08 +08:00
|
|
|
if (shell->size_allocate_center_image)
|
|
|
|
{
|
|
|
|
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
|
|
|
|
|
|
|
|
shell->size_allocate_center_image = FALSE;
|
|
|
|
}
|
|
|
|
|
2018-05-30 03:09:44 +08:00
|
|
|
/* undo size request from gimp_display_shell_constructed() */
|
|
|
|
gtk_widget_set_size_request (widget, -1, -1);
|
2018-06-28 06:52:08 +08:00
|
|
|
|
2019-07-22 00:13:53 +08:00
|
|
|
g_free (tick);
|
|
|
|
|
2018-06-28 06:52:08 +08:00
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_canvas_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
2019-07-22 00:13:53 +08:00
|
|
|
TickClosure *tick;
|
|
|
|
|
2018-06-28 06:52:08 +08:00
|
|
|
/* are we in destruction? */
|
|
|
|
if (! shell->display || ! gimp_display_get_shell (shell->display))
|
|
|
|
return;
|
|
|
|
|
2019-07-22 00:13:53 +08:00
|
|
|
tick = g_new0 (TickClosure, 1);
|
|
|
|
|
|
|
|
tick->shell = shell;
|
|
|
|
tick->prev_width = shell->disp_width;
|
|
|
|
tick->prev_height = shell->disp_height;
|
|
|
|
|
|
|
|
if (shell->disp_width != allocation->width ||
|
|
|
|
shell->disp_height != allocation->height)
|
|
|
|
{
|
|
|
|
g_clear_pointer (&shell->render_cache, cairo_surface_destroy);
|
|
|
|
gimp_display_shell_render_invalidate_full (shell);
|
|
|
|
|
|
|
|
shell->disp_width = allocation->width;
|
|
|
|
shell->disp_height = allocation->height;
|
|
|
|
}
|
|
|
|
|
2018-06-28 06:52:08 +08:00
|
|
|
gtk_widget_add_tick_callback (widget,
|
|
|
|
(GtkTickCallback) gimp_display_shell_canvas_tick,
|
2019-07-22 00:13:53 +08:00
|
|
|
tick, NULL);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
gboolean
|
2010-10-20 02:00:10 +08:00
|
|
|
gimp_display_shell_canvas_draw (GtkWidget *widget,
|
|
|
|
cairo_t *cr,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2003-10-06 19:25:59 +08:00
|
|
|
/* are we in destruction? */
|
2009-10-06 01:58:03 +08:00
|
|
|
if (! shell->display || ! gimp_display_get_shell (shell->display))
|
|
|
|
return TRUE;
|
2008-03-19 05:22:21 +08:00
|
|
|
|
2018-06-28 06:52:08 +08: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-19 04:19:29 +08:00
|
|
|
/* ignore events on overlays */
|
2010-10-20 02:00:10 +08:00
|
|
|
if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
|
2003-11-12 01:07:41 +08:00
|
|
|
{
|
2010-08-28 06:09:31 +08:00
|
|
|
if (gimp_display_get_image (shell->display))
|
|
|
|
{
|
2013-04-18 17:56:43 +08:00
|
|
|
gimp_display_shell_canvas_draw_image (shell, cr);
|
2010-05-02 00:02:42 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-04-18 17:56:43 +08:00
|
|
|
gimp_display_shell_canvas_draw_drop_zone (shell, cr);
|
2010-05-02 00:02:42 +08:00
|
|
|
}
|
2003-11-12 01:07:41 +08:00
|
|
|
}
|
2008-03-20 03:33:51 +08:00
|
|
|
|
2010-05-02 00:02:42 +08:00
|
|
|
return FALSE;
|
2001-12-01 00:39:40 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-08-19 19:21:48 +08:00
|
|
|
gboolean
|
2001-11-02 17:31:21 +08:00
|
|
|
gimp_display_shell_origin_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GimpDisplayShell *shell)
|
1998-06-09 17:20:46 +08:00
|
|
|
{
|
2008-03-19 05:22:21 +08:00
|
|
|
if (! shell->display->gimp->busy)
|
1998-06-09 17:20:46 +08:00
|
|
|
{
|
2011-09-19 06:45:36 +08:00
|
|
|
if (event->type == GDK_BUTTON_PRESS && event->button == 1)
|
2004-11-09 19:38:29 +08:00
|
|
|
{
|
|
|
|
gboolean unused;
|
|
|
|
|
|
|
|
g_signal_emit_by_name (shell, "popup-menu", &unused);
|
|
|
|
}
|
1998-06-09 17:20:46 +08:00
|
|
|
}
|
|
|
|
|
2001-07-29 22:09:50 +08:00
|
|
|
/* Return TRUE to stop signal emission so the button doesn't grab the
|
2001-08-07 20:42:23 +08:00
|
|
|
* pointer away from us.
|
|
|
|
*/
|
2001-07-29 22:09:50 +08:00
|
|
|
return TRUE;
|
1998-06-09 17:20:46 +08:00
|
|
|
}
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
gboolean
|
2005-09-19 20:44:06 +08:00
|
|
|
gimp_display_shell_quick_mask_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 22:41:56 +08:00
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
if (! gimp_display_get_image (shell->display))
|
2008-03-19 05:22:21 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2011-10-02 22:23:59 +08:00
|
|
|
if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
|
2001-11-30 22:41:56 +08:00
|
|
|
{
|
2009-09-30 02:32:26 +08:00
|
|
|
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
2009-09-23 22:58:03 +08:00
|
|
|
|
2009-09-30 02:32:26 +08:00
|
|
|
if (window)
|
2009-09-30 03:44:43 +08:00
|
|
|
{
|
|
|
|
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
|
|
|
|
2018-05-02 18:09:39 +08:00
|
|
|
gimp_ui_manager_ui_popup_at_widget (manager,
|
|
|
|
"/quick-mask-popup",
|
|
|
|
widget,
|
|
|
|
GDK_GRAVITY_EAST,
|
|
|
|
GDK_GRAVITY_SOUTH_WEST,
|
|
|
|
(GdkEvent *) bevent,
|
|
|
|
NULL, NULL);
|
2009-09-30 03:44:43 +08:00
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-09-19 20:44:06 +08:00
|
|
|
gimp_display_shell_quick_mask_toggled (GtkWidget *widget,
|
|
|
|
GimpDisplayShell *shell)
|
2001-11-30 22:41:56 +08:00
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
|
|
|
gboolean active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
|
2009-07-15 20:29:43 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
if (active != gimp_image_get_quick_mask_state (image))
|
2004-02-14 23:37:23 +08:00
|
|
|
{
|
2016-10-01 07:06:02 +08:00
|
|
|
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
|
|
|
|
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
2001-11-30 22:41:56 +08:00
|
|
|
|
2016-10-01 07:06:02 +08:00
|
|
|
gimp_ui_manager_toggle_action (manager,
|
|
|
|
"quick-mask", "quick-mask-toggle",
|
|
|
|
active);
|
|
|
|
}
|
2004-02-14 23:37:23 +08:00
|
|
|
}
|
2001-11-30 22:41:56 +08:00
|
|
|
}
|
2001-12-01 00:39:40 +08:00
|
|
|
|
2002-05-06 03:17:41 +08:00
|
|
|
gboolean
|
2011-02-23 14:13:45 +08:00
|
|
|
gimp_display_shell_navigation_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell)
|
2002-05-06 03:17:41 +08:00
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
if (! gimp_display_get_image (shell->display))
|
2008-03-19 05:22:21 +08:00
|
|
|
return TRUE;
|
|
|
|
|
2011-09-19 06:45:36 +08:00
|
|
|
if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 1)
|
2002-05-06 03:17:41 +08:00
|
|
|
{
|
2018-05-01 19:42:19 +08:00
|
|
|
gimp_navigation_editor_popup (shell, widget,
|
|
|
|
(GdkEvent *) bevent,
|
|
|
|
bevent->x, bevent->y);
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
|
2011-02-22 23:27:18 +08:00
|
|
|
/* private functions */
|
|
|
|
|
2001-12-01 00:39:40 +08:00
|
|
|
static void
|
2011-02-23 14:13:45 +08:00
|
|
|
gimp_display_shell_vadjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
2001-12-01 00:39:40 +08:00
|
|
|
{
|
2011-02-23 14: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 21:23:09 +08:00
|
|
|
*/
|
|
|
|
if (! shell->scrolling)
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
0,
|
|
|
|
gtk_adjustment_get_value (adjustment) -
|
|
|
|
shell->offset_y);
|
2001-12-01 00:39:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-02-23 14:13:45 +08:00
|
|
|
gimp_display_shell_hadjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpDisplayShell *shell)
|
2001-12-01 00:39:40 +08:00
|
|
|
{
|
2011-02-23 14: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 21:23:09 +08:00
|
|
|
*/
|
|
|
|
if (! shell->scrolling)
|
|
|
|
gimp_display_shell_scroll (shell,
|
|
|
|
gtk_adjustment_get_value (adjustment) -
|
|
|
|
shell->offset_x,
|
|
|
|
0);
|
2001-12-01 00:39:40 +08:00
|
|
|
}
|
|
|
|
|
2008-08-05 19:05:56 +08:00
|
|
|
static gboolean
|
2011-02-23 14:13:45 +08:00
|
|
|
gimp_display_shell_hscrollbar_change_value (GtkRange *range,
|
2008-08-05 19:05:56 +08: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 15:54:27 +08:00
|
|
|
g_object_freeze_notify (G_OBJECT (shell->hsbdata));
|
|
|
|
|
2016-01-06 01:02:59 +08:00
|
|
|
gimp_display_shell_scrollbars_setup_horizontal (shell, value);
|
2008-08-05 19:05:56 +08:00
|
|
|
|
2009-10-09 15:54:27 +08:00
|
|
|
g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */
|
2008-08-05 19:05:56 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-02-23 14:13:45 +08:00
|
|
|
gimp_display_shell_vscrollbar_change_value (GtkRange *range,
|
2008-08-05 19:05:56 +08: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 15:54:27 +08:00
|
|
|
g_object_freeze_notify (G_OBJECT (shell->vsbdata));
|
|
|
|
|
2016-01-06 01:02:59 +08:00
|
|
|
gimp_display_shell_scrollbars_setup_vertical (shell, value);
|
2008-08-05 19:05:56 +08:00
|
|
|
|
2009-10-09 15:54:27 +08:00
|
|
|
g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */
|
2008-08-05 19:05:56 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-20 03:33:51 +08:00
|
|
|
static void
|
2013-04-18 17:56:43 +08:00
|
|
|
gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
|
|
|
|
cairo_t *cr)
|
2008-03-20 03:19:37 +08:00
|
|
|
{
|
2013-04-19 22:22:19 +08:00
|
|
|
cairo_rectangle_list_t *clip_rectangles;
|
|
|
|
cairo_rectangle_int_t image_rect;
|
2017-12-09 17:25:35 +08:00
|
|
|
cairo_matrix_t matrix;
|
2010-05-02 18:12:48 +08:00
|
|
|
|
|
|
|
image_rect.x = - shell->offset_x;
|
|
|
|
image_rect.y = - shell->offset_y;
|
2013-04-19 01:06:17 +08:00
|
|
|
gimp_display_shell_scale_get_image_size (shell,
|
|
|
|
&image_rect.width,
|
|
|
|
&image_rect.height);
|
2008-03-20 03:19:37 +08:00
|
|
|
|
2018-05-24 04:46:54 +08:00
|
|
|
/* first, draw the background
|
2013-04-19 08:08:10 +08:00
|
|
|
*/
|
2013-04-18 17:56:43 +08:00
|
|
|
|
2018-05-24 04:46:54 +08:00
|
|
|
gimp_display_shell_draw_background (shell, cr);
|
2008-03-20 03:19:37 +08:00
|
|
|
|
|
|
|
|
2010-05-02 18:12:48 +08:00
|
|
|
/* then, draw the exposed part of the region that is inside the
|
2013-04-19 08:08:10 +08:00
|
|
|
* image
|
2010-05-02 18:12:48 +08:00
|
|
|
*/
|
|
|
|
|
2013-04-19 08:08:10 +08:00
|
|
|
cairo_save (cr);
|
2013-04-19 22:22:19 +08:00
|
|
|
clip_rectangles = cairo_copy_clip_rectangle_list (cr);
|
2017-12-09 17:25:35 +08:00
|
|
|
cairo_get_matrix (cr, &matrix);
|
2013-04-19 22:22:19 +08:00
|
|
|
|
|
|
|
if (shell->rotate_transform)
|
|
|
|
cairo_transform (cr, shell->rotate_transform);
|
2010-05-02 18:12:48 +08:00
|
|
|
|
2013-04-19 08:08:10 +08:00
|
|
|
cairo_rectangle (cr,
|
|
|
|
image_rect.x,
|
|
|
|
image_rect.y,
|
|
|
|
image_rect.width,
|
|
|
|
image_rect.height);
|
|
|
|
cairo_clip (cr);
|
2008-03-20 03:19:37 +08:00
|
|
|
|
2013-04-19 08:08:10 +08:00
|
|
|
if (gdk_cairo_get_clip_rectangle (cr, NULL))
|
2008-03-20 03:19:37 +08:00
|
|
|
{
|
2013-04-19 22:22:19 +08:00
|
|
|
gint i;
|
2013-04-19 08:08:10 +08:00
|
|
|
|
2010-09-29 03:10:03 +08:00
|
|
|
cairo_save (cr);
|
2013-04-20 16:47:13 +08:00
|
|
|
gimp_display_shell_draw_checkerboard (shell, cr);
|
2010-09-29 03:10:03 +08:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
2017-12-09 17:25:35 +08:00
|
|
|
cairo_set_matrix (cr, &matrix);
|
|
|
|
|
2013-04-19 08:08:10 +08:00
|
|
|
for (i = 0; i < clip_rectangles->num_rectangles; i++)
|
2013-04-18 17:56:43 +08:00
|
|
|
{
|
2013-04-19 08:08:10 +08:00
|
|
|
cairo_rectangle_t rect = clip_rectangles->rectangles[i];
|
2013-04-18 17:56:43 +08:00
|
|
|
|
|
|
|
gimp_display_shell_draw_image (shell, cr,
|
2013-04-19 08:08:10 +08:00
|
|
|
floor (rect.x),
|
|
|
|
floor (rect.y),
|
|
|
|
ceil (rect.width),
|
|
|
|
ceil (rect.height));
|
2013-04-18 17:56:43 +08:00
|
|
|
}
|
2010-05-02 18:12:48 +08:00
|
|
|
}
|
2008-03-20 03:19:37 +08:00
|
|
|
|
2013-04-19 22:22:19 +08:00
|
|
|
cairo_rectangle_list_destroy (clip_rectangles);
|
2013-04-19 08:08:10 +08:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
2010-05-02 18:12:48 +08:00
|
|
|
|
|
|
|
/* finally, draw all the remaining image window stuff on top
|
|
|
|
*/
|
2008-03-20 03:19:37 +08:00
|
|
|
|
2010-10-01 15:15:52 +08:00
|
|
|
/* draw canvas items */
|
2013-04-24 06:01:01 +08:00
|
|
|
cairo_save (cr);
|
|
|
|
|
2013-04-19 22:22:19 +08:00
|
|
|
if (shell->rotate_transform)
|
|
|
|
cairo_transform (cr, shell->rotate_transform);
|
|
|
|
|
2010-10-01 20:54:53 +08:00
|
|
|
gimp_canvas_item_draw (shell->canvas_item, cr);
|
2010-09-23 04:24:22 +08:00
|
|
|
|
2013-04-24 06:01:01 +08:00
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
gimp_canvas_item_draw (shell->unrotated_item, cr);
|
|
|
|
|
2008-03-20 03:19:37 +08:00
|
|
|
/* restart (and recalculate) the selection boundaries */
|
2010-10-10 02:23:05 +08:00
|
|
|
gimp_display_shell_selection_restart (shell);
|
2008-03-20 03:33:51 +08:00
|
|
|
}
|
2008-03-20 03:19:37 +08:00
|
|
|
|
2008-03-20 03:33:51 +08:00
|
|
|
static void
|
2013-04-18 17:56:43 +08:00
|
|
|
gimp_display_shell_canvas_draw_drop_zone (GimpDisplayShell *shell,
|
|
|
|
cairo_t *cr)
|
2008-03-20 03:33:51 +08:00
|
|
|
{
|
2014-03-07 18:32:24 +08:00
|
|
|
cairo_save (cr);
|
|
|
|
|
2013-04-18 17:56:43 +08:00
|
|
|
gimp_display_shell_draw_background (shell, cr);
|
2008-03-20 03:33:51 +08:00
|
|
|
|
2013-09-29 00:00:31 +08:00
|
|
|
gimp_cairo_draw_drop_wilber (shell->canvas, cr, shell->blink);
|
2014-03-07 18:32:24 +08:00
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
|
|
|
#ifdef GIMP_UNSTABLE
|
|
|
|
{
|
2018-05-07 06:22:39 +08:00
|
|
|
GtkWidget *widget = GTK_WIDGET (shell);
|
|
|
|
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
|
|
|
GtkStateFlags state = gtk_widget_get_state_flags (widget);
|
|
|
|
PangoLayout *layout;
|
|
|
|
gchar *msg;
|
|
|
|
GtkAllocation allocation;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gdouble scale;
|
|
|
|
GdkRGBA color;
|
2014-03-07 18:32:24 +08:00
|
|
|
|
2014-05-28 03:58:10 +08:00
|
|
|
layout = gtk_widget_create_pango_layout (shell->canvas, NULL);
|
2015-03-12 14:37:32 +08:00
|
|
|
|
|
|
|
msg = g_strdup_printf (_("<big>Unstable Development Version</big>\n\n"
|
|
|
|
"<small>commit <tt>%s</tt></small>\n\n"
|
2015-08-31 21:19:37 +08:00
|
|
|
"<small>Please test bugs against "
|
|
|
|
"latest git master branch\n"
|
|
|
|
"before reporting them.</small>"),
|
2017-03-22 10:54:11 +08:00
|
|
|
GIMP_GIT_VERSION_ABBREV);
|
2015-03-12 14:37:32 +08:00
|
|
|
pango_layout_set_markup (layout, msg, -1);
|
|
|
|
g_free (msg);
|
2014-03-07 18: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);
|
|
|
|
|
2018-05-07 06:22:39 +08:00
|
|
|
gtk_style_context_get_color (context, state, &color);
|
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
|
|
|
|
2014-03-07 18:32:24 +08:00
|
|
|
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-20 03:19:37 +08:00
|
|
|
}
|