gcal-view: modified mark_current_unit API

Added x,y return values, positions of the current unit
This commit is contained in:
Erick Pérez Castellanos
2014-12-04 17:10:29 -05:00
parent 8cbac83723
commit a24eca0386
3 changed files with 42 additions and 10 deletions
+29 -4
View File
@@ -114,7 +114,9 @@ static icaltimetype* gcal_month_view_get_initial_date (GcalView *vie
static icaltimetype* gcal_month_view_get_final_date (GcalView *view);
static void gcal_month_view_mark_current_unit (GcalView *view);
static void gcal_month_view_mark_current_unit (GcalView *view,
gint *x,
gint *y);
static void gcal_month_view_clear_marks (GcalView *view);
@@ -1162,26 +1164,49 @@ gcal_month_view_get_final_date (GcalView *view)
new_date->day = icaltime_days_in_month (priv->date->month, priv->date->year);
return new_date;
}
static void
gcal_month_view_mark_current_unit (GcalView *view)
gcal_month_view_mark_current_unit (GcalView *view,
gint *x,
gint *y)
{
GcalMonthViewPrivate *priv;
gdouble horizontal_block;
gdouble vertical_block;
gint days;
gint shown_rows;
gint february_gap;
gdouble lines_gap;
gdouble lines_gap_for_5;
gint x_pos, y_pos;
gdouble start_grid_y;
priv = gcal_month_view_get_instance_private (GCAL_MONTH_VIEW (view));
start_grid_y = gcal_month_view_get_start_grid_y (GTK_WIDGET (view));
horizontal_block = (gdouble) gtk_widget_get_allocated_width (GTK_WIDGET (view)) / 7.0;
vertical_block = (gdouble) (gtk_widget_get_allocated_height (GTK_WIDGET (view)) - start_grid_y) / 6.0;
days = priv->days_delay + icaltime_days_in_month (priv->date->month,
priv->date->year);
days = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year);
shown_rows = ceil (days / 7.0);
february_gap = shown_rows == 4 ? 1 : 0;
lines_gap = ((gdouble) (shown_rows + 1) / 2.0) + 0.5 - ceil (shown_rows / 2.0);
lines_gap_for_5 = shown_rows == 5 ? lines_gap : 0;
priv->start_mark_cell = priv->date->day + 7 * february_gap + priv->days_delay - 1;
priv->end_mark_cell = priv->start_mark_cell;
x_pos = horizontal_block * (( priv->end_mark_cell % 7) + 0.5);
y_pos = start_grid_y + vertical_block * (lines_gap_for_5 + ( priv->end_mark_cell / 7) + 0.5);
gtk_widget_queue_draw (GTK_WIDGET (view));
if (x != NULL)
*x = x_pos;
if (y != NULL)
*y = y_pos;
}
static void