13
0

subtle but important changes to IO Selector widgets etc.

git-svn-id: svn://localhost/ardour2/branches/3.0@3830 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-09-29 13:34:35 +00:00
parent 474f8bc376
commit e8869b28a2
3 changed files with 75 additions and 55 deletions

View File

@ -41,16 +41,17 @@ using namespace Gtk;
IOSelector::IOSelector (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io, bool offer_inputs)
: PortMatrix (
session, io->default_type(), !offer_inputs,
PortGroupList::Mask (PortGroupList::BUSS | PortGroupList::SYSTEM | PortGroupList::OTHER)
),
session, io->default_type(), offer_inputs,
PortGroupList::Mask (PortGroupList::BUSS |
PortGroupList::SYSTEM |
PortGroupList::OTHER)),
_io (io)
{
/* Listen for ports changing on the IO */
if (_offer_inputs) {
_io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
} else {
_io->output_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
} else {
_io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
}
/* this got lost in a merge from 2.0 */
@ -68,8 +69,6 @@ IOSelector::ports_changed (ARDOUR::IOChange change, void *src)
redisplay ();
}
void
IOSelector::set_state (int r, std::string const & p, bool s)
{
@ -146,12 +145,20 @@ IOSelector::minimum_rows () const
std::string
IOSelector::row_name (int r) const
{
string n;
string::size_type pos;
if (!_offer_inputs) {
return _io->input(r)->name();
n = _io->input(r)->short_name();
} else {
return _io->output(r)->name();
n = _io->output(r)->short_name();
}
if ((pos = n.find ('/')) != string::npos) {
return n.substr (pos+1);
} else {
return n;
}
}
void
@ -257,6 +264,7 @@ IOSelectorWindow::IOSelectorWindow (
)
: ArdourDialog ("I/O selector"),
_selector (session, io, !for_input),
add_button (_("Add Port")),
ok_button (can_cancel ? _("OK"): _("Close")),
cancel_button (_("Cancel")),
rescan_button (_("Rescan"))
@ -272,23 +280,31 @@ IOSelectorWindow::IOSelectorWindow (
title = string_compose(_("%1 output"), io->name());
}
ok_button.set_name ("IOSelectorButton");
if (!can_cancel) {
ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
if (_selector.maximum_rows() > _selector.n_rows()) {
add_button.set_name ("IOSelectorButton");
add_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
get_action_area()->pack_start (add_button, false, false);
add_button.signal_clicked().connect (sigc::mem_fun (_selector, &IOSelector::add_row));
} else {
add_button.hide ();
}
cancel_button.set_name ("IOSelectorButton");
rescan_button.set_name ("IOSelectorButton");
rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON)));
get_action_area()->pack_start (rescan_button, false, false);
if (can_cancel) {
cancel_button.set_name ("IOSelectorButton");
cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON)));
get_action_area()->pack_start (cancel_button, false, false);
} else {
cancel_button.hide();
}
ok_button.set_name ("IOSelectorButton");
if (!can_cancel) {
ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
}
get_action_area()->pack_start (ok_button, false, false);
get_vbox()->set_spacing (8);

View File

@ -38,10 +38,9 @@ class IOSelector : public PortMatrix {
std::string row_descriptor () const;
private:
boost::shared_ptr<ARDOUR::IO> _io;
void ports_changed (ARDOUR::IOChange, void*);
boost::shared_ptr<ARDOUR::IO> _io;
};
class IOSelectorWindow : public ArdourDialog
@ -60,6 +59,7 @@ class IOSelectorWindow : public ArdourDialog
/* overall operation buttons */
Gtk::Button add_button;
Gtk::Button ok_button;
Gtk::Button cancel_button;
Gtk::Button rescan_button;

View File

@ -177,11 +177,11 @@ PortGroupUI::setup_visibility ()
}
if (_visibility_checkbutton.get_active () != _port_group.visible) {
_visibility_checkbutton.set_active (_port_group.visible);
}
}
RotatedLabelSet::RotatedLabelSet (PortGroupList& g)
: Glib::ObjectBase ("RotatedLabelSet"), Gtk::Widget (), _port_group_list (g), _base_width (128)
{
@ -390,7 +390,7 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type, bool of
_scrolled_window.add (*Gtk::manage (a));
_overall_hbox.pack_start (_scrolled_window);
_side_vbox[1].pack_start (*Gtk::manage (new Gtk::Label ("")));
_overall_hbox.pack_start (_side_vbox[1]);
// _overall_hbox.pack_start (_side_vbox[1]);
pack_start (_overall_hbox);
_port_group_hbox.signal_size_allocate().connect (sigc::hide (sigc::mem_fun (*this, &IOSelector::setup_dimensions)));
@ -509,23 +509,22 @@ PortMatrix::setup ()
/* Checkbutton tables and visibility checkbuttons */
int n = 0;
for (PortGroupList::iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) {
if ((*i)->visible) {
PortGroupUI* t = new PortGroupUI (*this, **i);
/* XXX: this is a bit of a hack; should probably use a configurable colour here */
Gdk::Color alt_bg = get_style()->get_bg (Gtk::STATE_NORMAL);
alt_bg.set_rgb (alt_bg.get_red() + 4096, alt_bg.get_green() + 4096, alt_bg.get_blue () + 4096);
if ((n % 2) == 0) {
t->get_table().modify_bg (Gtk::STATE_NORMAL, alt_bg);
}
PortGroupUI* t = new PortGroupUI (*this, **i);
_port_group_ui.push_back (t);
_port_group_hbox.pack_start (t->get_table(), false, false);
/* XXX: this is a bit of a hack; should probably use a configurable colour here */
Gdk::Color alt_bg = get_style()->get_bg (Gtk::STATE_NORMAL);
alt_bg.set_rgb (alt_bg.get_red() + 4096, alt_bg.get_green() + 4096, alt_bg.get_blue () + 4096);
if ((n % 2) == 0) {
t->get_table().modify_bg (Gtk::STATE_NORMAL, alt_bg);
}
_visibility_checkbutton_box.pack_start (t->get_visibility_checkbutton(), false, false);
++n;
}
}
_port_group_ui.push_back (t);
_port_group_hbox.pack_start (t->get_table(), false, false);
_visibility_checkbutton_box.pack_start (t->get_visibility_checkbutton(), false, false);
++n;
}
show_all ();
@ -620,21 +619,20 @@ PortGroupList::refresh ()
other.ports.clear ();
/* Find the ports provided by ardour; we can't derive their type just from their
names, so we'll have to be more devious. */
names, so we'll have to be more devious.
*/
boost::shared_ptr<ARDOUR::Session::RouteList> routes = _session.get_routes ();
for (ARDOUR::Session::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
PortGroup* g = 0;
if (_type == ARDOUR::DataType::AUDIO && dynamic_cast<ARDOUR::AudioTrack*> ((*i).get())) {
/* Audio track for an audio IO */
if (_type == ARDOUR::DataType::AUDIO && boost::dynamic_pointer_cast<ARDOUR::AudioTrack> (*i)) {
g = &track;
} else if (_type == ARDOUR::DataType::MIDI && dynamic_cast<ARDOUR::MidiTrack*> ((*i).get())) {
/* Midi track for a MIDI IO */
} else if (_type == ARDOUR::DataType::MIDI && boost::dynamic_pointer_cast<ARDOUR::MidiTrack> (*i)) {
g = &track;
} else if (_type == ARDOUR::DataType::AUDIO && dynamic_cast<ARDOUR::MidiTrack*> ((*i).get()) == 0) {
/* Non-MIDI track for an Audio IO; must be an audio buss */
} else if (_type == ARDOUR::DataType::AUDIO && boost::dynamic_pointer_cast<ARDOUR::Route> (*i)) {
g = &buss;
}
@ -648,18 +646,22 @@ PortGroupList::refresh ()
}
}
/* XXX: inserts, sends, plugin inserts? */
/* Now we need to find the non-ardour ports; we do this by first
finding all the ports that we can connect to. */
const char **ports = _session.engine().get_ports (
"", _type.to_jack_type(), _offer_inputs ? JackPortIsInput : JackPortIsOutput
);
finding all the ports that we can connect to.
*/
const char **ports = _session.engine().get_ports ("", _type.to_jack_type(), _offer_inputs ?
JackPortIsInput : JackPortIsOutput);
if (ports) {
int n = 0;
string client_matching_string;
client_matching_string = _session.engine().client_name();
client_matching_string += ':';
while (ports[n]) {
std::string const p = ports[n];
@ -667,7 +669,7 @@ PortGroupList::refresh ()
/* system: prefix */
system.add (p);
} else {
if (p.substr(0, strlen("ardour:")) != "ardour:") {
if (p.substr(0, client_matching_string.length()) != client_matching_string) {
/* other (non-ardour) prefix */
other.add (p);
}
@ -675,11 +677,13 @@ PortGroupList::refresh ()
++n;
}
free (ports);
}
push_back (&system);
push_back (&buss);
push_back (&track);
push_back (&system);
push_back (&other);
}