[libegg] Initial shot at rendering a drag icon for EggSpreadTableDnd
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libegg] Initial shot at rendering a drag icon for EggSpreadTableDnd
- Date: Mon, 29 Aug 2011 16:31:47 +0000 (UTC)
commit fa232eb12dac62d8679c69d892b8eade0beef743
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Mon Aug 29 18:31:54 2011 +0200
Initial shot at rendering a drag icon for EggSpreadTableDnd
This patch uses the dragged widget itself to draw an icon for Drag'n'Drop.
Currently there are still problems if the widget itself is not 100% viewable.
libegg/spreadtable/eggspreadtablednd.c | 33 +++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/libegg/spreadtable/eggspreadtablednd.c b/libegg/spreadtable/eggspreadtablednd.c
index 6fad48e..2b7360a 100644
--- a/libegg/spreadtable/eggspreadtablednd.c
+++ b/libegg/spreadtable/eggspreadtablednd.c
@@ -926,10 +926,38 @@ egg_spread_table_dnd_drop_possible (EggSpreadTableDnd *table,
/*****************************************************
* Drag'n'Drop signals & other functions *
*****************************************************/
+static void
+set_drag_icon (GtkWidget *widget,
+ GdkDragContext *context)
+{
+ GtkWidget *toplevel;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ gint x, y;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+ cr = cairo_create (surface);
+
+ gtk_widget_translate_coordinates (widget, toplevel, 0, 0, &x, &y);
+
+ cairo_translate (cr, -x, -y);
+
+ gtk_widget_draw (toplevel, cr);
+
+ gtk_drag_set_icon_surface (context, surface);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+}
+
static void
drag_begin (GtkWidget *widget,
- G_GNUC_UNUSED GdkDragContext *context,
+ GdkDragContext *context,
EggSpreadTableDnd *spread_table)
{
GtkAllocation allocation;
@@ -962,6 +990,9 @@ drag_begin (GtkWidget *widget,
adjust_line_segment (spread_table,
get_child_line (spread_table, spread_table->priv->drop_target), 1);
+ /* Set the icon for the drag */
+ set_drag_icon (spread_table->priv->drag_child, context);
+
/* Hide the drag child (we cant remove it because it needs a GdkWindow in the mean time) */
gtk_widget_hide (spread_table->priv->drag_child);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]