app: show full image contents in GimpNavigationEditor
In GimpNavigation{Editor,View}, show the full image contents when the corresponding display is in "show all" mode. Additionally, when the display's "show canvas boundary" is active, show the canvas boundary in the navigation view as well.
This commit is contained in:
@ -36,6 +36,7 @@
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimageviewable.h"
|
||||
|
||||
#include "widgets/gimpdocked.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
@ -46,6 +47,7 @@
|
||||
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
#include "gimpdisplayshell-appearance.h"
|
||||
#include "gimpdisplayshell-scale.h"
|
||||
#include "gimpdisplayshell-scroll.h"
|
||||
#include "gimpdisplayshell-transform.h"
|
||||
@ -88,6 +90,9 @@ static void gimp_navigation_editor_scroll (GimpNavigationView
|
||||
static void gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
|
||||
GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_shell_show_all_notify (GimpDisplayShell *shell,
|
||||
const GParamSpec *pspec,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_scrolled (GimpDisplayShell *shell,
|
||||
@ -96,6 +101,14 @@ static void gimp_navigation_editor_shell_rotated (GimpDisplayShell
|
||||
GimpNavigationEditor *editor);
|
||||
static void gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_viewable_size_changed (GimpViewable *viewable,
|
||||
GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_options_show_canvas_notify (GimpDisplayOptions *options,
|
||||
const GParamSpec *pspec,
|
||||
GimpNavigationEditor *editor);
|
||||
|
||||
static void gimp_navigation_editor_update_marker (GimpNavigationEditor *editor);
|
||||
|
||||
|
||||
@ -137,7 +150,7 @@ gimp_navigation_editor_init (GimpNavigationEditor *editor)
|
||||
|
||||
editor->view = gimp_view_new_by_types (NULL,
|
||||
GIMP_TYPE_NAVIGATION_VIEW,
|
||||
GIMP_TYPE_IMAGE,
|
||||
GIMP_TYPE_IMAGE_VIEWABLE,
|
||||
GIMP_VIEW_SIZE_MEDIUM, 0, TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), editor->view);
|
||||
gtk_widget_show (editor->view);
|
||||
@ -459,6 +472,9 @@ gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
|
||||
|
||||
if (editor->shell)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_show_all_notify,
|
||||
editor);
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_scaled,
|
||||
editor);
|
||||
@ -471,6 +487,13 @@ gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
|
||||
g_signal_handlers_disconnect_by_func (editor->shell,
|
||||
gimp_navigation_editor_shell_reconnect,
|
||||
editor);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (editor->shell->options,
|
||||
gimp_navigation_editor_options_show_canvas_notify,
|
||||
editor);
|
||||
g_signal_handlers_disconnect_by_func (editor->shell->fullscreen_options,
|
||||
gimp_navigation_editor_options_show_canvas_notify,
|
||||
editor);
|
||||
}
|
||||
else if (shell)
|
||||
{
|
||||
@ -483,9 +506,24 @@ gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (shell->display);
|
||||
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view),
|
||||
GIMP_VIEWABLE (image));
|
||||
g_clear_object (&editor->image_viewable);
|
||||
|
||||
if (image)
|
||||
{
|
||||
editor->image_viewable = gimp_image_viewable_new (image);
|
||||
|
||||
g_signal_connect (
|
||||
editor->image_viewable, "size-changed",
|
||||
G_CALLBACK (gimp_navigation_editor_viewable_size_changed),
|
||||
editor);
|
||||
}
|
||||
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view),
|
||||
GIMP_VIEWABLE (editor->image_viewable));
|
||||
|
||||
g_signal_connect (editor->shell, "notify::show-all",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_show_all_notify),
|
||||
editor);
|
||||
g_signal_connect (editor->shell, "scaled",
|
||||
G_CALLBACK (gimp_navigation_editor_shell_scaled),
|
||||
editor);
|
||||
@ -499,12 +537,21 @@ gimp_navigation_editor_set_shell (GimpNavigationEditor *editor,
|
||||
G_CALLBACK (gimp_navigation_editor_shell_reconnect),
|
||||
editor);
|
||||
|
||||
g_signal_connect (editor->shell->options, "notify::show-canvas-boundary",
|
||||
G_CALLBACK (gimp_navigation_editor_options_show_canvas_notify),
|
||||
editor);
|
||||
g_signal_connect (editor->shell->fullscreen_options, "notify::show-canvas-boundary",
|
||||
G_CALLBACK (gimp_navigation_editor_options_show_canvas_notify),
|
||||
editor);
|
||||
|
||||
gimp_navigation_editor_shell_scaled (editor->shell, editor);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view), NULL);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
|
||||
|
||||
g_clear_object (&editor->image_viewable);
|
||||
}
|
||||
|
||||
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
|
||||
@ -533,12 +580,24 @@ gimp_navigation_editor_marker_changed (GimpNavigationView *view,
|
||||
gdouble height,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
GimpViewRenderer *renderer = GIMP_VIEW (editor->view)->renderer;
|
||||
|
||||
if (editor->shell)
|
||||
{
|
||||
if (gimp_display_get_image (editor->shell->display))
|
||||
{
|
||||
GeglRectangle bounding_box;
|
||||
|
||||
bounding_box = gimp_image_viewable_get_bounding_box (
|
||||
GIMP_IMAGE_VIEWABLE (renderer->viewable));
|
||||
|
||||
center_x += bounding_box.x;
|
||||
center_y += bounding_box.y;
|
||||
|
||||
gimp_display_shell_scroll_center_image_xy (editor->shell,
|
||||
center_x, center_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -637,6 +696,18 @@ gimp_navigation_editor_zoom_adj_changed (GtkAdjustment *adj,
|
||||
editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_shell_show_all_notify (GimpDisplayShell *shell,
|
||||
const GParamSpec *pspec,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
gimp_navigation_editor_update_marker (editor);
|
||||
|
||||
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
|
||||
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
|
||||
gimp_editor_get_popup_data (GIMP_EDITOR (editor)));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_shell_scaled (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor)
|
||||
@ -698,14 +769,45 @@ gimp_navigation_editor_shell_rotated (GimpDisplayShell *shell,
|
||||
gimp_editor_get_popup_data (GIMP_EDITOR (editor)));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_viewable_size_changed (GimpViewable *viewable,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
gimp_navigation_editor_update_marker (editor);
|
||||
|
||||
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
|
||||
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
|
||||
gimp_editor_get_popup_data (GIMP_EDITOR (editor)));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_options_show_canvas_notify (GimpDisplayOptions *options,
|
||||
const GParamSpec *pspec,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
gimp_navigation_editor_update_marker (editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_navigation_editor_shell_reconnect (GimpDisplayShell *shell,
|
||||
GimpNavigationEditor *editor)
|
||||
{
|
||||
GimpImage *image = gimp_display_get_image (shell->display);
|
||||
|
||||
g_clear_object (&editor->image_viewable);
|
||||
|
||||
if (image)
|
||||
{
|
||||
editor->image_viewable = gimp_image_viewable_new (image);
|
||||
|
||||
g_signal_connect (
|
||||
editor->image_viewable, "size-changed",
|
||||
G_CALLBACK (gimp_navigation_editor_viewable_size_changed),
|
||||
editor);
|
||||
}
|
||||
|
||||
gimp_view_set_viewable (GIMP_VIEW (editor->view),
|
||||
GIMP_VIEWABLE (image));
|
||||
GIMP_VIEWABLE (editor->image_viewable));
|
||||
|
||||
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
|
||||
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
|
||||
@ -724,19 +826,40 @@ gimp_navigation_editor_update_marker (GimpNavigationEditor *editor)
|
||||
if (renderer->viewable)
|
||||
{
|
||||
GimpNavigationView *view = GIMP_NAVIGATION_VIEW (editor->view);
|
||||
GimpImage *image;
|
||||
GeglRectangle bounding_box;
|
||||
gdouble x, y;
|
||||
gdouble w, h;
|
||||
|
||||
image = gimp_image_viewable_get_image (
|
||||
GIMP_IMAGE_VIEWABLE (renderer->viewable));
|
||||
|
||||
gimp_image_viewable_set_show_all (
|
||||
GIMP_IMAGE_VIEWABLE (renderer->viewable),
|
||||
shell->show_all);
|
||||
|
||||
bounding_box = gimp_image_viewable_get_bounding_box (
|
||||
GIMP_IMAGE_VIEWABLE (renderer->viewable));
|
||||
|
||||
gimp_display_shell_scroll_get_viewport (shell, &x, &y, &w, &h);
|
||||
gimp_display_shell_untransform_xy_f (shell,
|
||||
shell->disp_width / 2,
|
||||
shell->disp_height / 2,
|
||||
&x, &y);
|
||||
|
||||
x -= bounding_box.x;
|
||||
y -= bounding_box.y;
|
||||
|
||||
gimp_navigation_view_set_marker (view,
|
||||
x, y, w, h,
|
||||
shell->flip_horizontally,
|
||||
shell->flip_vertically,
|
||||
shell->rotate_angle);
|
||||
|
||||
gimp_navigation_view_set_canvas (
|
||||
view,
|
||||
shell->show_all && gimp_display_shell_get_show_canvas (shell),
|
||||
-bounding_box.x, -bounding_box.y,
|
||||
gimp_image_get_width (image), gimp_image_get_height (image));
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ struct _GimpNavigationEditor
|
||||
GimpContext *context;
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
GimpImageViewable *image_viewable;
|
||||
|
||||
GtkWidget *view;
|
||||
GtkWidget *zoom_label;
|
||||
GtkAdjustment *zoom_adjustment;
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpmarshal.h"
|
||||
|
||||
#include "display/gimpcanvas-style.h"
|
||||
|
||||
#include "gimpnavigationview.h"
|
||||
#include "gimpviewrenderer.h"
|
||||
#include "gimpwidgets-utils.h"
|
||||
@ -66,12 +68,23 @@ struct _GimpNavigationView
|
||||
gboolean flip_vertically;
|
||||
gdouble rotate_angle;
|
||||
|
||||
gboolean canvas_visible;
|
||||
gdouble canvas_x;
|
||||
gdouble canvas_y;
|
||||
gdouble canvas_width;
|
||||
gdouble canvas_height;
|
||||
|
||||
/* values in view coordinates */
|
||||
gint p_center_x;
|
||||
gint p_center_y;
|
||||
gint p_width;
|
||||
gint p_height;
|
||||
|
||||
gint p_canvas_x;
|
||||
gint p_canvas_y;
|
||||
gint p_canvas_width;
|
||||
gint p_canvas_height;
|
||||
|
||||
gint motion_offset_x;
|
||||
gint motion_offset_y;
|
||||
gboolean has_grab;
|
||||
@ -177,11 +190,22 @@ gimp_navigation_view_init (GimpNavigationView *view)
|
||||
view->flip_vertically = FALSE;
|
||||
view->rotate_angle = 0.0;
|
||||
|
||||
view->canvas_visible = FALSE;
|
||||
view->canvas_x = 0.0;
|
||||
view->canvas_y = 0.0;
|
||||
view->canvas_width = 0.0;
|
||||
view->canvas_height = 0.0;
|
||||
|
||||
view->p_center_x = 0;
|
||||
view->p_center_y = 0;
|
||||
view->p_width = 0;
|
||||
view->p_height = 0;
|
||||
|
||||
view->p_canvas_x = 0;
|
||||
view->p_canvas_y = 0;
|
||||
view->p_canvas_width = 0;
|
||||
view->p_canvas_height = 0;
|
||||
|
||||
view->motion_offset_x = 0;
|
||||
view->motion_offset_y = 0;
|
||||
view->has_grab = FALSE;
|
||||
@ -464,6 +488,34 @@ gimp_navigation_view_set_marker (GimpNavigationView *nav_view,
|
||||
gtk_widget_queue_draw (GTK_WIDGET (view));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_navigation_view_set_canvas (GimpNavigationView *nav_view,
|
||||
gboolean visible,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height)
|
||||
{
|
||||
GimpView *view;
|
||||
|
||||
g_return_if_fail (GIMP_IS_NAVIGATION_VIEW (nav_view));
|
||||
|
||||
view = GIMP_VIEW (nav_view);
|
||||
|
||||
g_return_if_fail (view->renderer->viewable);
|
||||
|
||||
nav_view->canvas_visible = visible;
|
||||
nav_view->canvas_x = x;
|
||||
nav_view->canvas_y = y;
|
||||
nav_view->canvas_width = MAX (1.0, width);
|
||||
nav_view->canvas_height = MAX (1.0, height);
|
||||
|
||||
gimp_navigation_view_transform (nav_view);
|
||||
|
||||
/* Marker changed, redraw */
|
||||
gtk_widget_queue_draw (GTK_WIDGET (view));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_navigation_view_set_motion_offset (GimpNavigationView *view,
|
||||
gint motion_offset_x,
|
||||
@ -505,6 +557,12 @@ gimp_navigation_view_transform (GimpNavigationView *nav_view)
|
||||
|
||||
nav_view->p_width = ceil (nav_view->width * ratiox);
|
||||
nav_view->p_height = ceil (nav_view->height * ratioy);
|
||||
|
||||
nav_view->p_canvas_x = RINT (nav_view->canvas_x * ratiox);
|
||||
nav_view->p_canvas_y = RINT (nav_view->canvas_y * ratioy);
|
||||
|
||||
nav_view->p_canvas_width = ceil (nav_view->canvas_width * ratiox);
|
||||
nav_view->p_canvas_height = ceil (nav_view->canvas_height * ratioy);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -517,6 +575,7 @@ gimp_navigation_view_draw_marker (GimpNavigationView *nav_view,
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (view);
|
||||
GtkAllocation allocation;
|
||||
cairo_matrix_t matrix;
|
||||
gint p_width_2;
|
||||
gint p_height_2;
|
||||
gdouble angle;
|
||||
@ -531,6 +590,9 @@ gimp_navigation_view_draw_marker (GimpNavigationView *nav_view,
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
cairo_translate (cr, allocation.x, allocation.y);
|
||||
|
||||
cairo_get_matrix (cr, &matrix);
|
||||
|
||||
cairo_rectangle (cr,
|
||||
0, 0,
|
||||
allocation.width, allocation.height);
|
||||
@ -544,6 +606,24 @@ gimp_navigation_view_draw_marker (GimpNavigationView *nav_view,
|
||||
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
||||
cairo_fill (cr);
|
||||
|
||||
if (nav_view->canvas_visible &&
|
||||
nav_view->canvas_width && nav_view->canvas_height)
|
||||
{
|
||||
cairo_save (cr);
|
||||
|
||||
cairo_set_matrix (cr, &matrix);
|
||||
|
||||
cairo_rectangle (cr,
|
||||
nav_view->p_canvas_x + 0.5,
|
||||
nav_view->p_canvas_y + 0.5,
|
||||
nav_view->p_canvas_width - 1.0,
|
||||
nav_view->p_canvas_height - 1.0);
|
||||
gimp_canvas_set_canvas_style (GTK_WIDGET (nav_view), cr, 0, 0);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
cairo_rectangle (cr,
|
||||
-p_width_2, -p_height_2,
|
||||
nav_view->p_width, nav_view->p_height);
|
||||
@ -581,14 +661,13 @@ gimp_navigation_view_get_ratio (GimpNavigationView *nav_view,
|
||||
gdouble *ratioy)
|
||||
{
|
||||
GimpView *view = GIMP_VIEW (nav_view);
|
||||
GimpImage *image;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
image = GIMP_IMAGE (view->renderer->viewable);
|
||||
gimp_viewable_get_size (view->renderer->viewable, &width, &height);
|
||||
|
||||
*ratiox = (gdouble) view->renderer->width /
|
||||
(gdouble) gimp_image_get_width (image);
|
||||
*ratioy = (gdouble) view->renderer->height /
|
||||
(gdouble) gimp_image_get_height (image);
|
||||
*ratiox = (gdouble) view->renderer->width / (gdouble) width;
|
||||
*ratioy = (gdouble) view->renderer->height / (gdouble) height;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -63,6 +63,12 @@ void gimp_navigation_view_set_marker (GimpNavigationView *view,
|
||||
gboolean flip_horizontally,
|
||||
gboolean flip_vertically,
|
||||
gdouble rotate_angle);
|
||||
void gimp_navigation_view_set_canvas (GimpNavigationView *view,
|
||||
gboolean visible,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble width,
|
||||
gdouble height);
|
||||
void gimp_navigation_view_set_motion_offset
|
||||
(GimpNavigationView *view,
|
||||
gint motion_offset_x,
|
||||
|
Reference in New Issue
Block a user