mirror of https://github.com/GNOME/gimp.git
improve wilber scaling and remove the drop zone layout.
2008-03-26 Michael Natterer <mitch@gimp.org> * app/display/gimpcanvas.[ch]: improve wilber scaling and remove the drop zone layout. * app/display/gimpdisplayshell.c: add a tooltip instead. svn path=/trunk/; revision=25241
This commit is contained in:
parent
7b8890fa66
commit
7301aaaeae
|
@ -1,3 +1,10 @@
|
|||
2008-03-26 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpcanvas.[ch]: improve wilber scaling and remove
|
||||
the drop zone layout.
|
||||
|
||||
* app/display/gimpdisplayshell.c: add a tooltip instead.
|
||||
|
||||
2008-03-26 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell-callbacks.c
|
||||
|
|
|
@ -263,12 +263,6 @@ gimp_canvas_unrealize (GtkWidget *widget)
|
|||
canvas->layout = NULL;
|
||||
}
|
||||
|
||||
if (canvas->drop_zone_layout)
|
||||
{
|
||||
g_object_unref (canvas->drop_zone_layout);
|
||||
canvas->drop_zone_layout = NULL;
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
|
||||
}
|
||||
|
||||
|
@ -286,12 +280,6 @@ gimp_canvas_style_set (GtkWidget *widget,
|
|||
g_object_unref (canvas->layout);
|
||||
canvas->layout = NULL;
|
||||
}
|
||||
|
||||
if (canvas->drop_zone_layout)
|
||||
{
|
||||
g_object_unref (canvas->drop_zone_layout);
|
||||
canvas->drop_zone_layout = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns: %TRUE if the XOR color is not white */
|
||||
|
@ -839,74 +827,50 @@ gimp_canvas_draw_drop_zone (GimpCanvas *canvas,
|
|||
cairo_t *cr)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (canvas);
|
||||
GdkColor *color = &widget->style->fg[widget->state];
|
||||
GdkPixbuf *wilber;
|
||||
gint wilber_width;
|
||||
gint wilber_height;
|
||||
gint wilber_x;
|
||||
gint wilber_y;
|
||||
gint width;
|
||||
gint height;
|
||||
gint side;
|
||||
gdouble factor;
|
||||
gdouble opacity;
|
||||
|
||||
if (! canvas->drop_zone_layout)
|
||||
{
|
||||
canvas->drop_zone_layout = gtk_widget_create_pango_layout (widget,
|
||||
_("Drag images here"));
|
||||
gimp_pango_layout_set_weight (canvas->drop_zone_layout,
|
||||
PANGO_WEIGHT_BOLD);
|
||||
}
|
||||
wilber = gtk_widget_render_icon (widget,
|
||||
GIMP_STOCK_WILBER,
|
||||
GTK_ICON_SIZE_DIALOG,
|
||||
NULL);
|
||||
|
||||
pango_layout_get_pixel_size (canvas->drop_zone_layout, &width, &height);
|
||||
wilber_width = gdk_pixbuf_get_width (wilber) / 2;
|
||||
wilber_height = gdk_pixbuf_get_height (wilber) / 2;
|
||||
|
||||
factor = 4.0 / 5.0 * MIN ((gdouble) widget->allocation.width / width,
|
||||
(gdouble) widget->allocation.height / height);
|
||||
side = MIN (MIN (widget->allocation.width,
|
||||
widget->allocation.height),
|
||||
MAX (widget->allocation.width,
|
||||
widget->allocation.height) / 2);
|
||||
|
||||
width = MAX (wilber_width, side);
|
||||
height = MAX (wilber_height, side);
|
||||
|
||||
factor = MIN ((gdouble) width / wilber_width,
|
||||
(gdouble) height / wilber_height);
|
||||
|
||||
cairo_scale (cr, factor, factor);
|
||||
cairo_move_to (cr,
|
||||
(widget->allocation.width / factor - width) / 2.0,
|
||||
(widget->allocation.height / factor - height) / 2.0);
|
||||
|
||||
opacity = CLAMP (0.5 / factor, 0.1, 1.0);
|
||||
/* magic factors depend on the image used, everything else is
|
||||
* generic
|
||||
*/
|
||||
wilber_x = -wilber_width * 0.6;
|
||||
wilber_y = widget->allocation.height / factor - wilber_height * 1.1;
|
||||
|
||||
cairo_set_source_rgba (cr,
|
||||
color->red / 65535.0,
|
||||
color->green / 65535.0,
|
||||
color->blue / 65535.0,
|
||||
opacity);
|
||||
gdk_cairo_set_source_pixbuf (cr, wilber, wilber_x, wilber_y);
|
||||
cairo_rectangle (cr,
|
||||
wilber_x, wilber_y,
|
||||
wilber_width * 2, wilber_height * 2);
|
||||
cairo_fill (cr);
|
||||
|
||||
pango_cairo_show_layout (cr, canvas->drop_zone_layout);
|
||||
|
||||
cairo_scale (cr, 1.0 / factor, 1.0 / factor);
|
||||
|
||||
{
|
||||
GdkPixbuf *pixbuf = gtk_widget_render_icon (GTK_WIDGET (canvas),
|
||||
GIMP_STOCK_WILBER,
|
||||
GTK_ICON_SIZE_DIALOG,
|
||||
NULL);
|
||||
gint wilber_width = gdk_pixbuf_get_width (pixbuf) / 2;
|
||||
gint wilber_height = gdk_pixbuf_get_height (pixbuf) / 2;
|
||||
gint wilber_x;
|
||||
gint wilber_y;
|
||||
|
||||
width = MAX (wilber_width, widget->allocation.width);
|
||||
height = MAX (wilber_height, widget->allocation.height);
|
||||
|
||||
factor = 0.5 * MIN ((gdouble) width / wilber_width,
|
||||
(gdouble) height / wilber_height);
|
||||
|
||||
cairo_scale (cr, factor, factor);
|
||||
|
||||
/* magic factors depend on the image used, everything else is
|
||||
* generic
|
||||
*/
|
||||
wilber_x = -wilber_width * 0.6;
|
||||
wilber_y = widget->allocation.height / factor - wilber_height * 1.1;
|
||||
|
||||
gdk_cairo_set_source_pixbuf (cr, pixbuf, wilber_x, wilber_y);
|
||||
cairo_rectangle (cr,
|
||||
wilber_x, wilber_y,
|
||||
wilber_width * 2, wilber_height * 2);
|
||||
cairo_fill (cr);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
g_object_unref (wilber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -66,7 +66,6 @@ struct _GimpCanvas
|
|||
GdkGC *gc[GIMP_CANVAS_NUM_STYLES];
|
||||
GdkBitmap *stipple[GIMP_CANVAS_NUM_STIPPLES];
|
||||
PangoLayout *layout;
|
||||
PangoLayout *drop_zone_layout;
|
||||
};
|
||||
|
||||
struct _GimpCanvasClass
|
||||
|
|
|
@ -1202,6 +1202,8 @@ gimp_display_shell_new (GimpDisplay *display,
|
|||
gimp_dialog_factory_add_foreign (display_factory,
|
||||
"gimp-empty-image-window",
|
||||
GTK_WIDGET (shell));
|
||||
gimp_help_set_help_data (shell->canvas, _("Drop files to open them."),
|
||||
NULL);
|
||||
}
|
||||
|
||||
gimp_display_shell_title_init (shell);
|
||||
|
@ -1288,6 +1290,8 @@ gimp_display_shell_empty (GimpDisplayShell *shell)
|
|||
|
||||
gimp_display_shell_appearance_update (shell);
|
||||
|
||||
gimp_help_set_help_data (shell->canvas, _("Drop files to open them."), NULL);
|
||||
|
||||
gimp_display_shell_expose_full (shell);
|
||||
|
||||
gtk_window_resize (GTK_WINDOW (shell), width, height);
|
||||
|
@ -1330,6 +1334,8 @@ gimp_display_shell_fill (GimpDisplayShell *shell,
|
|||
|
||||
gimp_display_shell_appearance_update (shell);
|
||||
|
||||
gimp_help_set_help_data (shell->canvas, NULL, NULL);
|
||||
|
||||
shell->fill_idle_id = g_idle_add_full (G_PRIORITY_LOW,
|
||||
(GSourceFunc) gimp_display_shell_fill_idle,
|
||||
shell, NULL);
|
||||
|
|
Loading…
Reference in New Issue