Scale panel elements (issue #656)

This commit is contained in:
o9000
2018-01-17 05:19:32 +00:00
parent 12f04e3055
commit c7b23ee94a
18 changed files with 183 additions and 133 deletions

View File

@@ -950,7 +950,8 @@ void area_compute_text_geometry(Area *area,
strlen(line1),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
FALSE,
((Panel*)area->panel)->scale);
else
*line1_width = *line1_height_ink = *line1_height = 0;
@@ -965,7 +966,8 @@ void area_compute_text_geometry(Area *area,
strlen(line2),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
FALSE,
((Panel*)area->panel)->scale);
else
*line2_width = *line2_height_ink = *line2_height = 0;
}
@@ -1067,12 +1069,16 @@ void draw_text_area(Area *area,
PangoFontDescription *line2_font_desc,
int line1_posy,
int line2_posy,
Color *color)
Color *color,
double scale)
{
int inner_w, inner_h;
area_compute_inner_size(area, &inner_w, &inner_h);
PangoLayout *layout = pango_cairo_create_layout(c);
PangoContext *context = pango_cairo_create_context(c);
pango_cairo_context_set_resolution(context, 96 * scale);
PangoLayout *layout = pango_layout_new(context);
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
@@ -1096,6 +1102,7 @@ void draw_text_area(Area *area,
}
g_object_unref(layout);
g_object_unref(context);
}
Area *compute_element_area(Area *area, Element element)

View File

@@ -299,7 +299,8 @@ void draw_text_area(Area *area,
PangoFontDescription *line2_font_desc,
int line1_posy,
int line2_posy,
Color *color);
Color *color,
double scale);
int left_border_width(Area *a);
int right_border_width(Area *a);

View File

@@ -934,7 +934,8 @@ void get_text_size2(const PangoFontDescription *font,
int text_len,
PangoWrapMode wrap,
PangoEllipsizeMode ellipsis,
gboolean markup)
gboolean markup,
double scale)
{
PangoRectangle rect_ink, rect;
@@ -945,7 +946,9 @@ void get_text_size2(const PangoFontDescription *font,
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, available_height, available_width);
cairo_t *c = cairo_create(cs);
PangoLayout *layout = pango_cairo_create_layout(c);
PangoContext *context = pango_cairo_create_context(c);
pango_cairo_context_set_resolution(context, 96 * scale);
PangoLayout *layout = pango_layout_new(context);
pango_layout_set_width(layout, available_width * PANGO_SCALE);
pango_layout_set_height(layout, available_height * PANGO_SCALE);
pango_layout_set_wrap(layout, wrap);
@@ -964,6 +967,7 @@ void get_text_size2(const PangoFontDescription *font,
// fprintf(stderr, "tint2: dimension : %d - %d\n", rect_ink.height, rect.height);
g_object_unref(layout);
g_object_unref(context);
cairo_destroy(c);
cairo_surface_destroy(cs);
}

View File

@@ -122,7 +122,8 @@ void get_text_size2(const PangoFontDescription *font,
int text_len,
PangoWrapMode wrap,
PangoEllipsizeMode ellipsis,
gboolean markup);
gboolean markup,
double scale);
void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow);

View File

@@ -313,10 +313,10 @@ void sort_monitors()
int compute_dpi(XRRCrtcInfo *crtc, XRROutputInfo *output)
{
int width = output->mm_width;
int height = output->mm_height;
int x_res = crtc->width;
int y_res = crtc->height;
double width = output->mm_width;
double height = output->mm_height;
double x_res = crtc->width;
double y_res = crtc->height;
if (width > 0 && height > 0) {
int dpi_x = x_res / width * 25.4;
@@ -364,7 +364,7 @@ void get_monitors()
if (dpi)
server.monitors[i_monitor].dpi = dpi;
fprintf(stderr,
"tint2: xRandr: Linking output %s with crtc %d, resolution %dx%d, DPI %d\n",
BLUE "tint2: xRandr: Linking output %s with crtc %d, resolution %dx%d, DPI %d" RESET "\n",
output_info->name,
i,
server.monitors[i_monitor].width,