[california/wip/730602-stack: 2/2] Merge branch 'master' into wip/730602-stack



commit aacfca1c96f705d6f77b04746728991be8cab433
Merge: 454f9ae 3a51ff7
Author: Jim Nelson <jim yorba org>
Date:   Tue Oct 21 17:58:14 2014 -0700

    Merge branch 'master' into wip/730602-stack
    
    Conflicts:
        src/view/week/week-day-pane.vala

 src/view/week/week-day-pane.vala |   40 +++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 15 deletions(-)
---
diff --cc src/view/week/week-day-pane.vala
index 3d67185,40fd842..abb0144
--- a/src/view/week/week-day-pane.vala
+++ b/src/view/week/week-day-pane.vala
@@@ -140,52 -106,6 +140,47 @@@ internal class DayPane : Pane, Common.I
          schedule_monitor_minutes();
      }
      
 +    private bool filter_date_spanning_events(Component.Event event) {
 +        // All-day events are handled in separate container ...
 +        if (event.is_all_day)
 +            return false;
 +        
-         // ... as are events that span days (or outside this date, although that technically
-         // shouldn't happen)
-         Calendar.DateSpan date_span = event.get_event_date_span(Calendar.Timezone.local);
-         if (!date_span.is_same_day || !(date in date_span))
-             return false;
-         
-         return true;
++        // filter events entirely outside this date (although that should've been caught before)
++        return date in event.get_event_date_span(Calendar.Timezone.local);
 +    }
 +    
 +    private void restack_events() {
 +        // filter out date-spanning Events and not-visible calendars
 +        Gee.ArrayList<Component.Event> filtered_events = traverse<Component.Event>(days_events)
 +            .filter(filter_date_spanning_events)
 +            .filter(event => event.calendar_source != null && event.calendar_source.visible)
 +            .to_array_list();
 +        
 +        Gee.ArrayList<EventStack> stack_list = new Gee.ArrayList<EventStack>();
 +        foreach (Component.Event event in filtered_events) {
 +            // search existing stacks for a place for this Event
 +            EventStack? found = null;
 +            foreach (EventStack event_stack in stack_list) {
 +                if (event_stack.coincides_with(event)) {
 +                    found = event_stack;
 +                    
 +                    break;
 +                }
 +            }
 +            
 +            if (found == null) {
 +                found = new EventStack(event);
 +                stack_list.add(found);
 +            } else {
 +                found.add(event);
 +            }
 +        }
 +        
 +        // Can't persist EventStacks in TreeSet because mutation is not handled well, see
 +        // https://bugzilla.gnome.org/show_bug.cgi?id=736444
 +        event_stacks = traverse<EventStack>(stack_list).to_tree_set();
 +    }
 +    
      public void add_event(Component.Event event) {
          if (!days_events.add(event)) {
              debug("Unable to add event %s to day pane for %s: already present", event.to_string(),
@@@ -322,66 -258,68 +317,81 @@@
          // each event is drawn with a slightly-transparent rectangle with a solid hairline bounding
          Palette.prepare_hairline(ctx, palette.border);
          
 -        // Can't persist events in TreeSet because mutation is not handled well, see
 -        // https://bugzilla.gnome.org/show_bug.cgi?id=736444
 -        Gee.TreeSet<Component.Event> sorted_events = traverse<Component.Event>(days_events)
 -            .filter(filter_date_spanning_events)
 -            .filter(event => event.calendar_source != null && event.calendar_source.visible)
 -            .to_tree_set();
 -        foreach (Component.Event event in sorted_events) {
 -            // The actual WallTime is the time on the starting date (which may not be this Pane's
 -            // date).  The draw WallTime is the time on this Pane's date to start and end drawing
 -            // the rectangle
 -            
 -            Calendar.WallTime actual_start_time =
 -                event.exact_time_span.start_exact_time.to_timezone(Calendar.Timezone.local).to_wall_time();
 -            Calendar.WallTime draw_start_time;
 -            if (event.exact_time_span.start_date.equal_to(date))
 -                draw_start_time = actual_start_time;
 -            else
 -                draw_start_time = Calendar.WallTime.earliest;
 -            
 -            Calendar.WallTime actual_end_time =
 -                event.exact_time_span.end_exact_time.to_timezone(Calendar.Timezone.local).to_wall_time();
 -            Calendar.WallTime draw_end_time;
 -            if (event.exact_time_span.end_date.equal_to(date))
 -                draw_end_time = actual_end_time;
 -            else
 -                draw_end_time = Calendar.WallTime.latest;
 +        foreach (EventStack event_stack in event_stacks) {
 +            int stack_count = event_stack.events.size;
              
 -            int start_y = get_line_y(draw_start_time);
 -            int end_y = get_line_y(draw_end_time);
 -            
 -            Gdk.RGBA rgba = event.calendar_source.color_as_rgba();
 +            debug("stacked events: size=%d earliest=%s", stack_count, event_stack.earliest.to_string());
 +            if (stack_count > 1) {
 +                foreach (Component.Event event in event_stack.events)
 +                    debug("%s %s", event.exact_time_span.start_exact_time.to_string(), event.summary);
 +            }
              
              // 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.WHITE);
 -            ctx.fill_preserve();
 -            
 -            // interior rectangle (use alpha to mute colors)
 -            rgba.alpha = 0.25;
 -            Gdk.cairo_set_source_rgba(ctx, rgba);
 -            ctx.fill_preserve();
 -            
 -            // bounding border line and text color
 -            rgba.alpha = 1.0;
 -            Gdk.cairo_set_source_rgba(ctx, rgba);
 -            ctx.stroke();
 -            
 -            // time range on first line, summary on second ... note that separator character is an
 -            // endash
 -            string timespan = "%s &#x2013; %s".printf(
 -                actual_start_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE),
 -                actual_end_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE));
 -            Pango.Layout layout_0 = print_line(ctx, draw_start_time, 0, timespan, rgba, rect_width, true);
 -            Pango.Layout layout_1 = print_line(ctx, draw_start_time, 1, event.summary, rgba, rect_width, 
false);
 +            int rect_width = (get_allocated_width() - RIGHT_MARGIN_PX) / stack_count;
              
 -            // if either was ellipsized, set tooltip (otherwise clear any existing)
 -            bool is_ellipsized = layout_0.is_ellipsized() || layout_1.is_ellipsized();
 -            event.set_data<string?>(KEY_TOOLTIP,
 -                is_ellipsized ? "%s\n%s".printf(timespan, GLib.Markup.escape_text(event.summary)) : null);
 +            int ctr = 0;
 +            foreach (Component.Event event in event_stack.events) {
-                 Calendar.WallTime start_time =
++                // The actual WallTime is the time on the starting date (which may not be this Pane's
++                // date).  The draw WallTime is the time on this Pane's date to start and end drawing
++                // the rectangle
++                
++                Calendar.WallTime actual_start_time =
 +                    
event.exact_time_span.start_exact_time.to_timezone(Calendar.Timezone.local).to_wall_time();
-                 Calendar.WallTime end_time =
++                Calendar.WallTime draw_start_time;
++                if (event.exact_time_span.start_date.equal_to(date))
++                    draw_start_time = actual_start_time;
++                else
++                    draw_start_time = Calendar.WallTime.earliest;
++                
++                Calendar.WallTime actual_end_time =
 +                    
event.exact_time_span.end_exact_time.to_timezone(Calendar.Timezone.local).to_wall_time();
++                Calendar.WallTime draw_end_time;
++                if (event.exact_time_span.end_date.equal_to(date))
++                    draw_end_time = actual_end_time;
++                else
++                    draw_end_time = Calendar.WallTime.latest;
 +                
 +                int start_x = ctr * rect_width;
-                 int start_y = get_line_y(start_time);
-                 int end_y = get_line_y(end_time);
++                int start_y = get_line_y(draw_start_time);
++                int end_y = get_line_y(draw_end_time);
 +                int rect_height = end_y - start_y;
 +                
 +                Gdk.RGBA rgba = event.calendar_source.color_as_rgba();
 +                
 +                ctx.rectangle(start_x, start_y, rect_width, rect_height);
 +                region_manager.add_points(event, start_x, start_y, rect_width, rect_height);
 +                
 +                // background rectangle (to prevent hour lines from showing when using alpha, below)
 +                Gdk.cairo_set_source_rgba(ctx, Gfx.WHITE);
 +                ctx.fill_preserve();
 +                
 +                // interior rectangle (use alpha to mute colors)
 +                rgba.alpha = 0.25;
 +                Gdk.cairo_set_source_rgba(ctx, rgba);
 +                ctx.fill_preserve();
 +                
 +                // bounding border line and text color
 +                rgba.alpha = 1.0;
 +                Gdk.cairo_set_source_rgba(ctx, rgba);
 +                ctx.stroke();
 +                
 +                // time range on first line, summary on second ... note that separator character is an
 +                // endash
 +                string timespan = "%s &#x2013; %s".printf(
-                     start_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE),
-                     end_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE));
-                 Pango.Layout layout_0 = print_line(ctx, start_time, 0, timespan, rgba, start_x, rect_width,
++                    actual_start_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE),
++                    actual_end_time.to_pretty_string(Calendar.WallTime.PrettyFlag.NONE));
++                Pango.Layout layout_0 = print_line(ctx, draw_start_time, 0, timespan, rgba, start_x, 
rect_width,
 +                    true);
-                 Pango.Layout layout_1 = print_line(ctx, start_time, 1, event.summary, rgba, start_x,
++                Pango.Layout layout_1 = print_line(ctx, draw_start_time, 1, event.summary, rgba, start_x,
 +                    rect_width, false);
 +                
 +                // if either was ellipsized, set tooltip (otherwise clear any existing)
 +                bool is_ellipsized = layout_0.is_ellipsized() || layout_1.is_ellipsized();
 +                event.set_data<string?>(KEY_TOOLTIP,
 +                    is_ellipsized ? "%s\n%s".printf(timespan, GLib.Markup.escape_text(event.summary)) : 
null);
 +                
 +                ctr++;
 +            }
          }
          
          // draw horizontal line indicating current time


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