[gnome-calendar/wip/pandusonu/week-view: 45/60] week-view: improve drawing of the week grid
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/wip/pandusonu/week-view: 45/60] week-view: improve drawing of the week grid
- Date: Fri, 2 Dec 2016 01:52:17 +0000 (UTC)
commit 12da2c44e71c3a5ccf06d6d0999e95b8bcd197b4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Nov 2 15:45:19 2016 -0200
week-view: improve drawing of the week grid
src/views/gcal-week-grid.c | 5 ++++-
src/views/gcal-week-view.c | 24 ++++++++----------------
2 files changed, 12 insertions(+), 17 deletions(-)
---
diff --git a/src/views/gcal-week-grid.c b/src/views/gcal-week-grid.c
index 91db16d..461fb88 100644
--- a/src/views/gcal-week-grid.c
+++ b/src/views/gcal-week-grid.c
@@ -241,13 +241,15 @@ gcal_week_grid_draw (GtkWidget *widget,
cairo_set_line_width (cr, 0.65);
+ /* Vertical lines */
for (i = 0; i < 7; i++)
{
cairo_move_to (cr, ((width) / 7) * i + 0.4, 0);
cairo_rel_line_to (cr, 0, height);
}
- for (i = 0; i < 24; i++)
+ /* Horizontal lines */
+ for (i = 1; i < 24; i++)
{
cairo_move_to (cr, 0, (height / 24) * i + 0.4);
cairo_rel_line_to (cr, width, 0);
@@ -255,6 +257,7 @@ gcal_week_grid_draw (GtkWidget *widget,
cairo_stroke (cr);
+ /* Dashed lines between the vertical lines */
cairo_set_dash (cr, dashed, 2, 0);
for (i = 0; i < 24; i++)
diff --git a/src/views/gcal-week-view.c b/src/views/gcal-week-view.c
index fe0e8ab..c55463a 100644
--- a/src/views/gcal-week-view.c
+++ b/src/views/gcal-week-view.c
@@ -53,7 +53,7 @@ struct _GcalWeekView
/*
* first day of the week according to user locale, being
- * 0 for Sunday, 1 for Monday and so on
+ * 0 for Sunday, 1 for Monday and so on
*/
gint first_weekday;
@@ -205,7 +205,7 @@ update_hours_sidebar_size (GcalWeekView *self)
pango_layout_get_pixel_size (layout, &hours_24_width, &hours_24_height);
sidebar_width = MAX (hours_12_width, hours_24_width) + padding.left + padding.right;
- cell_height = MAX (hours_12_height, hours_24_height) + padding.top + padding.bottom;
+ cell_height = MAX (hours_12_height, hours_24_height) + padding.top + padding.bottom + 1;
gtk_style_context_restore (context);
@@ -339,18 +339,13 @@ gcal_week_view_draw_hours (GcalWeekView *self,
else
{
hours = g_strdup_printf ("%d %s",
- i % 12,
- i < 12 ? _("AM") : _("PM"));
-
- if (i == 0)
- pango_layout_set_text (layout, _("12 PM"), -1);
- else if (i == 12)
- pango_layout_set_text (layout, _("12 AM"), -1);
- else
- pango_layout_set_text (layout, hours, -1);
+ i % 12 == 0 ? 12 : i % 12,
+ i > 12 ? _("PM") : _("AM"));
+
+ pango_layout_set_text (layout, hours, -1);
}
- cairo_move_to (cr, padding.left, (height / 24) * i + (height / 120));
+ cairo_move_to (cr, padding.left, (height / 24) * i + padding.top);
pango_cairo_show_layout (cr, layout);
g_free (hours);
@@ -358,11 +353,8 @@ gcal_week_view_draw_hours (GcalWeekView *self,
cairo_set_line_width (cr, 0.65);
- cairo_move_to (cr, gtk_widget_get_allocated_width (self->hours_bar), 0);
- cairo_rel_line_to (cr, 0, height);
-
/* Draws the horizontal complete lines */
- for (i = 0; i < 24; i++)
+ for (i = 1; i < 24; i++)
{
cairo_move_to (cr, 0, (height / 24) * i + 0.4);
cairo_rel_line_to (cr, width, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]