[california/wip/725767-week] Fix some pixel issues with all-day event bars overlapping borders
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california/wip/725767-week] Fix some pixel issues with all-day event bars overlapping borders
- Date: Thu, 22 May 2014 20:18:32 +0000 (UTC)
commit a6f0da51cc3d7999b3d8a95c7a717603c8e62b36
Author: Jim Nelson <jim yorba org>
Date: Thu May 22 13:17:57 2014 -0700
Fix some pixel issues with all-day event bars overlapping borders
Also fixes all-day event cells in week view lining up properly with
day panes below.
src/view/common/common-events-cell.vala | 17 +++------------
src/view/week/week-all-day-cell.vala | 10 ++------
src/view/week/week-grid.vala | 32 +++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 20 deletions(-)
---
diff --git a/src/view/common/common-events-cell.vala b/src/view/common/common-events-cell.vala
index a6cc26b..4b54ab0 100644
--- a/src/view/common/common-events-cell.vala
+++ b/src/view/common/common-events-cell.vala
@@ -407,13 +407,7 @@ internal abstract class EventsCell : Gtk.EventBox {
protected virtual void draw_borders(Cairo.Context ctx) {
}
- /**
- * Can be overridden by children to achieve painters' strategy effects while drawing.
- */
- protected virtual bool on_draw(Cairo.Context ctx) {
- // save and restore context so subclasses don't have to deal with it
- ctx.save();
-
+ private bool on_draw(Cairo.Context ctx) {
// shade background of cell for selection or if today
if (selected) {
Gdk.cairo_set_source_rgba(ctx, Palette.instance.selection);
@@ -442,8 +436,7 @@ internal abstract class EventsCell : Gtk.EventBox {
// only show the title if (a) the first day of an all-day event or (b) this is the
// first day of a contiguous span of a multi-day event. (b) handles the contingency of a
// multi-day event starting in a previous week prior to the top of the current view
- display_text = date_span.start_date.equal_to(date)
- || neighbors.start_date.equal_to(date);
+ display_text = date_span.start_date.equal_to(date) || neighbors.start_date.equal_to(date);
}
string text;
@@ -484,8 +477,6 @@ internal abstract class EventsCell : Gtk.EventBox {
event.set_data<string?>(KEY_TOOLTIP, layout.is_ellipsized() ? text : null);
}
- ctx.restore();
-
return true;
}
@@ -537,7 +528,7 @@ internal abstract class EventsCell : Gtk.EventBox {
case CapEffect.POINTED:
ctx.move_to(right - POINTED_CAP_WIDTH_PX, top);
- ctx.line_to(right, top + (Palette.instance.small_font_height_px / 2));
+ ctx.line_to(right - 1, top + (Palette.instance.small_font_height_px / 2));
ctx.line_to(right - POINTED_CAP_WIDTH_PX, bottom);
break;
@@ -559,7 +550,7 @@ internal abstract class EventsCell : Gtk.EventBox {
case CapEffect.POINTED:
ctx.line_to(left + POINTED_CAP_WIDTH_PX, bottom);
- ctx.line_to(left, top + (Palette.instance.small_font_height_px / 2));
+ ctx.line_to(left + 1, top + (Palette.instance.small_font_height_px / 2));
ctx.line_to(left + POINTED_CAP_WIDTH_PX, top);
break;
diff --git a/src/view/week/week-all-day-cell.vala b/src/view/week/week-all-day-cell.vala
index 617e24a..8886056 100644
--- a/src/view/week/week-all-day-cell.vala
+++ b/src/view/week/week-all-day-cell.vala
@@ -50,21 +50,17 @@ internal class AllDayCell : Common.EventsCell {
// draw border lines (creates grid effect)
Palette.prepare_hairline(ctx, Palette.instance.border);
- // if last day of week, draw right border prepping for bottom border
+ // draw right border, unless last one in row, in which case spacer deals with that
if (date.equal_to(neighbors.end_date)) {
+ ctx.move_to(width, height);
+ } else {
ctx.move_to(width, 0);
ctx.line_to(width, height);
- } else {
- // otherwise, prepare for bottom border
- ctx.move_to(width, height);
}
// draw bottom border
ctx.line_to(0, height);
- // draw left border
- ctx.line_to(0, 0);
-
ctx.stroke();
}
}
diff --git a/src/view/week/week-grid.vala b/src/view/week/week-grid.vala
index 29ee9b5..f0a87cf 100644
--- a/src/view/week/week-grid.vala
+++ b/src/view/week/week-grid.vala
@@ -62,6 +62,7 @@ internal class Grid : Gtk.Box {
Gtk.DrawingArea left_spacer = new Gtk.DrawingArea();
left_spacer.set_size_request(HourRunner.REQUESTED_WIDTH, -1);
left_spacer.draw.connect(on_draw_bottom_line);
+ left_spacer.draw.connect(on_draw_left_spacer_right_border);
top_box.pack_start(left_spacer, false, false, 0);
// hold day labels and all-day cells in a non-scrolling horizontal grid
@@ -75,6 +76,7 @@ internal class Grid : Gtk.Box {
// to line up with day panes grid below, need to account for the space of the ScrolledWindow's
// scrollbar
right_spacer = new Gtk.DrawingArea();
+ right_spacer.draw.connect(on_draw_right_spacer_left_border);
top_box.pack_end(right_spacer, false, false, 0);
// hold Panes (DayPanes and HourRunner) in a scrolling Gtk.Grid
@@ -183,6 +185,36 @@ internal class Grid : Gtk.Box {
return false;
}
+ // Draw the left spacer's right-hand line, which only goes up from the bottom to the top of the
+ // all-day cell it's adjacent to
+ private bool on_draw_left_spacer_right_border(Gtk.Widget widget, Cairo.Context ctx) {
+ int width = widget.get_allocated_width();
+ int height = widget.get_allocated_height();
+ Gtk.Widget adjacent = date_to_all_day.get(week.start_date);
+
+ Palette.prepare_hairline(ctx, Palette.instance.border);
+
+ ctx.move_to(width, height - adjacent.get_allocated_height());
+ ctx.line_to(width, height);
+ ctx.stroke();
+
+ return false;
+ }
+
+ // Like on_draw_left_spacer_right_line, this line is for the right spacer's left border
+ private bool on_draw_right_spacer_left_border(Gtk.Widget widget, Cairo.Context ctx) {
+ int height = widget.get_allocated_height();
+ Gtk.Widget adjacent = date_to_all_day.get(week.end_date);
+
+ Palette.prepare_hairline(ctx, Palette.instance.border);
+
+ ctx.move_to(0, height - adjacent.get_allocated_height());
+ ctx.line_to(0, height);
+ ctx.stroke();
+
+ return false;
+ }
+
private void on_realloc_right_spacer() {
// need to do outside of allocation signal due to some mechanism in GTK that prevents resizes
// while resizing
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]