From 4541e87aa843dd97c542f7c66fcbc0a16ffbcee5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 5 Apr 2007 17:06:53 +0000 Subject: Code cleanups. git-svn-id: http://svn.drobilla.net/lad/machina@399 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/MachinaCanvas.cpp | 48 ------------- src/gui/MachinaGUI.cpp | 178 +--------------------------------------------- src/gui/MachinaGUI.hpp | 16 ----- src/gui/machina.glade | 97 +++---------------------- 4 files changed, 11 insertions(+), 328 deletions(-) (limited to 'src/gui') diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index 716a40d..1be5ef0 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -99,7 +99,6 @@ MachinaCanvas::canvas_event(GdkEvent* event) string name = string("Note")+(char)(last++ +'0'); SharedPtr node(new Machina::Node(1.0, false)); - //node->add_enter_action(SharedPtr(new Machina::PrintAction(name))); SharedPtr view(new NodeView(_app->window(), shared_from_this(), node, name, x, y)); @@ -137,38 +136,6 @@ MachinaCanvas::disconnect_node(boost::shared_ptr src, { src->node()->remove_outgoing_edges_to(head->node()); remove_connection(src, head); - -#if 0 - boost::shared_ptr input - = boost::dynamic_pointer_cast(port1); - boost::shared_ptr output - = boost::dynamic_pointer_cast(port2); - - if (!input || !output) - return; - - if (input->is_output() && output->is_input()) { - // Damn, guessed wrong - boost::shared_ptr swap = input; - input = output; - output = swap; - } - - if (!input || !output || input->is_output() || output->is_input()) { - status_message("ERROR: Attempt to disconnect mismatched/unknown ports"); - return; - } - - if (input->type() == JACK_AUDIO && output->type() == JACK_AUDIO - || input->type() == JACK_MIDI && output->type() == JACK_MIDI) - _app->jack_driver()->disconnect(output, input); -#ifdef HAVE_ALSA - else if (input->type() == ALSA_MIDI && output->type() == ALSA_MIDI) - _app->alsa_driver()->disconnect(output, input); -#endif - else - status_message("ERROR: Attempt to disconnect ports with mismatched types"); -#endif } @@ -185,7 +152,6 @@ MachinaCanvas::create_node_view(SharedPtr node) &MachinaCanvas::node_clicked), WeakPtr(view))); add_item(view); - //view->resize(); return view; } @@ -235,20 +201,6 @@ MachinaCanvas::build(SharedPtr machine) } arrange(); - /* - while (Gtk::Main::events_pending()) - Gtk::Main::iteration(false); - - for (list >::iterator c = _connections.begin(); c != _connections.end(); ++c) { - const SharedPtr view = PtrCast(*c); - if (view) - view->update_label(); // very, very slow - - while (Gtk::Main::events_pending()) - Gtk::Main::iteration(false); - - } - */ } diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp index e5e6d90..e1ba61f 100644 --- a/src/gui/MachinaGUI.cpp +++ b/src/gui/MachinaGUI.cpp @@ -33,16 +33,10 @@ MachinaGUI::MachinaGUI(SharedPtr engine) -: _pane_closed(false), - _update_pane_position(true), - _user_pane_position(0), - _refresh(false), +: _refresh(false), _engine(engine), _maid(new Raul::Maid(32)) { - /*_settings_filename = getenv("HOME"); - _settings_filename += "/.machinarc";*/ - _canvas = boost::shared_ptr(new MachinaCanvas(this, 1600*2, 1200*2)); Glib::RefPtr xml = GladeXml::create(); @@ -60,14 +54,10 @@ MachinaGUI::MachinaGUI(SharedPtr engine) xml->get_widget("export_graphviz_menuitem", _menu_export_graphviz); xml->get_widget("view_toolbar_menuitem", _menu_view_toolbar); xml->get_widget("view_labels_menuitem", _menu_view_labels); - //xml->get_widget("view_refresh_menuitem", _menu_view_refresh); - //xml->get_widget("view_messages_menuitem", _menu_view_messages); xml->get_widget("help_about_menuitem", _menu_help_about); xml->get_widget("help_help_menuitem", _menu_help_help); xml->get_widget("canvas_scrolledwindow", _canvas_scrolledwindow); xml->get_widget("status_text", _status_text); - xml->get_widget("main_paned", _main_paned); - xml->get_widget("messages_expander", _messages_expander); xml->get_widget("slave_radiobutton", _slave_radiobutton); xml->get_widget("bpm_radiobutton", _bpm_radiobutton); xml->get_widget("bpm_spinbutton", _bpm_spinbutton); @@ -86,8 +76,6 @@ MachinaGUI::MachinaGUI(SharedPtr engine) _canvas->scroll_to(static_cast(_canvas->width()/2 - 320), static_cast(_canvas->height()/2 - 240)); // FIXME: hardcoded - //_zoom_slider->signal_value_changed().connect(sigc::mem_fun(this, &MachinaGUI::zoom_changed)); - _record_button->signal_toggled().connect(sigc::mem_fun(this, &MachinaGUI::record_toggled)); _stop_button->signal_clicked().connect(sigc::mem_fun(this, &MachinaGUI::stop_clicked)); _play_button->signal_toggled().connect(sigc::mem_fun(this, &MachinaGUI::play_toggled)); @@ -113,14 +101,10 @@ MachinaGUI::MachinaGUI(SharedPtr engine) sigc::mem_fun(this, &MachinaGUI::menu_export_midi)); _menu_export_graphviz->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_export_graphviz)); - //_menu_view_refresh->signal_activate().connect( - // sigc::mem_fun(this, &MachinaGUI::menu_view_refresh)); _menu_view_toolbar->signal_toggled().connect( sigc::mem_fun(this, &MachinaGUI::show_toolbar_toggled)); _menu_view_labels->signal_toggled().connect( sigc::mem_fun(this, &MachinaGUI::show_labels_toggled)); - //_menu_view_messages->signal_toggled().connect( - // sigc::mem_fun(this, &MachinaGUI::show_messages_toggled)); _menu_help_about->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_help_about)); _menu_help_help->signal_activate().connect( @@ -138,26 +122,10 @@ MachinaGUI::MachinaGUI(SharedPtr engine) connect_widgets(); - //update_state(); - _canvas->show(); _main_window->present(); - _update_pane_position = false; - _main_paned->set_position(max_pane_position()); - - _main_paned->property_position().signal_changed().connect( - sigc::mem_fun(*this, &MachinaGUI::on_pane_position_changed)); - - _messages_expander->property_expanded().signal_changed().connect( - sigc::mem_fun(*this, &MachinaGUI::on_messages_expander_changed)); - - _main_paned->set_position(max_pane_position()); - _user_pane_position = max_pane_position() - _main_window->get_height()/8; - _update_pane_position = true; - _pane_closed = true; - _bpm_radiobutton->set_active(true); _quantize_checkbutton->set_active(false); @@ -171,9 +139,6 @@ MachinaGUI::MachinaGUI(SharedPtr engine) // Idle callback to update node states Glib::signal_timeout().connect(sigc::mem_fun(this, &MachinaGUI::idle_callback), 100); - // Faster idle callback to update DSP load progress bar - //Glib::signal_timeout().connect(sigc::mem_fun(this, &MachinaGUI::update_load), 50); - _canvas->build(engine->machine()); } @@ -183,21 +148,6 @@ MachinaGUI::~MachinaGUI() } -void -MachinaGUI::attach() -{ -#if 0 - _jack_driver->attach(true); - - menu_view_refresh(); - - update_toolbar(); - - //m_status_bar->push("Connected to JACK server"); -#endif -} - - bool MachinaGUI::idle_callback() { @@ -273,46 +223,6 @@ MachinaGUI::zoom(double z) } -void -MachinaGUI::zoom_changed() -{ -/* - static bool enable_signal = true; - if (enable_signal) { - enable_signal = false; - zoom(_zoom_slider->get_value()); - enable_signal = true; - } - */ -} - - -#if 0 -void -MachinaGUI::update_state() -{ - for (ModuleMap::iterator i = _canvas->modules().begin(); i != _canvas->modules().end(); ++i) - (*i).second->load_location(); - - //cerr << "[Machina] Resizing window: (" << _state_manager->get_window_size().x - // << "," << _state_manager->get_window_size().y << ")" << endl; - - _main_window->resize( - static_cast(_state_manager->get_window_size().x), - static_cast(_state_manager->get_window_size().y)); - - //cerr << "[Machina] Moving window: (" << _state_manager->get_window_location().x - // << "," << _state_manager->get_window_location().y << ")" << endl; - - _main_window->move( - static_cast(_state_manager->get_window_location().x), - static_cast(_state_manager->get_window_location().y)); - -} - -#endif - - void MachinaGUI::status_message(const string& msg) { @@ -352,7 +262,6 @@ MachinaGUI::menu_file_open() const int result = dialog.run(); if (result == Gtk::RESPONSE_OK) { - //SharedPtr new_machine = _engine->load_machine(dialog.get_uri()); SharedPtr new_machine = _engine->import_machine(dialog.get_uri()); if (new_machine) { _canvas->destroy(); @@ -457,23 +366,10 @@ MachinaGUI::menu_import_midi() extra_widget->show_all(); - /*Gtk::HBox* extra_widget = Gtk::manage(new Gtk::HBox()); - Gtk::SpinButton* track_sb = Gtk::manage(new Gtk::SpinButton()); - track_sb->set_increments(1, 10); - track_sb->set_range(1, 256); - extra_widget->pack_start(*Gtk::manage(new Gtk::Label("")), true, true); - extra_widget->pack_start(*Gtk::manage(new Gtk::Label("Track: ")), false, false); - extra_widget->pack_start(*track_sb, false, false); - dialog.set_extra_widget(*extra_widget); - extra_widget->show_all(); - */ - const int result = dialog.run(); if (result == Gtk::RESPONSE_OK) { SharedPtr file_driver(new Machina::SMFDriver()); - //SharedPtr machine = file_driver->learn(dialog.get_uri(), - // track_sb->get_value_as_int()); double length = length_sb->get_value_as_int(); @@ -510,7 +406,7 @@ MachinaGUI::menu_export_midi() const SharedPtr m = _engine->machine(); m->set_sink(file_driver->writer()); file_driver->writer()->start(dialog.get_filename()); - file_driver->run(m, 32); // FIXME: hardcoded max length. TODO: solve halting problem + file_driver->run(m, 32); // TODO: solve halting problem m->set_sink(_engine->driver()); m->reset(); file_driver->writer()->finish(); @@ -534,66 +430,6 @@ MachinaGUI::menu_export_graphviz() } -void -MachinaGUI::on_pane_position_changed() -{ - // avoid infinite recursion... - if (!_update_pane_position) - return; - - _update_pane_position = false; - - int new_position = _main_paned->get_position(); - - if (_pane_closed && new_position < max_pane_position()) { - // Auto open - _user_pane_position = new_position; - _messages_expander->set_expanded(true); - _pane_closed = false; - //_menu_view_messages->set_active(true); - } else if (new_position >= max_pane_position()) { - // Auto close - _pane_closed = true; - - _messages_expander->set_expanded(false); - if (new_position > max_pane_position()) - _main_paned->set_position(max_pane_position()); // ... here - //_menu_view_messages->set_active(false); - - _user_pane_position = max_pane_position() - _main_window->get_height()/8; - } - - _update_pane_position = true; -} - - -void -MachinaGUI::on_messages_expander_changed() -{ - if (!_pane_closed) { - // Store pane position for restoring - _user_pane_position = _main_paned->get_position(); - if (_update_pane_position) { - _update_pane_position = false; - _main_paned->set_position(max_pane_position()); - _update_pane_position = true; - } - _pane_closed = true; - } else { - _main_paned->set_position(_user_pane_position); - _pane_closed = false; - } -} - -/* -void -MachinaGUI::show_messages_toggled() -{ - if (_update_pane_position) - //_messages_expander->set_expanded(_menu_view_messages->get_active()); -} -*/ - void MachinaGUI::show_toolbar_toggled() { @@ -624,16 +460,6 @@ MachinaGUI::show_labels_toggled() } -/* -void -MachinaGUI::menu_view_refresh() -{ - assert(_canvas); - - //_canvas->destroy(); -} -*/ - void MachinaGUI::menu_help_about() { diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp index eba8a93..391884e 100644 --- a/src/gui/MachinaGUI.hpp +++ b/src/gui/MachinaGUI.hpp @@ -49,9 +49,6 @@ public: void status_message(const string& msg); inline void queue_refresh() { _refresh = true; } - int max_pane_position() - { return _main_paned->property_max_position() - _messages_expander->get_label_widget()->get_height() - 8; } - protected: void connect_widgets(); @@ -62,14 +59,11 @@ protected: void menu_import_midi(); void menu_export_midi(); void menu_export_graphviz(); - //void show_messages_toggled(); void show_toolbar_toggled(); void show_labels_toggled(); - //void menu_view_refresh(); void menu_help_about(); void menu_help_help(); void zoom(double z); - void zoom_changed(); bool idle_callback(); void update_toolbar(); bool scrolled_window_event(GdkEvent* ev); @@ -78,16 +72,9 @@ protected: void stop_clicked(); void play_toggled(); - void on_pane_position_changed(); - void on_messages_expander_changed(); - void quantize_changed(); void tempo_changed(); - bool _pane_closed; - bool _update_pane_position; - int _user_pane_position; - bool _refresh; string _save_uri; @@ -113,12 +100,9 @@ protected: Gtk::MenuItem* _menu_help_about; Gtk::CheckMenuItem* _menu_view_labels; Gtk::CheckMenuItem* _menu_view_toolbar; - //Gtk::CheckMenuItem* _menu_view_messages; - //Gtk::MenuItem* _menu_view_refresh; Gtk::MenuItem* _menu_help_help; Gtk::ScrolledWindow* _canvas_scrolledwindow; Gtk::TextView* _status_text; - Gtk::Paned* _main_paned; Gtk::Expander* _messages_expander; Gtk::RadioButton* _slave_radiobutton; Gtk::RadioButton* _bpm_radiobutton; diff --git a/src/gui/machina.glade b/src/gui/machina.glade index 61096f1..4002ba1 100644 --- a/src/gui/machina.glade +++ b/src/gui/machina.glade @@ -579,98 +579,19 @@ - + True + True + True True - 0 + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - - True - True - True - True - True - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - - - - False - True - - - - - - True - False - 0 - - - - True - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - False - True - False - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - False - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - - - - True - Messages - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - label_item - - - - - True - True - + -- cgit v1.2.1