summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@gnome.org>2004-07-27 21:58:09 +0000
committerAnders Carlsson <andersca@src.gnome.org>2004-07-27 21:58:09 +0000
commit564ab37a07137d99b40cbddf89f7f28c2085ef05 (patch)
tree3d6da8d7ccc0c004415150eac2b4ee496aa9335a
parentc5541ca6c834475a8f44819c46293c4d4ccb222f (diff)
downloadgtk+-564ab37a07137d99b40cbddf89f7f28c2085ef05.tar.gz
Add gdk_draw_rectangle_alpha_libgtk_only which uses XRenderFillRectangle
2004-07-27 Anders Carlsson <andersca@gnome.org> * demos/gtk-demo/iconview.c: (do_iconview): * gdk/gdkdrawable.h: * gdk/linux-fb/gdkdrawable-fb2.c: (gdk_draw_rectangle_alpha_libgtk_only): * gdk/win32/gdkdrawable-win32.c: (gdk_draw_rectangle_alpha_libgtk_only): * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image), (get_impl_drawable), (gdk_x11_draw_pixbuf), (gdk_draw_rectangle_alpha_libgtk_only): Add gdk_draw_rectangle_alpha_libgtk_only which uses XRenderFillRectangle on X11. It's stubbed out on the Win32 and fb backends. * gtk/gtkiconview.c: (gtk_icon_view_paint_rubberband): Use gdk_draw_rectangle_alpha_libgtk_only here.
-rw-r--r--ChangeLog19
-rw-r--r--ChangeLog.pre-2-1019
-rw-r--r--ChangeLog.pre-2-619
-rw-r--r--ChangeLog.pre-2-819
-rw-r--r--demos/gtk-demo/iconview.c2
-rw-r--r--gdk/gdkdrawable.h9
-rw-r--r--gdk/linux-fb/gdkdrawable-fb2.c12
-rw-r--r--gdk/win32/gdkdrawable-win32.c12
-rw-r--r--gdk/x11/gdkdrawable-x11.c69
-rw-r--r--gtk/gtkiconview.c33
10 files changed, 196 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index b60191796f..b3e1e23d60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
+ * demos/gtk-demo/iconview.c: (do_iconview):
+ * gdk/gdkdrawable.h:
+ * gdk/linux-fb/gdkdrawable-fb2.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/win32/gdkdrawable-win32.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+ (get_impl_drawable), (gdk_x11_draw_pixbuf),
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ Add gdk_draw_rectangle_alpha_libgtk_only which uses
+ XRenderFillRectangle on X11. It's stubbed out on the
+ Win32 and fb backends.
+
+ * gtk/gtkiconview.c:
+ (gtk_icon_view_paint_rubberband):
+ Use gdk_draw_rectangle_alpha_libgtk_only here.
+
+2004-07-27 Anders Carlsson <andersca@gnome.org>
+
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
(text_view_style_set), (add_credits_page),
(display_credits_dialog), (display_license_dialog):
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index b60191796f..b3e1e23d60 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,5 +1,24 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
+ * demos/gtk-demo/iconview.c: (do_iconview):
+ * gdk/gdkdrawable.h:
+ * gdk/linux-fb/gdkdrawable-fb2.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/win32/gdkdrawable-win32.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+ (get_impl_drawable), (gdk_x11_draw_pixbuf),
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ Add gdk_draw_rectangle_alpha_libgtk_only which uses
+ XRenderFillRectangle on X11. It's stubbed out on the
+ Win32 and fb backends.
+
+ * gtk/gtkiconview.c:
+ (gtk_icon_view_paint_rubberband):
+ Use gdk_draw_rectangle_alpha_libgtk_only here.
+
+2004-07-27 Anders Carlsson <andersca@gnome.org>
+
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
(text_view_style_set), (add_credits_page),
(display_credits_dialog), (display_license_dialog):
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index b60191796f..b3e1e23d60 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,5 +1,24 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
+ * demos/gtk-demo/iconview.c: (do_iconview):
+ * gdk/gdkdrawable.h:
+ * gdk/linux-fb/gdkdrawable-fb2.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/win32/gdkdrawable-win32.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+ (get_impl_drawable), (gdk_x11_draw_pixbuf),
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ Add gdk_draw_rectangle_alpha_libgtk_only which uses
+ XRenderFillRectangle on X11. It's stubbed out on the
+ Win32 and fb backends.
+
+ * gtk/gtkiconview.c:
+ (gtk_icon_view_paint_rubberband):
+ Use gdk_draw_rectangle_alpha_libgtk_only here.
+
+2004-07-27 Anders Carlsson <andersca@gnome.org>
+
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
(text_view_style_set), (add_credits_page),
(display_credits_dialog), (display_license_dialog):
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index b60191796f..b3e1e23d60 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,5 +1,24 @@
2004-07-27 Anders Carlsson <andersca@gnome.org>
+ * demos/gtk-demo/iconview.c: (do_iconview):
+ * gdk/gdkdrawable.h:
+ * gdk/linux-fb/gdkdrawable-fb2.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/win32/gdkdrawable-win32.c:
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ * gdk/x11/gdkdrawable-x11.c: (gdk_x11_draw_image),
+ (get_impl_drawable), (gdk_x11_draw_pixbuf),
+ (gdk_draw_rectangle_alpha_libgtk_only):
+ Add gdk_draw_rectangle_alpha_libgtk_only which uses
+ XRenderFillRectangle on X11. It's stubbed out on the
+ Win32 and fb backends.
+
+ * gtk/gtkiconview.c:
+ (gtk_icon_view_paint_rubberband):
+ Use gdk_draw_rectangle_alpha_libgtk_only here.
+
+2004-07-27 Anders Carlsson <andersca@gnome.org>
+
* gtk/gtkaboutdialog.c: (gtk_about_dialog_init),
(text_view_style_set), (add_credits_page),
(display_credits_dialog), (display_license_dialog):
diff --git a/demos/gtk-demo/iconview.c b/demos/gtk-demo/iconview.c
index 56e74da745..b9f1dc6c23 100644
--- a/demos/gtk-demo/iconview.c
+++ b/demos/gtk-demo/iconview.c
@@ -320,6 +320,8 @@ do_iconview (GtkWidget *do_widget)
fill_store (store);
icon_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
+ gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
+ GTK_SELECTION_MULTIPLE);
g_object_unref (store);
/* Connect to the "clicked" signal of the "Up" tool button */
diff --git a/gdk/gdkdrawable.h b/gdk/gdkdrawable.h
index 89f2d43c44..7f8058493f 100644
--- a/gdk/gdkdrawable.h
+++ b/gdk/gdkdrawable.h
@@ -360,6 +360,15 @@ GdkImage *gdk_drawable_copy_to_image (GdkDrawable *drawable,
GdkRegion *gdk_drawable_get_clip_region (GdkDrawable *drawable);
GdkRegion *gdk_drawable_get_visible_region (GdkDrawable *drawable);
+
+gboolean gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GdkColor *color,
+ guint16 alpha);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gdk/linux-fb/gdkdrawable-fb2.c b/gdk/linux-fb/gdkdrawable-fb2.c
index eca6797043..20d1105304 100644
--- a/gdk/linux-fb/gdkdrawable-fb2.c
+++ b/gdk/linux-fb/gdkdrawable-fb2.c
@@ -1643,3 +1643,15 @@ gdk_shadow_fb_draw_lines (GdkDrawable *drawable,
}
#endif
+
+gboolean
+gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GdkColor *color,
+ guint16 alpha)
+{
+ return FALSE;
+}
diff --git a/gdk/win32/gdkdrawable-win32.c b/gdk/win32/gdkdrawable-win32.c
index c542eb9fe0..286cea9284 100644
--- a/gdk/win32/gdkdrawable-win32.c
+++ b/gdk/win32/gdkdrawable-win32.c
@@ -1822,3 +1822,15 @@ gdk_win32_drawable_get_handle (GdkDrawable *drawable)
{
return GDK_DRAWABLE_HANDLE (drawable);
}
+
+gboolean
+gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GdkColor *color,
+ guint16 alpha)
+{
+ return FALSE;
+}
diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c
index 043b3e2dcd..7d27a48e8a 100644
--- a/gdk/x11/gdkdrawable-x11.c
+++ b/gdk/x11/gdkdrawable-x11.c
@@ -817,7 +817,7 @@ gdk_x11_draw_image (GdkDrawable *drawable,
gint height)
{
GdkDrawableImplX11 *impl;
-
+
impl = GDK_DRAWABLE_IMPL_X11 (drawable);
#ifdef USE_SHM
@@ -846,7 +846,7 @@ static GdkDrawable * get_impl_drawable (GdkDrawable *drawable)
GdkDrawable *impl;
if (GDK_IS_WINDOW (drawable))
- impl = ((GdkPixmapObject *)drawable)->impl;
+ impl = ((GdkWindowObject *)drawable)->impl;
else if (GDK_IS_PIXMAP (drawable))
impl = ((GdkPixmapObject *)drawable)->impl;
else
@@ -1456,3 +1456,68 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
rowstride,
dest_x, dest_y, width, height);
}
+
+/**
+ * gdk_draw_rectangle_alpha_libgtk_only:
+ * @drawable: The #GdkDrawable to draw on
+ * @x: the x coordinate of the left edge of the rectangle.
+ * @y: the y coordinate of the top edge of the rectangle.
+ * @width: the width of the rectangle.
+ * @height: the height of the rectangle.
+ * @color: The color
+ * @alpha: The alpha value.
+ *
+ * Tries to draw a filled alpha blended rectangle using the window
+ * system's native routines. This is not public API and must not be
+ * used by applications.
+ *
+ * Return value: TRUE if the rectangle could be drawn, FALSE
+ * otherwise.
+ **/
+gboolean
+gdk_draw_rectangle_alpha_libgtk_only (GdkDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GdkColor *color,
+ guint16 alpha)
+{
+ Display *xdisplay;
+ XRenderColor render_color;
+ Picture pict;
+ int x_offset, y_offset;
+ GdkDrawable *real_drawable, *impl;
+
+ g_return_val_if_fail (color != NULL, FALSE);
+
+ if (!GDK_IS_WINDOW (drawable))
+ return FALSE;
+
+ if (!_gdk_x11_have_render (gdk_drawable_get_display (drawable)))
+ return FALSE;
+
+ gdk_window_get_internal_paint_info (GDK_WINDOW (drawable),
+ &real_drawable,
+ &x_offset, &y_offset);
+
+ impl = ((GdkWindowObject *)real_drawable)->impl;
+
+ pict = gdk_x11_drawable_get_picture (impl);
+
+ if (pict == None)
+ return FALSE;
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_drawable_get_display (drawable));
+
+ render_color.alpha = alpha;
+ render_color.red = color->red * render_color.alpha / 0xffff;
+ render_color.green = color->green * render_color.alpha / 0xffff;
+ render_color.blue = color->blue * render_color.alpha / 0xffff;
+
+ XRenderFillRectangle (xdisplay,
+ PictOpOver, pict, &render_color,
+ x - x_offset, y - y_offset,
+ width, height);
+ return TRUE;
+}
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index cf773b6345..e679642fde 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -109,7 +109,7 @@ struct _GtkIconViewPrivate
gint press_start_x;
gint press_start_y;
#endif
-
+
/* Layout used to draw icon text */
PangoLayout *layout;
@@ -173,7 +173,6 @@ static gboolean gtk_icon_view_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean gtk_icon_view_button_release (GtkWidget *widget,
GdkEventButton *event);
-
/* GtkIconView signals */
static void gtk_icon_view_set_adjustments (GtkIconView *icon_view,
GtkAdjustment *hadj,
@@ -293,7 +292,7 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
widget_class->motion_notify_event = gtk_icon_view_motion;
widget_class->button_press_event = gtk_icon_view_button_press;
widget_class->button_release_event = gtk_icon_view_button_release;
-
+
klass->set_scroll_adjustments = gtk_icon_view_set_adjustments;
klass->select_all = gtk_icon_view_real_select_all;
klass->unselect_all = gtk_icon_view_real_unselect_all;
@@ -736,8 +735,6 @@ gtk_icon_view_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window);
gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
-
-
}
static void
@@ -1067,7 +1064,6 @@ gtk_icon_view_button_release (GtkWidget *widget,
return TRUE;
}
-
static void
gtk_icon_view_update_rubberband (gpointer data)
{
@@ -1888,16 +1884,23 @@ gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
fill_color = gtk_gdk_color_to_rgb (fill_color_gdk) << 8 | fill_color_alpha;
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rect.width, rect.height);
- gdk_pixbuf_fill (pixbuf, fill_color);
+ if (!gdk_draw_rectangle_alpha_libgtk_only (icon_view->priv->bin_window,
+ rect.x, rect.y, rect.width, rect.height,
+ fill_color_gdk,
+ fill_color_alpha << 8 | fill_color_alpha))
+ {
+ pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rect.width, rect.height);
+ gdk_pixbuf_fill (pixbuf, fill_color);
+
+ gdk_draw_pixbuf (icon_view->priv->bin_window, NULL, pixbuf,
+ 0, 0,
+ rect.x,rect.y,
+ rect.width, rect.height,
+ GDK_RGB_DITHER_NONE,
+ 0, 0);
+ g_object_unref (pixbuf);
+ }
- gdk_draw_pixbuf (icon_view->priv->bin_window, NULL, pixbuf,
- 0, 0,
- rect.x,rect.y,
- rect.width, rect.height,
- GDK_RGB_DITHER_NONE,
- 0, 0);
- g_object_unref (pixbuf);
gc = gdk_gc_new (icon_view->priv->bin_window);
gdk_gc_set_rgb_fg_color (gc, fill_color_gdk);
gdk_gc_set_clip_rectangle (gc, &rect);