[goffice] Fixed canvas widgets stacking order.
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Fixed canvas widgets stacking order.
- Date: Sun, 25 Sep 2011 19:57:45 +0000 (UTC)
commit f019e5ce2573623649b4e8070594eb4ea9325807
Author: Jean Brefort <jean brefort normalesup org>
Date: Sun Sep 25 21:52:08 2011 +0200
Fixed canvas widgets stacking order.
ChangeLog | 10 ++++++++++
goffice/canvas/goc-item.c | 40 ++++++++++++++++++++++++++++++++++++++++
goffice/canvas/goc-item.h | 3 +++
goffice/canvas/goc-widget.c | 8 +++++++-
4 files changed, 60 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f690f6e..b57887f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-09-25 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/canvas/goc-item.c (goc_item_reordered), (goc_item_raise),
+ (goc_item_lower), (goc_item_lower_to_bottom),
+ (goc_item_raise_to_top), (_goc_item_unrealize),
+ (goc_item_get_parent), (goc_item_get_window): fixed widgets stacking order.
+ * goffice/canvas/goc-item.h: ditto.
+ * goffice/canvas/goc-widget.c (goc_widget_get_window),
+ (goc_widget_class_init): ditto.
+
2011-09-24 Jean Brefort <jean brefort normalesup org>
* goffice/gtk/go-color-palette.c (draw_color_cb),
diff --git a/goffice/canvas/goc-item.c b/goffice/canvas/goc-item.c
index 6cb6dcf..8606c07 100644
--- a/goffice/canvas/goc-item.c
+++ b/goffice/canvas/goc-item.c
@@ -599,6 +599,29 @@ goc_item_ungrab (GocItem *item)
goc_canvas_ungrab_item (item->canvas);
}
+static void
+goc_item_reordered (GocItem *item, int n)
+{
+ GocGroup *group = item->parent;
+ GList *cur = g_list_find (group->children, item);
+ GdkWindow *window;
+ if (n > 0) {
+ while (cur) {
+ window = goc_item_get_window (GOC_ITEM (cur->data));
+ if (window)
+ gdk_window_raise (window);
+ cur = cur->next;
+ }
+ } else {
+ while (cur) {
+ window = goc_item_get_window (GOC_ITEM (cur->data));
+ if (window)
+ gdk_window_lower (window);
+ cur = cur->prev;
+ }
+ }
+}
+
/**
* goc_item_raise :
* @item: #GocItem
@@ -619,6 +642,7 @@ goc_item_raise (GocItem *item, int n)
item->parent->children = g_list_append (item->parent->children, item);
item->parent->children = g_list_remove_link (item->parent->children, orig);
goc_item_invalidate (item);
+ goc_item_reordered (item, n);
}
/**
@@ -641,6 +665,7 @@ goc_item_lower (GocItem *item, int n)
item->parent->children = g_list_prepend (item->parent->children, item);
item->parent->children = g_list_remove_link (item->parent->children, orig);
goc_item_invalidate (item);
+ goc_item_reordered (item, -n);
}
/**
@@ -657,6 +682,7 @@ goc_item_lower_to_bottom (GocItem *item)
item->parent->children = g_list_remove (item->parent->children, item);
item->parent->children = g_list_prepend (item->parent->children, item);
goc_item_invalidate (item);
+ goc_item_reordered (item, G_MININT);
}
/**
@@ -673,6 +699,7 @@ goc_item_raise_to_top (GocItem *item)
item->parent->children = g_list_remove (item->parent->children, item);
item->parent->children = g_list_append (item->parent->children, item);
goc_item_invalidate (item);
+ goc_item_reordered (item, G_MAXINT);
}
void
@@ -692,3 +719,16 @@ _goc_item_unrealize (GocItem *item)
klass->unrealize (item);
}
}
+
+GocGroup *
+goc_item_get_parent (GocItem *item)
+{
+ return item->parent;
+}
+
+GdkWindow *
+goc_item_get_window (GocItem *item)
+{
+ GocItemClass *klass = GOC_ITEM_GET_CLASS (item);
+ return (klass->get_window)? klass->get_window (item): NULL;
+}
diff --git a/goffice/canvas/goc-item.h b/goffice/canvas/goc-item.h
index e8e0f6b..9da18e1 100644
--- a/goffice/canvas/goc-item.h
+++ b/goffice/canvas/goc-item.h
@@ -59,6 +59,7 @@ struct _GocItemClass {
gboolean (*key_pressed) (GocItem *item, GdkEventKey* ev);
gboolean (*key_released) (GocItem *item, GdkEventKey* ev);
void (*notify_scrolled) (GocItem *item);
+ GdkWindow* (*get_window) (GocItem *item);
};
#define GOC_TYPE_ITEM (goc_item_get_type ())
@@ -85,6 +86,8 @@ gboolean goc_item_is_visible (GocItem *item);
void goc_item_get_bounds (GocItem const *item,
double *x0, double *y0,
double *x1, double *y1);
+GocGroup *goc_item_get_parent (GocItem *item);
+GdkWindow *goc_item_get_window (GocItem *item);
void goc_item_bounds_changed (GocItem *item);
void goc_item_grab (GocItem *item);
void goc_item_ungrab (GocItem *item);
diff --git a/goffice/canvas/goc-widget.c b/goffice/canvas/goc-widget.c
index d799186..4f6621f 100644
--- a/goffice/canvas/goc-widget.c
+++ b/goffice/canvas/goc-widget.c
@@ -49,7 +49,6 @@ struct _GocOffscreenBox
GtkWidget *child;
GdkWindow *offscreen_window;
gdouble angle, scale;
- cairo_surface_t *surf;
};
struct _GocOffscreenBoxClass
@@ -728,6 +727,12 @@ goc_widget_draw (GocItem const *item, cairo_t *cr)
cairo_restore (cr);
}
+static GdkWindow *
+goc_widget_get_window (GocItem *item)
+{
+ return gtk_widget_get_window (GOC_WIDGET (item)->ofbox);
+}
+
static void
goc_widget_dispose (GObject *object)
{
@@ -792,6 +797,7 @@ goc_widget_class_init (GocItemClass *item_klass)
item_klass->draw = goc_widget_draw;
item_klass->update_bounds = goc_widget_update_bounds;
item_klass->notify_scrolled = goc_widget_notify_scrolled;
+ item_klass->get_window = goc_widget_get_window;
}
GSF_CLASS (GocWidget, goc_widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]