1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
Index: trunk/src/panel.h
===================================================================
--- trunk/src/panel.h (revision 639)
+++ trunk/src/panel.h (working copy)
@@ -61,6 +61,9 @@
extern int panel_strut_policy;
extern char *panel_items_order;
+// tasks alignment
+enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT };
+
extern int max_tick_urgent;
extern GArray* backgrounds;
Index: src/config.c
===================================================================
--- trunk/src/config.c (revision 639)
+++ trunk/src/config.c (working copy)
@@ -484,6 +484,14 @@
if (value2) panel_config.g_task.area.paddingy = atoi (value2);
if (value3) panel_config.g_task.area.paddingx = atoi (value3);
}
+ else if (strcmp (key, "task_align") == 0) {
+ extract_values(value, &value1, &value2, &value3);
+ printf("task_align: %s\n", value1);
+ if (strcmp (value1, "left") == 0) panel_config.g_task.align = ALIGN_LEFT;
+ else if (strcmp (value1, "center") == 0) panel_config.g_task.align = ALIGN_CENTER;
+ else if (strcmp (value1, "right") == 0) panel_config.g_task.align = ALIGN_RIGHT;
+ else fprintf(stderr, "Unknown value for task_align: %s\n", value1);
+ }
else if (strcmp (key, "task_font") == 0) {
panel_config.g_task.font_desc = pango_font_description_from_string (value);
}
Index: trunk/src/taskbar/task.h
===================================================================
--- trunk/src/taskbar/task.h (revision 639)
+++ trunk/src/taskbar/task.h (working copy)
@@ -26,6 +26,7 @@
int text;
int icon;
int centered;
+ int align;
int icon_posy;
int icon_size1;
Index: trunk/src/util/area.c
===================================================================
--- trunk/src/util/area.c (revision 639)
+++ trunk/src/util/area.c (working copy)
@@ -130,6 +130,54 @@
}
+// calculate total size of all children including
+// parent's padding
+int children_size(Area *a, int horizontal)
+{
+ int size = 0;
+ GSList *l;
+
+ for (l = a->list; l; l = l->next) {
+ Area *child = ((Area*)l->data);
+ if (!child->on_screen) continue;
+
+ if (horizontal)
+ size += child->width + a->paddingx;
+ else
+ size += child->height + a->paddingy;
+ }
+
+ return size;
+}
+
+
+// calculate chilren's align offset depending on the align type
+int align_offset(Area *a, int align, int horizontal)
+{
+ int size = 0;
+ int child_size = children_size(a, horizontal);
+
+ if (horizontal)
+ size = a->width;
+ else
+ size = a->height;
+
+ switch (align) {
+ case ALIGN_LEFT:
+ return 0;
+
+ case ALIGN_CENTER:
+ return (size - child_size) / 2;
+
+ case ALIGN_RIGHT:
+ return size - child_size;
+
+ default:
+ return 0;
+ }
+}
+
+
void size_by_layout (Area *a, int pos, int level)
{
// don't resize hiden objects
@@ -179,7 +227,9 @@
int k;
for (k=0 ; k < level ; k++) printf(" ");
printf("tree level %d, object %d, pos %d, %s\n", level, i, pos, (child->size_mode == SIZE_BY_LAYOUT) ? "SIZE_BY_LAYOUT" : "SIZE_BY_CONTENT");*/
- size_by_layout(child, pos, level+1);
+
+ int offset = align_offset(child, panel_config.g_task.align, panel_horizontal);
+ size_by_layout(child, pos + offset, level + 1);
if (panel_horizontal)
pos += child->width + a->paddingx;
|