panel_items : fixed clock on vertical panel
git-svn-id: http://tint2.googlecode.com/svn/trunk@557 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
parent
570cf17f4e
commit
8f1709079e
1 changed files with 7 additions and 16 deletions
|
@ -169,9 +169,10 @@ void init_clock_panel(void *p)
|
||||||
clock->area.height = panel->area.height - (2 * clock->area.posy);
|
clock->area.height = panel->area.height - (2 * clock->area.posy);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// panel vertical => fixed width, height, posy and posx
|
// panel vertical => fixed width, posx, height
|
||||||
clock->area.posx = panel->area.bg->border.width + panel->area.paddingy;
|
clock->area.posx = panel->area.bg->border.width + panel->area.paddingy;
|
||||||
clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
|
clock->area.width = panel->area.width - (2 * panel->area.bg->border.width) - (2 * panel->area.paddingy);
|
||||||
|
clock->area.height = time_height + date_height + (2 * clock->area.paddingxlr) + (2*clock->area.bg->border.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
clock->time1_posy = (clock->area.height - time_height) / 2;
|
clock->time1_posy = (clock->area.height - time_height) / 2;
|
||||||
|
@ -228,7 +229,7 @@ int resize_clock (void *obj)
|
||||||
{
|
{
|
||||||
Clock *clock = obj;
|
Clock *clock = obj;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
int time_width, date_width, new_width, ret = 0;
|
int time_width, date_width, ret = 0;
|
||||||
|
|
||||||
clock->area.redraw = 1;
|
clock->area.redraw = 1;
|
||||||
time_width = date_width = 0;
|
time_width = date_width = 0;
|
||||||
|
@ -237,11 +238,7 @@ int resize_clock (void *obj)
|
||||||
strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
|
strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
|
||||||
|
|
||||||
// vertical panel doen't adjust width
|
// vertical panel doen't adjust width
|
||||||
if (!panel_horizontal) {
|
if (!panel_horizontal) return ret;
|
||||||
// clock->area.posy = panel->area.bg->border.width + panel->area.paddingxlr;
|
|
||||||
// clock->area.height = (2 * clock->area.paddingxlr) + (time_height + date_height);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//printf(" resize_clock\n");
|
//printf(" resize_clock\n");
|
||||||
cairo_surface_t *cs;
|
cairo_surface_t *cs;
|
||||||
|
@ -253,7 +250,7 @@ int resize_clock (void *obj)
|
||||||
c = cairo_create (cs);
|
c = cairo_create (cs);
|
||||||
layout = pango_cairo_create_layout (c);
|
layout = pango_cairo_create_layout (c);
|
||||||
|
|
||||||
// check width
|
// check width/height
|
||||||
pango_layout_set_font_description (layout, time1_font_desc);
|
pango_layout_set_font_description (layout, time1_font_desc);
|
||||||
pango_layout_set_indent(layout, 0);
|
pango_layout_set_indent(layout, 0);
|
||||||
pango_layout_set_text (layout, buf_time, strlen(buf_time));
|
pango_layout_set_text (layout, buf_time, strlen(buf_time));
|
||||||
|
@ -265,17 +262,11 @@ int resize_clock (void *obj)
|
||||||
pango_layout_get_pixel_size (layout, &date_width, NULL);
|
pango_layout_get_pixel_size (layout, &date_width, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time_width > date_width) new_width = time_width;
|
int new_width = (time_width > date_width) ? time_width : date_width;
|
||||||
else new_width = date_width;
|
|
||||||
new_width += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width);
|
new_width += (2*clock->area.paddingxlr) + (2*clock->area.bg->border.width);
|
||||||
|
|
||||||
if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
|
if (new_width > clock->area.width || new_width < (clock->area.width-6)) {
|
||||||
// resize clock
|
|
||||||
// we try to limit the number of resize
|
// we try to limit the number of resize
|
||||||
// printf("clock_width %d, new_width %d\n", clock->area.width, new_width);
|
|
||||||
clock->area.width = new_width + 1;
|
clock->area.width = new_width + 1;
|
||||||
|
|
||||||
// resize other objects on panel
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
panel_refresh = 1;
|
panel_refresh = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue