#include "weston-desktop-shell-client-protocol.h"
#define DEFAULT_CLOCK_FORMAT CLOCK_FORMAT_MINUTES
+#define DEFAULT_SPACING 10
extern char **environ; /* defined by libc */
cr = widget_cairo_create(launcher->panel->widget);
widget_get_allocation(widget, &allocation);
+ allocation.x += allocation.width / 2 -
+ cairo_image_surface_get_width(launcher->icon) / 2;
+ if (allocation.width > allocation.height)
+ allocation.x += allocation.width / 2 - allocation.height / 2;
+ allocation.y += allocation.height / 2 -
+ cairo_image_surface_get_height(launcher->icon) / 2;
+ if (allocation.height > allocation.width)
+ allocation.y += allocation.height / 2 - allocation.width / 2;
if (launcher->pressed) {
allocation.x++;
allocation.y++;
cairo_t *cr;
struct rectangle allocation;
cairo_text_extents_t extents;
- cairo_font_extents_t font_extents;
time_t rawtime;
struct tm * timeinfo;
char string[128];
return;
cr = widget_cairo_create(clock->panel->widget);
- cairo_select_font_face(cr, "sans",
- CAIRO_FONT_SLANT_NORMAL,
- CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 14);
cairo_text_extents(cr, string, &extents);
- cairo_font_extents (cr, &font_extents);
- cairo_move_to(cr, allocation.x + 5,
- allocation.y + 3 * (allocation.height >> 2) + 1);
- cairo_set_source_rgb(cr, 0, 0, 0);
+ if (allocation.x > 0)
+ allocation.x +=
+ allocation.width - DEFAULT_SPACING * 1.5 - extents.width;
+ else
+ allocation.x +=
+ allocation.width / 2 - extents.width / 2;
+ allocation.y += allocation.height / 2 - 1 + extents.height / 2;
+ cairo_move_to(cr, allocation.x + 1, allocation.y + 1);
+ cairo_set_source_rgba(cr, 0, 0, 0, 0.85);
cairo_show_text(cr, string);
- cairo_move_to(cr, allocation.x + 4,
- allocation.y + 3 * (allocation.height >> 2));
- cairo_set_source_rgb(cr, 1, 1, 1);
+ cairo_move_to(cr, allocation.x, allocation.y);
+ cairo_set_source_rgba(cr, 1, 1, 1, 0.85);
cairo_show_text(cr, string);
cairo_destroy(cr);
}
{
struct panel_launcher *launcher;
struct panel *panel = data;
- int bx = width / 2;
- int by = height / 2;
- int spacing = 10;
- int x = spacing;
- int y = spacing;
- int w, h;
+ int x = 0;
+ int y = 0;
+ int w = height > width ? width : height;
+ int h = w;
int horizontal = panel->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP || panel->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
+ int first_pad_h = horizontal ? 0 : DEFAULT_SPACING / 2;
+ int first_pad_w = horizontal ? DEFAULT_SPACING / 2 : 0;
wl_list_for_each(launcher, &panel->launcher_list, link) {
- w = cairo_image_surface_get_width(launcher->icon);
- h = cairo_image_surface_get_height(launcher->icon);
-
+ widget_set_allocation(launcher->widget, x, y,
+ w + first_pad_w + 1, h + first_pad_h + 1);
if (horizontal)
- y = by - h / 2;
+ x += w + first_pad_w;
else
- x = bx - w / 2;
- widget_set_allocation(launcher->widget,
- x, y, w + 1, h + 1);
- if (horizontal)
- x += w + spacing;
- else
- y += h + spacing;
+ y += h + first_pad_h;
+ first_pad_h = first_pad_w = 0;
}
- h = 20;
-
if (panel->clock_format == CLOCK_FORMAT_SECONDS)
- w = 190;
- else /* CLOCK_FORMAT_MINUTES */
w = 170;
+ else /* CLOCK_FORMAT_MINUTES */
+ w = 150;
- if (horizontal) {
- x = width - w - spacing;
- y = by - h / 2;
- } else {
- x = bx - w / 2;
- y = height - h - spacing;
- }
+ if (horizontal)
+ x = width - w;
+ else
+ y = height - (h = DEFAULT_SPACING * 3);
if (panel->clock)
widget_set_allocation(panel->clock->widget,
width = 32;
break;
case CLOCK_FORMAT_MINUTES:
- width = 170;
+ width = 150;
break;
case CLOCK_FORMAT_SECONDS:
- width = 190;
+ width = 170;
break;
}
break;
cairo_set_source_rgba(cr, 0.0, 0.0, 0.4, 0.8);
cairo_fill(cr);
- cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
- cairo_move_to(cr, 10, 16);
+ cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.85);
+ cairo_move_to(cr, 10, 17);
+ cairo_set_font_size(cr, 14);
cairo_show_text(cr, tooltip->entry);
cairo_destroy(cr);
}
* outside repaint, either.
*/
cr = cairo_create(display->dummy_surface);
+ cairo_set_font_size(cr, 14);
cairo_text_extents(cr, tooltip->entry, &extents);
cairo_destroy(cr);