[gnome-calendar] Added actua date mark to implemented views.
- From: Erick PÃrez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] Added actua date mark to implemented views.
- Date: Fri, 13 Jul 2012 13:29:18 +0000 (UTC)
commit f462712227ef451d21d3a211f7ba4b79fc352efa
Author: Erick PÃrez Castellanos <erick red gmail com>
Date: Fri Jul 13 00:17:39 2012 -0400
Added actua date mark to implemented views.
Following mockups by Reda Lazri, the actual day it's marked by drawing a box
around the weekday and a 2px line on the cell belonging to the actual date.
Added icon to gnome-calendar.desktop. Tweaked css a little bit.
data/gnome-calendar.desktop.in.in | 2 +-
data/gtk-styles.css | 20 +++++--
src/gcal-month-view.c | 117 +++++++++++++++++++++++++++----------
src/gcal-week-view.c | 95 ++++++++++++++++++++++++-----
4 files changed, 179 insertions(+), 55 deletions(-)
---
diff --git a/data/gnome-calendar.desktop.in.in b/data/gnome-calendar.desktop.in.in
index 57d6e7f..bdb98e7 100644
--- a/data/gnome-calendar.desktop.in.in
+++ b/data/gnome-calendar.desktop.in.in
@@ -2,7 +2,7 @@
_Name=Calendar
_Comment=Access, and manage calendar
Exec=gnome-calendar
-Icon=calendr
+Icon=x-office-calendar
Terminal=false
Type=Application
StartupNotify=true
diff --git a/data/gtk-styles.css b/data/gtk-styles.css
index 7271f96..3d86c6c 100644
--- a/data/gtk-styles.css
+++ b/data/gtk-styles.css
@@ -45,10 +45,12 @@
}
.calendar-view:selected {
- background-color: #555753;
+ color: #0C73E5;
+ font: bold;
}
.event {
+ border-radius: 0;
padding-top: 3px;
padding-left: 6px;
padding-bottom: 3px;
@@ -60,15 +62,23 @@
border-style: solid;
border-color: @borders;
border-width: 0.5px;
- border-radius: 3px;
+ border-radius: 0;
}
-/* TODO: not working */
-.event-details .view {
- box-shadow: 40px 40px black;
+.entry {
+ border-radius: 0;
}
GtkClutterOffscreen.overlay {
background-color: transparent;
background-image: none;
}
+
+GtkClutterOffscreen.overlay .frame {
+ padding: 12px;
+ margin: 12px;
+}
+
+GtkClutterOffscreen.overlay .frame * {
+ color: @theme_fg_color;
+}
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 755f03d..f78b372 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -389,7 +389,7 @@ gcal_month_view_size_allocate (GtkWidget *widget,
pango_layout_get_pixel_size (layout, NULL, &font_height);
/* 6: is padding around the header */
- priv->header_size = font_height + 6;
+ priv->header_size = font_height + 12;
gtk_style_context_remove_region (context, "header");
gtk_style_context_restore (context);
@@ -799,10 +799,11 @@ gcal_month_view_draw_grid (GcalMonthView *view,
GtkStyleContext *context;
GtkStateFlags state;
GdkRGBA color;
+ GdkRGBA selected_color;
gint i, j;
gint font_width;
- gint font_height;
+ gint max_day_width;
gdouble start_grid_x;
gdouble start_grid_y;
@@ -810,6 +811,9 @@ gcal_month_view_draw_grid (GcalMonthView *view,
guint8 n_days_in_month;
PangoLayout *layout;
+ const PangoFontDescription *font;
+ const PangoFontDescription *selected_font;
+
gchar *day;
priv = view->priv;
@@ -820,81 +824,130 @@ gcal_month_view_draw_grid (GcalMonthView *view,
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
-
- /* drawing selected_cell */
- //FIXME: to draw date in the selected cell if it's not in the month
state |= GTK_STATE_FLAG_SELECTED;
- gtk_style_context_get_background_color (context, state, &color);
- cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.6);
- cairo_rectangle (cr,
- start_grid_x + priv->horizontal_step * ( priv->selected_cell % 7),
- start_grid_y + priv->vertical_step * ( priv->selected_cell / 7),
- priv->horizontal_step,
- priv->vertical_step);
- cairo_fill (cr);
-
- /* drawing grid */
+ gtk_style_context_get_color (context, state, &selected_color);
+ selected_font = gtk_style_context_get_font (context, state);
+
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_color (context, state, &color);
+ font = gtk_style_context_get_font (context, state);
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
layout = pango_cairo_create_layout (cr);
- pango_layout_set_font_description (layout,
- gtk_style_context_get_font (context,
- state));
+ pango_layout_set_font_description (layout, font);
n_days_in_month = icaltime_days_in_month (priv->date->month,
priv->date->year);
+ /* drawing grid text */
+ max_day_width = 0;
+ /* calculating maximus */
for (i = 0; i < 7; i++)
{
pango_layout_set_text (layout, gcal_get_weekday (i), -1);
pango_cairo_update_layout (cr, layout);
- pango_layout_get_pixel_size (layout, &font_width, &font_height);
+ pango_layout_get_pixel_size (layout, &font_width, NULL);
+
+ max_day_width = max_day_width < font_width ? font_width : max_day_width;
+ }
+
+ for (i = 0; i < 7; i++)
+ {
+ if (i == priv->selected_cell % 7)
+ {
+ cairo_set_source_rgba (cr, selected_color.red, selected_color.green, selected_color.blue, 1);
+ cairo_rectangle (cr,
+ start_grid_x + priv->horizontal_step * i,
+ start_grid_y - priv->grid_header_size - 6,
+ max_day_width + 12,
+ priv->grid_header_size + 6);
+ cairo_fill (cr);
+
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
+ }
+
+ pango_layout_set_text (layout, gcal_get_weekday (i), -1);
+ pango_cairo_update_layout (cr, layout);
+ pango_layout_get_pixel_size (layout, &font_width, NULL);
+
/* 6: is padding around the grid-header */
cairo_move_to (cr,
- start_grid_x + priv->horizontal_step * i + 6,
+ start_grid_x + priv->horizontal_step * i + 6 + (gint) ( (max_day_width - font_width) / 2),
start_grid_y - priv->grid_header_size);
pango_cairo_show_layout (cr, layout);
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, 1);
+
for (j = 0; j < 5; j++)
{
- gint n_day = j * 7 + i + priv->days_delay;
- if (n_day <= 0 ||
- n_day > n_days_in_month)
+ gint n_day;
+ n_day = j * 7 + i + priv->days_delay;
+ if (n_day <= 0 || n_day > n_days_in_month)
continue;
+
+ /* drawing selected_day */
+ if (priv->selected_cell == n_day - 1)
+ {
+ cairo_set_source_rgba (cr, selected_color.red, selected_color.green, selected_color.blue, 1);
+ pango_layout_set_font_description ( layout, selected_font);
+ }
+
day = g_strdup_printf ("%d", n_day);
pango_layout_set_text (layout, day, -1);
pango_cairo_update_layout (cr, layout);
- pango_layout_get_pixel_size (layout, &font_width, &font_height);
+ pango_layout_get_pixel_size (layout, &font_width, NULL);
/* 2: is margin-left and 1: is margin_top for numbers */
cairo_move_to (cr,
start_grid_x + priv->horizontal_step * i + 2,
start_grid_y + priv->vertical_step * j + 1);
pango_cairo_show_layout (cr, layout);
+
+ /* unsetting selected flag */
+ if (priv->selected_cell == n_day - 1)
+ {
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, 1);
+ pango_layout_set_font_description ( layout, font);
+ }
g_free (day);
}
}
- /* free the layout object */
- g_object_unref (layout);
+ /* drawing grid skel */
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, 1);
+ cairo_set_line_width (cr, 1.5);
for (i = 0; i < 6; i++)
{
cairo_move_to (cr, start_grid_x, start_grid_y + priv->vertical_step * i);
- cairo_line_to (cr,
- start_grid_x + priv->horizontal_step * 7,
- start_grid_y + priv->vertical_step * i);
+ cairo_rel_line_to (cr, priv->horizontal_step * 7, 0);
}
for (i = 0; i < 8; i++)
{
cairo_move_to (cr, start_grid_x + priv->horizontal_step * i, start_grid_y);
- cairo_line_to (cr,
- start_grid_x + priv->horizontal_step * i,
- start_grid_y + priv->vertical_step * 5);
+ cairo_rel_line_to (cr, 0, priv->vertical_step * 5);
}
cairo_stroke (cr);
+
+ /* drawing selected_cell */
+ //FIXME: What to do when the selected date isn't on the in the month
+ cairo_set_source_rgba (cr, selected_color.red, selected_color.green, selected_color.blue, 1);
+ /* Tiny line behind weekday box */
+ cairo_move_to (cr,
+ start_grid_x + priv->horizontal_step * ( priv->selected_cell % 7),
+ start_grid_y);
+ cairo_rel_line_to (cr, max_day_width + 12, 0);
+
+ /* Two pixel line on the selected day cell */
+ cairo_set_line_width (cr, 2.0);
+ cairo_move_to (cr,
+ start_grid_x + priv->horizontal_step * ( priv->selected_cell % 7),
+ start_grid_y + priv->vertical_step * ( priv->selected_cell / 7));
+ cairo_rel_line_to (cr, priv->horizontal_step, 0);
+ cairo_stroke (cr);
+
+ /* free the layout object */
+ g_object_unref (layout);
}
/* GcalView Interface API */
diff --git a/src/gcal-week-view.c b/src/gcal-week-view.c
index d1bda71..2744ab3 100644
--- a/src/gcal-week-view.c
+++ b/src/gcal-week-view.c
@@ -386,7 +386,7 @@ gcal_week_view_size_allocate (GtkWidget *widget,
pango_layout_get_pixel_size (layout, NULL, &font_height);
/* 6: is padding around the header */
- priv->header_size = font_height + 6;
+ priv->header_size = font_height + 12;
gtk_style_context_remove_region (context, "header");
gtk_style_context_restore (context);
@@ -726,36 +726,88 @@ gcal_week_view_draw_grid (GcalWeekView *view,
GtkStyleContext *context;
GtkStateFlags state;
GdkRGBA color;
+ GdkRGBA selected_color;
gint i;
gint font_width;
gint font_height;
+ gint max_day_width;
+ gint actual_day;
+
+ gdouble start_grid_x;
+ gdouble start_grid_y;
+
PangoLayout *layout;
+ const PangoFontDescription *font;
icaltimetype *start_of_week;
priv = view->priv;
widget = GTK_WIDGET (view);
+
+ start_grid_x = alloc->x + padding->left + priv->grid_sidebar_size;
+ start_grid_y = alloc->y + padding->top + priv->header_size + priv->grid_header_size;
+
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
+ state |= GTK_STATE_FLAG_SELECTED;
+ gtk_style_context_get_color (context, state, &selected_color);
- /* drawing grid header */
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_color (context, state, &color);
+ font = gtk_style_context_get_font (context, state);
+
+ /* drawing grid header */
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
layout = pango_cairo_create_layout (cr);
- pango_layout_set_font_description (layout,
- gtk_style_context_get_font (context,
- state));
+ pango_layout_set_font_description (layout, font);
start_of_week = gcal_week_view_get_initial_date (GCAL_VIEW (view));
+
+ /* drawing grid text */
+ max_day_width = 0;
+ actual_day = icaltime_day_of_week (*(priv->date)) - 1;
+ /* calculating maximus */
+ for (i = 0; i < 7; i++)
+ {
+ gchar *weekday_header;
+ gint n_day;
+
+ n_day = start_of_week->day + i;
+ if (n_day > icaltime_days_in_month (start_of_week->month, start_of_week->year))
+ n_day = n_day - icaltime_days_in_month (start_of_week->month, start_of_week->year);
+
+ weekday_header = g_strdup_printf ("%s %d",gcal_get_weekday (i), n_day);
+ pango_layout_set_text (layout, weekday_header, -1);
+ pango_cairo_update_layout (cr, layout);
+ pango_layout_get_pixel_size (layout, &font_width, &font_height);
+
+ max_day_width = max_day_width < font_width ? font_width : max_day_width;
+ }
+
for (i = 0; i < 7; i++)
{
gchar *weekday_header;
gint n_day;
+ if (i == actual_day)
+ {
+ cairo_set_source_rgba (cr, selected_color.red, selected_color.green, selected_color.blue, 1);
+ cairo_rectangle (cr,
+ start_grid_x + priv->horizontal_step * i,
+ start_grid_y - priv->grid_header_size - 6,
+ max_day_width + 12,
+ priv->grid_header_size + 6);
+ cairo_fill (cr);
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
+ }
+ else
+ {
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, 1);
+ }
+
n_day = start_of_week->day + i;
if (n_day > icaltime_days_in_month (start_of_week->month, start_of_week->year))
n_day = n_day - icaltime_days_in_month (start_of_week->month, start_of_week->year);
@@ -765,8 +817,8 @@ gcal_week_view_draw_grid (GcalWeekView *view,
pango_cairo_update_layout (cr, layout);
pango_layout_get_pixel_size (layout, &font_width, &font_height);
cairo_move_to (cr,
- alloc->x + padding->left + priv->grid_sidebar_size + priv->horizontal_step * i + 1 + ((priv->horizontal_step - font_width) / 2),
- alloc->y + padding->top + priv->header_size);
+ start_grid_x + priv->horizontal_step * i + 6 + (gint) ( (max_day_width - font_width) / 2),
+ start_grid_y - priv->grid_header_size);
pango_cairo_show_layout (cr, layout);
g_free (weekday_header);
@@ -774,6 +826,7 @@ gcal_week_view_draw_grid (GcalWeekView *view,
g_free (start_of_week);
/* draw grid_sidebar */
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, 1);
pango_layout_set_text (layout, _("All day"), -1);
pango_cairo_update_layout (cr, layout);
pango_layout_get_pixel_size (layout, &font_width, &font_height);
@@ -807,29 +860,37 @@ gcal_week_view_draw_grid (GcalWeekView *view,
}
/* grid, vertical lines first */
+ cairo_set_line_width (cr, 1.5);
for (i = 0; i < 8; i++)
{
cairo_move_to (cr,
- alloc->x + padding->left + priv->grid_sidebar_size + priv->horizontal_step * i,
- alloc->y + padding->top + priv->header_size + priv->grid_header_size);
- cairo_line_to (cr,
- alloc->x + padding->left + priv->grid_sidebar_size + priv->horizontal_step * i,
- alloc->y + padding->top + priv->header_size + priv->grid_header_size + priv->vertical_step * ((10 / priv->hours_steps) + 1));
+ start_grid_x + priv->horizontal_step * i,
+ start_grid_y);
+ cairo_rel_line_to (cr, 0, priv->vertical_step * ((10 / priv->hours_steps) + 1));
}
/* rest of the lines */
for (i = 0; i <= 10 / priv->hours_steps + 1; i++)
{
cairo_move_to (cr,
- alloc->x + padding->left + priv->grid_sidebar_size,
- alloc->y + padding->top + priv->header_size + priv->grid_header_size + priv->vertical_step * i);
- cairo_line_to (cr,
- alloc->x + padding->left + priv->grid_sidebar_size + priv->horizontal_step * 7,
- alloc->y + padding->top + priv->header_size + priv->grid_header_size + priv->vertical_step * i);
+ start_grid_x,
+ start_grid_y + priv->vertical_step * i);
+ cairo_rel_line_to (cr, priv->horizontal_step * 7, 0);
}
cairo_stroke (cr);
+ /* drawing selected_cell */
+ //FIXME: What to do when the selected date isn't on the in the month
+ cairo_set_source_rgba (cr, selected_color.red, selected_color.green, selected_color.blue, 1);
+ /* Two pixel line on the selected day cell */
+ cairo_set_line_width (cr, 2.0);
+ cairo_move_to (cr,
+ start_grid_x + priv->horizontal_step * ( actual_day % 7),
+ start_grid_y);
+ cairo_rel_line_to (cr, priv->horizontal_step, 0);
+ cairo_stroke (cr);
+
g_object_unref (layout);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]