More port controls fixes/cleanups

git-svn-id: http://svn.drobilla.net/lad@78 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
dave 2006-06-22 08:03:12 +00:00
parent a9c2f87953
commit c2f51fe4df
7 changed files with 47 additions and 36 deletions

View File

@ -20,6 +20,7 @@
#include <cstdlib>
#include <string>
#include <list>
#include <sigc++/sigc++.h>
#include "ObjectModel.h"
#include "util/CountedPtr.h"
using std::string; using std::list;
@ -77,7 +78,7 @@ public:
inline float user_max() const { return m_user_max; }
inline void user_max(float f) { m_user_max = f; }
inline float value() const { return m_current_val; }
inline void value(float f) { m_current_val = f; }
inline void value(float f) { m_current_val = f; control_change_sig.emit(f); }
inline bool connected() { return m_connected; }
inline void connected(bool b) { m_connected = b; }
inline Type type() { return m_type; }
@ -94,6 +95,9 @@ public:
inline bool operator==(const PortModel& pm)
{ return (m_path == pm.m_path); }
// Signals
sigc::signal<void, float> control_change_sig; ///< "Control" ports only
private:
// Prevent copies (undefined)
PortModel(const PortModel& copy);

View File

@ -36,6 +36,7 @@ Store::Store(SigClientInterface& emitter)
emitter.connection_sig.connect(sigc::mem_fun(this, &Store::connection_event));
emitter.disconnection_sig.connect(sigc::mem_fun(this, &Store::disconnection_event));
emitter.metadata_update_sig.connect(sigc::mem_fun(this, &Store::metadata_update_event));
emitter.control_change_sig.connect(sigc::mem_fun(this, &Store::control_change_event));
}
@ -310,6 +311,17 @@ Store::metadata_update_event(const string& subject_path, const string& predicate
}
void
Store::control_change_event(const string& port_path, float value)
{
CountedPtr<PortModel> port = object(port_path);
if (port)
port->value(value);
else
cerr << "ERROR: metadata for nonexistant object." << endl;
}
void
Store::connection_event(const Path& src_port_path, const Path& dst_port_path)
{

View File

@ -73,6 +73,7 @@ private:
void new_node_event(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports);
void new_port_event(const string& path, const string& data_type, bool is_output);
void metadata_update_event(const string& subject_path, const string& predicate, const string& value);
void control_change_event(const string& port_path, float value);
void connection_event(const Path& src_port_path, const Path& dst_port_path);
void disconnection_event(const Path& src_port_path, const Path& dst_port_path);

View File

@ -98,7 +98,7 @@ ControlPanel::add_port(PortController* port)
{
assert(port);
assert(port->model());
assert(port->control_panel() == NULL);
//assert(port->control_panel() == NULL);
const CountedPtr<PortModel> pm = port->port_model();
@ -117,6 +117,8 @@ ControlPanel::add_port(PortController* port)
else
cg = new SliderControlGroup(this, pm, separator);
// FIXME: ControlGroup constructor should do this
pm->control_change_sig.connect(sigc::mem_fun(cg, &ControlGroup::set_value));
m_controls.push_back(cg);
m_control_box->pack_start(*cg, false, false, 0);
@ -126,7 +128,7 @@ ControlPanel::add_port(PortController* port)
cg->enable();
}
port->set_control_panel(this);
//port->set_control_panel(this);
Gtk::Requisition controls_size;
m_control_box->size_request(controls_size);
@ -230,7 +232,7 @@ ControlPanel::value_changed(const Path& port_path, float val)
}
}
/*
void
ControlPanel::set_range_min(const Path& port_path, float val)
{
@ -259,7 +261,7 @@ ControlPanel::set_range_max(const Path& port_path, float val)
if (found == false)
cerr << "[ControlPanel::set_range_max] Unable to find control " << port_path << endl;
}
*/
void
ControlPanel::all_voices_selected()

View File

@ -71,19 +71,19 @@ public:
size_t num_controls() const { return m_controls.size(); }
pair<int,int> ideal_size() const { return m_ideal_size; }
// Callback for ControlGroup
// Callback for ControlGroup (FIXME: ugly)
void value_changed(const Path& port_path, float val);
inline void set_control(const Path& port_path, float value);
void set_range_min(const Path& port_path, float value);
void set_range_max(const Path& port_path, float value);
//inline void set_control(const Path& port_path, float value);
//void set_range_min(const Path& port_path, float value);
//void set_range_max(const Path& port_path, float value);
private:
void all_voices_selected();
void specific_voice_selected();
void voice_selected();
bool m_callback_enabled;
bool m_callback_enabled;
pair<int,int> m_ideal_size;
@ -101,6 +101,7 @@ private:
* Profiling has shown this is performance critical. Needs to be made
* faster.
*/
/*
inline void
ControlPanel::set_control(const Path& port_path, const float val)
{
@ -122,7 +123,7 @@ ControlPanel::set_control(const Path& port_path, const float val)
cerr << "[ControlPanel::set_control] Unable to find control " << port_path << endl;
m_callback_enabled = true;
}
*/
} // namespace OmGtk

View File

@ -28,8 +28,8 @@ namespace OmGtk {
PortController::PortController(CountedPtr<PortModel> model)
: GtkObjectController(model),
m_module(NULL),
m_port(NULL),
m_control_panel(NULL)
m_port(NULL)
//m_control_panel(NULL)
{
assert(model);
assert(model->parent());
@ -60,8 +60,8 @@ PortController::destroy()
NodeController* parent = (NodeController*)m_model->parent()->controller();
assert(parent != NULL);
if (m_control_panel != NULL)
m_control_panel->remove_port(path());
//if (m_control_panel != NULL)
// m_control_panel->remove_port(path());
parent->remove_port(path(), false);
}
@ -91,6 +91,8 @@ PortController::metadata_update(const string& key, const string& value)
//cerr << path() << ": " << key << " = " << value << endl;
/* Panel now listens to model signals..
if (key == "user-min") {
port_model()->user_min(atof(value.c_str()));
if (m_control_panel != NULL)
@ -100,6 +102,8 @@ PortController::metadata_update(const string& key, const string& value)
if (m_control_panel != NULL)
m_control_panel->set_range_max(m_model->path(), atof(value.c_str()));
}
*/
cerr << "FIXME: PortController::metadata_update" << endl;
if (m_module != NULL) {
if (key == "module-x") {
@ -117,30 +121,19 @@ PortController::metadata_update(const string& key, const string& value)
}
void
PortController::control_change(float value)
{
// FIXME: double lookups
port_model()->value(value);
if (m_control_panel != NULL)
m_control_panel->set_control(port_model()->path(), value);
}
/** "Register" a control panel that is monitoring this port.
*
* The OmPort will handle notifying the ControlPanel when state
* changes occur, etc.
*/
/*
void
PortController::set_control_panel(ControlPanel* cp)
{
assert(m_control_panel == NULL);
m_control_panel = cp;
}
*/
void
PortController::set_path(const Path& new_path)
@ -149,8 +142,8 @@ PortController::set_path(const Path& new_path)
if (m_port != NULL)
m_port->set_name(new_path.name());
if (m_control_panel != NULL)
m_control_panel->rename_port(m_model->path(), new_path);
//if (m_control_panel != NULL)
// m_control_panel->rename_port(m_model->path(), new_path);
m_model->set_path(new_path);
}

View File

@ -35,7 +35,7 @@ namespace OmGtk {
class Controller;
class OmPort;
class OmPatchPort;
class ControlPanel;
//class ControlPanel;
class OmModule;
class OmPortModule;
class OmFlowCanvas;
@ -64,10 +64,8 @@ public:
void create_port(OmModule* module);
void set_path(const Path& new_path);
void control_change(float value);
ControlPanel* control_panel() const { return m_control_panel; }
void set_control_panel(ControlPanel* cp);
//ControlPanel* control_panel() const { return m_control_panel; }
//void set_control_panel(ControlPanel* cp);
CountedPtr<PortModel> port_model() const { return m_model; }
@ -75,7 +73,7 @@ private:
OmPatchPort* m_patch_port; ///< Port on m_module
OmPortModule* m_module; ///< Port pseudo-module (for patch ports only)
OmPort* m_port; ///< Port on some other canvas module
ControlPanel* m_control_panel; ///< Control panel that contains this port
//ControlPanel* m_control_panel; ///< Control panel that contains this port
};