From e35a76e7352729408e82c2965dfd2e0e2de21294 Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Thu, 25 Oct 2012 16:40:00 +0700 Subject: [PATCH] Use Display as background for LineGraph --- src/Display.vala | 7 +++++-- src/LineGraph.vala | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Display.vala b/src/Display.vala index b8b64a7..7891293 100644 --- a/src/Display.vala +++ b/src/Display.vala @@ -293,11 +293,14 @@ public abstract class DisplayBase : DrawingArea { cr.fill (); } - public static void reflection(Cairo.Context cr, double w, double h) { + public static void reflection(Cairo.Context cr, double w, double h, double reflection_start = -1) { // reflection + if (reflection_start < 0) + reflection_start = h - 3; + cr.new_path (); cr.move_to (0.0, 0.0); - cr.line_to (0.0, h - 3); + cr.line_to (0.0, reflection_start); cr.curve_to (w / 3.0, h / 3.0, w * 2.0 / 3.0, 17.0 * h / 59.0, w, 15.0 * h / 59.0); cr.line_to (w, 0.0); cr.close_path (); diff --git a/src/LineGraph.vala b/src/LineGraph.vala index 3937740..9b46d2e 100644 --- a/src/LineGraph.vala +++ b/src/LineGraph.vala @@ -231,7 +231,7 @@ public class LineGraph : DrawingArea { private int last_generation; construct { - set_size_request (40, 40); + set_size_request (400, 400); cache_surface = null; last_generation = 0; var src = new FrequencyResponseGraphSource(); @@ -352,6 +352,7 @@ public class LineGraph : DrawingArea { cairo_set_source_color (c, sc); c.rectangle (ox, oy, sx, sy); c.clip (); + CairoLineProperties cairoimpl = new CairoLineProperties (); cairoimpl.context = c; ILineProperties cimpl = cairoimpl; @@ -381,6 +382,36 @@ public class LineGraph : DrawingArea { cache_cr.clip_preserve (); cache_cr.fill (); + { //Display + bool show_matrix = true; + bool show_glass_rim = false; + double inner_width = show_glass_rim ? (sx - 14) : (sx - 6); + double inner_height = show_glass_rim ? (sy - 13) : (sy - 6); + cache_cr.save(); + + set_line_width_from_device (cache_cr); + + DisplayBase.outer_rim_for_display (cache_cr, 0, 0, sx, sy, style.bg[(int)Gtk.StateType.NORMAL]); + + if (show_glass_rim) { + cache_cr.translate (4.5, 3.5); + DisplayBase.inner_glass_rim (cache_cr, 0, 0, sx - 8, sy - 9, 2); + } + + cache_cr.translate (3.0, 3.0); + + DisplayBase.lcd(cache_cr, inner_width, inner_height, sy > 30 ? 5.0 : 3.0); + + if (show_matrix) { + DisplayBase.dot_matrix (cache_cr, show_glass_rim ? 0 : 0.5, show_glass_rim ? 0 : 0.5, inner_width, inner_height, DisplayBase.matrix_dot_color ()); + } + + DisplayBase.reflection(cache_cr, inner_width, inner_height, inner_height / 2.0); + + cache_cr.restore(); + } + + CairoLineProperties cache_cairoimpl = new CairoLineProperties (); cache_cairoimpl.context = cache_cr; ILineProperties cache_cimpl = cache_cairoimpl; -- 2.11.4.GIT