Beispiel #1
0
int freespace_get_max_size(Panel *panel)
{
    if (panel_shrink)
        return 0;
    // Get space used by every element except the freespace
    int size = 0;
    int spacers = 0;
    for (GList *walk = panel->area.children; walk; walk = g_list_next(walk)) {
        Area *a = (Area *)walk->data;

        if (!a->on_screen)
            continue;
        if (a->_resize == resize_freespace) {
            spacers++;
            continue;
        }

        if (panel_horizontal)
            size += a->width + panel->area.paddingx * panel->scale;
        else
            size += a->height + panel->area.paddingy * panel->scale;
    }

    if (panel_horizontal)
        size = panel->area.width - size - left_right_border_width(&panel->area) - panel->area.paddingxlr * panel->scale;
    else
        size = panel->area.height - size - top_bottom_border_width(&panel->area) - panel->area.paddingxlr * panel->scale;

    return size / spacers;
}
Beispiel #2
0
int separator_compute_desired_size(void *obj)
{
	Separator *separator = (Separator *)obj;
	if (!separator->area.on_screen)
		return 0;

	if (panel_horizontal)
		return separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area);
	else
		return separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area);
}
Beispiel #3
0
gboolean resize_separator(void *obj)
{
	Separator *separator = (Separator *)obj;
	if (!separator->area.on_screen)
		return FALSE;

	if (panel_horizontal) {
		separator->area.width =
		    separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area);
		separator->length =
		    separator->area.height - 2 * separator->area.paddingy - top_bottom_border_width(&separator->area);
	} else {
		separator->area.height =
		    separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area);
		separator->length =
		    separator->area.width - 2 * separator->area.paddingy - left_right_border_width(&separator->area);
	}

	schedule_redraw(&separator->area);
	panel_refresh = TRUE;
	return TRUE;
}
Beispiel #4
0
int clock_compute_desired_size(void *obj)
{
	Clock *clock = (Clock *)obj;
	Panel *panel = (Panel *)clock->area.panel;
	int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
	clock_compute_text_geometry(panel,
	                            &time_height_ink,
	                            &time_height,
	                            &time_width,
	                            &date_height_ink,
	                            &date_height,
	                            &date_width);

	if (panel_horizontal) {
		int new_size = (time_width > date_width) ? time_width : date_width;
		new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area);
		return new_size;
	} else {
		int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
		return new_size;
	}
}
Beispiel #5
0
gboolean resize_execp(void *obj)
{
	Execp *execp = (Execp *)obj;
	Panel *panel = (Panel *)execp->area.panel;
	int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
	int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
	int interior_padding = execp->area.paddingx;

	int icon_w, icon_h;
	if (reload_icon(execp)) {
		if (execp->backend->icon) {
			imlib_context_set_image(execp->backend->icon);
			icon_w = imlib_image_get_width();
			icon_h = imlib_image_get_height();
		} else {
			icon_w = icon_h = 0;
		}
	} else {
		icon_w = icon_h = 0;
	}

	int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2;

	int txt_height_ink, txt_height, txt_width;
	if (panel_horizontal) {
		get_text_size2(execp->backend->font_desc,
		               &txt_height_ink,
		               &txt_height,
		               &txt_width,
		               panel->area.height,
		               panel->area.width,
		               execp->backend->text,
		               strlen(execp->backend->text),
		               PANGO_WRAP_WORD_CHAR,
		               PANGO_ELLIPSIZE_NONE,
		               execp->backend->has_markup);
	} else {
		get_text_size2(execp->backend->font_desc,
		               &txt_height_ink,
		               &txt_height,
		               &txt_width,
		               panel->area.height,
		               !text_next_line
		                   ? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
		                         left_right_border_width(&execp->area)
		                   : execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
		               execp->backend->text,
		               strlen(execp->backend->text),
		               PANGO_WRAP_WORD_CHAR,
		               PANGO_ELLIPSIZE_NONE,
		               execp->backend->has_markup);
	}

	gboolean result = FALSE;
	if (panel_horizontal) {
		int new_size = txt_width;
		if (icon_w)
			new_size += interior_padding + icon_w;
		new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
		if (new_size > execp->area.width || new_size < (execp->area.width - 6)) {
			// we try to limit the number of resize
			execp->area.width = new_size + 1;
			result = TRUE;
		}
	} else {
		int new_size;
		if (!text_next_line) {
			new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
			new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
		} else {
			new_size =
			    icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
		}
		if (new_size != execp->area.height) {
			execp->area.height = new_size;
			result = TRUE;
		}
	}
	execp->frontend->textw = txt_width;
	execp->frontend->texth = txt_height;
	if (execp->backend->centered) {
		if (icon_w) {
			if (!text_next_line) {
				execp->frontend->icony = (execp->area.height - icon_h) / 2;
				execp->frontend->iconx = (execp->area.width - txt_width - interior_padding - icon_w) / 2;
				execp->frontend->texty = (execp->area.height - txt_height) / 2;
				execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding;
			} else {
				execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2;
				execp->frontend->iconx = (execp->area.width - icon_w) / 2;
				execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding;
				execp->frontend->textx = (execp->area.width - txt_width) / 2;
			}
		} else {
			execp->frontend->texty = (execp->area.height - txt_height) / 2;
			execp->frontend->textx = (execp->area.width - txt_width) / 2;
		}
	} else {
		if (icon_w) {
			if (!text_next_line) {
				execp->frontend->icony = (execp->area.height - icon_h) / 2;
				execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
				execp->frontend->texty = (execp->area.height - txt_height) / 2;
				execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding;
			} else {
				execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2;
				execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
				execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding;
				execp->frontend->textx = execp->frontend->iconx;
			}
		} else {
			execp->frontend->texty = (execp->area.height - txt_height) / 2;
			execp->frontend->textx = left_border_width(&execp->area) + horiz_padding;
		}
	}

	schedule_redraw(&execp->area);

	return result;
}
Beispiel #6
0
int execp_compute_desired_size(void *obj)
{
	Execp *execp = (Execp *)obj;
	Panel *panel = (Panel *)execp->area.panel;
	int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
	int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
	int interior_padding = execp->area.paddingx;

	int icon_w, icon_h;
	if (reload_icon(execp)) {
		if (execp->backend->icon) {
			imlib_context_set_image(execp->backend->icon);
			icon_w = imlib_image_get_width();
			icon_h = imlib_image_get_height();
		} else {
			icon_w = icon_h = 0;
		}
	} else {
		icon_w = icon_h = 0;
	}

	int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2;

	int txt_height_ink, txt_height, txt_width;
	if (panel_horizontal) {
		get_text_size2(execp->backend->font_desc,
					   &txt_height_ink,
					   &txt_height,
					   &txt_width,
					   panel->area.height,
					   panel->area.width,
					   execp->backend->text,
					   strlen(execp->backend->text),
					   PANGO_WRAP_WORD_CHAR,
					   PANGO_ELLIPSIZE_NONE,
					   execp->backend->has_markup);
	} else {
		get_text_size2(execp->backend->font_desc,
					   &txt_height_ink,
					   &txt_height,
					   &txt_width,
					   panel->area.height,
					   !text_next_line
						   ? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
								 left_right_border_width(&execp->area)
						   : execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
					   execp->backend->text,
					   strlen(execp->backend->text),
					   PANGO_WRAP_WORD_CHAR,
					   PANGO_ELLIPSIZE_NONE,
					   execp->backend->has_markup);
	}

	if (panel_horizontal) {
		int new_size = txt_width;
		if (icon_w)
			new_size += interior_padding + icon_w;
		new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
		return new_size;
	} else {
		int new_size;
		if (!text_next_line) {
			new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
			new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
		} else {
			new_size =
				icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
		}
		return new_size;
	}
}