Commit 8f5adb2f authored by Martin Nordholts's avatar Martin Nordholts Committed by Martin Nordholts

Prevent the popup from being positioned far away from the click position.

2008-08-24  Martin Nordholts  <martinn@svn.gnome.org>

	* app/display/gimpnavigationeditor.c
	(gimp_navigation_editor_popup): Prevent the popup from being
	positioned far away from the click position. This is further work
	on bug #362915.

svn path=/trunk/; revision=26741
parent f50037c4
2008-08-24 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpnavigationeditor.c
(gimp_navigation_editor_popup): Prevent the popup from being
positioned far away from the click position. This is further work
on bug #362915.
2008-08-24 Martin Nordholts <martinn@svn.gnome.org>
* app/display/gimpnavigationeditor.c
......
......@@ -275,6 +275,7 @@ gimp_navigation_editor_popup (GimpDisplayShell *shell,
/* Position the popup */
{
gint x_origin, y_origin;
gint popup_width, popup_height;
gint border_width, border_height;
gint screen_click_x, screen_click_y;
......@@ -284,6 +285,8 @@ gimp_navigation_editor_popup (GimpDisplayShell *shell,
screen_click_y = y_origin + click_y;
border_width = style->xthickness * 4;
border_height = style->ythickness * 4;
popup_width = GIMP_VIEW (view)->renderer->width - border_width;
popup_height = GIMP_VIEW (view)->renderer->height - border_height;
x = screen_click_x -
border_width -
......@@ -295,6 +298,13 @@ gimp_navigation_editor_popup (GimpDisplayShell *shell,
view_marker_y -
view_marker_height / 2;
/* When the image is zoomed out and overscrolled, the above
* calculation risks positioning the popup far far away from the
* click coordinate. We don't want that, so perform some clamping.
*/
x = CLAMP (x, screen_click_x - popup_width, screen_click_x);
y = CLAMP (y, screen_click_y - popup_height, screen_click_y);
/* 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
......@@ -304,13 +314,8 @@ gimp_navigation_editor_popup (GimpDisplayShell *shell,
*
* Warping the pointer would be another solution ...
*/
x = CLAMP (x, 0, gdk_screen_get_width (screen) -
GIMP_VIEW (view)->renderer->width -
border_width);
y = CLAMP (y, 0, gdk_screen_get_height (screen) -
GIMP_VIEW (view)->renderer->height -
border_height);
x = CLAMP (x, 0, gdk_screen_get_width (screen) - popup_width);
y = CLAMP (y, 0, gdk_screen_get_height (screen) - popup_height);
gtk_window_move (GTK_WINDOW (shell->nav_popup), x, y);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment