1999-08-13 06:21:04 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2002-05-08 00:23:14 +08:00
|
|
|
* gimpnavigationview.c
|
|
|
|
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
|
|
|
* partly based on app/nav_window
|
|
|
|
* Copyright (C) 1999 Andy Thomas <alt@gimp.org>
|
|
|
|
*
|
1999-08-13 06:21:04 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-12-14 21:52:16 +08:00
|
|
|
|
1999-09-06 08:07:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
#include "display-types.h"
|
2001-05-15 19:25:25 +08:00
|
|
|
|
2002-11-22 01:17:03 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
2002-11-19 04:50:31 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpimage.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
#include "widgets/gimpnavigationpreview.h"
|
2003-03-01 11:53:41 +08:00
|
|
|
#include "widgets/gimppreviewrenderer.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
#include "gimpdisplay.h"
|
|
|
|
#include "gimpdisplayshell.h"
|
|
|
|
#include "gimpdisplayshell-scale.h"
|
|
|
|
#include "gimpdisplayshell-scroll.h"
|
|
|
|
#include "gimpnavigationview.h"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
#define MAX_SCALE_BUF 20
|
1999-08-28 03:07:21 +08:00
|
|
|
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static void gimp_navigation_view_class_init (GimpNavigationViewClass *klass);
|
|
|
|
static void gimp_navigation_view_init (GimpNavigationView *view);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-13 07:20:21 +08:00
|
|
|
static void gimp_navigation_view_destroy (GtkObject *object);
|
|
|
|
|
|
|
|
static GtkWidget * gimp_navigation_view_new_private (GimpDisplayShell *shell,
|
|
|
|
gboolean popup);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-11 21:51:26 +08:00
|
|
|
static gboolean gimp_navigation_view_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell);
|
2002-05-08 00:23:14 +08:00
|
|
|
static void gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
static void gimp_navigation_view_zoom (GimpNavigationPreview *preview,
|
|
|
|
GimpZoomType direction,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
static void gimp_navigation_view_scroll (GimpNavigationPreview *preview,
|
|
|
|
GdkScrollDirection direction,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
|
|
|
|
static void gimp_navigation_view_zoom_adj_changed (GtkAdjustment *adj,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
|
|
|
|
static void gimp_navigation_view_zoom_out_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
static void gimp_navigation_view_zoom_in_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
static void gimp_navigation_view_zoom_100_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
static void gimp_navigation_view_zoom_fit_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
static void gimp_navigation_view_shrink_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
|
|
|
|
static void gimp_navigation_view_shell_scaled (GimpDisplayShell *shell,
|
|
|
|
GimpNavigationView *view);
|
|
|
|
static void gimp_navigation_view_shell_scrolled (GimpDisplayShell *shell,
|
|
|
|
GimpNavigationView *view);
|
2002-09-28 00:17:31 +08:00
|
|
|
static void gimp_navigation_view_shell_reconnect (GimpDisplayShell *shell,
|
|
|
|
GimpNavigationView *view);
|
2002-05-08 00:23:14 +08:00
|
|
|
static void gimp_navigation_view_update_marker (GimpNavigationView *view);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static GimpEditorClass *parent_class = NULL;
|
1999-08-13 06:21:04 +08:00
|
|
|
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
GType
|
|
|
|
gimp_navigation_view_get_type (void)
|
|
|
|
{
|
|
|
|
static GType view_type = 0;
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
if (! view_type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo view_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpNavigationViewClass),
|
|
|
|
NULL, /* base_init */
|
|
|
|
NULL, /* base_finalize */
|
|
|
|
(GClassInitFunc) gimp_navigation_view_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_navigation */
|
|
|
|
sizeof (GimpNavigationView),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_navigation_view_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
view_type = g_type_register_static (GIMP_TYPE_EDITOR,
|
|
|
|
"GimpNavigationView",
|
|
|
|
&view_info, 0);
|
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
return view_type;
|
|
|
|
}
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_class_init (GimpNavigationViewClass *klass)
|
|
|
|
{
|
2002-05-13 07:20:21 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkObjectClass *gtk_object_class;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-13 07:20:21 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
gtk_object_class = GTK_OBJECT_CLASS (klass);
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2002-05-13 07:20:21 +08:00
|
|
|
|
|
|
|
gtk_object_class->destroy = gimp_navigation_view_destroy;
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_navigation_view_init (GimpNavigationView *view)
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
|
|
|
view->shell = NULL;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-06 03:17:41 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2002-05-10 21:05:09 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (view), frame, TRUE, TRUE, 0);
|
2002-05-06 03:17:41 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2003-03-10 22:07:22 +08:00
|
|
|
view->preview = gimp_preview_new_by_types (GIMP_TYPE_NAVIGATION_PREVIEW,
|
|
|
|
GIMP_TYPE_IMAGE,
|
|
|
|
GIMP_PREVIEW_SIZE_MEDIUM, 0, TRUE);
|
|
|
|
gtk_widget_set_size_request (view->preview,
|
|
|
|
GIMP_PREVIEW_SIZE_HUGE, GIMP_PREVIEW_SIZE_HUGE);
|
|
|
|
gimp_preview_set_expand (GIMP_PREVIEW (view->preview), TRUE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), view->preview);
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_widget_show (view->preview);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->preview, "marker_changed",
|
2002-05-08 00:23:14 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_marker_changed),
|
|
|
|
view);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->preview, "zoom",
|
2002-05-08 00:23:14 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_zoom),
|
|
|
|
view);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->preview, "scroll",
|
2002-05-08 00:23:14 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_scroll),
|
|
|
|
view);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
|
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-13 07:20:21 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GimpNavigationView *view;
|
|
|
|
|
|
|
|
view = GIMP_NAVIGATION_VIEW (object);
|
|
|
|
|
|
|
|
if (view->shell)
|
|
|
|
gimp_navigation_view_set_shell (view, NULL);
|
|
|
|
|
2002-09-28 00:17:31 +08:00
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
2002-05-13 07:20:21 +08:00
|
|
|
}
|
|
|
|
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
/* public functions */
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_navigation_view_new (GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
return gimp_navigation_view_new_private (shell, FALSE);
|
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
void
|
|
|
|
gimp_navigation_view_set_shell (GimpNavigationView *view,
|
|
|
|
GimpDisplayShell *shell)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (view));
|
|
|
|
g_return_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell));
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
if (shell == view->shell)
|
|
|
|
return;
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (view->shell,
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_shell_scaled,
|
|
|
|
view);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (view->shell,
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_shell_scrolled,
|
|
|
|
view);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (view->shell,
|
2002-09-28 00:17:31 +08:00
|
|
|
gimp_navigation_view_shell_reconnect,
|
|
|
|
view);
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
|
|
|
else if (shell)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (view), TRUE);
|
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
view->shell = shell;
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
{
|
|
|
|
gimp_preview_set_viewable (GIMP_PREVIEW (view->preview),
|
|
|
|
GIMP_VIEWABLE (shell->gdisp->gimage));
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->shell, "scaled",
|
2002-05-08 00:23:14 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_shell_scaled),
|
|
|
|
view);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->shell, "scrolled",
|
2002-05-08 00:23:14 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_shell_scrolled),
|
|
|
|
view);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->shell, "reconnect",
|
2002-09-28 00:17:31 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_shell_reconnect),
|
|
|
|
view);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_shell_scaled (view->shell, view);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_preview_set_viewable (GIMP_PREVIEW (view->preview), NULL);
|
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (view), FALSE);
|
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_popup (GimpDisplayShell *shell,
|
|
|
|
GtkWidget *widget,
|
|
|
|
gint click_x,
|
|
|
|
gint click_y)
|
2002-05-06 03:17:41 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
GimpNavigationView *view;
|
2002-05-06 03:17:41 +08:00
|
|
|
GimpNavigationPreview *preview;
|
|
|
|
gint x, y;
|
|
|
|
gint x_org, y_org;
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
2002-05-06 03:17:41 +08:00
|
|
|
if (! shell->nav_popup)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2002-05-06 03:17:41 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
shell->nav_popup = gtk_window_new (GTK_WINDOW_POPUP);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (shell->nav_popup), frame);
|
2002-05-06 03:17:41 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-11-22 01:17:03 +08:00
|
|
|
view = GIMP_NAVIGATION_VIEW (gimp_navigation_view_new_private (shell,
|
|
|
|
TRUE));
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view));
|
|
|
|
gtk_widget_show (GTK_WIDGET (view));
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->preview, "button_release_event",
|
2002-05-08 00:23:14 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_button_release),
|
|
|
|
shell);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
else
|
|
|
|
{
|
2003-01-15 11:55:20 +08:00
|
|
|
view = GIMP_NAVIGATION_VIEW (GTK_BIN (GTK_BIN (shell->nav_popup)->child)->child);
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
preview = GIMP_NAVIGATION_PREVIEW (view->preview);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
|
|
|
/* decide where to put the popup */
|
|
|
|
gdk_window_get_origin (widget->window, &x_org, &y_org);
|
|
|
|
|
2002-05-10 21:05:09 +08:00
|
|
|
#define BORDER_PEN_WIDTH 3
|
2002-05-08 00:23:14 +08:00
|
|
|
|
|
|
|
x = (x_org + click_x -
|
2002-05-06 03:17:41 +08:00
|
|
|
preview->p_x -
|
2002-05-10 21:05:09 +08:00
|
|
|
0.5 * (preview->p_width - BORDER_PEN_WIDTH) -
|
|
|
|
2 * widget->style->xthickness);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
y = (y_org + click_y -
|
2002-05-06 03:17:41 +08:00
|
|
|
preview->p_y -
|
2002-05-10 21:05:09 +08:00
|
|
|
0.5 * (preview->p_height - BORDER_PEN_WIDTH) -
|
|
|
|
2 * widget->style->ythickness);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
|
|
|
/* If the popup doesn't fit into the screen, we have a problem.
|
|
|
|
* We move the popup onscreen and risk that the pointer is not
|
|
|
|
* in the square representing the viewable area anymore. Moving
|
|
|
|
* the pointer will make the image scroll by a large amount,
|
|
|
|
* but then it works as usual. Probably better than a popup that
|
|
|
|
* is completely unusable in the lower right of the screen.
|
|
|
|
*
|
|
|
|
* Warping the pointer would be another solution ...
|
|
|
|
*/
|
2002-05-10 21:05:09 +08:00
|
|
|
x = CLAMP (x, 0, (gdk_screen_width () -
|
2003-03-01 11:53:41 +08:00
|
|
|
GIMP_PREVIEW (preview)->renderer->width -
|
2002-05-10 21:05:09 +08:00
|
|
|
4 * widget->style->xthickness));
|
|
|
|
y = CLAMP (y, 0, (gdk_screen_height () -
|
2003-03-01 11:53:41 +08:00
|
|
|
GIMP_PREVIEW (preview)->renderer->height -
|
2002-05-10 21:05:09 +08:00
|
|
|
4 * widget->style->ythickness));
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_window_move (GTK_WINDOW (shell->nav_popup), x, y);
|
|
|
|
gtk_widget_show (shell->nav_popup);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
|
|
|
gdk_flush ();
|
|
|
|
|
|
|
|
/* fill in then grab pointer */
|
2002-05-10 21:05:09 +08:00
|
|
|
preview->motion_offset_x = 0.5 * (preview->p_width - BORDER_PEN_WIDTH);
|
|
|
|
preview->motion_offset_y = 0.5 * (preview->p_height - BORDER_PEN_WIDTH);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-10 21:05:09 +08:00
|
|
|
#undef BORDER_PEN_WIDTH
|
2002-05-06 03:17:41 +08:00
|
|
|
|
|
|
|
gimp_navigation_preview_grab_pointer (preview);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
1999-10-22 03:35:35 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
/* private functions */
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static GtkWidget *
|
|
|
|
gimp_navigation_view_new_private (GimpDisplayShell *shell,
|
|
|
|
gboolean popup)
|
|
|
|
{
|
|
|
|
GimpNavigationView *view;
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
g_return_val_if_fail (! shell || GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
2002-11-23 06:10:40 +08:00
|
|
|
g_return_val_if_fail (! popup || (popup && shell), NULL);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
view = g_object_new (GIMP_TYPE_NAVIGATION_VIEW, NULL);
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-11-23 06:10:40 +08:00
|
|
|
if (popup)
|
|
|
|
{
|
|
|
|
GimpDisplayConfig *config;
|
|
|
|
GimpPreview *preview;
|
|
|
|
|
|
|
|
preview = GIMP_PREVIEW (view->preview);
|
|
|
|
config = GIMP_DISPLAY_CONFIG (shell->gdisp->gimage->gimp->config);
|
|
|
|
|
|
|
|
gimp_preview_set_size (preview,
|
|
|
|
config->nav_preview_size * 3,
|
2003-03-01 11:53:41 +08:00
|
|
|
preview->renderer->border_width);
|
2002-11-23 06:10:40 +08:00
|
|
|
}
|
|
|
|
else
|
2002-05-08 00:23:14 +08:00
|
|
|
{
|
|
|
|
GtkWidget *hscale;
|
|
|
|
|
|
|
|
/* the editor buttons */
|
|
|
|
|
|
|
|
view->zoom_out_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (view),
|
|
|
|
GTK_STOCK_ZOOM_OUT,
|
|
|
|
_("Zoom out"), NULL,
|
|
|
|
G_CALLBACK (gimp_navigation_view_zoom_out_clicked),
|
|
|
|
NULL,
|
|
|
|
view);
|
|
|
|
|
|
|
|
view->zoom_in_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (view),
|
|
|
|
GTK_STOCK_ZOOM_IN,
|
|
|
|
_("Zoom in"), NULL,
|
|
|
|
G_CALLBACK (gimp_navigation_view_zoom_in_clicked),
|
|
|
|
NULL,
|
|
|
|
view);
|
|
|
|
|
|
|
|
view->zoom_100_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (view),
|
|
|
|
GTK_STOCK_ZOOM_100,
|
|
|
|
_("Zoom 1:1"), NULL,
|
|
|
|
G_CALLBACK (gimp_navigation_view_zoom_100_clicked),
|
|
|
|
NULL,
|
|
|
|
view);
|
|
|
|
|
|
|
|
view->zoom_fit_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (view),
|
|
|
|
GTK_STOCK_ZOOM_FIT,
|
|
|
|
_("Zoom to fit window"), NULL,
|
|
|
|
G_CALLBACK (gimp_navigation_view_zoom_fit_clicked),
|
|
|
|
NULL,
|
|
|
|
view);
|
|
|
|
|
|
|
|
view->shrink_wrap_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (view),
|
|
|
|
GTK_STOCK_ZOOM_FIT,
|
|
|
|
_("Shrink Wrap"), NULL,
|
|
|
|
G_CALLBACK (gimp_navigation_view_shrink_clicked),
|
|
|
|
NULL,
|
|
|
|
view);
|
|
|
|
|
|
|
|
/* the zoom scale */
|
|
|
|
|
|
|
|
view->zoom_adjustment =
|
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (0.0, -15.0, 15.0, 1.0, 1.0, 0.0));
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (view->zoom_adjustment, "value_changed",
|
2002-05-08 00:23:14 +08:00
|
|
|
G_CALLBACK (gimp_navigation_view_zoom_adj_changed),
|
|
|
|
view);
|
|
|
|
|
|
|
|
hscale = gtk_hscale_new (GTK_ADJUSTMENT (view->zoom_adjustment));
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (hscale), FALSE);
|
|
|
|
gtk_scale_set_digits (GTK_SCALE (hscale), 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (view), hscale, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hscale);
|
|
|
|
|
|
|
|
/* the zoom label */
|
|
|
|
|
|
|
|
view->zoom_label = gtk_label_new ("1:1");
|
|
|
|
gtk_box_pack_end (GTK_BOX (view), view->zoom_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (view->zoom_label);
|
2002-05-10 21:05:09 +08:00
|
|
|
|
|
|
|
/* eek */
|
|
|
|
{
|
|
|
|
GtkRequisition requisition;
|
|
|
|
|
|
|
|
gtk_widget_size_request (view->zoom_label, &requisition);
|
|
|
|
gtk_widget_set_size_request (view->zoom_label,
|
2002-11-22 01:17:03 +08:00
|
|
|
4 * requisition.width,
|
|
|
|
requisition.height);
|
2002-05-10 21:05:09 +08:00
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
if (shell)
|
|
|
|
gimp_navigation_view_set_shell (view, shell);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
return GTK_WIDGET (view);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_navigation_view_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpDisplayShell *shell)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (bevent->button == 1)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_widget_hide (shell->nav_popup);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
return FALSE;
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_marker_changed (GimpNavigationPreview *preview,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpNavigationView *view)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gdouble xratio;
|
|
|
|
gdouble yratio;
|
|
|
|
gint xoffset;
|
|
|
|
gint yoffset;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
xratio = SCALEFACTOR_X (view->shell);
|
|
|
|
yratio = SCALEFACTOR_Y (view->shell);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
xoffset = x * xratio - view->shell->offset_x;
|
|
|
|
yoffset = y * yratio - view->shell->offset_y;
|
1999-08-24 06:47:36 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_display_shell_scroll (view->shell, xoffset, yoffset);
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
2002-05-08 00:23:14 +08:00
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_zoom (GimpNavigationPreview *preview,
|
|
|
|
GimpZoomType direction,
|
|
|
|
GimpNavigationView *view)
|
|
|
|
{
|
|
|
|
if (view->shell)
|
2002-05-06 03:17:41 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_display_shell_scale (view->shell, direction);
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_scroll (GimpNavigationPreview *preview,
|
|
|
|
GdkScrollDirection direction,
|
|
|
|
GimpNavigationView *view)
|
1999-08-13 06:21:04 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
{
|
|
|
|
GtkAdjustment *adj = NULL;
|
|
|
|
gdouble value;
|
2000-12-15 06:29:49 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
adj = view->shell->hsbdata;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
adj = view->shell->vsbdata;
|
|
|
|
break;
|
|
|
|
}
|
1999-08-28 03:07:21 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
g_assert (adj != NULL);
|
2000-12-15 23:54:17 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
value = adj->value;
|
2001-11-01 05:18:57 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
switch (direction)
|
|
|
|
{
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
value -= adj->page_increment / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
value += adj->page_increment / 2;
|
|
|
|
break;
|
|
|
|
}
|
2000-12-15 23:54:17 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
value = CLAMP (value, adj->lower, adj->upper - adj->page_size);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_adjustment_set_value (adj, value);
|
|
|
|
}
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_zoom_adj_changed (GtkAdjustment *adj,
|
|
|
|
GimpNavigationView *view)
|
2002-05-06 03:17:41 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gint value;
|
|
|
|
gint scalesrc;
|
|
|
|
gint scaledest;
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
value = RINT (adj->value);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
if (value < 0)
|
|
|
|
{
|
|
|
|
scalesrc = - value + 1;
|
|
|
|
scaledest = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
scalesrc = 1;
|
|
|
|
scaledest = value + 1;
|
|
|
|
}
|
2000-12-14 21:52:16 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
g_print ("zoom_adj_changed: %d : %d (%f)\n", scaledest, scalesrc,
|
|
|
|
adj->value);
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_display_shell_scale (view->shell, (scaledest * 100) + scalesrc);
|
2002-05-06 03:17:41 +08:00
|
|
|
}
|
1999-10-21 06:15:13 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_zoom_out_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
gimp_display_shell_scale (view->shell, GIMP_ZOOM_OUT);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_zoom_in_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
gimp_display_shell_scale (view->shell, GIMP_ZOOM_IN);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_zoom_100_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
gimp_display_shell_scale (view->shell, 101);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_zoom_fit_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view)
|
2001-06-18 21:10:03 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
gimp_display_shell_scale_fit (view->shell);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_shrink_clicked (GtkWidget *widget,
|
|
|
|
GimpNavigationView *view)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->shell)
|
|
|
|
gimp_display_shell_scale_shrink_wrap (view->shell);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
1999-08-28 03:07:21 +08:00
|
|
|
static void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_shell_scaled (GimpDisplayShell *shell,
|
|
|
|
GimpNavigationView *view)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->zoom_label)
|
1999-08-28 03:07:21 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gchar scale_str[MAX_SCALE_BUF];
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
/* Update the zoom scale string */
|
|
|
|
g_snprintf (scale_str, sizeof (scale_str), "%d:%d",
|
2002-06-27 06:16:59 +08:00
|
|
|
SCALEDEST (view->shell),
|
|
|
|
SCALESRC (view->shell));
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (view->zoom_label), scale_str);
|
2001-06-18 21:10:03 +08:00
|
|
|
}
|
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
if (view->zoom_adjustment)
|
|
|
|
{
|
|
|
|
gdouble f;
|
|
|
|
gint val;
|
1999-09-02 06:39:44 +08:00
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
f = (((gdouble) SCALEDEST (view->shell)) /
|
|
|
|
((gdouble) SCALESRC (view->shell)));
|
2002-05-08 00:23:14 +08:00
|
|
|
|
|
|
|
if (f < 1.0)
|
|
|
|
val = - RINT (1.0 / f) + 1;
|
|
|
|
else
|
|
|
|
val = RINT (f) - 1;
|
2001-06-18 21:10:03 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_block_by_func (view->zoom_adjustment,
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_zoom_adj_changed,
|
|
|
|
view);
|
1999-08-13 06:21:04 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gtk_adjustment_set_value (view->zoom_adjustment, val);
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_handlers_unblock_by_func (view->zoom_adjustment,
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_zoom_adj_changed,
|
|
|
|
view);
|
|
|
|
}
|
1999-11-20 08:46:58 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_update_marker (view);
|
1999-11-20 08:46:58 +08:00
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_shell_scrolled (GimpDisplayShell *shell,
|
|
|
|
GimpNavigationView *view)
|
1999-11-20 08:46:58 +08:00
|
|
|
{
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_update_marker (view);
|
1999-08-13 06:21:04 +08:00
|
|
|
}
|
|
|
|
|
2002-09-28 00:17:31 +08:00
|
|
|
static void
|
|
|
|
gimp_navigation_view_shell_reconnect (GimpDisplayShell *shell,
|
|
|
|
GimpNavigationView *view)
|
|
|
|
{
|
|
|
|
gimp_preview_set_viewable (GIMP_PREVIEW (view->preview),
|
|
|
|
GIMP_VIEWABLE (shell->gdisp->gimage));
|
|
|
|
}
|
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
static void
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_view_update_marker (GimpNavigationView *view)
|
1999-09-02 06:39:44 +08:00
|
|
|
{
|
2002-05-10 21:05:09 +08:00
|
|
|
gdouble xratio;
|
|
|
|
gdouble yratio;
|
2000-02-19 21:19:08 +08:00
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
xratio = SCALEFACTOR_X (view->shell);
|
|
|
|
yratio = SCALEFACTOR_Y (view->shell);
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2003-03-01 11:53:41 +08:00
|
|
|
if (GIMP_PREVIEW (view->preview)->renderer->dot_for_dot !=
|
|
|
|
view->shell->dot_for_dot)
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_preview_set_dot_for_dot (GIMP_PREVIEW (view->preview),
|
2002-06-27 06:16:59 +08:00
|
|
|
view->shell->dot_for_dot);
|
1999-09-05 06:27:20 +08:00
|
|
|
|
2002-05-08 00:23:14 +08:00
|
|
|
gimp_navigation_preview_set_marker (GIMP_NAVIGATION_PREVIEW (view->preview),
|
|
|
|
RINT (view->shell->offset_x / xratio),
|
|
|
|
RINT (view->shell->offset_y / yratio),
|
|
|
|
RINT (view->shell->disp_width / xratio),
|
|
|
|
RINT (view->shell->disp_height / yratio));
|
1999-09-05 06:27:20 +08:00
|
|
|
}
|