more tweaks to the IO Selector

git-svn-id: svn://localhost/ardour2/branches/3.0@3840 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-09-30 14:18:15 +00:00
parent 9a30bb2aec
commit caa305ed2b
10 changed files with 169 additions and 132 deletions

View File

@ -402,6 +402,7 @@
<menuitem action='ToggleInspector'/>
<menuitem action='ToggleLocations'/>
<menuitem action='ToggleKeyEditor'/>
<menuitem action='ToggleBundleManager'/>
<menuitem action='ToggleThemeManager'/>
<menuitem action='ToggleBigClock'/>
<menuitem action='toggle-rhythm-ferret'/>

View File

@ -1202,6 +1202,16 @@ style "ardour_button" ="default_button"
ythickness = 1
}
style "odd_port_groups"
{
fg[NORMAL] = { 0.6, 0.6, 0.6 }
}
style "even_port_groups"
{
fg[NORMAL] = { 0.3, 0.3, 0.3 }
}
#---------------------------------------------------------------
class "GtkWidget" style:highest "default_base"
@ -1578,4 +1588,6 @@ widget "*ChannelCountSelector" style:highest "medium_bold_entry"
widget "*ChannelCountSelector.GtkArrow" style:highest "default_generic"
widget "*RegionListWholeFile" style:highest "treeview_parent_node"
widget "*EditorHScrollbar" style:highest "editor_hscrollbar"
widget "*OddPortGroups" style:highest "odd_port_groups"
widget "*EvenPortGroups" style:highest "even_port_groups"

View File

@ -1199,6 +1199,16 @@ style "ardour_button" ="default_button"
ythickness = 1
}
style "odd_port_groups"
{
fg[NORMAL] = { 0.6, 0.6, 0.6 }
}
style "even_port_groups"
{
fg[NORMAL] = { 0.3, 0.3, 0.3 }
}
#---------------------------------------------------------------
class "GtkWidget" style:highest "default_base"
@ -1575,4 +1585,5 @@ widget "*ChannelCountSelector" style:highest "medium_bold_entry"
widget "*ChannelCountSelector.GtkArrow" style:highest "default_generic"
widget "*RegionListWholeFile" style:highest "treeview_parent_node"
widget "*EditorHScrollbar" style:highest "editor_hscrollbar"
widget "*OddPortGroups" style:highest "odd_port_groups"
widget "*EvenPortGroups" style:highest "even_port_groups"

View File

@ -81,7 +81,7 @@ std::string
BundleEditorMatrix::row_name (int r) const
{
std::stringstream s;
s << r;
s << r + 1; // 1-based counting
return s.str();
}

View File

@ -103,7 +103,7 @@ Editor::handle_new_route (Session::RouteList& routes)
row = *(route_display_model->append ());
#endif
cerr << route->name() << " marked for display ? " << tv->marked_for_display() << endl;
// cerr << route->name() << " marked for display ? " << tv->marked_for_display() << endl;
row[route_display_columns.text] = route->name();
row[route_display_columns.visible] = tv->marked_for_display();

View File

@ -53,12 +53,6 @@ IOSelector::IOSelector (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO>
} else {
_io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
}
/* this got lost in a merge from 2.0 */
// set_button_sensitivity ();
// io->name_changed.connect (mem_fun(*this, &IOSelector::name_changed));
}
void
@ -210,55 +204,6 @@ IOSelector::row_descriptor () const
return _("port");
}
#if 0
void
IOSelector::set_button_sensitivity ()
{
if (for_input) {
if (io->input_maximum() < 0 || io->input_maximum() > (int) io->n_inputs()) {
add_port_button.set_sensitive (true);
} else {
add_port_button.set_sensitive (false);
}
} else {
if (io->output_maximum() < 0 || io->output_maximum() > (int) io->n_outputs()) {
add_port_button.set_sensitive (true);
} else {
add_port_button.set_sensitive (false);
}
}
if (for_input) {
if (io->n_inputs() && (io->input_minimum() < 0 || io->input_minimum() < (int) io->n_inputs())) {
remove_port_button.set_sensitive (true);
} else {
remove_port_button.set_sensitive (false);
}
} else {
if (io->n_outputs() && (io->output_minimum() < 0 || io->output_minimum() < (int) io->n_outputs())) {
remove_port_button.set_sensitive (true);
} else {
remove_port_button.set_sensitive (false);
}
}
}
#endif
#if 0
void
IOSelector::name_changed (void* src)
{
ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelector::name_changed), src));
display_ports ();
}
#endif
IOSelectorWindow::IOSelectorWindow (
ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io, bool for_input, bool can_cancel
)
@ -273,20 +218,19 @@ IOSelectorWindow::IOSelectorWindow (
add_events (Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
set_name ("IOSelectorWindow2");
string title;
if (for_input) {
title = string_compose(_("%1 input"), io->name());
} else {
title = string_compose(_("%1 output"), io->name());
}
// io->name_changed.connect (mem_fun(*this, &IOSelectorWindow::io_name_changed));
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));
}
if (!for_input) {
io->output_changed.connect (mem_fun(*this, &IOSelectorWindow::ports_changed));
} else {
add_button.hide ();
io->input_changed.connect (mem_fun(*this, &IOSelectorWindow::ports_changed));
}
rescan_button.set_name ("IOSelectorButton");
@ -314,12 +258,14 @@ IOSelectorWindow::IOSelectorWindow (
cancel_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::cancel));
rescan_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::rescan));
set_title (title);
set_position (Gtk::WIN_POS_MOUSE);
io_name_changed (this);
ports_changed (IOChange (0), this);
show_all ();
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), this));
}
IOSelectorWindow::~IOSelectorWindow()
@ -327,6 +273,16 @@ IOSelectorWindow::~IOSelectorWindow()
}
void
IOSelectorWindow::ports_changed (ARDOUR::IOChange change, void *src)
{
if (_selector.maximum_rows() > _selector.n_rows()) {
add_button.set_sensitive (true);
} else {
add_button.set_sensitive (false);
}
}
void
IOSelectorWindow::rescan ()
{
@ -354,6 +310,21 @@ IOSelectorWindow::on_map ()
Window::on_map ();
}
void
IOSelectorWindow::io_name_changed (void* src)
{
ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelectorWindow::io_name_changed), src));
string title;
if (!_selector.offering_input()) {
title = string_compose(_("%1 input"), _selector.io()->name());
} else {
title = string_compose(_("%1 output"), _selector.io()->name());
}
set_title (title);
}
PortInsertUI::PortInsertUI (ARDOUR::Session& sess, boost::shared_ptr<ARDOUR::PortInsert> pi)
: input_selector (sess, pi->io(), true),

View File

@ -36,10 +36,11 @@ class IOSelector : public PortMatrix {
void add_row ();
void remove_row (int);
std::string row_descriptor () const;
boost::shared_ptr<ARDOUR::IO> const io() { return _io; }
private:
boost::shared_ptr<ARDOUR::IO> _io;
void ports_changed (ARDOUR::IOChange, void*);
};
@ -67,6 +68,9 @@ class IOSelectorWindow : public ArdourDialog
void rescan ();
void cancel ();
void accept ();
void ports_changed (ARDOUR::IOChange change, void *src);
void io_name_changed (void *src);
};

View File

@ -41,6 +41,8 @@
#include "gui_thread.h"
#include "i18n.h"
using namespace Gtk;
/** Add a port to a group.
* @param p Port name, with or without prefix.
*/
@ -81,7 +83,7 @@ PortGroupUI::PortGroupUI (PortMatrix& m, PortGroup& g)
for (int i = 0; i < rows; ++i) {
for (uint32_t j = 0; j < _port_group.ports.size(); ++j) {
Gtk::CheckButton* b = new Gtk::CheckButton;
CheckButton* b = new CheckButton;
b->signal_toggled().connect (
sigc::bind (sigc::mem_fun (*this, &PortGroupUI::port_checkbutton_toggled), b, i, j)
@ -118,7 +120,6 @@ void
PortGroupUI::visibility_checkbutton_toggled ()
{
_port_group.visible = _visibility_checkbutton.get_active ();
setup_visibility ();
}
/** @return Width and height of a single checkbutton in a port group table */
@ -143,14 +144,14 @@ PortGroupUI::unit_size () const
}
/** @return Table widget containing the port checkbuttons */
Gtk::Widget&
Widget&
PortGroupUI::get_table ()
{
return _table_box;
}
/** @return Checkbutton used to toggle visibility */
Gtk::Widget&
Widget&
PortGroupUI::get_visibility_checkbutton ()
{
return _visibility_checkbutton;
@ -159,7 +160,7 @@ PortGroupUI::get_visibility_checkbutton ()
/** Handle a toggle of a port check button */
void
PortGroupUI::port_checkbutton_toggled (Gtk::CheckButton* b, int r, int c)
PortGroupUI::port_checkbutton_toggled (CheckButton* b, int r, int c)
{
if (_ignore_check_button_toggle == false) {
_port_matrix.set_state (r, _port_group.prefix + _port_group.ports[c], b->get_active());
@ -183,9 +184,9 @@ PortGroupUI::setup_visibility ()
}
RotatedLabelSet::RotatedLabelSet (PortGroupList& g)
: Glib::ObjectBase ("RotatedLabelSet"), Gtk::Widget (), _port_group_list (g), _base_width (128)
: Glib::ObjectBase ("RotatedLabelSet"), Widget (), _port_group_list (g), _base_width (128)
{
set_flags (Gtk::NO_WINDOW);
set_flags (NO_WINDOW);
set_angle (30);
}
@ -209,9 +210,9 @@ RotatedLabelSet::set_angle (int degrees)
}
void
RotatedLabelSet::on_size_request (Gtk::Requisition* requisition)
RotatedLabelSet::on_size_request (Requisition* requisition)
{
*requisition = Gtk::Requisition ();
*requisition = Requisition ();
if (_pango_layout == 0) {
return;
@ -238,7 +239,7 @@ RotatedLabelSet::on_size_request (Gtk::Requisition* requisition)
}
void
RotatedLabelSet::on_size_allocate (Gtk::Allocation& allocation)
RotatedLabelSet::on_size_allocate (Allocation& allocation)
{
set_allocation (allocation);
@ -252,15 +253,15 @@ RotatedLabelSet::on_size_allocate (Gtk::Allocation& allocation)
void
RotatedLabelSet::on_realize ()
{
Gtk::Widget::on_realize ();
Widget::on_realize ();
Glib::RefPtr<Gtk::Style> style = get_style ();
Glib::RefPtr<Style> style = get_style ();
if (!_gdk_window) {
GdkWindowAttr attributes;
memset (&attributes, 0, sizeof (attributes));
Gtk::Allocation allocation = get_allocation ();
Allocation allocation = get_allocation ();
attributes.x = allocation.get_x ();
attributes.y = allocation.get_y ();
attributes.width = allocation.get_width ();
@ -271,13 +272,13 @@ RotatedLabelSet::on_realize ()
attributes.wclass = GDK_INPUT_OUTPUT;
_gdk_window = Gdk::Window::create (get_window (), &attributes, GDK_WA_X | GDK_WA_Y);
unset_flags (Gtk::NO_WINDOW);
unset_flags (NO_WINDOW);
set_window (_gdk_window);
_bg_colour = style->get_bg (Gtk::STATE_NORMAL );
modify_bg (Gtk::STATE_NORMAL, _bg_colour);
_fg_colour = style->get_fg (Gtk::STATE_NORMAL);
;
_bg_colour = style->get_bg (STATE_NORMAL );
modify_bg (STATE_NORMAL, _bg_colour);
_fg_colour = style->get_fg (STATE_NORMAL);
_gdk_window->set_user_data (gobj ());
/* Set up Pango stuff */
@ -297,7 +298,7 @@ RotatedLabelSet::on_unrealize()
{
_gdk_window.clear ();
Gtk::Widget::on_unrealize ();
Widget::on_unrealize ();
}
@ -376,20 +377,21 @@ PortMatrix::PortMatrix (ARDOUR::Session& session, ARDOUR::DataType type, bool of
_row_labels_vbox[0] = _row_labels_vbox[1] = 0;
_side_vbox_pad[0] = _side_vbox_pad[1] = 0;
_visibility_checkbutton_box.pack_start (*(manage (new Label (_("Connections displayed: ")))), false, false, 10);
pack_start (_visibility_checkbutton_box, false, false);
_side_vbox[0].pack_start (*Gtk::manage (new Gtk::Label ("")));
_side_vbox[0].pack_start (*manage (new Label ("")));
_overall_hbox.pack_start (_side_vbox[0], false, false);
_scrolled_window.set_policy (Gtk::POLICY_ALWAYS, Gtk::POLICY_NEVER);
_scrolled_window.set_shadow_type (Gtk::SHADOW_NONE);
Gtk::VBox* b = new Gtk::VBox;
_scrolled_window.set_policy (POLICY_ALWAYS, POLICY_NEVER);
_scrolled_window.set_shadow_type (SHADOW_NONE);
VBox* b = new VBox;
b->pack_start (_column_labels, false, false);
b->pack_start (_port_group_hbox, false, false);
Gtk::Alignment* a = new Gtk::Alignment (0, 1, 0, 0);
a->add (*Gtk::manage (b));
_scrolled_window.add (*Gtk::manage (a));
Alignment* a = new Alignment (0, 1, 0, 0);
a->add (*manage (b));
_scrolled_window.add (*manage (a));
_overall_hbox.pack_start (_scrolled_window);
_side_vbox[1].pack_start (*Gtk::manage (new Gtk::Label ("")));
_side_vbox[1].pack_start (*manage (new Label ("")));
// _overall_hbox.pack_start (_side_vbox[1]);
pack_start (_overall_hbox);
@ -407,7 +409,7 @@ PortMatrix::clear ()
{
for (int i = 0; i < 2; ++i) {
for (std::vector<Gtk::EventBox*>::iterator j = _row_labels[i].begin(); j != _row_labels[i].end(); ++j) {
for (std::vector<EventBox*>::iterator j = _row_labels[i].begin(); j != _row_labels[i].end(); ++j) {
delete *j;
}
_row_labels[i].clear ();
@ -468,7 +470,7 @@ PortMatrix::setup_dimensions ()
/* Row labels */
for (int i = 0; i < 2; ++i) {
for (std::vector<Gtk::EventBox*>::iterator j = _row_labels[i].begin(); j != _row_labels[i].end(); ++j) {
for (std::vector<EventBox*>::iterator j = _row_labels[i].begin(); j != _row_labels[i].end(); ++j) {
(*j)->get_child()->set_size_request (-1, unit_size.second);
}
@ -489,49 +491,77 @@ PortMatrix::setup ()
/* Row labels */
for (int i = 0; i < 2; ++i) {
_row_labels_vbox[i] = new Gtk::VBox;
_row_labels_vbox[i] = new VBox;
int const run_rows = std::max (1, rows);
for (int j = 0; j < run_rows; ++j) {
Gtk::Label* label = new Gtk::Label (rows == 0 ? "Quim" : row_name (j));
Gtk::EventBox* b = new Gtk::EventBox;
/* embolden the port/channel name */
string s = "<b>";
s += row_name (j);
s += "</b>";
Label* label = manage (new Label (s));
EventBox* b = manage (new EventBox);
label->set_use_markup (true);
b->set_events (Gdk::BUTTON_PRESS_MASK);
b->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &IOSelector::row_label_button_pressed), j));
b->add (*Gtk::manage (label));
b->add (*label);
_row_labels[i].push_back (b);
_row_labels_vbox[i]->pack_start (*b, false, false);
}
_side_vbox[i].pack_start (*_row_labels_vbox[i], false, false);
_side_vbox_pad[i] = new Gtk::Label ("");
_side_vbox_pad[i] = new Label ("");
_side_vbox[i].pack_start (*_side_vbox_pad[i], false, false);
}
/* Checkbutton tables and visibility checkbuttons */
int n = 0;
for (PortGroupList::iterator i = _port_group_list.begin(); i != _port_group_list.end(); ++i) {
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);
}
_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;
CheckButton* chk = dynamic_cast<CheckButton*>(&t->get_visibility_checkbutton());
if (chk) {
chk->signal_toggled().connect (sigc::mem_fun (*this, &PortMatrix::reset_visibility));
}
}
show_all ();
reset_visibility ();
}
void
PortMatrix::reset_visibility ()
{
/* now adjust visibility and coloring */
bool even = true;
Gdk::Color odd_bg (color_from_style ("OddPortGroups", STATE_NORMAL, "fg"));
Gdk::Color even_bg (color_from_style ("EvenPortGroups", STATE_NORMAL, "fg"));
for (std::vector<PortGroupUI*>::iterator i = _port_group_ui.begin(); i != _port_group_ui.end(); ++i) {
(*i)->setup_visibility ();
if ((*i)->port_group().visible) {
if (even) {
(*i)->get_table().modify_bg (STATE_NORMAL, even_bg);
} else {
(*i)->get_table().modify_bg (STATE_NORMAL, odd_bg);
}
even = !even;
}
}
}
void
@ -550,8 +580,8 @@ PortMatrix::row_label_button_pressed (GdkEventButton* e, int r)
return false;
}
Gtk::Menu* menu = Gtk::manage (new Gtk::Menu);
Gtk::Menu_Helpers::MenuList& items = menu->items ();
Menu* menu = manage (new Menu);
Menu_Helpers::MenuList& items = menu->items ();
menu->set_name ("ArdourContextMenu");
bool const can_add = maximum_rows () > n_rows ();
@ -559,13 +589,13 @@ PortMatrix::row_label_button_pressed (GdkEventButton* e, int r)
std::string const name = row_name (r);
items.push_back (
Gtk::Menu_Helpers::MenuElem (string_compose(_("Add %1"), row_descriptor()), sigc::mem_fun (*this, &PortMatrix::add_row))
Menu_Helpers::MenuElem (string_compose(_("Add %1"), row_descriptor()), sigc::mem_fun (*this, &PortMatrix::add_row))
);
items.back().set_sensitive (can_add);
items.push_back (
Gtk::Menu_Helpers::MenuElem (string_compose(_("Remove %1 \"%2\""), row_descriptor(), name), sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_row), r))
Menu_Helpers::MenuElem (string_compose(_("Remove %1 \"%2\""), row_descriptor(), name), sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_row), r))
);
items.back().set_sensitive (can_remove);
@ -628,12 +658,22 @@ PortGroupList::refresh ()
PortGroup* g = 0;
if (_type == ARDOUR::DataType::AUDIO && boost::dynamic_pointer_cast<ARDOUR::AudioTrack> (*i)) {
g = &track;
} else if (_type == ARDOUR::DataType::MIDI && boost::dynamic_pointer_cast<ARDOUR::MidiTrack> (*i)) {
g = &track;
} else if (_type == ARDOUR::DataType::AUDIO && boost::dynamic_pointer_cast<ARDOUR::Route> (*i)) {
g = &buss;
if (_type == ARDOUR::DataType::AUDIO) {
if (boost::dynamic_pointer_cast<ARDOUR::AudioTrack> (*i)) {
g = &track;
} else if (!boost::dynamic_pointer_cast<ARDOUR::MidiTrack>(*i)) {
g = &buss;
}
} else if (_type == ARDOUR::DataType::MIDI) {
if (boost::dynamic_pointer_cast<ARDOUR::MidiTrack> (*i)) {
g = &track;
}
/* No MIDI busses yet */
}
if (g) {

View File

@ -162,6 +162,7 @@ class PortMatrix : public Gtk::VBox {
void set_type (ARDOUR::DataType);
void set_offer_inputs (bool);
bool offering_input() const { return _offer_inputs; }
virtual void set_state (int, std::string const &, bool) = 0;
virtual bool get_state (int, std::string const &) const = 0;
@ -178,11 +179,6 @@ class PortMatrix : public Gtk::VBox {
bool _offer_inputs;
private:
void setup ();
void clear ();
void setup_dimensions ();
bool row_label_button_pressed (GdkEventButton*, int);
PortGroupList _port_group_list;
ARDOUR::DataType _type;
std::vector<PortGroupUI*> _port_group_ui;
@ -195,6 +191,12 @@ class PortMatrix : public Gtk::VBox {
Gtk::ScrolledWindow _scrolled_window;
Gtk::Label* _side_vbox_pad[2];
Gtk::HBox _visibility_checkbutton_box;
void setup ();
void clear ();
void setup_dimensions ();
bool row_label_button_pressed (GdkEventButton*, int);
void reset_visibility ();
};
#endif

View File

@ -1,7 +1,7 @@
/*
Copyright (C) 2003 Paul Davis
This program is free software; you can redistribute it and/or modify
This program is free software; you an redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@ -348,14 +348,11 @@ color_from_style (string widget_style_name, int state, string attr)
return Gdk::Color ("red");
}
cerr << "got style for " << widget_style_name << endl;
if (attr == "fg") {
return Gdk::Color (&style->fg[state]);
}
if (attr == "bg") {
cerr << "returning color from bg\n";
return Gdk::Color (&style->bg[state]);
}
@ -387,7 +384,6 @@ color_from_style (string widget_style_name, int state, string attr)
return Gdk::Color ("red");
}
bool
canvas_item_visible (ArdourCanvas::Item* item)
{