From 0bb32bcaf42131fc8f5466ad97ad0bf63c75b644 Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Wed, 4 Mar 2009 14:47:43 +0700 Subject: [PATCH] * Display: redraw when RT changes; clean up code --- jackpanel/Display.vala | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/jackpanel/Display.vala b/jackpanel/Display.vala index 8bedafb..587bdf4 100644 --- a/jackpanel/Display.vala +++ b/jackpanel/Display.vala @@ -11,7 +11,17 @@ public class Display : PanelDisplayBase { private double realtime_h; public signal void toggle_realtime_requested (bool new_state); - public bool realtime { get; set; } + + private bool _realtime; + public bool realtime { + get { return _realtime; } + set { + if (_realtime != value) { + _realtime = value; + queue_draw (); + } + } + } static jack_nframes_t[] sample_rates = { 22050, 32000, 44100, 48000, 96000, 192000 }; private jack_nframes_t _sample_rate; @@ -76,6 +86,12 @@ public class Display : PanelDisplayBase { cr.fill (); cr.restore (); } + + private void debug_rect (Cairo.Context cr, double x, double y, double w, double h) { + set_source_from_color_string (cr, "#ff0000"); + cr.rectangle (x, y, w, h); + cr.stroke (); + } protected override bool draw_contents (Cairo.Context cr, Gdk.EventExpose event) { double padding = 3; @@ -100,12 +116,6 @@ public class Display : PanelDisplayBase { Color.parse (text_color_default, out line_color); set_source_from_color (cr, line_color, 0.5); - /* shows text boundaries for visual debugging: left bound - cr.move_to (x, y + ext.y_bearing); - cr.rel_line_to (0, ext.height); - cr.stroke(); - */ - cr.text_extents (time, ref ext); // clock time separator line var vline_x = padding + x + ext.x_advance + ext.x_bearing + padding + 1; @@ -134,8 +144,7 @@ public class Display : PanelDisplayBase { realtime_x = padding; realtime_y = y_text_below - ext.height; realtime_w = ext.x_advance; - realtime_h = ext.height + ext.y_bearing; - + realtime_h = ext.height; var x_after_rt = padding + ext.x_advance; @@ -153,12 +162,6 @@ public class Display : PanelDisplayBase { xruns_w = vline_x - x_after_rt; xruns_h = ext.height; - /* debug rect - set_source_from_color_string (cr, "#ff0000"); - cr.rectangle (xruns_x, xruns_y, xruns_w, xruns_h); - cr.stroke (); - */ - // buffer size string buffer_size_str = "%2.1fms".printf (buffer_size*1000.0/(double)sample_rate); @@ -237,7 +240,6 @@ public class Display : PanelDisplayBase { private bool was_in_realtime_rect; - /* Mouse pointer moved over widget */ public override bool motion_notify_event (Gdk.EventMotion event) { /* var cr = Gdk.cairo_create (this.window); -- 2.11.4.GIT