mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
temporal: new object to try to make domain swaps undo-able
This commit is contained in:
parent
52c8a23aff
commit
d87b10037b
6 changed files with 117 additions and 7 deletions
|
|
@ -26,8 +26,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "temporal/beats.h"
|
#include "temporal/beats.h"
|
||||||
|
#include "temporal/domainswap.h"
|
||||||
#include "temporal/range.h"
|
#include "temporal/range.h"
|
||||||
#include "temporal/types.h"
|
|
||||||
|
|
||||||
#include "pbd/string_convert.h"
|
#include "pbd/string_convert.h"
|
||||||
|
|
||||||
|
|
|
||||||
54
libs/temporal/domainswap.cc
Normal file
54
libs/temporal/domainswap.cc
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Paul Davis <paul@linuxaudiosystems.com>
|
||||||
|
*
|
||||||
|
* 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.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "temporal/domainswap.h"
|
||||||
|
|
||||||
|
using namespace Temporal;
|
||||||
|
|
||||||
|
void
|
||||||
|
TimeDomainCommand::add (TimeDomainSwapper& tds)
|
||||||
|
{
|
||||||
|
tds.DropReferences.connect_same_thread (tds_connections, boost::bind (&TimeDomainCommand::going_away, this, &tds));
|
||||||
|
swappers.insert (&tds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimeDomainCommand::going_away (TimeDomainSwapper* tds)
|
||||||
|
{
|
||||||
|
Swappers::iterator i = swappers.find (tds);
|
||||||
|
|
||||||
|
if (i != swappers.end()) {
|
||||||
|
swappers.erase (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimeDomainCommand::operator() ()
|
||||||
|
{
|
||||||
|
for (auto & swapper : swappers) {
|
||||||
|
swapper->swap_domain (from, to);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TimeDomainCommand::undo ()
|
||||||
|
{
|
||||||
|
for (auto & swapper : swappers) {
|
||||||
|
swapper->swap_domain (to, from);
|
||||||
|
}
|
||||||
|
}
|
||||||
60
libs/temporal/temporal/domainswap.h
Normal file
60
libs/temporal/temporal/domainswap.h
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 Paul Davis <paul@linuxaudiosystems.com>
|
||||||
|
*
|
||||||
|
* 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.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __temporal_domain_swap_h__
|
||||||
|
#define __temporal_domain_swap_h__
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "pbd/command.h"
|
||||||
|
#include "pbd/destructible.h"
|
||||||
|
#include "pbd/signals.h"
|
||||||
|
|
||||||
|
#include "temporal/types.h"
|
||||||
|
|
||||||
|
namespace Temporal {
|
||||||
|
|
||||||
|
struct LIBTEMPORAL_API TimeDomainSwapper : public virtual PBD::Destructible {
|
||||||
|
virtual ~TimeDomainSwapper() {}
|
||||||
|
virtual void swap_domain (Temporal::TimeDomain from, Temporal::TimeDomain to) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct LIBTEMPORAL_API TimeDomainCommand : public Command {
|
||||||
|
public:
|
||||||
|
TimeDomainCommand (TimeDomain f, TimeDomain t) : from (f), to (t) {}
|
||||||
|
void add (TimeDomainSwapper&);
|
||||||
|
|
||||||
|
void operator() ();
|
||||||
|
void undo ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TimeDomain from;
|
||||||
|
TimeDomain to;
|
||||||
|
|
||||||
|
typedef std::set<TimeDomainSwapper*> Swappers;
|
||||||
|
Swappers swappers;
|
||||||
|
PBD::ScopedConnectionList tds_connections;
|
||||||
|
|
||||||
|
void going_away (TimeDomainSwapper*);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __tmeporal_domain_swap_h__ */
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
#include "temporal/beats.h"
|
#include "temporal/beats.h"
|
||||||
#include "temporal/bbt_argument.h"
|
#include "temporal/bbt_argument.h"
|
||||||
#include "temporal/bbt_time.h"
|
#include "temporal/bbt_time.h"
|
||||||
|
#include "temporal/domainswap.h"
|
||||||
#include "temporal/superclock.h"
|
#include "temporal/superclock.h"
|
||||||
#include "temporal/timeline.h"
|
#include "temporal/timeline.h"
|
||||||
#include "temporal/types.h"
|
#include "temporal/types.h"
|
||||||
|
|
|
||||||
|
|
@ -124,14 +124,8 @@ enum RoundMode {
|
||||||
|
|
||||||
extern void setup_enum_writer ();
|
extern void setup_enum_writer ();
|
||||||
|
|
||||||
struct LIBTEMPORAL_API TimeDomainSwapper {
|
|
||||||
virtual ~TimeDomainSwapper() {}
|
|
||||||
virtual void swap_domain (Temporal::TimeDomain from, Temporal::TimeDomain to) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream& o, Temporal::ratio_t const & r);
|
std::ostream& operator<< (std::ostream& o, Temporal::ratio_t const & r);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __libpbd_position_types_h__ */
|
#endif /* __libpbd_position_types_h__ */
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ temporal_sources = [
|
||||||
'debug.cc',
|
'debug.cc',
|
||||||
'bbt_time.cc',
|
'bbt_time.cc',
|
||||||
'beats.cc',
|
'beats.cc',
|
||||||
|
'domainswap.cc',
|
||||||
'enums.cc',
|
'enums.cc',
|
||||||
'range.cc',
|
'range.cc',
|
||||||
'superclock.cc',
|
'superclock.cc',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue