mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[View|Textbox] cleanups to drawing code
This commit is contained in:
parent
9b2b52b13e
commit
a53daa68c4
2 changed files with 27 additions and 36 deletions
|
@ -1344,20 +1344,18 @@ void rofi_view_update(RofiViewState *state, gboolean qr) {
|
||||||
cairo_set_source_surface(d, CacheState.fake_bg, 0.0, 0.0);
|
cairo_set_source_surface(d, CacheState.fake_bg, 0.0, 0.0);
|
||||||
} else {
|
} else {
|
||||||
cairo_set_source_surface(d, CacheState.fake_bg,
|
cairo_set_source_surface(d, CacheState.fake_bg,
|
||||||
-(double)(state->x - CacheState.mon.x),
|
(double)(CacheState.mon.x - state->x),
|
||||||
-(double)(state->y - CacheState.mon.y));
|
(double)(CacheState.mon.y - state->y));
|
||||||
}
|
}
|
||||||
cairo_paint(d);
|
|
||||||
cairo_set_operator(d, CAIRO_OPERATOR_OVER);
|
|
||||||
} else {
|
} else {
|
||||||
// Paint the background transparent.
|
// Paint the background transparent.
|
||||||
cairo_set_source_rgba(d, 0, 0, 0, 0.0);
|
cairo_set_source_rgba(d, 0, 0, 0, 0.0);
|
||||||
cairo_paint(d);
|
|
||||||
}
|
}
|
||||||
TICK_N("Background");
|
cairo_paint(d);
|
||||||
|
|
||||||
// Always paint as overlay over the background.
|
// Always paint as overlay over the background.
|
||||||
cairo_set_operator(d, CAIRO_OPERATOR_OVER);
|
cairo_set_operator(d, CAIRO_OPERATOR_OVER);
|
||||||
|
|
||||||
|
TICK_N("Background");
|
||||||
widget_draw(WIDGET(state->main_window), d);
|
widget_draw(WIDGET(state->main_window), d);
|
||||||
|
|
||||||
#ifdef XCB_IMDKIT
|
#ifdef XCB_IMDKIT
|
||||||
|
|
|
@ -494,37 +494,29 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
||||||
}
|
}
|
||||||
y += top;
|
y += top;
|
||||||
|
|
||||||
// TODO check if this is still needed after flatning.
|
// Set ARGB
|
||||||
cairo_set_operator(draw, CAIRO_OPERATOR_OVER);
|
// NOTE: cairo operator must be OVER at this moment,
|
||||||
|
// to not break subpixel text rendering.
|
||||||
|
|
||||||
cairo_set_source_rgb(draw, 0.0, 0.0, 0.0);
|
cairo_set_source_rgb(draw, 0.0, 0.0, 0.0);
|
||||||
// use text color as fallback for themes that don't specify the cursor color
|
// use text color as fallback for themes that don't specify the cursor color
|
||||||
rofi_theme_get_color(WIDGET(tb), "text-color", draw);
|
rofi_theme_get_color(WIDGET(tb), "text-color", draw);
|
||||||
|
|
||||||
// Set ARGB
|
{ int rem =
|
||||||
// We need to set over, otherwise subpixel hinting wont work.
|
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
||||||
switch (pango_layout_get_alignment(tb->layout)) {
|
line_width - dot_offset);
|
||||||
case PANGO_ALIGN_CENTER: {
|
switch (pango_layout_get_alignment(tb->layout)) {
|
||||||
int rem =
|
case PANGO_ALIGN_CENTER:
|
||||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
x = rem * (tb->xalign - 0.5);
|
||||||
line_width - dot_offset);
|
break;
|
||||||
x = (tb->xalign - 0.5) * rem + widget_padding_get_left(WIDGET(tb));
|
case PANGO_ALIGN_RIGHT:
|
||||||
break;
|
x = rem * (tb->xalign - 1.0);
|
||||||
}
|
break;
|
||||||
case PANGO_ALIGN_RIGHT: {
|
default:
|
||||||
int rem =
|
x = rem * tb->xalign + dot_offset;
|
||||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
break;
|
||||||
line_width - dot_offset);
|
}
|
||||||
x = -(1.0 - tb->xalign) * rem + widget_padding_get_left(WIDGET(tb));
|
x += widget_padding_get_left(WIDGET(tb));
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
int rem =
|
|
||||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
|
||||||
line_width - dot_offset);
|
|
||||||
x = tb->xalign * rem + widget_padding_get_left(WIDGET(tb));
|
|
||||||
x += dot_offset;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the cursor
|
// draw the cursor
|
||||||
|
@ -574,11 +566,12 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
||||||
cairo_rectangle(draw, x1, y1, x2 - x1, y2 - y1);
|
cairo_rectangle(draw, x1, y1, x2 - x1, y2 - y1);
|
||||||
cairo_clip(draw);
|
cairo_clip(draw);
|
||||||
|
|
||||||
gboolean show_outline =
|
gboolean show_outline;
|
||||||
rofi_theme_get_boolean(WIDGET(tb), "text-outline", FALSE);
|
|
||||||
if (tb->show_placeholder) {
|
if (tb->show_placeholder) {
|
||||||
rofi_theme_get_color(WIDGET(tb), "placeholder-color", draw);
|
rofi_theme_get_color(WIDGET(tb), "placeholder-color", draw);
|
||||||
show_outline = FALSE;
|
show_outline = FALSE;
|
||||||
|
} else {
|
||||||
|
show_outline = rofi_theme_get_boolean(WIDGET(tb), "text-outline", FALSE);
|
||||||
}
|
}
|
||||||
cairo_move_to(draw, x, top);
|
cairo_move_to(draw, x, top);
|
||||||
pango_cairo_show_layout(draw, tb->layout);
|
pango_cairo_show_layout(draw, tb->layout);
|
||||||
|
|
Loading…
Reference in a new issue