[california/wip/725767-week] Add right margin to week events so hour/min lines peek through



commit 9316ca2aef9217e680b9129549f4b68fea010c93
Author: Jim Nelson <jim yorba org>
Date:   Thu May 15 16:30:28 2014 -0700

    Add right margin to week events so hour/min lines peek through

 src/view/week/week-day-pane.vala |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/view/week/week-day-pane.vala b/src/view/week/week-day-pane.vala
index 0ab732e..66d570f 100644
--- a/src/view/week/week-day-pane.vala
+++ b/src/view/week/week-day-pane.vala
@@ -11,6 +11,10 @@ internal class DayPane : Pane {
     public const string PROP_DATE = "date";
     public const string PROP_SELECTED = "selected";
     
+    // No matter how wide the event is in the day, always leave a little peeking out so the hour/min
+    // lines are visible
+    private const int RIGHT_MARGIN_PX = 10;
+    
     public Calendar.Date date { get; set; }
     
     public bool selected { get; set; default = false; }
@@ -90,8 +94,9 @@ internal class DayPane : Pane {
             
             Gdk.RGBA rgba = event.calendar_source.color_as_rgba();
             
-            // event rectangle
-            ctx.rectangle(0, start_y, get_allocated_width(), end_y - start_y);
+            // event rectangle ... take some space off the right side to let the hour lines show
+            int rect_width = get_allocated_width() - RIGHT_MARGIN_PX;
+            ctx.rectangle(0, start_y, rect_width, end_y - start_y);
             
             // background rectangle (to prevent hour lines from showing when using alpha, below)
             Gdk.cairo_set_source_rgba(ctx, Gfx.RGBA_WHITE);
@@ -112,22 +117,22 @@ internal class DayPane : Pane {
             string timespan = "%s &#x2013; %s".printf(
                 start_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE),
                 end_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE));
-            print_line(ctx, start_time, 0, timespan, rgba, true);
-            print_line(ctx, start_time, 1, event.summary, rgba, false);
+            print_line(ctx, start_time, 0, timespan, rgba, rect_width, true);
+            print_line(ctx, start_time, 1, event.summary, rgba, rect_width, false);
         }
         
         return true;
     }
     
     private void print_line(Cairo.Context ctx, Calendar.WallTime start_time, int lineno, string text,
-        Gdk.RGBA rgba, bool is_markup) {
+        Gdk.RGBA rgba, int total_width, bool is_markup) {
         Pango.Layout layout = create_pango_layout(null);
         if (is_markup)
             layout.set_markup(text, -1);
         else
             layout.set_text(text, -1);
         layout.set_font_description(Palette.instance.small_font);
-        layout.set_width((get_allocated_width() - (Palette.TEXT_MARGIN_PX * 2)) * Pango.SCALE);
+        layout.set_width((total_width - (Palette.TEXT_MARGIN_PX * 2)) * Pango.SCALE);
         layout.set_ellipsize(Pango.EllipsizeMode.END);
         
         int y = get_line_y(start_time) + Palette.LINE_PADDING_PX


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