diff --git a/ChangeLog b/ChangeLog index 3a555fefe7..d09ed9e620 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,15 @@ +2008-07-11 Martin Nordholts + + * app/display/gimpdisplayshell-scroll.[ch] + (gimp_display_shell_get_viewport): Extend the interface with this + function. + + * app/display/gimpnavigationeditor.c + (gimp_navigation_editor_update_marker): Use it here. + 2008-07-10 Martin Nordholts - * app/display/gimpdisplayshell-scroll.[ch]: + * app/display/gimpdisplayshell-scroll.[ch] (gimp_display_shell_get_scaled_viewport): Extend the interface with this function diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c index b57b66b321..9f0096e2eb 100644 --- a/app/display/gimpdisplayshell-scroll.c +++ b/app/display/gimpdisplayshell-scroll.c @@ -144,6 +144,7 @@ gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell) * * Gets the viewport in screen coordinates, with origin at (0, 0) in * the image + * **/ void gimp_display_shell_get_scaled_viewport (GimpDisplayShell *shell, @@ -157,3 +158,29 @@ gimp_display_shell_get_scaled_viewport (GimpDisplayShell *shell, if (w) *w = shell->disp_width; if (h) *h = shell->disp_height; } + +/** + * gimp_display_shell_get_viewport: + * @shell: + * @x: + * @y: + * @w: + * @h: + * + * Gets the viewport in image coordinates + * + * TODO: Handle when the viewport is zoomed out + * + **/ +void +gimp_display_shell_get_viewport (GimpDisplayShell *shell, + gdouble *x, + gdouble *y, + gdouble *w, + gdouble *h) +{ + if (x) *x = shell->offset_x / shell->scale_x; + if (y) *y = shell->offset_y / shell->scale_y; + if (w) *w = shell->disp_width / shell->scale_x; + if (h) *h = shell->disp_height / shell->scale_y; +} diff --git a/app/display/gimpdisplayshell-scroll.h b/app/display/gimpdisplayshell-scroll.h index 70e26c83fa..d574bc2cc3 100644 --- a/app/display/gimpdisplayshell-scroll.h +++ b/app/display/gimpdisplayshell-scroll.h @@ -32,5 +32,11 @@ void gimp_display_shell_get_scaled_viewport (GimpDisplayShell *shell, gint *w, gint *h); +void gimp_display_shell_get_viewport (GimpDisplayShell *shell, + gdouble *x, + gdouble *y, + gdouble *w, + gdouble *h); + #endif /* __GIMP_DISPLAY_SHELL_SCROLL_H__ */ diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c index 45480b1bcc..7f4b98992d 100644 --- a/app/display/gimpnavigationeditor.c +++ b/app/display/gimpnavigationeditor.c @@ -640,9 +640,13 @@ gimp_navigation_editor_update_marker (GimpNavigationEditor *editor) gimp_view_renderer_set_dot_for_dot (renderer, shell->dot_for_dot); if (renderer->viewable) - gimp_navigation_view_set_marker (GIMP_NAVIGATION_VIEW (editor->view), - shell->offset_x / shell->scale_x, - shell->offset_y / shell->scale_y, - shell->disp_width / shell->scale_x, - shell->disp_height / shell->scale_y); + { + GimpNavigationView *view = GIMP_NAVIGATION_VIEW (editor->view); + gdouble x, y; + gdouble w, h; + + gimp_display_shell_get_viewport (shell, &x, &y, &w, &h); + + gimp_navigation_view_set_marker (view, x, y, w, h); + } }