month-view: grey out invalid days

It should be very clear that days outside the current
month are actually not valid. The current drawing
algorithm does not differentiate that, thought, and
draws everything at the same color.

Fix that by greying out the days outside the current
month.

https://bugzilla.gnome.org/show_bug.cgi?id=763771
This commit is contained in:
Georges Basile Stavracas Neto
2017-07-30 16:03:39 +01:00
parent 24919cb81a
commit d11ed85a7f
2 changed files with 65 additions and 1 deletions
+4
View File
@@ -56,6 +56,10 @@ calendar-view.lines {
color: alpha(@theme_fg_color, 0.4);
}
calendar-view.offset {
background-color: alpha(@theme_bg_color, 0.5);
}
/* Year View CSS */
.year-view {
padding: 0px;
+61 -1
View File
@@ -1479,15 +1479,21 @@ gcal_month_view_draw (GtkWidget *widget,
gint font_width, font_height, pos_x, pos_y, shown_rows;
gint i, j, sw, lower_mark = 43, upper_mark = -2;
gint cell_width, cell_height;
gint unused_start, unused_start_width;
gint unused_end, unused_end_width;
gdouble cell_width, cell_height;
gdouble start_grid_y, first_row_gap = 0.0;
gdouble days;
gboolean is_ltr;
self = GCAL_MONTH_VIEW (widget);
ppriv = GCAL_SUBSCRIBER_VIEW (widget)->priv;
today = g_date_time_new_now_local ();
is_ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
/* fonts and colors selection */
context = gtk_widget_get_style_context (widget);
state = gtk_style_context_get_state (context);
@@ -1619,6 +1625,60 @@ gcal_month_view_draw (GtkWidget *widget,
cell_height + 1);
}
/* grey background on cells outside the current month */
unused_start = is_ltr ? 0 : real_cell (self->days_delay - 1, self->k);
unused_start_width = self->days_delay;
unused_end = is_ltr ? real_cell (days, self->k) % 7 : 0;
unused_end_width = 7 * shown_rows - days;
gtk_style_context_save (context);
gtk_style_context_add_class (context, "offset");
/* Half-cell at the top and bottom */
if (shown_rows == 5)
{
gdouble half_cell = cell_height / 2.0;
gtk_render_background (context,
cr,
0,
start_grid_y,
alloc.width,
half_cell);
gtk_render_background (context,
cr,
0,
start_grid_y + cell_height * (shown_rows + first_row_gap),
alloc.width,
cell_height / 2);
}
/* Unused cells at the start */
if (unused_start_width > 0)
{
gtk_render_background (context,
cr,
floor (cell_width * unused_start),
floor (cell_height * first_row_gap + start_grid_y),
cell_width * unused_start_width,
cell_height + 1);
}
/* Unused cells at the end */
if (unused_end_width > 0)
{
gtk_render_background (context,
cr,
floor (cell_width * unused_end),
floor (start_grid_y + cell_height * (first_row_gap + shown_rows - 1)),
cell_width * unused_end_width + 1,
cell_height + 1);
}
gtk_style_context_restore (context);
/* grid numbers */
gtk_style_context_get (context, state, "font", &font_desc, NULL);
pango_layout_set_font_description (layout, font_desc);