[Xfce4-commits] <xfce4-panel:andrzejr/deskbar-panel> panel-itembar: changing item allocation order in a vertical mode.
Andrzej
noreply at xfce.org
Tue Dec 13 07:20:10 CET 2011
Updating branch refs/heads/andrzejr/deskbar-panel
to d5852e2a43a63510770c80566cb5b7142e92c22a (commit)
from 8d7d8e0df157017e5faa344cacd521d79b29129e (commit)
commit d5852e2a43a63510770c80566cb5b7142e92c22a
Author: Andrzej <ndrwrdck at gmail.com>
Date: Tue Dec 13 15:15:48 2011 +0900
panel-itembar: changing item allocation order in a vertical mode.
Also flipped the highlight coordinates to match it, even though current DnD implementation doesn't show highlights between "small" items the way andrzejr/deskbar-github did.
panel/panel-itembar.c | 44 ++++++++++++++++++++------------------------
1 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c
index fbd42bc..4312982 100644
--- a/panel/panel-itembar.c
+++ b/panel/panel-itembar.c
@@ -30,6 +30,7 @@
#include <panel/panel-itembar.h>
#define IS_HORIZONTAL(itembar) ((itembar)->mode == XFCE_PANEL_PLUGIN_MODE_HORIZONTAL)
+#define IS_VERTICAL(itembar) ((itembar)->mode == XFCE_PANEL_PLUGIN_MODE_VERTICAL)
#define HIGHLIGHT_SIZE 2
@@ -95,7 +96,7 @@ struct _PanelItembar
/* dnd support */
gint highlight_index;
- gint highlight_x, highlight_y;
+ GdkRectangle highlight_rect;
};
typedef enum
@@ -533,15 +534,19 @@ panel_itembar_size_allocate (GtkWidget *widget,
if (IS_HORIZONTAL (itembar))
{
- itembar->highlight_x = x;
- itembar->highlight_y = y_init;
+ itembar->highlight_rect.x = x;
+ itembar->highlight_rect.y = y_init;
+ itembar->highlight_rect.width = HIGHLIGHT_SIZE;
+ itembar->highlight_rect.height = rows_size;
x += HIGHLIGHT_SIZE;
}
else
{
- itembar->highlight_x = x_init;
- itembar->highlight_y = y;
+ itembar->highlight_rect.x = x_init;
+ itembar->highlight_rect.y = y;
+ itembar->highlight_rect.width = rows_size;
+ itembar->highlight_rect.height = HIGHLIGHT_SIZE;
y += HIGHLIGHT_SIZE;
}
@@ -665,6 +670,15 @@ panel_itembar_size_allocate (GtkWidget *widget,
}
}
+ /* change the allocation order in a vertical mode */
+ if (IS_VERTICAL (itembar))
+ {
+ child_alloc.x = 2*allocation->x + allocation->width
+ - child_alloc.x - child_alloc.width;
+ itembar->highlight_rect.x = 2*allocation->x + allocation->width
+ - itembar->highlight_rect.x - itembar->highlight_rect.width;
+ }
+
gtk_widget_size_allocate (child->widget, &child_alloc);
}
}
@@ -679,29 +693,11 @@ panel_itembar_expose_event (GtkWidget *widget,
gboolean result;
cairo_t *cr;
GdkWindow *window;
- GdkRectangle rect;
- gint row_size;
result = (*GTK_WIDGET_CLASS (panel_itembar_parent_class)->expose_event) (widget, event);
if (itembar->highlight_index != -1)
{
- row_size = itembar->size * itembar->nrows;
-
- rect.x = itembar->highlight_x - 1;
- rect.y = itembar->highlight_y - 1;
-
- if (IS_HORIZONTAL (itembar))
- {
- rect.width = HIGHLIGHT_SIZE;
- rect.height = row_size;
- }
- else
- {
- rect.height = HIGHLIGHT_SIZE;
- rect.width = row_size;
- }
-
/* draw highlight box */
window = gtk_widget_get_window (widget);
cr = gdk_cairo_create (window);
@@ -710,7 +706,7 @@ panel_itembar_expose_event (GtkWidget *widget,
gdk_cairo_rectangle (cr, &event->area);
cairo_clip (cr);
- gdk_cairo_rectangle (cr, &rect);
+ gdk_cairo_rectangle (cr, &itembar->highlight_rect);
cairo_fill (cr);
cairo_destroy (cr);
More information about the Xfce4-commits
mailing list