week-grid, week-header: improve rendering of vertical lines

This commit is contained in:
Georges Basile Stavracas Neto
2016-12-07 22:56:10 -02:00
parent 336e584099
commit 1c048fb538
2 changed files with 7 additions and 5 deletions
+4 -3
View File
@@ -28,6 +28,7 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#define ALIGNED(x) (round (x) + 0.5)
#define MINUTES_PER_DAY 1440 #define MINUTES_PER_DAY 1440
#define MAX_MINUTES (7 * MINUTES_PER_DAY) #define MAX_MINUTES (7 * MINUTES_PER_DAY)
@@ -370,14 +371,14 @@ gcal_week_grid_draw (GtkWidget *widget,
/* Vertical lines */ /* Vertical lines */
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
{ {
cairo_move_to (cr, ((width) / 7) * i + 0.4, 0); cairo_move_to (cr, ALIGNED (((width) / 7.0) * i), 0);
cairo_rel_line_to (cr, 0, height); cairo_rel_line_to (cr, 0, height);
} }
/* Horizontal lines */ /* Horizontal lines */
for (i = 1; i < 24; i++) for (i = 1; i < 24; i++)
{ {
cairo_move_to (cr, 0, (height / 24) * i + 0.4); cairo_move_to (cr, 0, ALIGNED ((height / 24.0) * i));
cairo_rel_line_to (cr, width, 0); cairo_rel_line_to (cr, width, 0);
} }
@@ -388,7 +389,7 @@ gcal_week_grid_draw (GtkWidget *widget,
for (i = 0; i < 24; i++) for (i = 0; i < 24; i++)
{ {
cairo_move_to (cr, 0, (height / 24) * i + (height / 48) + 0.4); cairo_move_to (cr, 0, ALIGNED ((height / 24.0) * i + (height / 48.0)));
cairo_rel_line_to (cr, width, 0); cairo_rel_line_to (cr, width, 0);
} }
+3 -2
View File
@@ -29,6 +29,7 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#define ALIGNED(x) (round (x) + 0.5)
#define COLUMN_PADDING 6 #define COLUMN_PADDING 6
struct _GcalWeekHeader struct _GcalWeekHeader
@@ -934,7 +935,7 @@ gcal_week_header_draw (GcalWeekHeader *self,
current_cell = icaltime_day_of_week (*(self->active_date)) - 1; current_cell = icaltime_day_of_week (*(self->active_date)) - 1;
current_cell = (7 + current_cell - self->first_weekday) % 7; current_cell = (7 + current_cell - self->first_weekday) % 7;
cell_width = alloc.width / 7; cell_width = alloc.width / 7.0;
pango_layout_get_pixel_size (layout, NULL, &font_height); pango_layout_get_pixel_size (layout, NULL, &font_height);
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
@@ -983,7 +984,7 @@ gcal_week_header_draw (GcalWeekHeader *self,
/* Draws the lines after each day of the week */ /* Draws the lines after each day of the week */
cairo_move_to (cr, cairo_move_to (cr,
cell_width * i + 0.5, ALIGNED (cell_width * i),
font_height + padding.bottom); font_height + padding.bottom);
cairo_set_line_width (cr, 0.25); cairo_set_line_width (cr, 0.25);