diff options
author | David Robillard <d@drobilla.net> | 2007-04-05 17:06:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-04-05 17:06:53 +0000 |
commit | 4541e87aa843dd97c542f7c66fcbc0a16ffbcee5 (patch) | |
tree | b78b2bc374e62401df6e6e5d3d250d1845053ec4 /src/gui | |
parent | 0123cdeacc9acc7ca16fa8b0a9dee7a5d916b7df (diff) | |
download | machina-4541e87aa843dd97c542f7c66fcbc0a16ffbcee5.tar.gz machina-4541e87aa843dd97c542f7c66fcbc0a16ffbcee5.tar.bz2 machina-4541e87aa843dd97c542f7c66fcbc0a16ffbcee5.zip |
Code cleanups.
git-svn-id: http://svn.drobilla.net/lad/machina@399 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/MachinaCanvas.cpp | 48 | ||||
-rw-r--r-- | src/gui/MachinaGUI.cpp | 178 | ||||
-rw-r--r-- | src/gui/MachinaGUI.hpp | 16 | ||||
-rw-r--r-- | src/gui/machina.glade | 97 |
4 files changed, 11 insertions, 328 deletions
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<Machina::Node> node(new Machina::Node(1.0, false)); - //node->add_enter_action(SharedPtr<Machina::Action>(new Machina::PrintAction(name))); SharedPtr<NodeView> view(new NodeView(_app->window(), shared_from_this(), node, name, x, y)); @@ -137,38 +136,6 @@ MachinaCanvas::disconnect_node(boost::shared_ptr<NodeView> src, { src->node()->remove_outgoing_edges_to(head->node()); remove_connection(src, head); - -#if 0 - boost::shared_ptr<MachinaPort> input - = boost::dynamic_pointer_cast<MachinaPort>(port1); - boost::shared_ptr<MachinaPort> output - = boost::dynamic_pointer_cast<MachinaPort>(port2); - - if (!input || !output) - return; - - if (input->is_output() && output->is_input()) { - // Damn, guessed wrong - boost::shared_ptr<MachinaPort> 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<Machina::Node> node) &MachinaCanvas::node_clicked), WeakPtr<NodeView>(view))); add_item(view); - //view->resize(); return view; } @@ -235,20 +201,6 @@ MachinaCanvas::build(SharedPtr<Machina::Machine> machine) } arrange(); - /* - while (Gtk::Main::events_pending()) - Gtk::Main::iteration(false); - - for (list<boost::shared_ptr<Connection> >::iterator c = _connections.begin(); c != _connections.end(); ++c) { - const SharedPtr<EdgeView> view = PtrCast<EdgeView>(*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<Machina::Engine> 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<MachinaCanvas>(new MachinaCanvas(this, 1600*2, 1200*2)); Glib::RefPtr<Gnome::Glade::Xml> xml = GladeXml::create(); @@ -60,14 +54,10 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> 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<Machina::Engine> engine) _canvas->scroll_to(static_cast<int>(_canvas->width()/2 - 320), static_cast<int>(_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<Machina::Engine> 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<Machina::Engine> 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<Machina::Engine> 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() { @@ -274,46 +224,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<int>(_state_manager->get_window_size().x), - static_cast<int>(_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<int>(_state_manager->get_window_location().x), - static_cast<int>(_state_manager->get_window_location().y)); - -} - -#endif - - -void MachinaGUI::status_message(const string& msg) { if (_status_text->get_buffer()->size() > 0) @@ -352,7 +262,6 @@ MachinaGUI::menu_file_open() const int result = dialog.run(); if (result == Gtk::RESPONSE_OK) { - //SharedPtr<Machina::Machine> new_machine = _engine->load_machine(dialog.get_uri()); SharedPtr<Machina::Machine> 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<Machina::SMFDriver> file_driver(new Machina::SMFDriver()); - //SharedPtr<Machina::Machine> 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<Machina::Machine> 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(); @@ -535,66 +431,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() { if (_menu_view_toolbar->get_active()) @@ -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 @@ </child> <child> - <widget class="GtkVPaned" id="main_paned"> + <widget class="GtkScrolledWindow" id="canvas_scrolledwindow"> <property name="visible">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> <property name="can_focus">True</property> - <property name="position">0</property> + <property name="has_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> + <property name="shadow_type">GTK_SHADOW_IN</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> <child> - <widget class="GtkScrolledWindow" id="canvas_scrolledwindow"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="shrink">False</property> - <property name="resize">True</property> - </packing> - </child> - - <child> - <widget class="GtkExpander" id="messages_expander"> - <property name="can_focus">True</property> - <property name="expanded">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_NEVER</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTextView" id="status_text"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="editable">False</property> - <property name="overwrite">False</property> - <property name="accepts_tab">True</property> - <property name="justification">GTK_JUSTIFY_LEFT</property> - <property name="wrap_mode">GTK_WRAP_WORD</property> - <property name="cursor_visible">False</property> - <property name="pixels_above_lines">0</property> - <property name="pixels_below_lines">0</property> - <property name="pixels_inside_wrap">0</property> - <property name="left_margin">0</property> - <property name="right_margin">0</property> - <property name="indent">0</property> - <property name="text" translatable="yes"></property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="label" translatable="yes">Messages</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> - <property name="width_chars">-1</property> - <property name="single_line_mode">False</property> - <property name="angle">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="shrink">True</property> - <property name="resize">True</property> - </packing> + <placeholder/> </child> </widget> <packing> |