[gnome-system-monitor] Show axis labels correctly (fixes #164)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-system-monitor] Show axis labels correctly (fixes #164)
- Date: Sun, 8 Nov 2020 01:36:32 +0000 (UTC)
commit 8d44b1f1726535b3672bf632f615c999bf654ec6
Author: Robert Roth <robert roth off gmail com>
Date: Sun Nov 8 03:36:23 2020 +0200
Show axis labels correctly (fixes #164)
src/load-graph.cpp | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index c1f29cc1..3bf1c883 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -57,6 +57,7 @@ static void draw_background(LoadGraph *graph) {
GtkAllocation allocation;
cairo_t *cr;
guint i;
+ double label_x_offset_modifier, label_y_offset_modifier;
unsigned num_bars;
char *caption;
PangoLayout* layout;
@@ -155,8 +156,12 @@ static void draw_background(LoadGraph *graph) {
pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
pango_layout_set_text (layout, caption, -1);
pango_layout_get_extents (layout, NULL, &extents);
+ label_y_offset_modifier = i == 0 ? 0.5
+ : i == num_bars
+ ? 1.0
+ : 0.85;
cairo_move_to (cr, graph->draw_width - graph->indent - 23,
- y - 1.0 * extents.height / PANGO_SCALE / 2);
+ y - label_y_offset_modifier * extents.height / PANGO_SCALE);
pango_cairo_show_layout (cr, layout);
g_free(caption);
@@ -236,8 +241,12 @@ static void draw_background(LoadGraph *graph) {
pango_layout_set_text (layout, caption, -1);
pango_layout_get_extents (layout, NULL, &extents);
+ label_x_offset_modifier = i == 0 ? 0
+ : i == 6
+ ? 1.0
+ : 0.5;
cairo_move_to (cr,
- (ceil(x) + 0.5 + graph->indent) - (1.0 * extents.width / PANGO_SCALE / 2) + 1.0,
+ (ceil(x) + 0.5 + graph->indent) - label_x_offset_modifier * extents.width /
PANGO_SCALE + 1.0,
graph->draw_height - 1.0 * extents.height / PANGO_SCALE);
gdk_cairo_set_source_rgba (cr, &fg);
pango_cairo_show_layout (cr, layout);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]