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-17 05:37:03 +08:00
|
|
|
|
1999-03-07 20:56:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2004-10-01 17:50:04 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-01-22 10:33:29 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2005-07-31 06:29:02 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display-types.h"
|
2003-01-13 22:08:10 +08:00
|
|
|
#include "tools/tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2005-02-21 08:45:17 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
2010-02-02 04:55:18 +08:00
|
|
|
#include "config/gimpdisplayoptions.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
#include "gegl/gimp-babl.h"
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "core/gimp.h"
|
2013-04-19 22:22:19 +08:00
|
|
|
#include "core/gimp-utils.h"
|
2005-01-16 03:31:09 +08:00
|
|
|
#include "core/gimpchannel.h"
|
2001-11-28 03:27:55 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2007-12-26 01:09:04 +08:00
|
|
|
#include "core/gimpimage-grid.h"
|
|
|
|
#include "core/gimpimage-guides.h"
|
2003-06-24 03:34:48 +08:00
|
|
|
#include "core/gimpimage-snap.h"
|
2007-10-01 01:24:47 +08:00
|
|
|
#include "core/gimpprojection.h"
|
2002-05-08 00:23:14 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2008-03-22 06:09:23 +08:00
|
|
|
#include "core/gimptemplate.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2010-12-20 04:23:54 +08:00
|
|
|
#include "widgets/gimpdevices.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2004-04-22 00:33:17 +08:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2003-05-29 19:34:30 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2003-11-10 07:24:40 +08:00
|
|
|
#include "gimpcanvas.h"
|
2010-10-03 06:28:40 +08:00
|
|
|
#include "gimpcanvaslayerboundary.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gimpdisplay.h"
|
|
|
|
#include "gimpdisplayshell.h"
|
2003-03-20 19:31:33 +08:00
|
|
|
#include "gimpdisplayshell-appearance.h"
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "gimpdisplayshell-callbacks.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-cursor.h"
|
2001-11-09 03:14:51 +08:00
|
|
|
#include "gimpdisplayshell-dnd.h"
|
2009-10-03 05:55:26 +08:00
|
|
|
#include "gimpdisplayshell-expose.h"
|
2002-03-15 06:42:50 +08:00
|
|
|
#include "gimpdisplayshell-filter.h"
|
2001-11-11 03:10:28 +08:00
|
|
|
#include "gimpdisplayshell-handlers.h"
|
2010-10-01 23:13:00 +08:00
|
|
|
#include "gimpdisplayshell-items.h"
|
2015-05-27 18:28:33 +08:00
|
|
|
#include "gimpdisplayshell-profile.h"
|
2006-06-29 17:42:05 +08:00
|
|
|
#include "gimpdisplayshell-progress.h"
|
2009-10-03 06:15:04 +08:00
|
|
|
#include "gimpdisplayshell-render.h"
|
2013-04-19 22:22:19 +08:00
|
|
|
#include "gimpdisplayshell-rotate.h"
|
2016-01-06 01:02:59 +08:00
|
|
|
#include "gimpdisplayshell-rulers.h"
|
2003-06-04 21:06:59 +08:00
|
|
|
#include "gimpdisplayshell-scale.h"
|
2008-03-20 00:15:50 +08:00
|
|
|
#include "gimpdisplayshell-scroll.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"
|
2011-02-23 12:21:06 +08:00
|
|
|
#include "gimpdisplayshell-tool-events.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "gimpdisplayshell-transform.h"
|
2009-09-30 02:56:14 +08:00
|
|
|
#include "gimpimagewindow.h"
|
2011-04-18 00:53:42 +08:00
|
|
|
#include "gimpmotionbuffer.h"
|
2002-02-03 20:10:23 +08:00
|
|
|
#include "gimpstatusbar.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2009-10-06 16:56:10 +08:00
|
|
|
#include "about.h"
|
2009-07-20 17:01:56 +08:00
|
|
|
#include "gimp-log.h"
|
2014-07-02 10:47:24 +08:00
|
|
|
#include "gimp-priorities.h"
|
2009-10-06 16:56:10 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1998-11-23 22:47:09 +08:00
|
|
|
|
2012-12-16 02:27:16 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2009-09-25 18:28:49 +08:00
|
|
|
PROP_POPUP_MANAGER,
|
2014-05-03 06:54:20 +08:00
|
|
|
PROP_INITIAL_MONITOR,
|
2009-09-25 18:19:35 +08:00
|
|
|
PROP_DISPLAY,
|
2009-09-24 01:33:36 +08:00
|
|
|
PROP_UNIT,
|
|
|
|
PROP_TITLE,
|
2009-09-24 15:09:35 +08:00
|
|
|
PROP_STATUS,
|
|
|
|
PROP_ICON
|
2004-06-02 06:04:20 +08:00
|
|
|
};
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SCALED,
|
|
|
|
SCROLLED,
|
2013-04-21 09:15:22 +08:00
|
|
|
ROTATED,
|
2002-09-28 00:17:31 +08:00
|
|
|
RECONNECT,
|
2002-05-08 00:23:14 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
typedef struct _GimpDisplayShellOverlay GimpDisplayShellOverlay;
|
|
|
|
|
|
|
|
struct _GimpDisplayShellOverlay
|
|
|
|
{
|
2018-05-22 07:59:26 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble image_x;
|
|
|
|
gdouble image_y;
|
|
|
|
GimpHandleAnchor anchor;
|
|
|
|
gint spacing_x;
|
|
|
|
gint spacing_y;
|
2010-02-28 21:48:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* local function prototypes */
|
2000-02-09 07:45:20 +08:00
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
static void gimp_color_managed_iface_init (GimpColorManagedInterface *iface);
|
2007-08-07 03:23:22 +08:00
|
|
|
|
2011-01-13 06:06:03 +08:00
|
|
|
static void gimp_display_shell_constructed (GObject *object);
|
2010-09-27 04:35:49 +08:00
|
|
|
static void gimp_display_shell_dispose (GObject *object);
|
2004-07-14 08:15:57 +08:00
|
|
|
static void gimp_display_shell_finalize (GObject *object);
|
|
|
|
static void gimp_display_shell_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_display_shell_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2005-11-27 06:02:11 +08:00
|
|
|
static void gimp_display_shell_unrealize (GtkWidget *widget);
|
2018-10-22 06:00:59 +08:00
|
|
|
static void gimp_display_shell_unmap (GtkWidget *widget);
|
2004-07-14 08:15:57 +08:00
|
|
|
static void gimp_display_shell_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous);
|
2004-11-09 19:38:29 +08:00
|
|
|
static gboolean gimp_display_shell_popup_menu (GtkWidget *widget);
|
2004-07-14 08:15:57 +08:00
|
|
|
|
|
|
|
static void gimp_display_shell_real_scaled (GimpDisplayShell *shell);
|
2014-05-31 08:36:25 +08:00
|
|
|
static void gimp_display_shell_real_scrolled (GimpDisplayShell *shell);
|
2013-04-21 09:15:22 +08:00
|
|
|
static void gimp_display_shell_real_rotated (GimpDisplayShell *shell);
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2015-05-27 18:28:33 +08:00
|
|
|
static const guint8 *
|
|
|
|
gimp_display_shell_get_icc_profile(GimpColorManaged *managed,
|
2009-11-02 01:18:17 +08:00
|
|
|
gsize *len);
|
2015-07-11 04:43:53 +08:00
|
|
|
static GimpColorProfile *
|
2015-05-27 18:28:33 +08:00
|
|
|
gimp_display_shell_get_color_profile(GimpColorManaged *managed);
|
|
|
|
static void gimp_display_shell_profile_changed(GimpColorManaged *managed);
|
2009-11-02 01:18:17 +08:00
|
|
|
|
|
|
|
static void gimp_display_shell_zoom_button_callback
|
|
|
|
(GimpDisplayShell *shell,
|
|
|
|
GtkWidget *zoom_button);
|
|
|
|
static void gimp_display_shell_sync_config (GimpDisplayShell *shell,
|
|
|
|
GimpDisplayConfig *config);
|
2007-08-07 03:23:22 +08:00
|
|
|
|
2018-05-22 07:59:26 +08:00
|
|
|
static void gimp_display_shell_overlay_allocate (GtkWidget *child,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpDisplayShellOverlay *overlay);
|
2010-02-20 21:52:37 +08:00
|
|
|
static void gimp_display_shell_remove_overlay (GtkWidget *canvas,
|
|
|
|
GtkWidget *child,
|
|
|
|
GimpDisplayShell *shell);
|
2010-02-28 21:48:47 +08:00
|
|
|
static void gimp_display_shell_transform_overlay (GimpDisplayShell *shell,
|
|
|
|
GtkWidget *child,
|
|
|
|
gdouble *x,
|
|
|
|
gdouble *y);
|
2010-02-20 21:52:37 +08:00
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2009-09-23 18:32:36 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpDisplayShell, gimp_display_shell,
|
2017-02-23 07:31:39 +08:00
|
|
|
GTK_TYPE_EVENT_BOX,
|
2006-06-29 17:42:05 +08:00
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PROGRESS,
|
2007-08-07 03:23:22 +08:00
|
|
|
gimp_display_shell_progress_iface_init)
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_COLOR_MANAGED,
|
|
|
|
gimp_color_managed_iface_init))
|
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_display_shell_parent_class
|
|
|
|
|
|
|
|
static guint display_shell_signals[LAST_SIGNAL] = { 0 };
|
2002-05-08 00:23:14 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_class_init (GimpDisplayShellClass *klass)
|
|
|
|
{
|
2010-09-27 04:35:49 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
2001-10-13 20:52:30 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
display_shell_signals[SCALED] =
|
|
|
|
g_signal_new ("scaled",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDisplayShellClass, scaled),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
display_shell_signals[SCROLLED] =
|
|
|
|
g_signal_new ("scrolled",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDisplayShellClass, scrolled),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2013-04-21 09:15:22 +08:00
|
|
|
display_shell_signals[ROTATED] =
|
|
|
|
g_signal_new ("rotated",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDisplayShellClass, rotated),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2002-09-28 00:17:31 +08:00
|
|
|
display_shell_signals[RECONNECT] =
|
|
|
|
g_signal_new ("reconnect",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpDisplayShellClass, reconnect),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2011-01-13 06:06:03 +08:00
|
|
|
object_class->constructed = gimp_display_shell_constructed;
|
2010-09-27 04:35:49 +08:00
|
|
|
object_class->dispose = gimp_display_shell_dispose;
|
2008-03-25 21:42:40 +08:00
|
|
|
object_class->finalize = gimp_display_shell_finalize;
|
|
|
|
object_class->set_property = gimp_display_shell_set_property;
|
|
|
|
object_class->get_property = gimp_display_shell_get_property;
|
2003-10-22 22:46:05 +08:00
|
|
|
|
2008-03-25 21:42:40 +08:00
|
|
|
widget_class->unrealize = gimp_display_shell_unrealize;
|
2018-10-22 06:00:59 +08:00
|
|
|
widget_class->unmap = gimp_display_shell_unmap;
|
2008-03-25 21:42:40 +08:00
|
|
|
widget_class->screen_changed = gimp_display_shell_screen_changed;
|
|
|
|
widget_class->popup_menu = gimp_display_shell_popup_menu;
|
2002-09-28 00:17:31 +08:00
|
|
|
|
2008-03-25 21:42:40 +08:00
|
|
|
klass->scaled = gimp_display_shell_real_scaled;
|
2014-05-31 08:36:25 +08:00
|
|
|
klass->scrolled = gimp_display_shell_real_scrolled;
|
2013-04-21 09:15:22 +08:00
|
|
|
klass->rotated = gimp_display_shell_real_rotated;
|
2008-03-25 21:42:40 +08:00
|
|
|
klass->reconnect = NULL;
|
2004-06-02 06:04:20 +08:00
|
|
|
|
2009-09-25 18:28:49 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_POPUP_MANAGER,
|
|
|
|
g_param_spec_object ("popup-manager",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_UI_MANAGER,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2018-04-29 23:27:47 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_INITIAL_MONITOR,
|
|
|
|
g_param_spec_object ("initial-monitor",
|
2014-05-03 06:54:20 +08:00
|
|
|
NULL, NULL,
|
2018-04-29 23:27:47 +08:00
|
|
|
GDK_TYPE_MONITOR,
|
2014-05-03 06:54:20 +08:00
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2009-09-25 18:19:35 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_DISPLAY,
|
|
|
|
g_param_spec_object ("display", NULL, NULL,
|
|
|
|
GIMP_TYPE_DISPLAY,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_UNIT,
|
2004-06-02 06:04:20 +08:00
|
|
|
gimp_param_spec_unit ("unit", NULL, NULL,
|
|
|
|
TRUE, FALSE,
|
|
|
|
GIMP_UNIT_PIXEL,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READWRITE));
|
2005-05-18 21:33:52 +08:00
|
|
|
|
2009-09-24 01:33:36 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_TITLE,
|
2009-09-30 04:20:12 +08:00
|
|
|
g_param_spec_string ("title", NULL, NULL,
|
2009-10-06 16:56:10 +08:00
|
|
|
GIMP_NAME,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT));
|
2009-09-24 01:33:36 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_STATUS,
|
|
|
|
g_param_spec_string ("status", NULL, NULL,
|
|
|
|
NULL,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
|
2009-09-24 15:09:35 +08:00
|
|
|
g_object_class_install_property (object_class, PROP_ICON,
|
2009-09-30 04:20:12 +08:00
|
|
|
g_param_spec_object ("icon", NULL, NULL,
|
2009-09-24 15:09:35 +08:00
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
|
2018-05-02 18:57:13 +08:00
|
|
|
gtk_widget_class_set_css_name (widget_class, "GimpDisplayShell");
|
2001-10-13 20:52:30 +08:00
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_color_managed_iface_init (GimpColorManagedInterface *iface)
|
|
|
|
{
|
2015-05-27 18:28:33 +08:00
|
|
|
iface->get_icc_profile = gimp_display_shell_get_icc_profile;
|
|
|
|
iface->get_color_profile = gimp_display_shell_get_color_profile;
|
|
|
|
iface->profile_changed = gimp_display_shell_profile_changed;
|
2009-11-02 01:18:17 +08:00
|
|
|
}
|
|
|
|
|
2001-10-13 20:52:30 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_init (GimpDisplayShell *shell)
|
|
|
|
{
|
2009-11-01 21:49:19 +08:00
|
|
|
shell->options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
|
|
|
|
shell->fullscreen_options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
|
|
|
|
shell->no_image_options = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_NO_IMAGE, NULL);
|
|
|
|
|
|
|
|
shell->zoom = gimp_zoom_model_new ();
|
|
|
|
shell->dot_for_dot = TRUE;
|
|
|
|
shell->scale_x = 1.0;
|
|
|
|
shell->scale_y = 1.0;
|
|
|
|
|
2010-10-01 23:13:00 +08:00
|
|
|
gimp_display_shell_items_init (shell);
|
2010-10-01 15:01:51 +08:00
|
|
|
|
2015-10-26 04:55:35 +08:00
|
|
|
shell->icon_size = 128;
|
|
|
|
shell->icon_size_small = 96;
|
2009-11-01 21:49:19 +08:00
|
|
|
|
2011-07-25 04:09:21 +08:00
|
|
|
shell->cursor_handedness = GIMP_HANDEDNESS_RIGHT;
|
|
|
|
shell->current_cursor = (GimpCursorType) -1;
|
|
|
|
shell->tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
|
|
|
shell->cursor_modifier = GIMP_CURSOR_MODIFIER_NONE;
|
|
|
|
shell->override_cursor = (GimpCursorType) -1;
|
2009-11-01 21:49:19 +08:00
|
|
|
|
2015-06-02 06:01:28 +08:00
|
|
|
shell->filter_format = babl_format ("R'G'B'A float");
|
Initial space invasion commit in GIMP
All babl formats now have a space equivalent to a color profile,
determining the format's primaries and TRCs. This commit makes GIMP
aware of this.
libgimp:
- enum GimpPrecision: rename GAMMA values to NON_LINEAR and keep GAMMA
as deprecated aliases, add PERCEPTUAL values so we now have LINEAR,
NON_LINEAR and PERCPTUAL for each encoding, matching the babl
encoding variants RGB, R'G'B' and R~G~B~.
- gimp_color_transform_can_gegl_copy() now returns TRUE if both
profiles can return a babl space, increasing the amount of fast babl
color conversions significantly.
- TODO: no solution yet for getting libgimp drawable proxy buffers in
the right format with space.
plug-ins:
- follow the GimpPrecision change.
- TODO: everything else unchanged and partly broken or sub-optimal,
like setting a new image's color profile too late.
app:
- add enum GimpTRCType { LINEAR, NON_LINEAR, PERCEPTUAL } as
replacement for all "linear" booleans.
- change gimp-babl functions to take babl spaces and GimpTRCType
parameters and support all sorts of new perceptual ~ formats.
- a lot of places changed in the early days of goat invasion didn't
take advantage of gimp-babl utility functions and constructed
formats manually. They all needed revisiting and many now use much
simpler code calling gimp-babl API.
- change gimp_babl_format_get_color_profile() to really extract a
newly allocated color profile from the format, and add
gimp_babl_get_builtin_color_profile() which does the same as
gimp_babl_format_get_color_profile() did before. Visited all callers
to decide whether they are looking for the format's actual profile,
or for one of the builtin profiles, simplifying code that only needs
builtin profiles.
- drawables have a new get_space_api(), get_linear() is now get_trc().
- images now have a "layer space" and an API to get it,
gimp_image_get_layer_format() returns formats in that space.
- an image's layer space is created from the image's color profile,
change gimpimage-color-profile to deal with that correctly
- change many babl_format() calls to babl_format_with_space() and take
the space from passed formats or drawables
- add function gimp_layer_fix_format_space() which replaces the
layer's buffer with one that has the image's layer format, but
doesn't change pixel values
- use gimp_layer_fix_format_space() to make sure layers loaded from
XCF and created by plug-ins have the right space when added to the
image, because it's impossible to always assign the right space upon
layer creation
- "assign color profile" and "discard color profile" now require use
of gimp_layer_fix_format_space() too because the profile is now
embedded in all formats via the space. Add
gimp_image_assign_color_profile() which does all that and call it
instead of a simple gimp_image_set_color_profile(), also from the
PDB set-color-profile functions, which are essentially "assign" and
"discard" calls.
- generally, make sure a new image's color profile is set before
adding layers to it, gimp_image_set_color_profile() is more than
before considered know-what-you-are-doing API.
- take special precaution in all places that call
gimp_drawable_convert_type(), we now must pass a new_profile from
all callers that convert layers within the same image (such as
image_convert_type, image_convert_precision), because the layer's
new space can't be determined from the image's layer format during
the call.
- change all "linear" properties to "trc", in all config objects like
for levels and curves, in the histogram, in the widgets. This results
in some GUI that now has three choices instead of two.
TODO: we might want to reduce that back to two later.
- keep "linear" boolean properties around as compat if needed for file
pasring, but always convert the parsed parsed boolean to
GimpTRCType.
- TODO: the image's "enable color management" switch is currently
broken, will fix that in another commit.
2018-07-21 20:23:01 +08:00
|
|
|
shell->filter_profile = gimp_babl_get_builtin_color_profile (GIMP_RGB,
|
|
|
|
GIMP_TRC_NON_LINEAR);
|
2015-06-02 06:01:28 +08:00
|
|
|
|
2011-04-18 00:53:42 +08:00
|
|
|
shell->motion_buffer = gimp_motion_buffer_new ();
|
2009-01-10 08:48:30 +08:00
|
|
|
|
2011-04-18 17:08:24 +08:00
|
|
|
g_signal_connect (shell->motion_buffer, "stroke",
|
|
|
|
G_CALLBACK (gimp_display_shell_buffer_stroke),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->motion_buffer, "hover",
|
|
|
|
G_CALLBACK (gimp_display_shell_buffer_hover),
|
2011-04-18 03:46:29 +08:00
|
|
|
shell);
|
|
|
|
|
2010-06-19 02:57:59 +08:00
|
|
|
shell->zoom_focus_pointer_queue = g_queue_new ();
|
|
|
|
|
2011-12-11 06:22:08 +08:00
|
|
|
gtk_widget_set_events (GTK_WIDGET (shell), (GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_KEY_PRESS_MASK |
|
|
|
|
GDK_KEY_RELEASE_MASK |
|
|
|
|
GDK_FOCUS_CHANGE_MASK |
|
|
|
|
GDK_VISIBILITY_NOTIFY_MASK |
|
2018-05-11 08:08:51 +08:00
|
|
|
GDK_SCROLL_MASK |
|
|
|
|
GDK_SMOOTH_SCROLL_MASK));
|
2002-01-26 02:34:33 +08:00
|
|
|
|
2007-03-14 18:01:08 +08:00
|
|
|
/* zoom model callback */
|
|
|
|
g_signal_connect_swapped (shell->zoom, "zoomed",
|
2016-01-06 01:48:22 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_scale_update),
|
2007-03-14 18:01:08 +08:00
|
|
|
shell);
|
|
|
|
|
2002-01-26 02:34:33 +08:00
|
|
|
/* active display callback */
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (shell, "button-press-event",
|
2004-06-13 02:31:49 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (shell, "button-release-event",
|
2004-06-13 02:31:49 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (shell, "key-press-event",
|
2004-06-13 02:31:49 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_events),
|
|
|
|
shell);
|
2008-03-25 21:12:36 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
gimp_help_connect (GTK_WIDGET (shell), gimp_standard_help_func,
|
2004-06-13 02:31:49 +08:00
|
|
|
GIMP_HELP_IMAGE_WINDOW, NULL);
|
2003-10-22 22:46:05 +08:00
|
|
|
}
|
|
|
|
|
2011-01-13 06:06:03 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_constructed (GObject *object)
|
2009-09-25 18:31:59 +08:00
|
|
|
{
|
2011-01-13 06:06:03 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
2009-11-02 01:18:17 +08:00
|
|
|
GimpDisplayConfig *config;
|
|
|
|
GimpImage *image;
|
|
|
|
GimpColorDisplayStack *filter;
|
2018-05-13 23:46:10 +08:00
|
|
|
GtkWidget *grid;
|
2009-11-02 01:18:17 +08:00
|
|
|
GtkWidget *gtk_image;
|
2019-07-02 09:54:38 +08:00
|
|
|
GimpAction *action;
|
2009-11-02 01:18:17 +08:00
|
|
|
gint image_width;
|
|
|
|
gint image_height;
|
|
|
|
gint shell_width;
|
|
|
|
gint shell_height;
|
2009-09-25 18:31:59 +08:00
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2009-09-25 18:31:59 +08:00
|
|
|
|
2018-02-12 05:23:10 +08:00
|
|
|
gimp_assert (GIMP_IS_UI_MANAGER (shell->popup_manager));
|
|
|
|
gimp_assert (GIMP_IS_DISPLAY (shell->display));
|
2009-09-25 18:31:59 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
config = shell->display->config;
|
|
|
|
image = gimp_display_get_image (shell->display);
|
2005-11-27 06:02:11 +08:00
|
|
|
|
2016-05-15 05:50:58 +08:00
|
|
|
gimp_display_shell_profile_init (shell);
|
2016-05-14 06:56:26 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (image)
|
2005-11-27 06:02:11 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
image_width = gimp_image_get_width (image);
|
|
|
|
image_height = gimp_image_get_height (image);
|
2005-11-27 06:02:11 +08:00
|
|
|
}
|
2009-11-02 01:18:17 +08:00
|
|
|
else
|
2005-11-27 06:02:11 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
/* These values are arbitrary. The width is determined by the
|
|
|
|
* menubar and the height is chosen to give a window aspect
|
|
|
|
* ratio of roughly 3:1 (as requested by the UI team).
|
|
|
|
*/
|
|
|
|
image_width = GIMP_DEFAULT_IMAGE_WIDTH;
|
|
|
|
image_height = GIMP_DEFAULT_IMAGE_HEIGHT / 3;
|
2005-11-27 06:02:11 +08:00
|
|
|
}
|
2003-11-22 06:52:36 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
shell->dot_for_dot = config->default_dot_for_dot;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (config->monitor_res_from_gdk)
|
2004-10-01 17:50:04 +08:00
|
|
|
{
|
2018-04-29 23:27:47 +08:00
|
|
|
gimp_get_monitor_resolution (shell->initial_monitor,
|
2014-05-03 05:56:16 +08:00
|
|
|
&shell->monitor_xres, &shell->monitor_yres);
|
2004-10-01 17:50:04 +08:00
|
|
|
}
|
2009-11-02 01:18:17 +08:00
|
|
|
else
|
2005-07-31 06:29:02 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
shell->monitor_xres = config->monitor_xres;
|
|
|
|
shell->monitor_yres = config->monitor_yres;
|
2005-07-31 06:29:02 +08:00
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* adjust the initial scale -- so that window fits on screen. */
|
|
|
|
if (image)
|
2009-01-10 08:48:30 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_display_shell_set_initial_scale (shell, 1.0, //scale,
|
|
|
|
&shell_width, &shell_height);
|
2009-01-10 08:48:30 +08:00
|
|
|
}
|
2009-11-02 01:18:17 +08:00
|
|
|
else
|
2009-01-10 08:48:30 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
shell_width = -1;
|
|
|
|
shell_height = image_height;
|
2009-01-10 08:48:30 +08:00
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_display_shell_sync_config (shell, config);
|
2003-02-26 03:01:10 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
/* the grid containing everything */
|
|
|
|
grid = gtk_grid_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (shell), grid);
|
|
|
|
gtk_widget_show (grid);
|
2004-06-02 06:04:20 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* the horizontal scrollbar */
|
2018-06-25 00:15:16 +08:00
|
|
|
shell->hsbdata = gtk_adjustment_new (0, 0, image_width,
|
|
|
|
1, 1, image_width);
|
2011-10-02 19:18:10 +08:00
|
|
|
shell->hsb = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, shell->hsbdata);
|
2009-11-02 01:18:17 +08:00
|
|
|
gtk_widget_set_can_focus (shell->hsb, FALSE);
|
2005-11-27 06:02:11 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* the vertical scrollbar */
|
2018-06-25 00:15:16 +08:00
|
|
|
shell->vsbdata = gtk_adjustment_new (0, 0, image_height,
|
|
|
|
1, 1, image_height);
|
2011-10-02 19:18:10 +08:00
|
|
|
shell->vsb = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, shell->vsbdata);
|
2009-11-02 01:18:17 +08:00
|
|
|
gtk_widget_set_can_focus (shell->vsb, FALSE);
|
2005-11-27 06:02:11 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* the menu popup button */
|
|
|
|
shell->origin = gtk_event_box_new ();
|
2017-03-05 23:01:59 +08:00
|
|
|
gtk_image = gtk_image_new_from_icon_name (GIMP_ICON_MENU_RIGHT,
|
2014-05-07 21:30:38 +08:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2009-11-02 01:18:17 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->origin), gtk_image);
|
|
|
|
gtk_widget_show (gtk_image);
|
2003-05-29 00:11:29 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
g_signal_connect (shell->origin, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_origin_button_press),
|
|
|
|
shell);
|
2003-05-29 00:11:29 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_help_set_help_data (shell->origin,
|
|
|
|
_("Access the image menu"),
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_ORIGIN);
|
2004-11-09 19:38:29 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
/* the canvas */
|
2009-11-02 01:18:17 +08:00
|
|
|
shell->canvas = gimp_canvas_new (config);
|
|
|
|
gtk_widget_set_size_request (shell->canvas, shell_width, shell_height);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (shell->canvas), 10);
|
2004-11-09 19:38:29 +08:00
|
|
|
|
2010-02-20 21:52:37 +08:00
|
|
|
g_signal_connect (shell->canvas, "remove",
|
|
|
|
G_CALLBACK (gimp_display_shell_remove_overlay),
|
|
|
|
shell);
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_display_shell_dnd_init (shell);
|
|
|
|
gimp_display_shell_selection_init (shell);
|
2004-11-09 19:38:29 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* the horizontal ruler */
|
|
|
|
shell->hrule = gimp_ruler_new (GTK_ORIENTATION_HORIZONTAL);
|
|
|
|
gtk_widget_set_events (GTK_WIDGET (shell->hrule),
|
2018-05-13 23:46:10 +08:00
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK);
|
2011-01-21 03:23:14 +08:00
|
|
|
gimp_ruler_add_track_widget (GIMP_RULER (shell->hrule), shell->canvas);
|
2018-05-13 23:46:10 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
g_signal_connect (shell->hrule, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_hruler_button_press),
|
|
|
|
shell);
|
2003-03-20 19:31:33 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_help_set_help_data (shell->hrule, NULL, GIMP_HELP_IMAGE_WINDOW_RULER);
|
2004-06-02 06:04:20 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* the vertical ruler */
|
|
|
|
shell->vrule = gimp_ruler_new (GTK_ORIENTATION_VERTICAL);
|
|
|
|
gtk_widget_set_events (GTK_WIDGET (shell->vrule),
|
2018-05-13 23:46:10 +08:00
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK);
|
2011-01-21 03:23:14 +08:00
|
|
|
gimp_ruler_add_track_widget (GIMP_RULER (shell->vrule), shell->canvas);
|
2018-05-13 23:46:10 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
g_signal_connect (shell->vrule, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_vruler_button_press),
|
|
|
|
shell);
|
2003-03-20 19:31:33 +08:00
|
|
|
|
2018-01-17 04:35:36 +08:00
|
|
|
gimp_help_set_help_data (shell->vrule, NULL, GIMP_HELP_IMAGE_WINDOW_RULER);
|
|
|
|
|
2011-04-10 03:04:40 +08:00
|
|
|
/* set the rulers as track widgets for each other, so we don't end up
|
|
|
|
* with one ruler wrongly being stuck a few pixels off while we are
|
|
|
|
* hovering the other
|
|
|
|
*/
|
|
|
|
gimp_ruler_add_track_widget (GIMP_RULER (shell->hrule), shell->vrule);
|
|
|
|
gimp_ruler_add_track_widget (GIMP_RULER (shell->vrule), shell->hrule);
|
|
|
|
|
2010-12-20 04:23:54 +08:00
|
|
|
gimp_devices_add_widget (shell->display->gimp, shell->hrule);
|
|
|
|
gimp_devices_add_widget (shell->display->gimp, shell->vrule);
|
2004-11-09 19:38:29 +08:00
|
|
|
|
2016-04-15 07:17:00 +08:00
|
|
|
g_signal_connect (shell->canvas, "grab-notify",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_grab_notify),
|
|
|
|
shell);
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
g_signal_connect (shell->canvas, "realize",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_realize),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "size-allocate",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_size_allocate),
|
|
|
|
shell);
|
2010-10-20 19:24:12 +08:00
|
|
|
g_signal_connect (shell->canvas, "draw",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_draw),
|
2009-11-02 01:18:17 +08:00
|
|
|
shell);
|
2007-08-07 03:23:22 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
g_signal_connect (shell->canvas, "enter-notify-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "leave-notify-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "proximity-in-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "proximity-out-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "focus-in-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "focus-out-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "button-release-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "scroll-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "motion-notify-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "key-press-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->canvas, "key-release-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_canvas_tool_events),
|
|
|
|
shell);
|
2008-03-19 05:22:21 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
/* the zoom button */
|
2009-11-02 01:18:17 +08:00
|
|
|
shell->zoom_button = g_object_new (GTK_TYPE_CHECK_BUTTON,
|
|
|
|
"draw-indicator", FALSE,
|
|
|
|
"relief", GTK_RELIEF_NONE,
|
|
|
|
"width-request", 18,
|
|
|
|
"height-request", 18,
|
|
|
|
NULL);
|
|
|
|
gtk_widget_set_can_focus (shell->zoom_button, FALSE);
|
2017-03-05 23:01:59 +08:00
|
|
|
gtk_image = gtk_image_new_from_icon_name (GIMP_ICON_ZOOM_FOLLOW_WINDOW,
|
2014-05-07 21:30:38 +08:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2009-11-02 01:18:17 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->zoom_button), gtk_image);
|
|
|
|
gtk_widget_show (gtk_image);
|
2008-08-14 01:36:29 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
g_signal_connect_swapped (shell->zoom_button, "toggled",
|
|
|
|
G_CALLBACK (gimp_display_shell_zoom_button_callback),
|
|
|
|
shell);
|
2009-06-06 04:21:19 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
gimp_help_set_help_data (shell->zoom_button,
|
|
|
|
_("Zoom image when window size changes"),
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_ZOOM_FOLLOW_BUTTON);
|
2008-03-19 05:22:21 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* the quick mask button */
|
|
|
|
shell->quick_mask_button = g_object_new (GTK_TYPE_CHECK_BUTTON,
|
|
|
|
"draw-indicator", FALSE,
|
|
|
|
"relief", GTK_RELIEF_NONE,
|
|
|
|
"width-request", 18,
|
|
|
|
"height-request", 18,
|
|
|
|
NULL);
|
|
|
|
gtk_widget_set_can_focus (shell->quick_mask_button, FALSE);
|
2017-03-05 23:01:59 +08:00
|
|
|
gtk_image = gtk_image_new_from_icon_name (GIMP_ICON_QUICK_MASK_OFF,
|
2014-05-07 21:30:38 +08:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2009-11-02 01:18:17 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->quick_mask_button), gtk_image);
|
|
|
|
gtk_widget_show (gtk_image);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
g_signal_connect (shell->quick_mask_button, "toggled",
|
|
|
|
G_CALLBACK (gimp_display_shell_quick_mask_toggled),
|
|
|
|
shell);
|
|
|
|
g_signal_connect (shell->quick_mask_button, "button-press-event",
|
|
|
|
G_CALLBACK (gimp_display_shell_quick_mask_button_press),
|
|
|
|
shell);
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
action = gimp_ui_manager_find_action (shell->popup_manager,
|
|
|
|
"quick-mask", "quick-mask-toggle");
|
|
|
|
if (action)
|
|
|
|
gimp_widget_set_accel_help (shell->quick_mask_button, action);
|
|
|
|
else
|
|
|
|
gimp_help_set_help_data (shell->quick_mask_button,
|
|
|
|
_("Toggle Quick Mask"),
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_QUICK_MASK_BUTTON);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* the navigation window button */
|
|
|
|
shell->nav_ebox = gtk_event_box_new ();
|
2017-03-05 23:01:59 +08:00
|
|
|
gtk_image = gtk_image_new_from_icon_name (GIMP_ICON_DIALOG_NAVIGATION,
|
2014-05-07 21:30:38 +08:00
|
|
|
GTK_ICON_SIZE_MENU);
|
2009-11-02 01:18:17 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->nav_ebox), gtk_image);
|
|
|
|
gtk_widget_show (gtk_image);
|
|
|
|
|
|
|
|
g_signal_connect (shell->nav_ebox, "button-press-event",
|
2011-02-23 14:13:45 +08:00
|
|
|
G_CALLBACK (gimp_display_shell_navigation_button_press),
|
2009-11-02 01:18:17 +08:00
|
|
|
shell);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_help_set_help_data (shell->nav_ebox,
|
|
|
|
_("Navigate the image display"),
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_NAV_BUTTON);
|
2002-11-19 04:50:31 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
/* the statusbar */
|
2009-11-02 01:18:17 +08:00
|
|
|
shell->statusbar = gimp_statusbar_new ();
|
|
|
|
gimp_statusbar_set_shell (GIMP_STATUSBAR (shell->statusbar), shell);
|
|
|
|
gimp_help_set_help_data (shell->statusbar, NULL,
|
|
|
|
GIMP_HELP_IMAGE_WINDOW_STATUS_BAR);
|
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
/* pack all the widgets */
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->origin, 0, 0, 1, 1);
|
2018-05-02 18:31:48 +08:00
|
|
|
|
|
|
|
gtk_widget_set_hexpand (shell->hrule, TRUE);
|
2018-05-13 23:46:10 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->hrule, 1, 0, 1, 1);
|
2018-05-02 18:31:48 +08:00
|
|
|
|
|
|
|
gtk_widget_set_vexpand (shell->vrule, TRUE);
|
2018-05-13 23:46:10 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->vrule, 0, 1, 1, 1);
|
2018-05-02 18:31:48 +08:00
|
|
|
|
|
|
|
gtk_widget_set_hexpand (shell->canvas, TRUE);
|
|
|
|
gtk_widget_set_vexpand (shell->canvas, TRUE);
|
2018-05-13 23:46:10 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->canvas, 1, 1, 1, 1);
|
|
|
|
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->zoom_button, 2, 0, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->quick_mask_button, 0, 2, 1, 1);
|
2009-11-02 01:18:17 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->vsb, 2, 1, 1, 1);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->hsb, 1, 2, 1, 1);
|
2009-11-02 01:18:17 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->nav_ebox, 2, 2, 1, 1);
|
2009-11-02 01:18:17 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
gtk_widget_set_hexpand (shell->statusbar, TRUE);
|
|
|
|
gtk_grid_attach (GTK_GRID (grid), shell->statusbar, 0, 3, 3, 1);
|
2009-11-02 01:18:17 +08:00
|
|
|
|
2018-05-13 23:46:10 +08:00
|
|
|
/* show everything that is always shown */
|
2009-11-02 01:18:17 +08:00
|
|
|
gtk_widget_show (GTK_WIDGET (shell->canvas));
|
|
|
|
|
2016-05-14 06:56:26 +08:00
|
|
|
/* add display filters */
|
2009-11-02 01:18:17 +08:00
|
|
|
|
2016-05-14 06:56:26 +08:00
|
|
|
filter = gimp_display_shell_filter_new (shell);
|
2009-11-02 01:18:17 +08:00
|
|
|
|
|
|
|
if (filter)
|
2003-10-06 04:34:48 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_display_shell_filter_set (shell, filter);
|
|
|
|
g_object_unref (filter);
|
2003-10-06 04:34:48 +08:00
|
|
|
}
|
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
if (image)
|
2008-03-20 21:27:49 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_display_shell_connect (shell);
|
|
|
|
|
|
|
|
/* After connecting to the image we want to center it. Since we
|
2018-03-25 04:49:01 +08:00
|
|
|
* not even finished creating the display shell, we can safely
|
2009-11-02 01:18:17 +08:00
|
|
|
* assume we will get a size-allocate later.
|
|
|
|
*/
|
2018-06-28 06:52:08 +08:00
|
|
|
shell->size_allocate_center_image = TRUE;
|
2008-03-20 21:27:49 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-06-19 00:14:43 +08:00
|
|
|
#if 0
|
|
|
|
/* Disabled because it sets GDK_POINTER_MOTION_HINT on
|
|
|
|
* shell->canvas. For info see Bug 677375
|
|
|
|
*/
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_help_set_help_data (shell->canvas,
|
|
|
|
_("Drop image files here to open them"),
|
|
|
|
NULL);
|
2012-06-19 00:14:43 +08:00
|
|
|
#endif
|
2009-11-02 01:18:17 +08:00
|
|
|
|
|
|
|
gimp_statusbar_empty (GIMP_STATUSBAR (shell->statusbar));
|
2008-03-20 21:27:49 +08:00
|
|
|
}
|
2016-05-30 03:45:30 +08:00
|
|
|
|
|
|
|
/* make sure the information is up-to-date */
|
|
|
|
gimp_display_shell_scale_update (shell);
|
2009-11-02 01:18:17 +08:00
|
|
|
}
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2010-09-27 04:35:49 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
|
|
|
|
|
|
|
if (shell->display && gimp_display_get_shell (shell->display))
|
|
|
|
gimp_display_shell_disconnect (shell);
|
|
|
|
|
|
|
|
shell->popup_manager = NULL;
|
|
|
|
|
2013-06-17 02:14:35 +08:00
|
|
|
if (shell->selection)
|
|
|
|
gimp_display_shell_selection_free (shell);
|
2010-09-27 04:35:49 +08:00
|
|
|
|
|
|
|
if (shell->filter_stack)
|
|
|
|
gimp_display_shell_filter_set (shell, NULL);
|
|
|
|
|
|
|
|
if (shell->filter_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->filter_idle_id);
|
|
|
|
shell->filter_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_pointer (&shell->mask_surface, cairo_surface_destroy);
|
|
|
|
g_clear_pointer (&shell->checkerboard, cairo_pattern_destroy);
|
2010-09-29 03:10:03 +08:00
|
|
|
|
2016-05-15 05:50:58 +08:00
|
|
|
gimp_display_shell_profile_finalize (shell);
|
2015-05-27 18:28:33 +08:00
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&shell->filter_buffer);
|
|
|
|
shell->filter_data = NULL;
|
|
|
|
shell->filter_stride = 0;
|
2013-11-03 03:56:25 +08:00
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&shell->mask);
|
2010-09-27 04:35:49 +08:00
|
|
|
|
2010-10-01 23:13:00 +08:00
|
|
|
gimp_display_shell_items_free (shell);
|
2010-09-30 04:12:01 +08:00
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&shell->motion_buffer);
|
2010-09-27 04:35:49 +08:00
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_pointer (&shell->zoom_focus_pointer_queue, g_queue_free);
|
2010-09-27 04:35:49 +08:00
|
|
|
|
|
|
|
if (shell->title_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->title_idle_id);
|
|
|
|
shell->title_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (shell->fill_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->fill_idle_id);
|
|
|
|
shell->fill_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_pointer (&shell->nav_popup, gtk_widget_destroy);
|
2010-09-27 04:35:49 +08:00
|
|
|
|
2013-09-29 00:00:31 +08:00
|
|
|
if (shell->blink_timeout_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->blink_timeout_id);
|
|
|
|
shell->blink_timeout_id = 0;
|
|
|
|
}
|
|
|
|
|
2010-09-27 04:35:49 +08:00
|
|
|
shell->display = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&shell->zoom);
|
|
|
|
g_clear_pointer (&shell->rotate_transform, g_free);
|
|
|
|
g_clear_pointer (&shell->rotate_untransform, g_free);
|
|
|
|
g_clear_object (&shell->options);
|
|
|
|
g_clear_object (&shell->fullscreen_options);
|
|
|
|
g_clear_object (&shell->no_image_options);
|
|
|
|
g_clear_pointer (&shell->title, g_free);
|
|
|
|
g_clear_pointer (&shell->status, g_free);
|
|
|
|
g_clear_object (&shell->icon);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
1998-06-15 10:25:27 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
2006-12-13 04:36:35 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_POPUP_MANAGER:
|
|
|
|
shell->popup_manager = g_value_get_object (value);
|
|
|
|
break;
|
2014-05-03 06:54:20 +08:00
|
|
|
case PROP_INITIAL_MONITOR:
|
2018-04-29 23:27:47 +08:00
|
|
|
shell->initial_monitor = g_value_get_object (value);
|
2014-05-03 06:54:20 +08:00
|
|
|
break;
|
2009-11-02 01:18:17 +08:00
|
|
|
case PROP_DISPLAY:
|
|
|
|
shell->display = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
case PROP_UNIT:
|
|
|
|
gimp_display_shell_set_unit (shell, g_value_get_int (value));
|
|
|
|
break;
|
|
|
|
case PROP_TITLE:
|
|
|
|
g_free (shell->title);
|
|
|
|
shell->title = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_STATUS:
|
|
|
|
g_free (shell->status);
|
|
|
|
shell->status = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
case PROP_ICON:
|
|
|
|
if (shell->icon)
|
|
|
|
g_object_unref (shell->icon);
|
|
|
|
shell->icon = g_value_dup_object (value);
|
|
|
|
break;
|
2001-07-31 01:17:36 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1998-07-20 23:07:13 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_POPUP_MANAGER:
|
|
|
|
g_value_set_object (value, shell->popup_manager);
|
|
|
|
break;
|
2014-05-03 06:54:20 +08:00
|
|
|
case PROP_INITIAL_MONITOR:
|
2018-04-29 23:27:47 +08:00
|
|
|
g_value_set_object (value, shell->initial_monitor);
|
2014-05-03 06:54:20 +08:00
|
|
|
break;
|
2009-11-02 01:18:17 +08:00
|
|
|
case PROP_DISPLAY:
|
|
|
|
g_value_set_object (value, shell->display);
|
|
|
|
break;
|
|
|
|
case PROP_UNIT:
|
|
|
|
g_value_set_int (value, shell->unit);
|
|
|
|
break;
|
|
|
|
case PROP_TITLE:
|
|
|
|
g_value_set_string (value, shell->title);
|
|
|
|
break;
|
|
|
|
case PROP_STATUS:
|
|
|
|
g_value_set_string (value, shell->status);
|
|
|
|
break;
|
|
|
|
case PROP_ICON:
|
|
|
|
g_value_set_object (value, shell->icon);
|
|
|
|
break;
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-11-11 22:50:07 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_unrealize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
|
2002-02-28 21:47:03 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (shell->nav_popup)
|
|
|
|
gtk_widget_unrealize (shell->nav_popup);
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
|
|
|
}
|
2001-11-30 00:44:51 +08:00
|
|
|
|
2018-10-22 06:00:59 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_unmap (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
|
|
|
|
|
|
|
|
gimp_display_shell_selection_undraw (shell);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (GTK_WIDGET_CLASS (parent_class)->screen_changed)
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous);
|
2009-10-07 01:20:44 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (shell->display->config->monitor_res_from_gdk)
|
|
|
|
{
|
2018-04-29 23:27:47 +08:00
|
|
|
gimp_get_monitor_resolution (gimp_widget_get_monitor (widget),
|
2014-05-03 05:56:16 +08:00
|
|
|
&shell->monitor_xres,
|
|
|
|
&shell->monitor_yres);
|
2009-11-02 01:18:17 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shell->monitor_xres = shell->display->config->monitor_xres;
|
|
|
|
shell->monitor_yres = shell->display->config->monitor_yres;
|
|
|
|
}
|
|
|
|
}
|
2001-11-10 00:54:56 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_popup_menu (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_context_set_display (gimp_get_user_context (shell->display->gimp),
|
|
|
|
shell->display);
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2018-05-02 06:44:38 +08:00
|
|
|
gimp_ui_manager_ui_popup_at_widget (shell->popup_manager,
|
|
|
|
"/dummy-menubar/image-popup",
|
|
|
|
shell->origin,
|
|
|
|
GDK_GRAVITY_EAST,
|
|
|
|
GDK_GRAVITY_NORTH_WEST,
|
|
|
|
NULL,
|
|
|
|
NULL, NULL);
|
2009-10-04 21:31:38 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
2009-10-04 21:31:38 +08:00
|
|
|
|
2014-05-31 08:36:25 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_set_priority_viewport (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
{
|
|
|
|
GimpProjection *projection = gimp_image_get_projection (image);
|
|
|
|
gint x, y;
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
|
|
|
gimp_projection_set_priority_rect (projection, x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_real_scaled (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GimpContext *user_context;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (! shell->display)
|
|
|
|
return;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
gimp_display_shell_title_update (shell);
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
user_context = gimp_get_user_context (shell->display->gimp);
|
1999-07-07 11:18:54 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (shell->display == gimp_context_get_display (user_context))
|
2014-05-31 08:36:25 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_set_priority_viewport (shell);
|
|
|
|
|
|
|
|
gimp_ui_manager_update (shell->popup_manager, shell->display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_real_scrolled (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GimpContext *user_context;
|
|
|
|
|
|
|
|
if (! shell->display)
|
|
|
|
return;
|
|
|
|
|
2015-01-29 21:05:23 +08:00
|
|
|
gimp_display_shell_title_update (shell);
|
|
|
|
|
2014-05-31 08:36:25 +08:00
|
|
|
user_context = gimp_get_user_context (shell->display->gimp);
|
|
|
|
|
|
|
|
if (shell->display == gimp_context_get_display (user_context))
|
|
|
|
{
|
|
|
|
gimp_display_shell_set_priority_viewport (shell);
|
2015-01-29 21:05:23 +08:00
|
|
|
|
2014-05-31 08:36:25 +08:00
|
|
|
}
|
2009-11-02 01:18:17 +08:00
|
|
|
}
|
2000-04-02 23:34:30 +08:00
|
|
|
|
2013-04-21 09:15:22 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_real_rotated (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GimpContext *user_context;
|
|
|
|
|
|
|
|
if (! shell->display)
|
|
|
|
return;
|
|
|
|
|
2015-01-29 21:05:23 +08:00
|
|
|
gimp_display_shell_title_update (shell);
|
|
|
|
|
2013-04-21 09:15:22 +08:00
|
|
|
user_context = gimp_get_user_context (shell->display->gimp);
|
|
|
|
|
|
|
|
if (shell->display == gimp_context_get_display (user_context))
|
2014-05-31 08:36:25 +08:00
|
|
|
{
|
|
|
|
gimp_display_shell_set_priority_viewport (shell);
|
|
|
|
|
|
|
|
gimp_ui_manager_update (shell->popup_manager, shell->display);
|
|
|
|
}
|
2013-04-21 09:15:22 +08:00
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static const guint8 *
|
|
|
|
gimp_display_shell_get_icc_profile (GimpColorManaged *managed,
|
|
|
|
gsize *len)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (managed);
|
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
2001-11-16 23:08:59 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
if (image)
|
|
|
|
return gimp_color_managed_get_icc_profile (GIMP_COLOR_MANAGED (image), len);
|
2008-04-29 17:08:53 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-03-25 17:19:11 +08:00
|
|
|
|
2015-07-11 04:43:53 +08:00
|
|
|
static GimpColorProfile *
|
2015-05-27 18:28:33 +08:00
|
|
|
gimp_display_shell_get_color_profile (GimpColorManaged *managed)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (managed);
|
|
|
|
GimpImage *image = gimp_display_get_image (shell->display);
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
return gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (image));
|
|
|
|
|
2015-09-03 07:36:02 +08:00
|
|
|
return NULL;
|
2015-05-27 18:28:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_display_shell_profile_changed (GimpColorManaged *managed)
|
|
|
|
{
|
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (managed);
|
|
|
|
|
|
|
|
gimp_display_shell_profile_update (shell);
|
|
|
|
gimp_display_shell_expose_full (shell);
|
|
|
|
}
|
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_zoom_button_callback (GimpDisplayShell *shell,
|
|
|
|
GtkWidget *zoom_button)
|
|
|
|
{
|
|
|
|
shell->zoom_on_resize =
|
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (zoom_button));
|
|
|
|
|
|
|
|
if (shell->zoom_on_resize &&
|
|
|
|
gimp_display_shell_scale_image_is_within_viewport (shell, NULL, NULL))
|
2007-11-12 17:36:45 +08:00
|
|
|
{
|
2009-11-02 01:18:17 +08:00
|
|
|
/* Implicitly make a View -> Fit Image in Window */
|
|
|
|
gimp_display_shell_scale_fit_in (shell);
|
2007-11-12 17:36:45 +08:00
|
|
|
}
|
2009-11-02 01:18:17 +08:00
|
|
|
}
|
2005-02-21 08:45:17 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_sync_config (GimpDisplayShell *shell,
|
|
|
|
GimpDisplayConfig *config)
|
|
|
|
{
|
|
|
|
gimp_config_sync (G_OBJECT (config->default_view),
|
|
|
|
G_OBJECT (shell->options), 0);
|
|
|
|
gimp_config_sync (G_OBJECT (config->default_fullscreen_view),
|
|
|
|
G_OBJECT (shell->fullscreen_options), 0);
|
|
|
|
}
|
2001-11-11 03:10:28 +08:00
|
|
|
|
2018-05-22 07:59:26 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_overlay_allocate (GtkWidget *child,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpDisplayShellOverlay *overlay)
|
|
|
|
{
|
|
|
|
gdouble x, y;
|
|
|
|
|
|
|
|
gimp_display_shell_transform_overlay (overlay->shell, child, &x, &y);
|
|
|
|
|
|
|
|
gimp_overlay_box_set_child_position (GIMP_OVERLAY_BOX (overlay->shell->canvas),
|
|
|
|
child, x, y);
|
|
|
|
}
|
|
|
|
|
2010-02-20 21:52:37 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_remove_overlay (GtkWidget *canvas,
|
|
|
|
GtkWidget *child,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
2018-05-22 07:59:26 +08:00
|
|
|
GimpDisplayShellOverlay *overlay;
|
|
|
|
|
|
|
|
overlay = g_object_get_data (G_OBJECT (child), "image-coords-overlay");
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (child,
|
|
|
|
gimp_display_shell_overlay_allocate,
|
|
|
|
overlay);
|
|
|
|
|
2010-02-20 21:52:37 +08:00
|
|
|
shell->children = g_list_remove (shell->children, child);
|
|
|
|
}
|
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
static void
|
|
|
|
gimp_display_shell_transform_overlay (GimpDisplayShell *shell,
|
|
|
|
GtkWidget *child,
|
|
|
|
gdouble *x,
|
|
|
|
gdouble *y)
|
|
|
|
{
|
|
|
|
GimpDisplayShellOverlay *overlay;
|
|
|
|
GtkRequisition requisition;
|
|
|
|
|
|
|
|
overlay = g_object_get_data (G_OBJECT (child), "image-coords-overlay");
|
|
|
|
|
|
|
|
gimp_display_shell_transform_xy_f (shell,
|
|
|
|
overlay->image_x,
|
|
|
|
overlay->image_y,
|
2010-09-23 16:50:39 +08:00
|
|
|
x, y);
|
2010-02-28 21:48:47 +08:00
|
|
|
|
2010-10-19 18:11:59 +08:00
|
|
|
gtk_widget_get_preferred_size (child, &requisition, NULL);
|
2010-02-28 21:48:47 +08:00
|
|
|
|
|
|
|
switch (overlay->anchor)
|
|
|
|
{
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_CENTER:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x -= requisition.width / 2;
|
|
|
|
*y -= requisition.height / 2;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_NORTH:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x -= requisition.width / 2;
|
|
|
|
*y += overlay->spacing_y;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_NORTH_WEST:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x += overlay->spacing_x;
|
|
|
|
*y += overlay->spacing_y;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_NORTH_EAST:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x -= requisition.width + overlay->spacing_x;
|
|
|
|
*y += overlay->spacing_y;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_SOUTH:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x -= requisition.width / 2;
|
|
|
|
*y -= requisition.height + overlay->spacing_y;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_SOUTH_WEST:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x += overlay->spacing_x;
|
|
|
|
*y -= requisition.height + overlay->spacing_y;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_SOUTH_EAST:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x -= requisition.width + overlay->spacing_x;
|
|
|
|
*y -= requisition.height + overlay->spacing_y;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_WEST:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x += overlay->spacing_x;
|
|
|
|
*y -= requisition.height / 2;
|
|
|
|
break;
|
|
|
|
|
2010-10-18 18:50:17 +08:00
|
|
|
case GIMP_HANDLE_ANCHOR_EAST:
|
2010-02-28 21:48:47 +08:00
|
|
|
*x -= requisition.width + overlay->spacing_x;
|
|
|
|
*y -= requisition.height / 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-01 01:24:47 +08:00
|
|
|
|
2009-11-02 01:18:17 +08:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GtkWidget *
|
2014-05-03 06:54:20 +08:00
|
|
|
gimp_display_shell_new (GimpDisplay *display,
|
|
|
|
GimpUnit unit,
|
|
|
|
gdouble scale,
|
|
|
|
GimpUIManager *popup_manager,
|
2018-04-29 23:27:47 +08:00
|
|
|
GdkMonitor *monitor)
|
2009-11-02 01:18:17 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_UI_MANAGER (popup_manager), NULL);
|
2018-04-29 23:27:47 +08:00
|
|
|
g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL);
|
2009-11-02 01:18:17 +08:00
|
|
|
|
|
|
|
return g_object_new (GIMP_TYPE_DISPLAY_SHELL,
|
2014-05-03 06:54:20 +08:00
|
|
|
"popup-manager", popup_manager,
|
|
|
|
"initial-monitor", monitor,
|
|
|
|
"display", display,
|
|
|
|
"unit", unit,
|
2009-11-02 01:18:17 +08:00
|
|
|
NULL);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
2010-02-20 21:52:37 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_add_overlay (GimpDisplayShell *shell,
|
|
|
|
GtkWidget *child,
|
|
|
|
gdouble image_x,
|
2010-02-28 21:48:47 +08:00
|
|
|
gdouble image_y,
|
2010-10-18 18:50:17 +08:00
|
|
|
GimpHandleAnchor anchor,
|
2010-02-28 21:48:47 +08:00
|
|
|
gint spacing_x,
|
|
|
|
gint spacing_y)
|
2010-02-20 21:52:37 +08:00
|
|
|
{
|
2010-02-28 21:48:47 +08:00
|
|
|
GimpDisplayShellOverlay *overlay;
|
|
|
|
gdouble x, y;
|
2010-02-20 21:52:37 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (shell));
|
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
overlay = g_new0 (GimpDisplayShellOverlay, 1);
|
2010-02-20 21:52:37 +08:00
|
|
|
|
2018-05-22 07:59:26 +08:00
|
|
|
overlay->shell = shell;
|
2010-02-28 21:48:47 +08:00
|
|
|
overlay->image_x = image_x;
|
|
|
|
overlay->image_y = image_y;
|
|
|
|
overlay->anchor = anchor;
|
|
|
|
overlay->spacing_x = spacing_x;
|
|
|
|
overlay->spacing_y = spacing_y;
|
2010-02-20 21:52:37 +08:00
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
g_object_set_data_full (G_OBJECT (child), "image-coords-overlay", overlay,
|
2010-02-20 21:52:37 +08:00
|
|
|
(GDestroyNotify) g_free);
|
|
|
|
|
|
|
|
shell->children = g_list_prepend (shell->children, child);
|
|
|
|
|
2018-05-22 07:59:26 +08:00
|
|
|
g_signal_connect (child, "size-allocate",
|
|
|
|
G_CALLBACK (gimp_display_shell_overlay_allocate),
|
|
|
|
overlay);
|
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
gimp_display_shell_transform_overlay (shell, child, &x, &y);
|
2010-02-20 21:52:37 +08:00
|
|
|
|
|
|
|
gimp_overlay_box_add_child (GIMP_OVERLAY_BOX (shell->canvas), child, 0.0, 0.0);
|
|
|
|
gimp_overlay_box_set_child_position (GIMP_OVERLAY_BOX (shell->canvas),
|
|
|
|
child, x, y);
|
|
|
|
}
|
|
|
|
|
2010-02-26 07:09:54 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_move_overlay (GimpDisplayShell *shell,
|
|
|
|
GtkWidget *child,
|
|
|
|
gdouble image_x,
|
2010-02-28 21:48:47 +08:00
|
|
|
gdouble image_y,
|
2010-10-18 18:50:17 +08:00
|
|
|
GimpHandleAnchor anchor,
|
2010-02-28 21:48:47 +08:00
|
|
|
gint spacing_x,
|
|
|
|
gint spacing_y)
|
2010-02-26 07:09:54 +08:00
|
|
|
{
|
2010-02-28 21:48:47 +08:00
|
|
|
GimpDisplayShellOverlay *overlay;
|
|
|
|
gdouble x, y;
|
2010-02-26 07:09:54 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (shell));
|
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
overlay = g_object_get_data (G_OBJECT (child), "image-coords-overlay");
|
2010-02-26 07:09:54 +08:00
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
g_return_if_fail (overlay != NULL);
|
2010-02-26 07:09:54 +08:00
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
overlay->image_x = image_x;
|
|
|
|
overlay->image_y = image_y;
|
|
|
|
overlay->anchor = anchor;
|
|
|
|
overlay->spacing_x = spacing_x;
|
|
|
|
overlay->spacing_y = spacing_y;
|
2010-02-26 07:09:54 +08:00
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
gimp_display_shell_transform_overlay (shell, child, &x, &y);
|
2010-02-26 07:09:54 +08:00
|
|
|
|
|
|
|
gimp_overlay_box_set_child_position (GIMP_OVERLAY_BOX (shell->canvas),
|
|
|
|
child, x, y);
|
|
|
|
}
|
|
|
|
|
2009-09-29 05:53:05 +08:00
|
|
|
GimpImageWindow *
|
|
|
|
gimp_display_shell_get_window (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
|
|
|
|
|
|
|
return GIMP_IMAGE_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (shell),
|
|
|
|
GIMP_TYPE_IMAGE_WINDOW));
|
|
|
|
}
|
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
GimpStatusbar *
|
|
|
|
gimp_display_shell_get_statusbar (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
|
|
|
|
|
|
|
return GIMP_STATUSBAR (shell->statusbar);
|
|
|
|
}
|
|
|
|
|
2016-05-14 06:56:26 +08:00
|
|
|
GimpColorConfig *
|
|
|
|
gimp_display_shell_get_color_config (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
|
|
|
|
|
|
|
return shell->color_config;
|
|
|
|
}
|
|
|
|
|
2009-10-05 01:24:55 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_present (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
GimpImageWindow *window;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
window = gimp_display_shell_get_window (shell);
|
|
|
|
|
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
gimp_image_window_set_active_shell (window, shell);
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (window));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_reconnect (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
|
2009-10-07 01:20:44 +08:00
|
|
|
g_return_if_fail (gimp_display_get_image (shell->display) != NULL);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2008-03-20 18:37:43 +08:00
|
|
|
if (shell->fill_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->fill_idle_id);
|
|
|
|
shell->fill_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2004-07-29 00:16:39 +08:00
|
|
|
g_signal_emit (shell, display_shell_signals[RECONNECT], 0);
|
|
|
|
|
2007-08-07 03:23:22 +08:00
|
|
|
gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (shell));
|
|
|
|
|
2008-08-14 23:55:56 +08:00
|
|
|
gimp_display_shell_scroll_clamp_and_update (shell);
|
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
gimp_display_shell_scaled (shell);
|
|
|
|
|
2004-03-22 21:12:07 +08:00
|
|
|
gimp_display_shell_expose_full (shell);
|
2008-03-20 00:15:50 +08:00
|
|
|
}
|
|
|
|
|
2013-09-29 00:00:31 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_blink (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
shell->blink_timeout_id = 0;
|
|
|
|
|
|
|
|
if (shell->blink)
|
|
|
|
{
|
|
|
|
shell->blink = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shell->blink = TRUE;
|
|
|
|
|
|
|
|
shell->blink_timeout_id =
|
|
|
|
g_timeout_add (100, (GSourceFunc) gimp_display_shell_blink, shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_expose_full (shell);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_empty (GimpDisplayShell *shell)
|
|
|
|
{
|
2013-07-03 18:44:53 +08:00
|
|
|
GimpContext *user_context;
|
|
|
|
GimpImageWindow *window;
|
2008-03-23 21:40:39 +08:00
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
|
2009-10-07 01:20:44 +08:00
|
|
|
g_return_if_fail (gimp_display_get_image (shell->display) == NULL);
|
2008-03-20 00:15:50 +08:00
|
|
|
|
2013-07-03 18:44:53 +08:00
|
|
|
window = gimp_display_shell_get_window (shell);
|
|
|
|
|
2008-03-20 18:37:43 +08:00
|
|
|
if (shell->fill_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->fill_idle_id);
|
|
|
|
shell->fill_idle_id = 0;
|
|
|
|
}
|
|
|
|
|
2010-10-10 02:23:05 +08:00
|
|
|
gimp_display_shell_selection_undraw (shell);
|
2008-03-20 00:15:50 +08:00
|
|
|
|
2008-03-31 00:09:55 +08:00
|
|
|
gimp_display_shell_unset_cursor (shell);
|
2008-03-20 06:18:54 +08:00
|
|
|
|
2017-11-13 01:09:02 +08:00
|
|
|
gimp_display_shell_filter_set (shell, NULL);
|
|
|
|
|
2012-11-12 07:57:43 +08:00
|
|
|
gimp_display_shell_sync_config (shell, shell->display->config);
|
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
gimp_display_shell_appearance_update (shell);
|
2013-07-03 18:44:53 +08:00
|
|
|
gimp_image_window_update_tabs (window);
|
2012-06-19 00:14:43 +08:00
|
|
|
#if 0
|
2008-03-27 02:26:13 +08:00
|
|
|
gimp_help_set_help_data (shell->canvas,
|
|
|
|
_("Drop image files here to open them"), NULL);
|
2012-06-19 00:14:43 +08:00
|
|
|
#endif
|
2008-03-26 21:49:27 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
gimp_statusbar_empty (GIMP_STATUSBAR (shell->statusbar));
|
|
|
|
|
2015-11-14 01:51:32 +08:00
|
|
|
shell->flip_horizontally = FALSE;
|
|
|
|
shell->flip_vertically = FALSE;
|
|
|
|
shell->rotate_angle = 0.0;
|
2013-04-21 08:46:17 +08:00
|
|
|
gimp_display_shell_rotate_update_transform (shell);
|
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
gimp_display_shell_expose_full (shell);
|
2008-03-23 21:40:39 +08:00
|
|
|
|
2008-04-06 04:32:24 +08:00
|
|
|
user_context = gimp_get_user_context (shell->display->gimp);
|
|
|
|
|
|
|
|
if (shell->display == gimp_context_get_display (user_context))
|
|
|
|
gimp_ui_manager_update (shell->popup_manager, shell->display);
|
2013-09-29 00:00:31 +08:00
|
|
|
|
|
|
|
shell->blink_timeout_id =
|
|
|
|
g_timeout_add (1403230, (GSourceFunc) gimp_display_shell_blink, shell);
|
2008-03-20 00:15:50 +08:00
|
|
|
}
|
|
|
|
|
2008-03-20 18:37:43 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_display_shell_fill_idle (GimpDisplayShell *shell)
|
|
|
|
{
|
2009-09-25 23:49:50 +08:00
|
|
|
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (shell));
|
|
|
|
|
2008-03-20 18:37:43 +08:00
|
|
|
shell->fill_idle_id = 0;
|
|
|
|
|
2009-09-30 02:32:26 +08:00
|
|
|
if (GTK_IS_WINDOW (toplevel))
|
|
|
|
{
|
|
|
|
gimp_display_shell_scale_shrink_wrap (shell, TRUE);
|
2008-03-20 18:37:43 +08:00
|
|
|
|
2009-09-30 02:32:26 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (toplevel));
|
|
|
|
}
|
2008-03-22 05:15:21 +08:00
|
|
|
|
2008-03-20 18:37:43 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_fill (GimpDisplayShell *shell,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpUnit unit,
|
|
|
|
gdouble scale)
|
|
|
|
{
|
2016-05-30 03:45:30 +08:00
|
|
|
GimpDisplayConfig *config;
|
|
|
|
GimpImageWindow *window;
|
2013-07-03 18:44:53 +08:00
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (image));
|
|
|
|
|
2016-05-30 03:45:30 +08:00
|
|
|
config = shell->display->config;
|
2013-07-03 18:44:53 +08:00
|
|
|
window = gimp_display_shell_get_window (shell);
|
|
|
|
|
2016-05-30 03:45:30 +08:00
|
|
|
shell->dot_for_dot = config->default_dot_for_dot;
|
|
|
|
|
2008-03-20 00:15:50 +08:00
|
|
|
gimp_display_shell_set_unit (shell, unit);
|
2008-07-13 14:25:23 +08:00
|
|
|
gimp_display_shell_set_initial_scale (shell, scale, NULL, NULL);
|
2016-05-30 03:45:30 +08:00
|
|
|
gimp_display_shell_scale_update (shell);
|
2008-03-20 00:15:50 +08:00
|
|
|
|
2016-05-30 03:45:30 +08:00
|
|
|
gimp_display_shell_sync_config (shell, config);
|
2009-06-06 04:21:19 +08:00
|
|
|
|
2016-01-11 08:50:29 +08:00
|
|
|
gimp_image_window_suspend_keep_pos (window);
|
2008-03-20 00:15:50 +08:00
|
|
|
gimp_display_shell_appearance_update (shell);
|
2016-01-11 08:50:29 +08:00
|
|
|
gimp_image_window_resume_keep_pos (window);
|
|
|
|
|
2013-07-03 18:44:53 +08:00
|
|
|
gimp_image_window_update_tabs (window);
|
2012-06-19 00:14:43 +08:00
|
|
|
#if 0
|
2008-03-26 21:49:27 +08:00
|
|
|
gimp_help_set_help_data (shell->canvas, NULL, NULL);
|
2012-06-19 00:14:43 +08:00
|
|
|
#endif
|
2008-03-26 21:49:27 +08:00
|
|
|
|
2009-10-04 21:31:38 +08:00
|
|
|
gimp_statusbar_fill (GIMP_STATUSBAR (shell->statusbar));
|
|
|
|
|
2008-08-17 02:25:32 +08:00
|
|
|
/* A size-allocate will always occur because the scrollbars will
|
|
|
|
* become visible forcing the canvas to become smaller
|
|
|
|
*/
|
2018-06-28 06:52:08 +08:00
|
|
|
shell->size_allocate_center_image = TRUE;
|
2008-07-14 04:23:15 +08:00
|
|
|
|
2013-09-29 00:00:31 +08:00
|
|
|
if (shell->blink_timeout_id)
|
|
|
|
{
|
|
|
|
g_source_remove (shell->blink_timeout_id);
|
|
|
|
shell->blink_timeout_id = 0;
|
|
|
|
}
|
|
|
|
|
2012-12-16 02:27:16 +08:00
|
|
|
shell->fill_idle_id =
|
2014-07-02 10:47:24 +08:00
|
|
|
g_idle_add_full (GIMP_PRIORITY_DISPLAY_SHELL_FILL_IDLE,
|
2012-12-16 02:27:16 +08:00
|
|
|
(GSourceFunc) gimp_display_shell_fill_idle, shell,
|
|
|
|
NULL);
|
2001-11-11 07:03:22 +08:00
|
|
|
}
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_scaled (GimpDisplayShell *shell)
|
|
|
|
{
|
2010-02-20 21:52:37 +08:00
|
|
|
GList *list;
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2013-04-19 22:22:19 +08:00
|
|
|
gimp_display_shell_rotate_update_transform (shell);
|
|
|
|
|
2010-02-20 21:52:37 +08:00
|
|
|
for (list = shell->children; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GtkWidget *child = list->data;
|
|
|
|
gdouble x, y;
|
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
gimp_display_shell_transform_overlay (shell, child, &x, &y);
|
2010-02-20 21:52:37 +08:00
|
|
|
|
|
|
|
gimp_overlay_box_set_child_position (GIMP_OVERLAY_BOX (shell->canvas),
|
|
|
|
child, x, y);
|
|
|
|
}
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (shell, display_shell_signals[SCALED], 0);
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_display_shell_scrolled (GimpDisplayShell *shell)
|
|
|
|
{
|
2010-02-20 21:52:37 +08:00
|
|
|
GList *list;
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2013-04-19 22:22:19 +08:00
|
|
|
gimp_display_shell_rotate_update_transform (shell);
|
|
|
|
|
2010-02-20 21:52:37 +08:00
|
|
|
for (list = shell->children; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GtkWidget *child = list->data;
|
|
|
|
gdouble x, y;
|
|
|
|
|
2010-02-28 21:48:47 +08:00
|
|
|
gimp_display_shell_transform_overlay (shell, child, &x, &y);
|
2010-02-20 21:52:37 +08:00
|
|
|
|
|
|
|
gimp_overlay_box_set_child_position (GIMP_OVERLAY_BOX (shell->canvas),
|
|
|
|
child, x, y);
|
|
|
|
}
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (shell, display_shell_signals[SCROLLED], 0);
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
|
|
|
|
2013-04-21 09:15:22 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_rotated (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
gimp_display_shell_rotate_update_transform (shell);
|
|
|
|
|
|
|
|
g_signal_emit (shell, display_shell_signals[ROTATED], 0);
|
|
|
|
}
|
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_set_unit (GimpDisplayShell *shell,
|
|
|
|
GimpUnit unit)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
if (shell->unit != unit)
|
|
|
|
{
|
|
|
|
shell->unit = unit;
|
|
|
|
|
2016-01-06 01:02:59 +08:00
|
|
|
gimp_display_shell_rulers_update (shell);
|
2008-08-14 23:55:56 +08:00
|
|
|
|
2004-06-02 06:04:20 +08:00
|
|
|
gimp_display_shell_scaled (shell);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (shell), "unit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-09 07:05:58 +08:00
|
|
|
GimpUnit
|
|
|
|
gimp_display_shell_get_unit (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), GIMP_UNIT_PIXEL);
|
|
|
|
|
|
|
|
return shell->unit;
|
|
|
|
}
|
|
|
|
|
2004-02-24 02:23:31 +08:00
|
|
|
gboolean
|
2003-04-17 10:57:33 +08:00
|
|
|
gimp_display_shell_snap_coords (GimpDisplayShell *shell,
|
|
|
|
GimpCoords *coords,
|
|
|
|
gint snap_offset_x,
|
|
|
|
gint snap_offset_y,
|
|
|
|
gint snap_width,
|
|
|
|
gint snap_height)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2008-01-29 00:00:30 +08:00
|
|
|
GimpImage *image;
|
|
|
|
gboolean snap_to_guides = FALSE;
|
|
|
|
gboolean snap_to_grid = FALSE;
|
|
|
|
gboolean snap_to_canvas = FALSE;
|
|
|
|
gboolean snap_to_vectors = FALSE;
|
|
|
|
gboolean snapped = FALSE;
|
2003-06-24 03:34:48 +08:00
|
|
|
|
2004-02-24 02:23:31 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
|
|
|
|
g_return_val_if_fail (coords != NULL, FALSE);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (shell->display);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2005-01-04 00:19:10 +08:00
|
|
|
if (gimp_display_shell_get_snap_to_guides (shell) &&
|
2008-01-29 00:00:30 +08:00
|
|
|
gimp_image_get_guides (image))
|
2003-06-24 03:34:48 +08:00
|
|
|
{
|
|
|
|
snap_to_guides = TRUE;
|
|
|
|
}
|
2003-07-18 06:30:13 +08:00
|
|
|
|
2003-08-13 02:02:55 +08:00
|
|
|
if (gimp_display_shell_get_snap_to_grid (shell) &&
|
2008-01-29 00:00:30 +08:00
|
|
|
gimp_image_get_grid (image))
|
2003-06-24 03:34:48 +08:00
|
|
|
{
|
|
|
|
snap_to_grid = TRUE;
|
|
|
|
}
|
|
|
|
|
2005-01-04 00:19:10 +08:00
|
|
|
snap_to_canvas = gimp_display_shell_get_snap_to_canvas (shell);
|
|
|
|
|
|
|
|
if (gimp_display_shell_get_snap_to_vectors (shell) &&
|
2008-01-29 00:00:30 +08:00
|
|
|
gimp_image_get_active_vectors (image))
|
2005-01-04 00:19:10 +08:00
|
|
|
{
|
|
|
|
snap_to_vectors = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (snap_to_guides || snap_to_grid || snap_to_canvas || snap_to_vectors)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2004-02-24 02:23:31 +08:00
|
|
|
gint snap_distance;
|
2008-01-29 00:00:30 +08:00
|
|
|
gdouble tx, ty;
|
2004-02-19 04:31:11 +08:00
|
|
|
|
2008-03-19 05:22:21 +08:00
|
|
|
snap_distance = shell->display->config->snap_distance;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-04-17 10:57:33 +08:00
|
|
|
if (snap_width > 0 && snap_height > 0)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
snapped = gimp_image_snap_rectangle (image,
|
2003-05-05 19:26:01 +08:00
|
|
|
coords->x + snap_offset_x,
|
|
|
|
coords->y + snap_offset_y,
|
|
|
|
coords->x + snap_offset_x +
|
|
|
|
snap_width,
|
|
|
|
coords->y + snap_offset_y +
|
|
|
|
snap_height,
|
|
|
|
&tx,
|
2003-06-24 03:34:48 +08:00
|
|
|
&ty,
|
2004-02-19 04:31:11 +08:00
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance),
|
2003-06-24 03:34:48 +08:00
|
|
|
snap_to_guides,
|
2005-01-04 00:19:10 +08:00
|
|
|
snap_to_grid,
|
|
|
|
snap_to_canvas,
|
|
|
|
snap_to_vectors);
|
2003-04-17 10:57:33 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
snapped = gimp_image_snap_point (image,
|
2003-05-05 19:26:01 +08:00
|
|
|
coords->x + snap_offset_x,
|
|
|
|
coords->y + snap_offset_y,
|
|
|
|
&tx,
|
2003-06-24 03:34:48 +08:00
|
|
|
&ty,
|
2004-02-19 04:31:11 +08:00
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance),
|
2003-06-24 03:34:48 +08:00
|
|
|
snap_to_guides,
|
2005-01-04 00:19:10 +08:00
|
|
|
snap_to_grid,
|
|
|
|
snap_to_canvas,
|
|
|
|
snap_to_vectors);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
2003-03-20 19:31:33 +08:00
|
|
|
|
2003-05-05 19:26:01 +08:00
|
|
|
if (snapped)
|
|
|
|
{
|
2008-01-29 00:00:30 +08:00
|
|
|
coords->x = tx - snap_offset_x;
|
|
|
|
coords->y = ty - snap_offset_y;
|
2003-05-05 19:26:01 +08:00
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
2004-02-24 02:23:31 +08:00
|
|
|
|
|
|
|
return snapped;
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
|
2015-07-02 07:53:46 +08:00
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image;
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpLayer *layer;
|
2015-07-02 07:53:46 +08:00
|
|
|
gint x1, y1;
|
|
|
|
gint x2, y2;
|
2012-02-21 23:01:53 +08:00
|
|
|
gdouble x1_f, y1_f;
|
|
|
|
gdouble x2_f, y2_f;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
|
2015-07-02 07:53:46 +08:00
|
|
|
g_return_val_if_fail (x != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (y != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (width != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (height != NULL, FALSE);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (shell->display);
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
/* If there is a floating selection, handle things differently */
|
2009-10-07 01:20:44 +08:00
|
|
|
if ((layer = gimp_image_get_floating_selection (image)))
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2015-07-02 07:53:46 +08:00
|
|
|
gint fs_x;
|
|
|
|
gint fs_y;
|
|
|
|
gint fs_width;
|
|
|
|
gint fs_height;
|
2005-11-14 07:35:33 +08:00
|
|
|
|
2015-07-02 07:53:46 +08:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (layer), &fs_x, &fs_y);
|
|
|
|
fs_width = gimp_item_get_width (GIMP_ITEM (layer));
|
|
|
|
fs_height = gimp_item_get_height (GIMP_ITEM (layer));
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2015-07-02 07:53:46 +08:00
|
|
|
if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
|
|
|
|
x, y, width, height))
|
2004-07-14 18:31:59 +08:00
|
|
|
{
|
2015-07-02 07:53:46 +08:00
|
|
|
*x = fs_x;
|
|
|
|
*y = fs_y;
|
|
|
|
*width = fs_width;
|
|
|
|
*height = fs_height;
|
2004-07-14 18:31:59 +08:00
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
else
|
2004-07-14 18:31:59 +08:00
|
|
|
{
|
2015-07-02 07:53:46 +08:00
|
|
|
gimp_rectangle_union (*x, *y, *width, *height,
|
|
|
|
fs_x, fs_y, fs_width, fs_height,
|
|
|
|
x, y, width, height);
|
2004-07-14 18:31:59 +08:00
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
2015-07-02 07:53:46 +08:00
|
|
|
else if (! gimp_item_bounds (GIMP_ITEM (gimp_image_get_mask (image)),
|
|
|
|
x, y, width, height))
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-07-02 07:53:46 +08:00
|
|
|
x1 = *x;
|
|
|
|
y1 = *y;
|
|
|
|
x2 = *x + *width;
|
|
|
|
y2 = *y + *height;
|
|
|
|
|
2015-07-02 05:58:29 +08:00
|
|
|
gimp_display_shell_transform_bounds (shell,
|
2015-07-02 07:53:46 +08:00
|
|
|
x1, y1, x2, y2,
|
2015-07-02 05:58:29 +08:00
|
|
|
&x1_f, &y1_f, &x2_f, &y2_f);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
/* Make sure the extents are within bounds */
|
2015-07-02 07:53:46 +08:00
|
|
|
x1 = CLAMP (floor (x1_f), 0, shell->disp_width);
|
|
|
|
y1 = CLAMP (floor (y1_f), 0, shell->disp_height);
|
|
|
|
x2 = CLAMP (ceil (x2_f), 0, shell->disp_width);
|
|
|
|
y2 = CLAMP (ceil (y2_f), 0, shell->disp_height);
|
|
|
|
|
|
|
|
*x = x1;
|
|
|
|
*y = y1;
|
|
|
|
*width = x2 - x1;
|
|
|
|
*height = y2 - y1;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2015-07-02 07:53:46 +08:00
|
|
|
return (*width > 0) && (*height > 0);
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-07-01 22:19:54 +08:00
|
|
|
gimp_display_shell_flush (GimpDisplayShell *shell)
|
2001-11-01 05:20:09 +08:00
|
|
|
{
|
2018-07-01 22:19:54 +08:00
|
|
|
GimpImageWindow *window;
|
|
|
|
GimpContext *context;
|
|
|
|
|
2001-11-01 05:20:09 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2018-07-01 22:19:54 +08:00
|
|
|
window = gimp_display_shell_get_window (shell);
|
2004-07-14 00:36:29 +08:00
|
|
|
|
2018-07-01 22:19:54 +08:00
|
|
|
gimp_display_shell_title_update (shell);
|
2014-04-22 05:57:57 +08:00
|
|
|
|
2018-07-01 22:19:54 +08:00
|
|
|
gimp_canvas_layer_boundary_set_layer (GIMP_CANVAS_LAYER_BOUNDARY (shell->layer_boundary),
|
|
|
|
gimp_image_get_active_layer (gimp_display_get_image (shell->display)));
|
2014-04-22 05:57:57 +08:00
|
|
|
|
2018-07-01 22:19:54 +08:00
|
|
|
if (window && gimp_image_window_get_active_shell (window) == shell)
|
|
|
|
{
|
|
|
|
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
2009-09-30 03:44:43 +08:00
|
|
|
|
2018-07-01 22:19:54 +08:00
|
|
|
gimp_ui_manager_update (manager, shell->display);
|
|
|
|
}
|
2004-07-14 00:36:29 +08:00
|
|
|
|
2018-07-01 22:19:54 +08:00
|
|
|
context = gimp_get_user_context (shell->display->gimp);
|
2004-07-14 00:36:29 +08:00
|
|
|
|
2018-07-01 22:19:54 +08:00
|
|
|
if (shell->display == gimp_context_get_display (context))
|
|
|
|
{
|
|
|
|
gimp_ui_manager_update (shell->popup_manager, shell->display);
|
2004-07-14 00:36:29 +08:00
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
}
|
|
|
|
|
2004-07-16 07:02:52 +08:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_pause:
|
|
|
|
* @shell: a display shell
|
|
|
|
*
|
|
|
|
* This function increments the pause count or the display shell.
|
2004-07-16 18:07:30 +08:00
|
|
|
* If it was zero coming in, then the function pauses the active tool,
|
|
|
|
* so that operations on the display can take place without corrupting
|
|
|
|
* anything that the tool has drawn. It "undraws" the current tool
|
|
|
|
* drawing, and must be followed by gimp_display_shell_resume() after
|
2004-07-16 07:02:52 +08:00
|
|
|
* the operation in question is completed.
|
|
|
|
**/
|
2003-09-12 06:24:30 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_pause (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
|
|
|
shell->paused_count++;
|
|
|
|
|
|
|
|
if (shell->paused_count == 1)
|
|
|
|
{
|
|
|
|
/* pause the currently active tool */
|
2008-03-19 05:22:21 +08:00
|
|
|
tool_manager_control_active (shell->display->gimp,
|
2006-05-22 05:12:01 +08:00
|
|
|
GIMP_TOOL_ACTION_PAUSE,
|
2006-03-29 01:55:52 +08:00
|
|
|
shell->display);
|
2003-09-12 06:24:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-16 07:02:52 +08:00
|
|
|
/**
|
2004-07-22 20:05:36 +08:00
|
|
|
* gimp_display_shell_resume:
|
2004-07-16 07:02:52 +08:00
|
|
|
* @shell: a display shell
|
|
|
|
*
|
|
|
|
* This function decrements the pause count for the display shell.
|
|
|
|
* If this brings it to zero, then the current tool is resumed.
|
|
|
|
* It is an error to call this function without having previously
|
|
|
|
* called gimp_display_shell_pause().
|
|
|
|
**/
|
2003-09-12 06:24:30 +08:00
|
|
|
void
|
|
|
|
gimp_display_shell_resume (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (shell->paused_count > 0);
|
|
|
|
|
|
|
|
shell->paused_count--;
|
|
|
|
|
|
|
|
if (shell->paused_count == 0)
|
|
|
|
{
|
|
|
|
/* start the currently active tool */
|
2008-03-19 05:22:21 +08:00
|
|
|
tool_manager_control_active (shell->display->gimp,
|
2006-05-22 05:12:01 +08:00
|
|
|
GIMP_TOOL_ACTION_RESUME,
|
2006-03-29 01:55:52 +08:00
|
|
|
shell->display);
|
2003-09-12 06:24:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-01 17:50:04 +08:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_set_highlight:
|
|
|
|
* @shell: a #GimpDisplayShell
|
|
|
|
* @highlight: a rectangle in image coordinates that should be brought out
|
2017-12-13 23:01:48 +08:00
|
|
|
* @opacity: how much to hide the unselected area
|
2004-10-01 17:50:04 +08:00
|
|
|
*
|
2012-11-11 22:50:25 +08:00
|
|
|
* This function sets an area of the image that should be
|
2004-10-01 17:50:04 +08:00
|
|
|
* accentuated. The actual implementation is to dim all pixels outside
|
|
|
|
* this rectangle. Passing %NULL for @highlight unsets the rectangle.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_display_shell_set_highlight (GimpDisplayShell *shell,
|
2017-12-13 23:01:48 +08:00
|
|
|
const GdkRectangle *highlight,
|
|
|
|
gdouble opacity)
|
2004-10-01 17:50:04 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
|
2010-11-13 02:47:51 +08:00
|
|
|
if (highlight)
|
2004-10-01 17:50:04 +08:00
|
|
|
{
|
2011-03-28 21:15:43 +08:00
|
|
|
gimp_canvas_item_begin_change (shell->passe_partout);
|
|
|
|
|
|
|
|
gimp_canvas_rectangle_set (shell->passe_partout,
|
|
|
|
highlight->x,
|
|
|
|
highlight->y,
|
|
|
|
highlight->width,
|
|
|
|
highlight->height);
|
2017-12-13 23:01:48 +08:00
|
|
|
g_object_set (shell->passe_partout, "opacity", opacity, NULL);
|
2011-03-28 21:15:43 +08:00
|
|
|
|
|
|
|
gimp_canvas_item_set_visible (shell->passe_partout, TRUE);
|
|
|
|
|
|
|
|
gimp_canvas_item_end_change (shell->passe_partout);
|
2004-10-01 17:50:04 +08:00
|
|
|
}
|
2010-11-13 02:47:51 +08:00
|
|
|
else
|
2004-10-01 17:50:04 +08:00
|
|
|
{
|
2010-11-13 02:47:51 +08:00
|
|
|
gimp_canvas_item_set_visible (shell->passe_partout, FALSE);
|
2004-10-01 17:50:04 +08:00
|
|
|
}
|
|
|
|
}
|
2005-07-31 02:19:54 +08:00
|
|
|
|
2005-07-31 06:29:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_display_shell_set_mask:
|
|
|
|
* @shell: a #GimpDisplayShell
|
|
|
|
* @mask: a #GimpDrawable (1 byte per pixel)
|
2006-03-17 21:27:08 +08:00
|
|
|
* @color: the color to use for drawing the mask
|
2014-06-12 03:33:57 +08:00
|
|
|
* @inverted: #TRUE if the mask should be drawn inverted
|
2005-07-31 06:29:02 +08:00
|
|
|
*
|
2016-02-06 04:19:17 +08:00
|
|
|
* Previews a mask originating at offset_x, offset_x. Depending on
|
|
|
|
* @inverted, pixels that are selected or not selected are tinted with
|
|
|
|
* the given color.
|
2005-07-31 06:29:02 +08:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_display_shell_set_mask (GimpDisplayShell *shell,
|
2013-06-23 04:26:46 +08:00
|
|
|
GeglBuffer *mask,
|
2016-02-06 04:19:17 +08:00
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
2014-06-12 03:33:57 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gboolean inverted)
|
2005-07-31 06:29:02 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
2013-06-23 04:26:46 +08:00
|
|
|
g_return_if_fail (mask == NULL || GEGL_IS_BUFFER (mask));
|
2010-09-29 06:10:37 +08:00
|
|
|
g_return_if_fail (mask == NULL || color != NULL);
|
2005-07-31 06:29:02 +08:00
|
|
|
|
2006-03-17 21:27:08 +08:00
|
|
|
if (mask)
|
|
|
|
g_object_ref (mask);
|
|
|
|
|
2005-07-31 06:29:02 +08:00
|
|
|
if (shell->mask)
|
|
|
|
g_object_unref (shell->mask);
|
|
|
|
|
2010-09-29 06:10:37 +08:00
|
|
|
shell->mask = mask;
|
|
|
|
|
2016-02-06 04:19:17 +08:00
|
|
|
shell->mask_offset_x = offset_x;
|
|
|
|
shell->mask_offset_y = offset_y;
|
|
|
|
|
2010-09-29 06:10:37 +08:00
|
|
|
if (mask)
|
|
|
|
shell->mask_color = *color;
|
2005-07-31 02:19:54 +08:00
|
|
|
|
2014-06-12 03:33:57 +08:00
|
|
|
shell->mask_inverted = inverted;
|
|
|
|
|
2005-07-31 02:19:54 +08:00
|
|
|
gimp_display_shell_expose_full (shell);
|
|
|
|
}
|