13
0

group clocks in location UI and region editor so that they all change modes together

git-svn-id: svn://localhost/ardour2/branches/3.0@9048 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-03-02 22:43:19 +00:00
parent 10b224790b
commit b3ddcbcee4
8 changed files with 309 additions and 127 deletions

View File

@ -2057,9 +2057,10 @@ AudioClock::set_mode (Mode m)
key_entry_state = 0; key_entry_state = 0;
if (!is_transient) { if (!is_transient) {
ModeChanged (); /* EMIT SIGNAL */ ModeChanged (); /* EMIT SIGNAL (the static one)*/
mode_changed (); /* EMIT SIGNAL */
} }
mode_changed (); /* EMIT SIGNAL (the member one) */
} }
void void

View File

@ -0,0 +1,66 @@
/*
Copyright (C) 2011 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.
*/
#include "clock_group.h"
ClockGroup::ClockGroup ()
: ignore_changes (false)
, _clock_mode (AudioClock::Frames)
{
}
ClockGroup::~ClockGroup()
{
}
void
ClockGroup::add (AudioClock& clock)
{
if (clocks.insert (&clock).second) {
clock.mode_changed.connect (sigc::bind (sigc::mem_fun (*this, &ClockGroup::one_clock_changed), &clock));
clock.set_mode (_clock_mode);
}
}
void
ClockGroup::remove (AudioClock& clock)
{
clocks.erase (&clock);
}
void
ClockGroup::one_clock_changed (AudioClock* clock)
{
if (!ignore_changes) {
set_clock_mode (clock->mode());
}
}
void
ClockGroup::set_clock_mode (AudioClock::Mode mode)
{
_clock_mode = mode;
ignore_changes = true;
for (std::set<AudioClock*>::iterator c = clocks.begin(); c != clocks.end(); ++c) {
(*c)->set_mode (mode);
}
ignore_changes = false;
}

47
gtk2_ardour/clock_group.h Normal file
View File

@ -0,0 +1,47 @@
/*
Copyright (C) 2011 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 __gtk_ardour_clock_group_h__
#define __gtk_ardour_clock_group_h__
#include <set>
#include <sigc++/signal.h>
#include "audio_clock.h"
class ClockGroup : public sigc::trackable {
public:
ClockGroup ();
~ClockGroup ();
void set_clock_mode (AudioClock::Mode);
AudioClock::Mode clock_mode() const { return _clock_mode; }
void add (AudioClock&);
void remove (AudioClock&);
private:
std::set<AudioClock*> clocks;
bool ignore_changes;
AudioClock::Mode _clock_mode;
void one_clock_changed (AudioClock*);
};
#endif /* __gtk_ardour_clock_group_h__ */

View File

@ -28,11 +28,12 @@
#include "pbd/memento_command.h" #include "pbd/memento_command.h"
#include "ardour_ui.h" #include "ardour_ui.h"
#include "prompter.h" #include "clock_group.h"
#include "location_ui.h"
#include "keyboard.h"
#include "utils.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "keyboard.h"
#include "location_ui.h"
#include "prompter.h"
#include "utils.h"
#include "i18n.h" #include "i18n.h"
@ -43,20 +44,20 @@ using namespace Gtk;
using namespace Gtkmm2ext; using namespace Gtkmm2ext;
LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num) LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
: SessionHandlePtr (0), /* explicitly set below */ : SessionHandlePtr (0) /* explicitly set below */
location(0), , location(0)
item_table (1, 6, false), , item_table (1, 6, false)
start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true, false), , start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true, false)
end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true, false), , end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true, false)
length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, false, true), , length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, false, true)
cd_check_button (_("CD")), , cd_check_button (_("CD"))
hide_check_button (_("Hide")), , hide_check_button (_("Hide"))
lock_check_button (_("Lock")), , lock_check_button (_("Lock"))
glue_check_button (_("Glue")), , glue_check_button (_("Glue"))
scms_check_button (_("SCMS")), , scms_check_button (_("SCMS"))
preemph_check_button (_("Pre-Emphasis")) , preemph_check_button (_("Pre-Emphasis"))
, _clock_group (0)
{ {
i_am_the_modifier = 0; i_am_the_modifier = 0;
start_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR))); start_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
@ -150,13 +151,35 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
set_location (loc); set_location (loc);
set_number (num); set_number (num);
} }
LocationEditRow::~LocationEditRow() LocationEditRow::~LocationEditRow()
{ {
if (location) { if (location) {
connections.drop_connections (); connections.drop_connections ();
} }
if (_clock_group) {
_clock_group->remove (start_clock);
_clock_group->remove (end_clock);
_clock_group->remove (length_clock);
}
}
void
LocationEditRow::set_clock_group (ClockGroup& cg)
{
if (_clock_group) {
_clock_group->remove (start_clock);
_clock_group->remove (end_clock);
_clock_group->remove (length_clock);
}
_clock_group = &cg;
_clock_group->add (start_clock);
_clock_group->add (end_clock);
_clock_group->add (length_clock);
} }
void void
@ -659,6 +682,15 @@ LocationEditRow::focus_name() {
name_entry.grab_focus(); name_entry.grab_focus();
} }
void
LocationEditRow::set_clock_sensitivity ()
{
start_clock.set_sensitive (!location->locked());
end_clock.set_sensitive (!location->locked());
length_clock.set_sensitive (!location->locked());
}
/*------------------------------------------------------------------------*/
LocationUI::LocationUI () LocationUI::LocationUI ()
: add_location_button (_("New Marker")) : add_location_button (_("New Marker"))
@ -666,6 +698,9 @@ LocationUI::LocationUI ()
{ {
i_am_the_modifier = 0; i_am_the_modifier = 0;
_clock_group = new ClockGroup;
_clock_group->set_clock_mode (AudioClock::Frames);
VBox* vbox = manage (new VBox); VBox* vbox = manage (new VBox);
Table* table = manage (new Table (2, 2)); Table* table = manage (new Table (2, 2));
@ -679,6 +714,9 @@ LocationUI::LocationUI ()
table->attach (*l, 0, 2, table_row, table_row + 1); table->attach (*l, 0, 2, table_row, table_row + 1);
++table_row; ++table_row;
loop_edit_row.set_clock_group (*_clock_group);
punch_edit_row.set_clock_group (*_clock_group);
loop_punch_box.pack_start (loop_edit_row, false, false); loop_punch_box.pack_start (loop_edit_row, false, false);
loop_punch_box.pack_start (punch_edit_row, false, false); loop_punch_box.pack_start (punch_edit_row, false, false);
@ -771,6 +809,7 @@ LocationUI::LocationUI ()
LocationUI::~LocationUI() LocationUI::~LocationUI()
{ {
delete _clock_group;
} }
gint gint
@ -830,7 +869,10 @@ LocationUI::location_added (Location* location)
loc.sort (LocationSortByStart ()); loc.sort (LocationSortByStart ());
LocationEditRow* erow = manage (new LocationEditRow (_session, location)); LocationEditRow* erow = manage (new LocationEditRow (_session, location));
erow->set_clock_group (*_clock_group);
erow->remove_requested.connect (sigc::mem_fun (*this, &LocationUI::location_remove_requested)); erow->remove_requested.connect (sigc::mem_fun (*this, &LocationUI::location_remove_requested));
Box_Helpers::BoxList & children = location->is_range_marker() ? range_rows.children () : location_rows.children (); Box_Helpers::BoxList & children = location->is_range_marker() ? range_rows.children () : location_rows.children ();
/* Step through the location list and the GUI list to find the place to insert */ /* Step through the location list and the GUI list to find the place to insert */
@ -900,8 +942,11 @@ LocationUI::map_locations (Locations::LocationList& locations)
if (location->is_mark()) { if (location->is_mark()) {
LocationEditRow* erow = manage (new LocationEditRow (_session, location, mark_n)); LocationEditRow* erow = manage (new LocationEditRow (_session, location, mark_n));
erow->set_clock_group (*_clock_group);
erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested)); erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested));
erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges)); erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges));
Box_Helpers::BoxList & loc_children = location_rows.children(); Box_Helpers::BoxList & loc_children = location_rows.children();
loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START)); loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
if (location == newest_location) { if (location == newest_location) {
@ -918,7 +963,10 @@ LocationUI::map_locations (Locations::LocationList& locations)
loop_edit_row.show_all(); loop_edit_row.show_all();
} else { } else {
LocationEditRow* erow = manage (new LocationEditRow(_session, location)); LocationEditRow* erow = manage (new LocationEditRow(_session, location));
erow->set_clock_group (*_clock_group);
erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested)); erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested));
Box_Helpers::BoxList & range_children = range_rows.children(); Box_Helpers::BoxList & range_children = range_rows.children();
range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START)); range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
} }
@ -1039,13 +1087,6 @@ LocationUI::session_going_away()
SessionHandlePtr::session_going_away (); SessionHandlePtr::session_going_away ();
} }
void
LocationEditRow::set_clock_sensitivity ()
{
start_clock.set_sensitive (!location->locked());
end_clock.set_sensitive (!location->locked());
length_clock.set_sensitive (!location->locked());
}
/*------------------------*/ /*------------------------*/

View File

@ -42,6 +42,8 @@ namespace ARDOUR {
class Location; class Location;
} }
class ClockGroup;
class LocationEditRow : public Gtk::HBox, public ARDOUR::SessionHandlePtr class LocationEditRow : public Gtk::HBox, public ARDOUR::SessionHandlePtr
{ {
public: public:
@ -55,6 +57,7 @@ class LocationEditRow : public Gtk::HBox, public ARDOUR::SessionHandlePtr
void set_number (int); void set_number (int);
void focus_name(); void focus_name();
void set_clock_group (ClockGroup&);
sigc::signal<void,ARDOUR::Location*> remove_requested; sigc::signal<void,ARDOUR::Location*> remove_requested;
sigc::signal<void> redraw_ranges; sigc::signal<void> redraw_ranges;
@ -102,6 +105,7 @@ class LocationEditRow : public Gtk::HBox, public ARDOUR::SessionHandlePtr
Gtk::Entry composer_entry; Gtk::Entry composer_entry;
Gtk::CheckButton scms_check_button; Gtk::CheckButton scms_check_button;
Gtk::CheckButton preemph_check_button; Gtk::CheckButton preemph_check_button;
ClockGroup* _clock_group;
guint32 i_am_the_modifier; guint32 i_am_the_modifier;
int number; int number;
@ -146,6 +150,7 @@ class LocationUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
~LocationUI (); ~LocationUI ();
void set_session (ARDOUR::Session *); void set_session (ARDOUR::Session *);
void set_clock_mode (AudioClock::Mode);
void add_new_location(); void add_new_location();
void add_new_range(); void add_new_range();
@ -191,6 +196,8 @@ class LocationUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
void location_added (ARDOUR::Location *); void location_added (ARDOUR::Location *);
void locations_changed (ARDOUR::Locations::Change); void locations_changed (ARDOUR::Locations::Change);
void map_locations (ARDOUR::Locations::LocationList&); void map_locations (ARDOUR::Locations::LocationList&);
ClockGroup* _clock_group;
}; };
class LocationUIWindow : public ArdourDialog class LocationUIWindow : public ArdourDialog

View File

@ -30,10 +30,11 @@
#include <gtkmm/listviewtext.h> #include <gtkmm/listviewtext.h>
#include <cmath> #include <cmath>
#include "region_editor.h"
#include "ardour_ui.h" #include "ardour_ui.h"
#include "utils.h" #include "clock_group.h"
#include "gui_thread.h" #include "gui_thread.h"
#include "region_editor.h"
#include "utils.h"
#include "i18n.h" #include "i18n.h"
@ -43,23 +44,32 @@ using namespace std;
using namespace Gtkmm2ext; using namespace Gtkmm2ext;
RegionEditor::RegionEditor (Session* s, boost::shared_ptr<Region> r) RegionEditor::RegionEditor (Session* s, boost::shared_ptr<Region> r)
: ArdourDialog (_("Region")), : ArdourDialog (_("Region"))
_table (9, 2), , _table (9, 2)
_table_row (0), , _table_row (0)
_region (r), , _region (r)
name_label (_("Name:")), , name_label (_("Name:"))
audition_button (_("Play")), , audition_button (_("Play"))
position_clock (X_("regionposition"), true, X_("RegionEditorClock"), true, false), , _clock_group (new ClockGroup)
end_clock (X_("regionend"), true, X_("RegionEditorClock"), true, false), , position_clock (X_("regionposition"), true, X_("RegionEditorClock"), true, false)
length_clock (X_("regionlength"), true, X_("RegionEditorClock"), true, false, true), , end_clock (X_("regionend"), true, X_("RegionEditorClock"), true, false)
sync_offset_relative_clock (X_("regionsyncoffsetrelative"), true, X_("RegionEditorClock"), true, false), , length_clock (X_("regionlength"), true, X_("RegionEditorClock"), true, false, true)
sync_offset_absolute_clock (X_("regionsyncoffsetabsolute"), true, X_("RegionEditorClock"), true, false), , sync_offset_relative_clock (X_("regionsyncoffsetrelative"), true, X_("RegionEditorClock"), true, false)
, sync_offset_absolute_clock (X_("regionsyncoffsetabsolute"), true, X_("RegionEditorClock"), true, false)
/* XXX cannot file start yet */ /* XXX cannot file start yet */
start_clock (X_("regionstart"), true, X_("RegionEditorClock"), false, false), , start_clock (X_("regionstart"), true, X_("RegionEditorClock"), false, false)
_sources (1) , _sources (1)
{ {
set_session (s); set_session (s);
_clock_group->set_clock_mode (AudioClock::Frames);
_clock_group->add (position_clock);
_clock_group->add (end_clock);
_clock_group->add (length_clock);
_clock_group->add (sync_offset_relative_clock);
_clock_group->add (sync_offset_absolute_clock);
_clock_group->add (start_clock);
position_clock.set_session (_session); position_clock.set_session (_session);
end_clock.set_session (_session); end_clock.set_session (_session);
length_clock.set_session (_session); length_clock.set_session (_session);
@ -186,6 +196,11 @@ RegionEditor::RegionEditor (Session* s, boost::shared_ptr<Region> r)
connect_editor_events (); connect_editor_events ();
} }
RegionEditor::~RegionEditor ()
{
delete _clock_group;
}
void void
RegionEditor::region_changed (const PBD::PropertyChange& what_changed) RegionEditor::region_changed (const PBD::PropertyChange& what_changed)
{ {

View File

@ -48,11 +48,13 @@ namespace ARDOUR {
class Session; class Session;
} }
class ClockGroup;
class RegionEditor : public ArdourDialog class RegionEditor : public ArdourDialog
{ {
public: public:
RegionEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Region>); RegionEditor (ARDOUR::Session*, boost::shared_ptr<ARDOUR::Region>);
virtual ~RegionEditor () {} virtual ~RegionEditor ();
protected: protected:
virtual void region_changed (const PBD::PropertyChange&); virtual void region_changed (const PBD::PropertyChange&);
@ -76,6 +78,8 @@ class RegionEditor : public ArdourDialog
Gtk::Label sync_absolute_label; Gtk::Label sync_absolute_label;
Gtk::Label start_label; Gtk::Label start_label;
ClockGroup* _clock_group;
AudioClock position_clock; AudioClock position_clock;
AudioClock end_clock; AudioClock end_clock;
AudioClock length_clock; AudioClock length_clock;

View File

@ -60,6 +60,7 @@ gtk2_ardour_sources = [
'canvas-simplerect.c', 'canvas-simplerect.c',
'canvas-sysex.cc', 'canvas-sysex.cc',
'canvas-waveview.c', 'canvas-waveview.c',
'clock_group.cc',
'configinfo.cc', 'configinfo.cc',
'control_point.cc', 'control_point.cc',
'control_point_dialog.cc', 'control_point_dialog.cc',