mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 18:45:10 +00:00
Use coordinate offsets to draw shades/outlines. Corrects behavior when GOTO-ing. (#287)
This commit is contained in:
parent
d621199883
commit
e2bd14e7b7
59
src/conky.cc
59
src/conky.cc
@ -422,6 +422,7 @@ struct _x11_stuff_s {
|
|||||||
/* text size */
|
/* text size */
|
||||||
|
|
||||||
static int text_start_x, text_start_y; /* text start position in window */
|
static int text_start_x, text_start_y; /* text start position in window */
|
||||||
|
static int text_offset_x, text_offset_y; /* offset for start position */
|
||||||
static int text_width = 1, text_height = 1; /* initially 1 so no zero-sized window is created */
|
static int text_width = 1, text_height = 1; /* initially 1 so no zero-sized window is created */
|
||||||
|
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
@ -1372,20 +1373,20 @@ static void draw_string(const char *s)
|
|||||||
c2.color.alpha = fonts[selected_font].font_alpha;
|
c2.color.alpha = fonts[selected_font].font_alpha;
|
||||||
if (utf8_mode.get(*state)) {
|
if (utf8_mode.get(*state)) {
|
||||||
XftDrawStringUtf8(window.xftdraw, &c2, fonts[selected_font].xftfont,
|
XftDrawStringUtf8(window.xftdraw, &c2, fonts[selected_font].xftfont,
|
||||||
cur_x, cur_y, (const XftChar8 *) s, strlen(s));
|
text_offset_x + cur_x, text_offset_y + cur_y, (const XftChar8 *) s, strlen(s));
|
||||||
} else {
|
} else {
|
||||||
XftDrawString8(window.xftdraw, &c2, fonts[selected_font].xftfont,
|
XftDrawString8(window.xftdraw, &c2, fonts[selected_font].xftfont,
|
||||||
cur_x, cur_y, (const XftChar8 *) s, strlen(s));
|
text_offset_x + cur_x, text_offset_y + cur_y, (const XftChar8 *) s, strlen(s));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (utf8_mode.get(*state)) {
|
if (utf8_mode.get(*state)) {
|
||||||
Xutf8DrawString(display, window.drawable, fonts[selected_font].fontset, window.gc, cur_x, cur_y, s,
|
Xutf8DrawString(display, window.drawable, fonts[selected_font].fontset, window.gc,
|
||||||
strlen(s));
|
text_offset_x + cur_x, text_offset_y + cur_y, s, strlen(s));
|
||||||
} else {
|
} else {
|
||||||
XDrawString(display, window.drawable, window.gc, cur_x, cur_y, s,
|
XDrawString(display, window.drawable, window.gc,
|
||||||
strlen(s));
|
text_offset_x + cur_x, text_offset_y + cur_y, s, strlen(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_x += width_of_s;
|
cur_x += width_of_s;
|
||||||
@ -1443,8 +1444,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
|
|
||||||
XSetLineAttributes(display, window.gc, h, LineSolid,
|
XSetLineAttributes(display, window.gc, h, LineSolid,
|
||||||
CapButt, JoinMiter);
|
CapButt, JoinMiter);
|
||||||
XDrawLine(display, window.drawable, window.gc, cur_x,
|
XDrawLine(display, window.drawable, window.gc, text_offset_x + cur_x,
|
||||||
cur_y - mid / 2, cur_x + w, cur_y - mid / 2);
|
text_offset_y + cur_y - mid / 2, text_offset_x + cur_x + w, text_offset_y + cur_y - mid / 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1459,8 +1460,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
XSetLineAttributes(display, window.gc, h, LineOnOffDash,
|
XSetLineAttributes(display, window.gc, h, LineOnOffDash,
|
||||||
CapButt, JoinMiter);
|
CapButt, JoinMiter);
|
||||||
XSetDashes(display, window.gc, 0, ss, 2);
|
XSetDashes(display, window.gc, 0, ss, 2);
|
||||||
XDrawLine(display, window.drawable, window.gc, cur_x,
|
XDrawLine(display, window.drawable, window.gc, text_offset_x + cur_x,
|
||||||
cur_y - mid / 2, cur_x + w, cur_y - mid / 2);
|
text_offset_y + cur_y - mid / 2, text_offset_x + cur_x + w, text_offset_x + cur_y - mid / 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1490,10 +1491,10 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
XSetLineAttributes(display, window.gc, 1, LineSolid,
|
XSetLineAttributes(display, window.gc, 1, LineSolid,
|
||||||
CapButt, JoinMiter);
|
CapButt, JoinMiter);
|
||||||
|
|
||||||
XDrawRectangle(display, window.drawable, window.gc, cur_x,
|
XDrawRectangle(display, window.drawable, window.gc, text_offset_x + cur_x,
|
||||||
by, w, h);
|
text_offset_y + by, w, h);
|
||||||
XFillRectangle(display, window.drawable, window.gc, cur_x,
|
XFillRectangle(display, window.drawable, window.gc, text_offset_x + cur_x,
|
||||||
by, w * bar_usage / scale, h);
|
text_offset_y + by, w * bar_usage / scale, h);
|
||||||
if (h > cur_y_add
|
if (h > cur_y_add
|
||||||
&& h > font_h) {
|
&& h > font_h) {
|
||||||
cur_y_add = h;
|
cur_y_add = h;
|
||||||
@ -1532,7 +1533,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
CapButt, JoinMiter);
|
CapButt, JoinMiter);
|
||||||
|
|
||||||
XDrawArc(display, window.drawable, window.gc,
|
XDrawArc(display, window.drawable, window.gc,
|
||||||
cur_x, by, w, h * 2, 0, 180*64);
|
text_offset_x + cur_x, text_offset_y + by, w, h * 2, 0, 180*64);
|
||||||
|
|
||||||
#ifdef BUILD_MATH
|
#ifdef BUILD_MATH
|
||||||
usage = current->arg;
|
usage = current->arg;
|
||||||
@ -1542,7 +1543,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
py = (float)(by+(h))-(float)(h)*sin(angle);
|
py = (float)(by+(h))-(float)(h)*sin(angle);
|
||||||
|
|
||||||
XDrawLine(display, window.drawable, window.gc,
|
XDrawLine(display, window.drawable, window.gc,
|
||||||
cur_x + (w/2.), by+(h), (int)(px), (int)(py));
|
text_offset_x + cur_x + (w/2.), text_offset_y + by+(h), text_offset_x + (int)(px), text_offset_y + (int)(py));
|
||||||
#endif /* BUILD_MATH */
|
#endif /* BUILD_MATH */
|
||||||
|
|
||||||
if (h > cur_y_add
|
if (h > cur_y_add
|
||||||
@ -1586,7 +1587,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
XSetLineAttributes(display, window.gc, 1, LineSolid,
|
XSetLineAttributes(display, window.gc, 1, LineSolid,
|
||||||
CapButt, JoinMiter);
|
CapButt, JoinMiter);
|
||||||
XDrawRectangle(display, window.drawable, window.gc,
|
XDrawRectangle(display, window.drawable, window.gc,
|
||||||
cur_x, by, w, h);
|
text_offset_x + cur_x, text_offset_y + by, w, h);
|
||||||
}
|
}
|
||||||
XSetLineAttributes(display, window.gc, 1, LineSolid,
|
XSetLineAttributes(display, window.gc, 1, LineSolid,
|
||||||
CapButt, JoinMiter);
|
CapButt, JoinMiter);
|
||||||
@ -1633,8 +1634,8 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied)
|
|||||||
}
|
}
|
||||||
/* this is mugfugly, but it works */
|
/* this is mugfugly, but it works */
|
||||||
XDrawLine(display, window.drawable, window.gc,
|
XDrawLine(display, window.drawable, window.gc,
|
||||||
cur_x + i + 1, by + h, cur_x + i + 1,
|
text_offset_x + cur_x + i + 1, text_offset_y + by + h, text_offset_x + cur_x + i + 1,
|
||||||
round_to_int((double)by + h - current->graph[j] *
|
text_offset_y + round_to_int((double)by + h - current->graph[j] *
|
||||||
(h - 1) / current->scale));
|
(h - 1) / current->scale));
|
||||||
++j;
|
++j;
|
||||||
}
|
}
|
||||||
@ -1897,7 +1898,7 @@ static void draw_text(void)
|
|||||||
|
|
||||||
int offset = border_inner_margin.get(*state) + bw;
|
int offset = border_inner_margin.get(*state) + bw;
|
||||||
XDrawRectangle(display, window.drawable, window.gc,
|
XDrawRectangle(display, window.drawable, window.gc,
|
||||||
text_start_x - offset, text_start_y - offset,
|
text_offset_x + text_start_x - offset, text_offset_y + text_start_y - offset,
|
||||||
text_width + 2*offset, text_height + 2*offset);
|
text_width + 2*offset, text_height + 2*offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1919,6 +1920,7 @@ static void draw_text(void)
|
|||||||
|
|
||||||
static void draw_stuff(void)
|
static void draw_stuff(void)
|
||||||
{
|
{
|
||||||
|
text_offset_x = text_offset_y = 0;
|
||||||
#ifdef BUILD_IMLIB2
|
#ifdef BUILD_IMLIB2
|
||||||
cimlib_render(text_start_x, text_start_y, window.width, window.height);
|
cimlib_render(text_start_x, text_start_y, window.width, window.height);
|
||||||
#endif /* BUILD_IMLIB2 */
|
#endif /* BUILD_IMLIB2 */
|
||||||
@ -1937,33 +1939,28 @@ static void draw_stuff(void)
|
|||||||
if (out_to_x.get(*state)) {
|
if (out_to_x.get(*state)) {
|
||||||
selected_font = 0;
|
selected_font = 0;
|
||||||
if (draw_shades.get(*state) && !draw_outline.get(*state)) {
|
if (draw_shades.get(*state) && !draw_outline.get(*state)) {
|
||||||
text_start_x++;
|
text_offset_x = text_offset_y = 1;
|
||||||
text_start_y++;
|
text_start_y++;
|
||||||
set_foreground_color(default_shade_color.get(*state));
|
set_foreground_color(default_shade_color.get(*state));
|
||||||
draw_mode = BG;
|
draw_mode = BG;
|
||||||
draw_text();
|
draw_text();
|
||||||
text_start_x--;
|
text_offset_x = text_offset_y = 0;
|
||||||
text_start_y--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (draw_outline.get(*state)) {
|
if (draw_outline.get(*state)) {
|
||||||
int i, j;
|
|
||||||
selected_font = 0;
|
selected_font = 0;
|
||||||
|
|
||||||
for (i = -1; i < 2; i++) {
|
for (text_offset_x = -1; text_offset_x < 2; text_offset_x++) {
|
||||||
for (j = -1; j < 2; j++) {
|
for (text_offset_y = -1; text_offset_y < 2; text_offset_y++) {
|
||||||
if (i == 0 && j == 0) {
|
if (text_offset_x == 0 && text_offset_y == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
text_start_x += i;
|
|
||||||
text_start_y += j;
|
|
||||||
set_foreground_color(default_outline_color.get(*state));
|
set_foreground_color(default_outline_color.get(*state));
|
||||||
draw_mode = OUTLINE;
|
draw_mode = OUTLINE;
|
||||||
draw_text();
|
draw_text();
|
||||||
text_start_x -= i;
|
|
||||||
text_start_y -= j;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
text_offset_x = text_offset_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_foreground_color(default_color.get(*state));
|
set_foreground_color(default_color.get(*state));
|
||||||
|
Loading…
Reference in New Issue
Block a user