better handling of selections and navigation popup. Still not perfect.

* libgimp/gimpzoompreview.c: better handling of selections and
  navigation popup. Still not perfect.
This commit is contained in:
David Odin 2005-10-09 13:54:03 +00:00
parent fb5707241e
commit 16aa8d299d
2 changed files with 67 additions and 26 deletions

View file

@ -1,3 +1,8 @@
2005-10-09 DindinX <dindinx@gimp.org>
* libgimp/gimpzoompreview.c: better handling of selections and
navigation popup. Still not perfect.
2005-10-09 DindinX <dindinx@gimp.org> 2005-10-09 DindinX <dindinx@gimp.org>
* libgimp/gimpdrawablepreview.c: made the navigation popup respect the * libgimp/gimpdrawablepreview.c: made the navigation popup respect the

View file

@ -80,8 +80,6 @@ gimp_zoom_preview_class_init (GimpZoomPreviewClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpPreviewClass *preview_class = GIMP_PREVIEW_CLASS (klass); GimpPreviewClass *preview_class = GIMP_PREVIEW_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
widget_class->style_set = gimp_zoom_preview_style_set; widget_class->style_set = gimp_zoom_preview_style_set;
preview_class->draw = gimp_zoom_preview_draw; preview_class->draw = gimp_zoom_preview_draw;
@ -112,18 +110,6 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
gtk_box_pack_end (GTK_BOX (box), button_bar, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (box), button_bar, FALSE, FALSE, 0);
gtk_widget_show (button_bar); gtk_widget_show (button_bar);
/* label */
#if 0
{
GtkWidget *label;
label = gimp_prop_label_new (G_OBJECT (priv->model), "fraction");
gtk_misc_set_padding (GTK_MISC (label), 3, 3);
gtk_box_pack_start (GTK_BOX (button_bar), label, FALSE, FALSE, 0);
gtk_widget_show (label);
}
#endif
/* zoom out */ /* zoom out */
button = gimp_zoom_button_new (priv->model, button = gimp_zoom_button_new (priv->model,
GIMP_ZOOM_OUT, GTK_ICON_SIZE_SMALL_TOOLBAR); GIMP_ZOOM_OUT, GTK_ICON_SIZE_SMALL_TOOLBAR);
@ -217,6 +203,8 @@ gimp_zoom_preview_style_set (GtkWidget *widget,
GimpDrawable *drawable = priv->drawable; GimpDrawable *drawable = priv->drawable;
gint size; gint size;
gint width, height; gint width, height;
gint x1, y1;
gint x2, y2;
if (GTK_WIDGET_CLASS (parent_class)->style_set) if (GTK_WIDGET_CLASS (parent_class)->style_set)
GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style); GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
@ -224,8 +212,16 @@ gimp_zoom_preview_style_set (GtkWidget *widget,
gtk_widget_style_get (widget, gtk_widget_style_get (widget,
"size", &size, "size", &size,
NULL); NULL);
width = gimp_drawable_width (drawable->drawable_id); if (gimp_zoom_preview_get_bounds (drawable, &x1, &y1, &x2, &y2))
height = gimp_drawable_height (drawable->drawable_id); {
width = x2 - x1;
height = y2 - y1;
}
else
{
width = gimp_drawable_width (drawable->drawable_id);
height = gimp_drawable_height (drawable->drawable_id);
}
if (width > height) if (width > height)
{ {
@ -329,14 +325,17 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
image_id = gimp_drawable_get_image (drawable->drawable_id); image_id = gimp_drawable_get_image (drawable->drawable_id);
/*
if (gimp_selection_is_empty (image_id)) if (gimp_selection_is_empty (image_id))
{ {
*/
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview->area), gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview->area),
0, 0, 0, 0,
preview->width, preview->height, preview->width, preview->height,
gimp_drawable_type (drawable->drawable_id), gimp_drawable_type (drawable->drawable_id),
buffer, buffer,
rowstride); rowstride);
/*
} }
else else
{ {
@ -366,6 +365,7 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview,
g_free (sel); g_free (sel);
g_free (src); g_free (src);
} }
*/
} }
static void static void
@ -379,27 +379,51 @@ gimp_zoom_preview_draw_thumb (GimpPreview *preview,
guchar *buffer; guchar *buffer;
gint x1, y1, x2, y2; gint x1, y1, x2, y2;
gint bpp; gint bpp;
gint size = 100;
gint nav_width, nav_height;
if (! drawable) if (! drawable)
return; return;
if (gimp_zoom_preview_get_bounds (drawable, &x1, &y1, &x2, &y2))
{
width = x2 - x1;
height = y2 - y1;
}
else
{
width = gimp_drawable_width (drawable->drawable_id);
height = gimp_drawable_height (drawable->drawable_id);
}
if (width > height)
{
nav_width = MIN (width, size);
nav_height = (height * nav_width) / width;
}
else
{
nav_height = MIN (height, size);
nav_width = (width * nav_height) / height;
}
if (gimp_zoom_preview_get_bounds (drawable, &x1, &y1, &x2, &y2)) if (gimp_zoom_preview_get_bounds (drawable, &x1, &y1, &x2, &y2))
{ {
buffer = gimp_drawable_get_sub_thumbnail_data (drawable->drawable_id, buffer = gimp_drawable_get_sub_thumbnail_data (drawable->drawable_id,
x1, y1, x2 - x1, y2 - y1, x1, y1, x2 - x1, y2 - y1,
&width, &height, &bpp); &nav_width, &nav_height, &bpp);
} }
else else
{ {
buffer = gimp_drawable_get_thumbnail_data (drawable->drawable_id, buffer = gimp_drawable_get_thumbnail_data (drawable->drawable_id,
&width, &height, &bpp); &nav_width, &nav_height, &bpp);
} }
if (buffer) if (buffer)
{ {
GimpImageType type; GimpImageType type;
gtk_widget_set_size_request (GTK_WIDGET (area), width, height); gtk_widget_set_size_request (GTK_WIDGET (area), nav_width, nav_height);
gtk_widget_show (GTK_WIDGET (area)); gtk_widget_show (GTK_WIDGET (area));
gtk_widget_realize (GTK_WIDGET (area)); gtk_widget_realize (GTK_WIDGET (area));
@ -414,8 +438,8 @@ gimp_zoom_preview_draw_thumb (GimpPreview *preview,
return; return;
} }
gimp_preview_area_draw (area, gimp_preview_area_draw (area,
0, 0, width, height, 0, 0, nav_width, nav_height,
type, buffer, bpp * width); type, buffer, bpp * nav_width);
g_free (buffer); g_free (buffer);
} }
@ -470,6 +494,8 @@ gimp_zoom_preview_new (GimpDrawable *drawable)
gint width, height; gint width, height;
gint max_width, max_height; gint max_width, max_height;
GimpZoomPreviewPrivate *priv; GimpZoomPreviewPrivate *priv;
gint x1, y1;
gint x2, y2;
preview = g_object_new (GIMP_TYPE_ZOOM_PREVIEW, NULL); preview = g_object_new (GIMP_TYPE_ZOOM_PREVIEW, NULL);
@ -477,14 +503,24 @@ gimp_zoom_preview_new (GimpDrawable *drawable)
priv->drawable = drawable; priv->drawable = drawable;
width = gimp_drawable_width (drawable->drawable_id); if (gimp_zoom_preview_get_bounds (drawable, &x1, &y1, &x2, &y2))
height = gimp_drawable_height (drawable->drawable_id); {
width = x2 - x1;
height = y2 - y1;
priv->extents.x = 0; priv->extents.x = x1;
priv->extents.y = 0; priv->extents.y = y1;
}
else
{
width = gimp_drawable_width (drawable->drawable_id);
height = gimp_drawable_height (drawable->drawable_id);
priv->extents.x = 0;
priv->extents.y = 0;
}
priv->extents.width = width; priv->extents.width = width;
priv->extents.height = height; priv->extents.height = height;
if (width > height) if (width > height)
{ {
max_width = MIN (width, 512); max_width = MIN (width, 512);