--- /dev/null
+/* Demo Recorder for MAEMO 5
+* Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2,
+* or (at your option) any later version, as published by the Free
+* Software Foundation
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details
+*
+* You should have received a copy of the GNU General Public
+* License along with this program; if not, write to the
+* Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+namespace IdWorks {
+
+public class DynamicsPopUp : Hildon.Dialog {
+
+ Hildon.TouchSelector characteristics_selector;
+ Hildon.TouchSelector mode_selector;
+ Gtk.HScale ratio_slider;
+ Gtk.HScale threshold_slider;
+
+ public signal void characteristics_updated(string val);
+ public signal void mode_updated(string val);
+ public signal void ratio_updated(double val);
+ public signal void threshold_updated(double val);
+
+ public SettingsStructures.DynamicsSettings get_settings_structure() {
+ SettingsStructures.DynamicsSettings settings = SettingsStructures.DynamicsSettings();
+ settings.active = true;
+ settings.mode = this.get_mode();
+ settings.characteristics = this.get_characteristics();
+ settings.ratio = this.get_ratio();
+ settings.threshold = this.get_threshold();
+ return settings;
+ }
+ public void set_settings_structure(SettingsStructures.DynamicsSettings settings) {
+ // ignore active for now
+ this.set_mode(settings.mode);
+ this.set_characteristics(settings.characteristics);
+ this.set_ratio(settings.ratio);
+ this.set_threshold(settings.threshold);
+ }
+
+ public DynamicsPopUp(string title, Gtk.Widget parent) {
+ this.set_title(title);
+ this.set_parent(parent);
+ this.construct_interface(SettingsStructures.DynamicsSettings());
+ }
+ public DynamicsPopUp.with_settings(string title, Gtk.Widget parent, SettingsStructures.DynamicsSettings settings) {
+ this.set_title(title);
+ this.set_parent(parent);
+ stdout.printf("dynamics popup constructing interface\n");
+ stdout.flush();
+ this.construct_interface(settings);
+ stdout.printf("dynamics popup interface constructed\n");
+ stdout.flush();
+ }
+
+ private void construct_interface(SettingsStructures.DynamicsSettings settings) {
+ this.set_default_response(Gtk.ResponseType.ACCEPT);
+ this.add_button(Gtk.STOCK_CLOSE, Gtk.ResponseType.ACCEPT);
+
+ Gtk.VBox control_area = (Gtk.VBox)this.get_content_area();
+
+ Gtk.HButtonBox button_bar = new Gtk.HButtonBox();
+ button_bar.set_layout(Gtk.ButtonBoxStyle.START);
+ button_bar.set_homogeneous(true);
+ button_bar.set_spacing(4);
+
+ mode_selector = new Hildon.TouchSelector.text();
+ mode_selector.append_text("compressor");
+ mode_selector.append_text("expander");
+ //mode_selector.set_active(0, 0);
+ stdout.printf("dynamics setting mode %s\n", settings.mode);
+ stdout.flush();
+ this.set_mode(settings.mode);
+ stdout.printf("dynamics mode set %s\n", settings.mode);
+ stdout.flush();
+ Hildon.PickerButton mode_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.AUTO_WIDTH, Hildon.ButtonArrangement.VERTICAL);
+ mode_picker.set_title("Mode:");
+ mode_picker.set_selector(mode_selector);
+ mode_picker.set_alignment(0, 0, 1, 1);
+ stdout.printf("dynamics mode connect\n");
+ stdout.flush();
+ mode_picker.value_changed.connect( (s) => { mode_updated(s.get_selector().get_current_text()); } );
+ stdout.printf("dynamics mode connected\n");
+ stdout.flush();
+ button_bar.pack_start(mode_picker, true, true, 2);
+
+ stdout.printf("dynamics mode starting 0\n");
+ stdout.flush();
+ characteristics_selector = new Hildon.TouchSelector.text();
+ stdout.printf("dynamics mode starting 1\n");
+ stdout.flush();
+ characteristics_selector.append_text("soft-knee");
+ stdout.printf("dynamics mode starting 2\n");
+ stdout.flush();
+ characteristics_selector.append_text("hard-knee");
+ //characteristics_selector.set_active(0, 0);
+ stdout.printf("dynamics setting characteristics %s\n", settings.characteristics);
+ stdout.flush();
+ this.set_characteristics(settings.characteristics);
+ Hildon.PickerButton characteristics_picker = new Hildon.PickerButton(Hildon.SizeType.FINGER_HEIGHT | Hildon.SizeType.AUTO_WIDTH, Hildon.ButtonArrangement.VERTICAL);
+ characteristics_picker.set_title("Characteristics:");
+ characteristics_picker.set_selector(characteristics_selector);
+ characteristics_picker.set_alignment(0, 0, 1, 1);
+ characteristics_picker.value_changed.connect( (s) => { characteristics_updated(s.get_selector().get_current_text()); } );
+ button_bar.pack_start(characteristics_picker, true, true, 2);
+
+ control_area.pack_start(button_bar, true, true, 2);
+
+ Gtk.HBox ratio_bar = new Gtk.HBox(false, 4);
+
+ Gtk.Label ratio_label = new Gtk.Label("Ratio: ");
+ ratio_slider = new Gtk.HScale.with_range(0.0, 25.0, 0.5);
+ ratio_slider.set_value_pos(Gtk.PositionType.LEFT);
+ stdout.printf("dynamics setting ratio\n");
+ stdout.flush();
+ this.set_ratio(settings.ratio);
+ ratio_slider.value_changed.connect((s) => {ratio_updated(s.get_value());});
+ ratio_bar.pack_start(ratio_label, false, false, 2);
+ ratio_bar.pack_start(ratio_slider, true, true, 2);
+
+ control_area.pack_start(ratio_bar, true, true, 2);
+
+ Gtk.HBox threshold_bar = new Gtk.HBox(false, 4);
+
+ Gtk.Label threshold_label = new Gtk.Label("Threshold: ");
+ threshold_slider = new Gtk.HScale.with_range(0.0, 1.0, 0.05);
+ threshold_slider.set_value_pos(Gtk.PositionType.LEFT);
+ stdout.printf("dynamics setting threshold\n");
+ stdout.flush();
+ this.set_threshold(settings.threshold);
+ threshold_slider.value_changed.connect((s) => {threshold_updated(s.get_value());});
+ threshold_bar.pack_start(threshold_label, false, false, 2);
+ threshold_bar.pack_start(threshold_slider, true, true, 2);
+
+ control_area.pack_start(threshold_bar, true, true, 2);
+
+ this.show_all();
+ }
+
+ public string get_mode() {
+ return mode_selector.get_current_text();
+ }
+ public void set_mode(string val) {
+ switch (val) {
+ case "compressor":
+ mode_selector.set_active(0, 0);
+ break;
+ case "expander":
+ mode_selector.set_active(0, 1);
+ break;
+ default:
+ mode_selector.set_active(0, 0);
+ break;
+ }
+ }
+
+ public string get_characteristics() {
+ return characteristics_selector.get_current_text();
+ }
+ public void set_characteristics(string val) {
+ switch (val) {
+ case "soft-knee":
+ characteristics_selector.set_active(0, 0);
+ break;
+ case "hard-knee":
+ characteristics_selector.set_active(0, 1);
+ break;
+ default:
+ characteristics_selector.set_active(0, 0);
+ break;
+ }
+ }
+
+ public double get_ratio() {
+ return ratio_slider.get_value();
+ }
+ public void set_ratio(double val) {
+ ratio_slider.set_value(val);
+ }
+
+ public double get_threshold() {
+ return threshold_slider.get_value();
+ }
+ public void set_threshold(double val) {
+ threshold_slider.set_value(val);
+ }
+
+}
+
+}
\ No newline at end of file