From 8b63f9cac7b034c4bbe0c28fd595cc0852b39938 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 18 Jun 2009 01:48:11 +0000 Subject: [PATCH] modified patch from lincoln to show/control rec-enable status in track/bus list git-svn-id: svn://localhost/ardour2/branches/3.0@5216 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 38 +++++- gtk2_ardour/editor.h | 10 ++ gtk2_ardour/editor_route_list.cc | 33 ++++- gtk2_ardour/icons/record_disabled_grey.png | Bin 0 -> 449 bytes gtk2_ardour/public_editor.h | 2 + gtk2_ardour/route_ui.cc | 6 +- libs/ardour/route.cc | 2 - libs/gtkmm2ext/cell_renderer_pixbuf_toggle.cc | 115 ++++++++++++++++++ .../gtkmm2ext/cell_renderer_pixbuf_toggle.h | 73 +++++++++++ libs/gtkmm2ext/wscript | 1 + 10 files changed, 272 insertions(+), 8 deletions(-) create mode 100644 gtk2_ardour/icons/record_disabled_grey.png create mode 100644 libs/gtkmm2ext/cell_renderer_pixbuf_toggle.cc create mode 100644 libs/gtkmm2ext/gtkmm2ext/cell_renderer_pixbuf_toggle.h diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 8df8881cae..7f2d502d95 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -48,6 +48,7 @@ #include #include #include +#include #include "ardour/audio_diskstream.h" #include "ardour/audio_track.h" @@ -523,20 +524,38 @@ Editor::Editor () bottom_hbox.set_border_width (2); bottom_hbox.set_spacing (3); + + CellRendererPixbufToggle* rec_col_renderer = Gtk::manage( new CellRendererPixbufToggle() ); + + rec_col_renderer->set_active_pixbuf(::get_icon("record_normal_red")); + rec_col_renderer->set_inactive_pixbuf(::get_icon("record_disabled_grey")); + + rec_col_renderer->signal_toggled().connect(mem_fun(*this, &Editor::on_tv_rec_enable_toggled)); + + Gtk::TreeViewColumn* rec_state_column = Gtk::manage(new Gtk::TreeViewColumn("Rec", *rec_col_renderer)); + rec_state_column->add_attribute(rec_col_renderer->property_active(), route_display_columns.rec_enabled); + rec_state_column->add_attribute(rec_col_renderer->property_visible(), route_display_columns.is_track); + route_display_model = ListStore::create(route_display_columns); route_list_display.set_model (route_display_model); + + route_list_display.append_column (*rec_state_column); route_list_display.append_column (_("Show"), route_display_columns.visible); route_list_display.append_column (_("Name"), route_display_columns.text); + route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0)); route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1)); + route_list_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2)); + route_list_display.set_headers_visible (true); route_list_display.set_name ("TrackListDisplay"); - route_list_display.get_selection()->set_mode (SELECTION_SINGLE); + route_list_display.get_selection()->set_mode (SELECTION_NONE); route_list_display.set_reorderable (true); route_list_display.set_size_request (100,-1); route_list_display.add_object_drag (route_display_columns.route.index(), "routes"); - CellRendererToggle* route_list_visible_cell = dynamic_cast(route_list_display.get_column_cell_renderer (0)); + CellRendererToggle* route_list_visible_cell = dynamic_cast(route_list_display.get_column_cell_renderer (1)); + route_list_visible_cell->property_activatable() = true; route_list_visible_cell->property_radio() = false; @@ -871,6 +890,21 @@ Editor::~Editor() delete _drag; } +void +Editor::on_tv_rec_enable_toggled(const Glib::ustring& path_string){ + + // Get the model row that has been toggled. + Gtk::TreeModel::Row row = *route_display_model->get_iter(Gtk::TreeModel::Path(path_string)); + + TimeAxisView *tv = row[route_display_columns.tv]; + AudioTimeAxisView *atv = dynamic_cast (tv); + + if(atv != 0 && atv->is_audio_track()){ + atv->get_diskstream()->set_record_enabled(!atv->get_diskstream()->record_enabled()); + } +} + + void Editor::add_toplevel_controls (Container& cont) { diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index a1b173fe40..81f8eab5aa 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -399,6 +399,8 @@ class Editor : public PublicEditor void goto_visual_state (uint32_t); void save_visual_state (uint32_t); + void update_rec_display (); + protected: void map_transport_state (); void map_position_change (nframes64_t); @@ -1761,22 +1763,30 @@ public: void reposition_zoom_rect (nframes64_t start, nframes64_t end); /* diskstream/route display management */ + Glib::RefPtr rec_enabled_icon; + Glib::RefPtr rec_disabled_icon; struct RouteDisplayModelColumns : public Gtk::TreeModel::ColumnRecord { RouteDisplayModelColumns() { add (text); add (visible); + add (rec_enabled); add (temporary_visible); + add (is_track); add (tv); add (route); } Gtk::TreeModelColumn text; Gtk::TreeModelColumn visible; + Gtk::TreeModelColumn rec_enabled; Gtk::TreeModelColumn temporary_visible; + Gtk::TreeModelColumn is_track; Gtk::TreeModelColumn tv; Gtk::TreeModelColumn > route; }; + void on_tv_rec_enable_toggled(const Glib::ustring& path_string); + RouteDisplayModelColumns route_display_columns; Glib::RefPtr route_display_model; Glib::RefPtr route_display_selection; diff --git a/gtk2_ardour/editor_route_list.cc b/gtk2_ardour/editor_route_list.cc index ae1688b1bc..56cc3f5cf1 100644 --- a/gtk2_ardour/editor_route_list.cc +++ b/gtk2_ardour/editor_route_list.cc @@ -32,6 +32,7 @@ #include "mixer_strip.h" #include "gui_thread.h" #include "actions.h" +#include "utils.h" #include "pbd/unknown_type.h" @@ -114,6 +115,7 @@ Editor::handle_new_route (RouteList& routes) row[route_display_columns.visible] = tv->marked_for_display(); row[route_display_columns.tv] = tv; row[route_display_columns.route] = route; + row[route_display_columns.is_track] = (boost::dynamic_pointer_cast(route) != 0); track_views.push_back (tv); @@ -381,9 +383,8 @@ Editor::redisplay_route_list () tv->set_marked_for_display (false); tv->hide (); } - - n++; + n++; } /* whenever we go idle, update the track view list to reflect the new order. @@ -395,6 +396,7 @@ Editor::redisplay_route_list () full_canvas_height = position + canvas_timebars_vsize; vertical_adjustment.set_upper (full_canvas_height); + if ((vertical_adjustment.get_value() + _canvas_height) > vertical_adjustment.get_upper()) { /* We're increasing the size of the canvas while the bottom is visible. @@ -595,7 +597,11 @@ Editor::route_list_display_button_press (GdkEventButton* ev) } switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) { + case 0: + /* allow normal processing to occur */ + return false; + case 1: if ((iter = route_display_model->get_iter (path))) { TimeAxisView* tv = (*iter)[route_display_columns.tv]; if (tv) { @@ -605,7 +611,7 @@ Editor::route_list_display_button_press (GdkEventButton* ev) } return true; - case 1: + case 2: /* allow normal processing to occur */ return false; @@ -688,6 +694,7 @@ Editor::route_list_delete (const Gtk::TreeModel::Path& path) ignore_route_list_reorder = false; } + void Editor::route_list_display_drag_data_received (const RefPtr& context, int x, int y, @@ -836,3 +843,23 @@ Editor::move_selected_tracks (bool up) session->sync_order_keys (_order_key); } + +void +Editor::update_rec_display () +{ + TreeModel::Children rows = route_display_model->children(); + TreeModel::Children::iterator i; + + for (i = rows.begin(); i != rows.end(); ++i) { + boost::shared_ptr route = (*i)[route_display_columns.route]; + + if (boost::dynamic_pointer_cast(route)) { + + if (route->record_enabled()){ + (*i)[route_display_columns.rec_enabled] = true; + } else { + (*i)[route_display_columns.rec_enabled] = false; + } + } + } +} diff --git a/gtk2_ardour/icons/record_disabled_grey.png b/gtk2_ardour/icons/record_disabled_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..bb3f4c9c70fbfac4268e118f91f92415b7c5335d GIT binary patch literal 449 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k#^NA%Cx&(BWL^R}Y)RhkE)4%c zaKYZ?lYt_f1s;*bK<(E-n9)gNb_Gz7y~NYkmHj5Gpr|f?@r^nSpec@?E{-7@=UXQ& z%s%WO(|Z5uq&stSl6Uo-*wNK>D2scds@4BvXO^ii|CTSZEb3Uuf=y{Y*Id|c^#*!f zjn%WPGfwtd^W^1w#akGe4gr&vNjf#Ae11ZZ5J621-oHKAej0 z7Hdd7tJIsM;waI!Vii|vq}lJk{|-xhc5#`-_+jak^36Bj?9$+p|DUomrtJ3HZ>uwB zvGX4=>3e)pRf3^w(FdSzrWqAMrz)qVGTEN|9HX&REbjKU@XT4?K6*@IIk&U%xaIpb zTlYFiv=yBDDfj$O$o10o0imKz3KkVnucv>ly8DF_XyvgPyzCz`*Y35Pe?H4bu39`R zw|w{AgO=a_SkIaA$*k{j;IvdF-{6Ss!0V=AtEXDZ^{Z#URTj+r_FT%YVda#fd)wZM oKHu|r&ipOc)-&9D$^M6}t!u{8%`Z>S0fsMwr>mdKI;Vst06_M>6aWAK literal 0 HcmV?d00001 diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index ed73f59258..dbb845274c 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -322,6 +322,8 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual bool canvas_markerview_end_handle_event(GdkEvent* event, ArdourCanvas::Item*,MarkerView*) = 0; #endif + virtual void update_rec_display () = 0; + static const int window_border_width; static const int container_border_width; static const int vertical_spacing; diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 6c56ab132c..8829967ac8 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -32,6 +32,7 @@ #include "pbd/controllable.h" #include "ardour_ui.h" +#include "editor.h" #include "route_ui.h" #include "keyboard.h" #include "utils.h" @@ -201,6 +202,7 @@ RouteUI::set_route (boost::shared_ptr rp) boost::shared_ptr t = boost::dynamic_pointer_cast(_route); connections.push_back (t->diskstream()->RecordEnableChanged.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed))); + connections.push_back (t->diskstream()->RecordEnableChanged.connect (mem_fun (PublicEditor::instance(), &PublicEditor::update_rec_display))); connections.push_back (_session.RecordStateChanged.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed))); rec_enable_button->show(); @@ -501,7 +503,6 @@ RouteUI::rec_enable_press(GdkEventButton* ev) set_mix_group_rec_enable (_route, !_route->record_enabled()); } else { - reversibly_apply_track_boolean ("rec-enable change", &Track::set_record_enable, !track()->record_enabled(), this); check_rec_enable_sensitivity (); } @@ -715,6 +716,9 @@ RouteUI::update_rec_display () rec_enable_button->set_active (model); ignore_toggle = false; } + else { + return; + } /* now make sure its color state is correct */ diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index b2c3d27766..739a2840ad 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -2316,8 +2316,6 @@ Route::put_control_outs_at (Placement p) _processors.insert(loc, _control_outs); - cerr << _name << " moved control outs to " << enum_2_string (p) << endl; - processors_changed (); /* EMIT SIGNAL */ _session.set_dirty (); } diff --git a/libs/gtkmm2ext/cell_renderer_pixbuf_toggle.cc b/libs/gtkmm2ext/cell_renderer_pixbuf_toggle.cc new file mode 100644 index 0000000000..d3f02a50f8 --- /dev/null +++ b/libs/gtkmm2ext/cell_renderer_pixbuf_toggle.cc @@ -0,0 +1,115 @@ +/* + Copyright (C) 2009 Paul Davis + + This program is free software; you can 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + $Id: cell_renderer_toggle_pixbuf.cc $ +*/ + +#include +#include + +#include + +using namespace std; +using namespace Gtk; +using namespace Gdk; +using namespace Glib; +using namespace Gtkmm2ext; + + +CellRendererPixbufToggle::CellRendererPixbufToggle() : + Glib::ObjectBase( typeid(CellRendererPixbufToggle) ), + Gtk::CellRenderer(), + property_pixbuf_(*this, "pixbuf"), + property_active_(*this, "active", false) +{ + property_mode() = Gtk::CELL_RENDERER_MODE_ACTIVATABLE; + property_xpad() = 2; + property_ypad() = 2; + property_sensitive() = false; +} + +Glib::PropertyProxy< Glib::RefPtr > +CellRendererPixbufToggle::property_pixbuf() +{ + return property_pixbuf_.get_proxy(); +} + +Glib::PropertyProxy +CellRendererPixbufToggle::property_active() +{ + return property_active_.get_proxy(); +} + +// Overridden methods of the parent CellRenderer +Glib::PropertyProxy_Base +CellRendererPixbufToggle::_property_renderable() +{ + return property_pixbuf(); +} + +bool +CellRendererPixbufToggle::activate_vfunc(GdkEvent*, Gtk::Widget&, const Glib::ustring& path, const Gdk::Rectangle&, const Gdk::Rectangle&, Gtk::CellRendererState) +{ + signal_toggled_(path); + return true; +} + + + +void +CellRendererPixbufToggle::render_vfunc (const Glib::RefPtr& window, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, const Gdk::Rectangle& expose_area, Gtk::CellRendererState flags) +{ + int offset_width = 0; + int offset_height = 0; + + if(property_active() == true){ + + offset_width = cell_area.get_x() + (int)(cell_area.get_width() - inactive_pixbuf->get_width())/2; + offset_height = cell_area.get_y() + (int)(cell_area.get_height() - inactive_pixbuf->get_height())/2; + + window->draw_pixbuf (RefPtr(), active_pixbuf, 0, 0, offset_width, offset_height, -1, -1, Gdk::RGB_DITHER_NORMAL, 0, 0); + } + else { + offset_width = cell_area.get_x() + (int)(cell_area.get_width() - inactive_pixbuf->get_width())/2; + offset_height = cell_area.get_y() + (int)(cell_area.get_height() - inactive_pixbuf->get_height())/2; + + window->draw_pixbuf (RefPtr(), inactive_pixbuf, 0, 0, offset_width, offset_height, -1, -1, Gdk::RGB_DITHER_NORMAL, 0, 0); + } +} + +void +CellRendererPixbufToggle::get_size_vfunc (Gtk::Widget& widget, const Gdk::Rectangle* cell_area, int* x_offset, int* y_offset, int* width, int* height) const +{ +//cerr << "cell_renderer_pixbuf_toggle get_size" << endl; + +} + +void +CellRendererPixbufToggle::set_active_pixbuf(Glib::RefPtr pixbuf){ + active_pixbuf = pixbuf; +} + +void +CellRendererPixbufToggle::set_inactive_pixbuf(Glib::RefPtr pixbuf){ + inactive_pixbuf = pixbuf; +} + +CellRendererPixbufToggle::SignalToggled& +CellRendererPixbufToggle::signal_toggled() +{ + return signal_toggled_; +} diff --git a/libs/gtkmm2ext/gtkmm2ext/cell_renderer_pixbuf_toggle.h b/libs/gtkmm2ext/gtkmm2ext/cell_renderer_pixbuf_toggle.h new file mode 100644 index 0000000000..74f5e59a52 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/cell_renderer_pixbuf_toggle.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2000-2009 Paul Davis + + This program is free software; you can 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtkmm2ext_cell_renderer_pixbuf_toggle_h__ +#define __gtkmm2ext_cell_renderer_pixbuf_toggle_h__ + +#include +#include +#include +#include + +using namespace Gtk; + +namespace Gtkmm2ext { + +class CellRendererPixbufToggle : public Gtk::CellRenderer +{ + public: + + CellRendererPixbufToggle(); + virtual ~CellRendererPixbufToggle(){}; + + virtual void render_vfunc (const Glib::RefPtr& window, Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, const Gdk::Rectangle& expose_area, Gtk::CellRendererState flags); + + virtual void get_size_vfunc (Gtk::Widget& widget, const Gdk::Rectangle* cell_area, int* x_offset, int* y_offset, int* width, int* height) const; + + virtual bool activate_vfunc(GdkEvent*, Gtk::Widget&, const Glib::ustring& path, const Gdk::Rectangle&, const Gdk::Rectangle&, Gtk::CellRendererState); + + Glib::PropertyProxy_Base _property_renderable(); + + Glib::PropertyProxy< Glib::RefPtr > property_pixbuf(); + Glib::PropertyProxy property_active(); + + void set_active_pixbuf(Glib::RefPtr pixbuf); + void set_inactive_pixbuf(Glib::RefPtr pixbuf); + + typedef sigc::signal SignalToggled; + + SignalToggled& signal_toggled(); + + protected: + + private: + Glib::Property< Glib::RefPtr > property_pixbuf_; + Glib::Property property_active_; + + Glib::RefPtr active_pixbuf; + Glib::RefPtr inactive_pixbuf; + + //void on_cell_toggled(const Glib::ustring& path_string); + + SignalToggled signal_toggled_; +}; + +} // namespace + +#endif /* __gtkmm2ext_cell_renderer_pixbuf_toggle_h__ */ diff --git a/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript index 81c0dfbacd..ec1fd3282c 100644 --- a/libs/gtkmm2ext/wscript +++ b/libs/gtkmm2ext/wscript @@ -40,6 +40,7 @@ def build(bld): auto_spin.cc barcontroller.cc binding_proxy.cc + cell_renderer_pixbuf_toggle.cc choice.cc click_box.cc dndtreeview.cc