1 /* Demo Recorder for MAEMO 5
2 * Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 public class MeterWidget : Gtk.VBox {
23 private Gtk.Label title_label;
24 private Gtk.Label peak_label;
25 private Gtk.Label decay_label;
26 private DbMonitorWidget meter;
28 private static const int BORDER_WIDTH = 4;
29 private static const int BORDER_HEIGHT = 4;
30 //private Pango.Layout layout;
31 private static const double MIN_VALUE = 0.0;
32 private static const double MAX_VALUE = 1.5;
34 private static const double ZERO_VALUE = 1.0;
38 public void set_peak(double val) {
39 this.peak = (MAX_VALUE > val) ? val : MAX_VALUE;
40 this.peak_label.set_text("%02.2f".printf(val));
41 meter.set_peak(Math.pow (10, val / 20));
43 public void set_decay(double val) {
44 this.decay = (MAX_VALUE > val) ? val : MAX_VALUE;
45 this.decay_label.set_text("%02.2f".printf(val));
46 meter.set_decay(Math.pow (10, val / 20));
48 private DbMonitorWidget.Layout layout = DbMonitorWidget.Layout.VERTICAL;
49 public void set_layout(DbMonitorWidget.Layout layout) {
51 meter.set_layout(layout);
56 return title_label.get_text();
59 title_label.set_text(value);
64 title_label = new Gtk.Label("");
65 title_label.modify_font(Pango.FontDescription.from_string("Sans 20"));
66 title_label.set_padding(4, 2);
67 //title_label.set_alignment(0,0);
69 this.pack_start(title_label, false, true, 4);
71 meter = new DbMonitorWidget();
72 meter.set_layout(layout);
75 this.pack_start(meter, true, true, 0);
77 Gtk.HBox display = new Gtk.HBox(true, 8);
79 peak_label = new Gtk.Label("0.0");
80 peak_label.modify_font(Pango.FontDescription.from_string("Sans 40"));
81 peak_label.set_padding(4, 2);
82 //peak_label.set_alignment(0,0);
83 decay_label = new Gtk.Label("0.0");
84 decay_label.modify_font(Pango.FontDescription.from_string("Sans 40"));
85 decay_label.set_padding(4, 2);
86 //decay_label.set_alignment(0,0);
88 display.add(peak_label);
89 display.add(decay_label);
91 this.pack_start(display, false, true, 0);
93 Gtk.HBox display2 = new Gtk.HBox(true, 0);
95 Gtk.Label peak_label2 = new Gtk.Label("dB Peak");
96 peak_label2.modify_font(Pango.FontDescription.from_string("Sans 16"));
97 peak_label2.set_padding(0, 0);
98 //peak_label2.set_alignment(0,0);
99 Gtk.Label decay_label2 = new Gtk.Label("dB Decay");
100 decay_label2.modify_font(Pango.FontDescription.from_string("Sans 16"));
101 decay_label2.set_padding(0, 0);
102 //decay_label2.set_alignment(0,0);
104 display2.add(peak_label2);
105 display2.add(decay_label2);
107 this.pack_start(display2, false, true, 0);