aboutsummaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-21 02:30:09 +0000
committerDavid Robillard <d@drobilla.net>2007-02-21 02:30:09 +0000
commit1429e4b2279566384ec09bfe3bfe7d7e0f0f79eb (patch)
tree9f0fb4eed56bacf52e738cd13029ec2683ee56e2 /src/gui
parenta865ddb5043c4dc094b8f64d2cae60e0df16b8ac (diff)
downloadmachina-1429e4b2279566384ec09bfe3bfe7d7e0f0f79eb.tar.gz
machina-1429e4b2279566384ec09bfe3bfe7d7e0f0f79eb.tar.bz2
machina-1429e4b2279566384ec09bfe3bfe7d7e0f0f79eb.zip
Tempo based time in Machina (and related utilities added to Raul).
git-svn-id: http://svn.drobilla.net/lad/machina@324 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/EdgeView.cpp1
-rw-r--r--src/gui/MachinaCanvas.cpp2
-rw-r--r--src/gui/MachinaGUI.cpp81
-rw-r--r--src/gui/MachinaGUI.hpp23
-rw-r--r--src/gui/machina.glade185
-rw-r--r--src/gui/main.cpp6
6 files changed, 275 insertions, 23 deletions
diff --git a/src/gui/EdgeView.cpp b/src/gui/EdgeView.cpp
index e681f26..3b5b8ec 100644
--- a/src/gui/EdgeView.cpp
+++ b/src/gui/EdgeView.cpp
@@ -62,6 +62,5 @@ EdgeView::on_event(GdkEvent* ev)
}
}
- cerr << "NO BUTTON\n";
return false;
}
diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp
index 5029682..26ce935 100644
--- a/src/gui/MachinaCanvas.cpp
+++ b/src/gui/MachinaCanvas.cpp
@@ -93,7 +93,7 @@ MachinaCanvas::canvas_event(GdkEvent* event)
if (event->button.button == 1) {
string name = string("Note")+(char)(last++ +'0');
- SharedPtr<Machina::Node> node(new Machina::Node(1024*10, false));
+ 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(node, shared_from_this(),
name, x, y));
diff --git a/src/gui/MachinaGUI.cpp b/src/gui/MachinaGUI.cpp
index 546bf7d..9fa0dbb 100644
--- a/src/gui/MachinaGUI.cpp
+++ b/src/gui/MachinaGUI.cpp
@@ -68,12 +68,12 @@ gtkmm_set_width_for_given_text (Gtk::Widget &w, const gchar *text,
-MachinaGUI::MachinaGUI(SharedPtr<Machina::Machine> machine)
+MachinaGUI::MachinaGUI(SharedPtr<Machina::Engine> engine)
: _pane_closed(false),
_update_pane_position(true),
_user_pane_position(0),
_refresh(false),
- _machine(machine),
+ _engine(engine),
_maid(new Raul::Maid(32))
{
/*_settings_filename = getenv("HOME");
@@ -109,10 +109,12 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Machine> machine)
xml->get_widget("machina_win", _main_window);
xml->get_widget("about_win", _about_window);
xml->get_widget("help_dialog", _help_dialog);
+ xml->get_widget("toolbar", _toolbar);
xml->get_widget("open_menuitem", _menu_file_open);
xml->get_widget("save_menuitem", _menu_file_save);
xml->get_widget("save_as_menuitem", _menu_file_save_as);
xml->get_widget("quit_menuitem", _menu_file_quit);
+ xml->get_widget("view_toolbar_menuitem", _menu_view_toolbar);
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);
@@ -121,6 +123,11 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Machine> machine)
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);
+ xml->get_widget("quantize_checkbutton", _quantize_checkbutton);
+ xml->get_widget("quantize_spinbutton", _quantize_spinbutton);
xml->get_widget("zoom_full_but", _zoom_full_button);
xml->get_widget("zoom_normal_but", _zoom_normal_button);
@@ -136,14 +143,32 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Machine> machine)
_zoom_full_button->signal_clicked().connect(sigc::mem_fun(_canvas.get(), &MachinaCanvas::zoom_full));
- _menu_file_open->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_open));
- _menu_file_save->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_save));
- _menu_file_save_as->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_save_as));
- _menu_file_quit->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_file_quit));
- _menu_view_refresh->signal_activate().connect( sigc::mem_fun(this, &MachinaGUI::menu_view_refresh));
- _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( sigc::mem_fun(this, &MachinaGUI::menu_help_help));
+ _menu_file_open->signal_activate().connect(
+ sigc::mem_fun(this, &MachinaGUI::menu_file_open));
+ _menu_file_save->signal_activate().connect(
+ sigc::mem_fun(this, &MachinaGUI::menu_file_save));
+ _menu_file_save_as->signal_activate().connect(
+ sigc::mem_fun(this, &MachinaGUI::menu_file_save_as));
+ _menu_file_quit->signal_activate().connect(
+ sigc::mem_fun(this, &MachinaGUI::menu_file_quit));
+ _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_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(
+ sigc::mem_fun(this, &MachinaGUI::menu_help_help));
+ _slave_radiobutton->signal_toggled().connect(
+ sigc::mem_fun(this, &MachinaGUI::tempo_changed));
+ _bpm_radiobutton->signal_toggled().connect(
+ sigc::mem_fun(this, &MachinaGUI::tempo_changed));
+ _bpm_spinbutton->signal_changed().connect(
+ sigc::mem_fun(this, &MachinaGUI::tempo_changed));
+ _quantize_checkbutton->signal_toggled().connect(
+ sigc::mem_fun(this, &MachinaGUI::quantize_changed));
connect_widgets();
@@ -167,6 +192,8 @@ MachinaGUI::MachinaGUI(SharedPtr<Machina::Machine> machine)
_update_pane_position = true;
_pane_closed = true;
+ _bpm_radiobutton->set_active(true);
+
// Idle callback to drive the maid (collect garbage)
Glib::signal_timeout().connect(
sigc::bind_return(
@@ -216,6 +243,28 @@ MachinaGUI::idle_callback()
void
+MachinaGUI::update_toolbar()
+{
+ _bpm_spinbutton->set_sensitive(_bpm_radiobutton->get_active());
+ _quantize_spinbutton->set_sensitive(_quantize_checkbutton->get_active());
+}
+
+
+void
+MachinaGUI::quantize_changed()
+{
+ _engine->set_quantization(1.0/(double)_quantize_spinbutton->get_value_as_int());
+}
+
+
+void
+MachinaGUI::tempo_changed()
+{
+ _engine->set_bpm(_bpm_spinbutton->get_value_as_int());
+}
+
+
+void
MachinaGUI::zoom(double z)
{
_canvas->set_zoom(z);
@@ -308,7 +357,7 @@ MachinaGUI::menu_file_save()
Raul::RDFWriter writer;
writer.start_to_filename("test.machina.ttl");
- _machine->write_state(writer);
+ machine()->write_state(writer);
writer.finish();}
@@ -379,6 +428,16 @@ MachinaGUI::show_messages_toggled()
void
+MachinaGUI::show_toolbar_toggled()
+{
+ if (_menu_view_toolbar->get_active())
+ _toolbar->show();
+ else
+ _toolbar->hide();
+}
+
+
+void
MachinaGUI::menu_view_refresh()
{
assert(_canvas);
diff --git a/src/gui/MachinaGUI.hpp b/src/gui/MachinaGUI.hpp
index a9ae5e5..ccf7557 100644
--- a/src/gui/MachinaGUI.hpp
+++ b/src/gui/MachinaGUI.hpp
@@ -22,21 +22,22 @@
#include <raul/SharedPtr.h>
#include <raul/Maid.h>
#include <libgnomecanvasmm.h>
+#include <machina/Engine.hpp>
using namespace std;
-namespace Machina { class Machine; }
+namespace Machina { class Machine; class Engine; }
class MachinaCanvas;
class MachinaGUI
{
public:
- MachinaGUI(SharedPtr<Machina::Machine> machine);
+ MachinaGUI(SharedPtr<Machina::Engine> engine);
~MachinaGUI();
boost::shared_ptr<MachinaCanvas> canvas() { return _canvas; }
- boost::shared_ptr<Machina::Machine> machine() { return _machine; }
+ boost::shared_ptr<Machina::Machine> machine() { return _engine->machine(); }
SharedPtr<Raul::Maid> maid() { return _maid; }
@@ -59,15 +60,20 @@ protected:
void menu_file_save();
void menu_file_save_as();
void show_messages_toggled();
+ void show_toolbar_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();
void on_pane_position_changed();
void on_messages_expander_changed();
+
+ void quantize_changed();
+ void tempo_changed();
bool _pane_closed;
bool _update_pane_position;
@@ -75,8 +81,8 @@ protected:
bool _refresh;
- boost::shared_ptr<MachinaCanvas> _canvas;
- boost::shared_ptr<Machina::Machine> _machine;
+ boost::shared_ptr<MachinaCanvas> _canvas;
+ boost::shared_ptr<Machina::Engine> _engine;
SharedPtr<Raul::Maid> _maid;
@@ -85,11 +91,13 @@ protected:
Gtk::Window* _main_window;
Gtk::Dialog* _help_dialog;
Gtk::AboutDialog* _about_window;
+ Gtk::Toolbar* _toolbar;
Gtk::MenuItem* _menu_file_open;
Gtk::MenuItem* _menu_file_save;
Gtk::MenuItem* _menu_file_save_as;
Gtk::MenuItem* _menu_file_quit;
Gtk::MenuItem* _menu_help_about;
+ Gtk::CheckMenuItem* _menu_view_toolbar;
Gtk::CheckMenuItem* _menu_view_messages;
Gtk::MenuItem* _menu_view_refresh;
Gtk::MenuItem* _menu_help_help;
@@ -97,6 +105,11 @@ protected:
Gtk::TextView* _status_text;
Gtk::Paned* _main_paned;
Gtk::Expander* _messages_expander;
+ Gtk::RadioButton* _slave_radiobutton;
+ Gtk::RadioButton* _bpm_radiobutton;
+ Gtk::SpinButton* _bpm_spinbutton;
+ Gtk::CheckButton* _quantize_checkbutton;
+ Gtk::SpinButton* _quantize_spinbutton;
Gtk::ToolButton* _zoom_normal_button;
Gtk::ToolButton* _zoom_full_button;
};
diff --git a/src/gui/machina.glade b/src/gui/machina.glade
index b319dab..f255d9f 100644
--- a/src/gui/machina.glade
+++ b/src/gui/machina.glade
@@ -99,6 +99,17 @@
<widget class="GtkMenu" id="view_menu_menu">
<child>
+ <widget class="GtkCheckMenuItem" id="view_toolbar_menuitem">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Toolbar</property>
+ <property name="use_underline">True</property>
+ <property name="active">False</property>
+ <signal name="activate" handler="on_toolbar2_activate" last_modification_time="Tue, 20 Feb 2007 22:56:06 GMT"/>
+ <accelerator key="T" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+ </widget>
+ </child>
+
+ <child>
<widget class="GtkCheckMenuItem" id="view_messages_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">View &quot;console&quot; messages</property>
@@ -175,7 +186,7 @@
</child>
<child>
- <widget class="GtkToolbar" id="toolbar1">
+ <widget class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
<property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property>
@@ -183,8 +194,177 @@
<property name="show_arrow">True</property>
<child>
+ <widget class="GtkToolItem" id="toolitem1">
+ <property name="visible">True</property>
+ <property name="visible_horizontal">True</property>
+ <property name="visible_vertical">True</property>
+ <property name="is_important">False</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkRadioButton" id="slave_radiobutton">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Slave</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkRadioButton" id="bpm_radiobutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">BPM: </property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">slave_radiobutton</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkSpinButton" id="bpm_spinbutton">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Set internal tempo</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">False</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">120 1 640 1 10 10</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkSeparatorToolItem" id="separatortoolitem2">
+ <property name="visible">True</property>
+ <property name="draw">True</property>
+ <property name="visible_horizontal">True</property>
+ <property name="visible_vertical">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkToolItem" id="toolitem2">
+ <property name="visible">True</property>
+ <property name="visible_horizontal">True</property>
+ <property name="visible_vertical">True</property>
+ <property name="is_important">False</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="quantize_checkbutton">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">Quantize: 1/</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkSpinButton" id="quantize_spinbutton">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="climb_rate">1</property>
+ <property name="digits">0</property>
+ <property name="numeric">False</property>
+ <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+ <property name="snap_to_ticks">False</property>
+ <property name="wrap">False</property>
+ <property name="adjustment">1 1 99 1 4 4</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkSeparatorToolItem" id="separatortoolitem3">
+ <property name="visible">True</property>
+ <property name="draw">True</property>
+ <property name="visible_horizontal">True</property>
+ <property name="visible_vertical">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">False</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkToolButton" id="zoom_normal_but">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Zoom to normal size</property>
<property name="stock_id">gtk-zoom-100</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
@@ -199,6 +379,7 @@
<child>
<widget class="GtkToolButton" id="zoom_full_but">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Zoom to fit entire machine</property>
<property name="stock_id">gtk-zoom-fit</property>
<property name="visible_horizontal">True</property>
<property name="visible_vertical">True</property>
@@ -226,6 +407,8 @@
<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="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
index 364fe17..d6c846e 100644
--- a/src/gui/main.cpp
+++ b/src/gui/main.cpp
@@ -15,15 +15,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
-//#include "../../config.h"
-
#include <signal.h>
#include <iostream>
#include <libgnomecanvasmm.h>
#include "machina/Loader.hpp"
#include "machina/JackDriver.hpp"
-#include "machina/JackNodeFactory.hpp"
#include "MachinaGUI.hpp"
@@ -46,6 +43,7 @@ main(int argc, char** argv)
driver->set_machine(m);
driver->attach("machina");
+ SharedPtr<Engine> engine(new Engine(driver, m));
// Launch GUI
try {
@@ -53,7 +51,7 @@ main(int argc, char** argv)
Gnome::Canvas::init();
Gtk::Main app(argc, argv);
- MachinaGUI gui(m);
+ MachinaGUI gui(engine);
app.run(*gui.window());
} catch (std::string msg) {