53
53
#include "gimp-intl.h"
56
static void gimp_navigation_editor_docked_iface_init (GimpDockedInterface *iface);
58
static void gimp_navigation_editor_destroy (GtkObject *object);
60
static void gimp_navigation_editor_set_context (GimpDocked *docked,
61
GimpContext *context);
63
static GtkWidget * gimp_navigation_editor_new_private (GimpMenuFactory *menu_factory,
64
GimpDisplayShell *shell);
66
static void gimp_navigation_editor_set_shell (GimpNavigationEditor *view,
67
GimpDisplayShell *shell);
68
static gboolean gimp_navigation_editor_button_release (GtkWidget *widget,
69
GdkEventButton *bevent,
70
GimpDisplayShell *shell);
71
static void gimp_navigation_editor_marker_changed (GimpNavigationView *view,
74
GimpNavigationEditor *editor);
75
static void gimp_navigation_editor_zoom (GimpNavigationView *view,
76
GimpZoomType direction,
77
GimpNavigationEditor *editor);
78
static void gimp_navigation_editor_scroll (GimpNavigationView *view,
79
GdkScrollDirection direction,
80
GimpNavigationEditor *editor);
82
static void gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
83
GimpNavigationEditor *editor);
85
static void gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
86
GimpNavigationEditor *editor);
87
static void gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
88
GimpNavigationEditor *editor);
89
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
90
GimpNavigationEditor *editor);
91
static void gimp_navigation_editor_update_marker (GimpNavigationEditor *editor);
56
static void gimp_navigation_editor_docked_iface_init (GimpDockedInterface *iface);
58
static void gimp_navigation_editor_destroy (GtkObject *object);
60
static void gimp_navigation_editor_set_context (GimpDocked *docked,
61
GimpContext *context);
63
static GtkWidget * gimp_navigation_editor_new_private (GimpMenuFactory *menu_factory,
64
GimpDisplayShell *shell);
66
static void gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
67
GimpDisplayShell *shell);
68
static gboolean gimp_navigation_editor_button_release (GtkWidget *widget,
69
GdkEventButton *bevent,
70
GimpDisplayShell *shell);
71
static void gimp_navigation_editor_marker_changed (GimpNavigationView *view,
76
GimpNavigationEditor *editor);
77
static void gimp_navigation_editor_zoom (GimpNavigationView *view,
78
GimpZoomType direction,
79
GimpNavigationEditor *editor);
80
static void gimp_navigation_editor_scroll (GimpNavigationView *view,
81
GdkScrollDirection direction,
82
GimpNavigationEditor *editor);
84
static void gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
85
GimpNavigationEditor *editor);
87
static void gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
88
GimpNavigationEditor *editor);
89
static void gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
90
GimpNavigationEditor *editor);
91
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
92
GimpNavigationEditor *editor);
93
static void gimp_navigation_editor_update_marker (GimpNavigationEditor *editor);
94
96
G_DEFINE_TYPE_WITH_CODE (GimpNavigationEditor, gimp_navigation_editor,
255
editor = GIMP_NAVIGATION_EDITOR (GTK_BIN (GTK_BIN (shell->nav_popup)->child)->child);
259
GtkWidget *bin = gtk_bin_get_child (GTK_BIN (shell->nav_popup));
261
editor = GIMP_NAVIGATION_EDITOR (gtk_bin_get_child (GTK_BIN (bin)));
264
view = GIMP_NAVIGATION_VIEW (editor->view);
266
/* Set poup screen */
258
267
screen = gtk_widget_get_screen (widget);
260
268
gtk_window_set_screen (GTK_WINDOW (shell->nav_popup), screen);
262
view = GIMP_NAVIGATION_VIEW (editor->view);
264
/* decide where to put the popup */
265
gdk_window_get_origin (widget->window, &x_org, &y_org);
267
#define BORDER_PEN_WIDTH 3
269
x = (x_org + click_x -
271
0.5 * (view->p_width - BORDER_PEN_WIDTH) -
272
2 * widget->style->xthickness);
274
y = (y_org + click_y -
276
0.5 * (view->p_height - BORDER_PEN_WIDTH) -
277
2 * widget->style->ythickness);
279
/* If the popup doesn't fit into the screen, we have a problem.
280
* We move the popup onscreen and risk that the pointer is not
281
* in the square representing the viewable area anymore. Moving
282
* the pointer will make the image scroll by a large amount,
283
* but then it works as usual. Probably better than a popup that
284
* is completely unusable in the lower right of the screen.
286
* Warping the pointer would be another solution ...
289
x = CLAMP (x, 0, (gdk_screen_get_width (screen) -
290
GIMP_VIEW (view)->renderer->width -
291
4 * widget->style->xthickness));
292
y = CLAMP (y, 0, (gdk_screen_get_height (screen) -
293
GIMP_VIEW (view)->renderer->height -
294
4 * widget->style->ythickness));
296
gtk_window_move (GTK_WINDOW (shell->nav_popup), x, y);
270
gimp_navigation_view_get_local_marker (view,
274
&view_marker_height);
275
/* Position the popup */
277
gint x_origin, y_origin;
278
gint popup_width, popup_height;
279
gint border_width, border_height;
280
gint screen_click_x, screen_click_y;
282
gdk_window_get_origin (widget->window, &x_origin, &y_origin);
284
screen_click_x = x_origin + click_x;
285
screen_click_y = y_origin + click_y;
286
border_width = style->xthickness * 4;
287
border_height = style->ythickness * 4;
288
popup_width = GIMP_VIEW (view)->renderer->width - border_width;
289
popup_height = GIMP_VIEW (view)->renderer->height - border_height;
294
view_marker_width / 2;
299
view_marker_height / 2;
301
/* When the image is zoomed out and overscrolled, the above
302
* calculation risks positioning the popup far far away from the
303
* click coordinate. We don't want that, so perform some clamping.
305
x = CLAMP (x, screen_click_x - popup_width, screen_click_x);
306
y = CLAMP (y, screen_click_y - popup_height, screen_click_y);
308
/* If the popup doesn't fit into the screen, we have a problem.
309
* We move the popup onscreen and risk that the pointer is not
310
* in the square representing the viewable area anymore. Moving
311
* the pointer will make the image scroll by a large amount,
312
* but then it works as usual. Probably better than a popup that
313
* is completely unusable in the lower right of the screen.
315
* Warping the pointer would be another solution ...
317
x = CLAMP (x, 0, gdk_screen_get_width (screen) - popup_width);
318
y = CLAMP (y, 0, gdk_screen_get_height (screen) - popup_height);
320
gtk_window_move (GTK_WINDOW (shell->nav_popup), x, y);
297
323
gtk_widget_show (shell->nav_popup);
301
326
/* fill in then grab pointer */
302
view->motion_offset_x = 0.5 * (view->p_width - BORDER_PEN_WIDTH);
303
view->motion_offset_y = 0.5 * (view->p_height - BORDER_PEN_WIDTH);
305
#undef BORDER_PEN_WIDTH
327
gimp_navigation_view_set_motion_offset (view,
328
view_marker_width / 2,
329
view_marker_height / 2);
307
330
gimp_navigation_view_grab_pointer (view);
637
663
if (renderer->dot_for_dot != shell->dot_for_dot)
638
664
gimp_view_renderer_set_dot_for_dot (renderer, shell->dot_for_dot);
640
gimp_navigation_view_set_marker (GIMP_NAVIGATION_VIEW (editor->view),
641
shell->offset_x / shell->scale_x,
642
shell->offset_y / shell->scale_y,
643
shell->disp_width / shell->scale_x,
644
shell->disp_height / shell->scale_y);
666
if (renderer->viewable)
668
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (editor->view);
672
gimp_display_shell_scroll_get_viewport (shell, &x, &y, &w, &h);
674
gimp_navigation_view_set_marker (view, x, y, w, h);