[gnome-calendar] month-view: helper to calculate the split of widgets



commit 9c29618fb6152cda6af5bcb4f7604ea0ba17f481
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Thu Dec 18 00:59:58 2014 -0500

    month-view: helper to calculate the split of widgets
    
    This calculates the split according to the space left on each cell

 src/gcal-month-view.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index c471b03..1f90e82 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -97,6 +97,14 @@ static gint           get_cell_and_center_from_position     (GcalMonthView  *vie
 
 static gdouble        get_start_grid_y                      (GtkWidget      *widget);
 
+static gboolean       get_widget_parts                      (gint            first_cell,
+                                                             gint            last_cell,
+                                                             gint            natural_height,
+                                                             gdouble         vertical_cell_space,
+                                                             gdouble        *size_left,
+                                                             GArray         *cells,
+                                                             GArray         *lengths);
+
 static void           gcal_view_interface_init              (GcalViewIface  *iface);
 
 static void           gcal_month_view_set_property          (GObject        *object,
@@ -251,6 +259,53 @@ get_start_grid_y (GtkWidget *widget)
   return start_grid_y;
 }
 
+static gboolean
+get_widget_parts (gint     first_cell,
+                  gint     last_cell,
+                  gint     natural_height,
+                  gdouble  vertical_cell_space,
+                  gdouble *size_left,
+                  GArray  *cells,
+                  GArray  *lengths)
+{
+  gint i;
+  gint current_part_length;
+  gdouble y, old_y = - 1.0;
+
+  if (last_cell < first_cell)
+    {
+      gint swap = last_cell;
+      last_cell = first_cell;
+      first_cell = swap;
+    }
+
+  for (i = first_cell; i <= last_cell; i++)
+    {
+      if (size_left[i] < natural_height)
+        {
+          return FALSE;
+        }
+      else
+        {
+          y = vertical_cell_space - size_left[i];
+          if (y != old_y)
+            {
+              current_part_length = 1;
+              g_array_append_val (cells, i);
+              g_array_append_val (lengths, current_part_length);
+              old_y = y;
+            }
+          else
+            {
+              current_part_length++;
+              g_array_index (lengths, gint, lengths->len - 1) = current_part_length;
+            }
+        }
+    }
+
+  return TRUE;
+}
+
 static void
 gcal_month_view_class_init (GcalMonthViewClass *klass)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]