audio clip editor: starting to add display material

This commit is contained in:
Paul Davis 2021-12-06 15:13:16 -07:00
parent 54c71c3d61
commit 94517a9de5
3 changed files with 76 additions and 0 deletions

View File

@ -16,10 +16,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ardour/audioregion.h"
#include "waveview/wave_view.h"
#include "audio_clip_editor.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
using namespace ArdourWaveView;
using namespace ArdourCanvas;
AudioClipEditor::AudioClipEditor ()
{
@ -27,4 +35,51 @@ AudioClipEditor::AudioClipEditor ()
AudioClipEditor::~AudioClipEditor ()
{
drop_waves ();
}
void
AudioClipEditor::drop_waves ()
{
for (auto & wave : waves) {
delete wave;
}
waves.clear ();
}
void
AudioClipEditor::set_region (boost::shared_ptr<AudioRegion> r)
{
drop_waves ();
uint32_t n_chans = r->n_channels ();
for (uint32_t n = 0; n < n_chans; ++n) {
WaveView* wv = new WaveView (this, r);
wv->set_channel (n);
waves.push_back (wv);
}
int h = get_allocation().get_height ();
if (h) {
set_wave_heights (h);
}
}
void
AudioClipEditor::size_allocate (Gtk::Allocation const & alloc)
{
GtkCanvas::size_allocate (alloc);
set_wave_heights (alloc.get_height());
}
void
AudioClipEditor::set_wave_heights (int h)
{
for (auto & wave : waves) {
wave->set_height (h/waves.size());
}
}

View File

@ -19,13 +19,32 @@
#ifndef __gtk2_ardour_audio_clip_editor_h__
#define __gtk2_ardour_audio_clip_editor_h__
#include <vector>
#include "canvas/canvas.h"
namespace ARDOUR {
class AudioRegion;
}
namespace ArdourWaveView {
class WaveView;
}
class AudioClipEditor : public ArdourCanvas::GtkCanvas
{
public:
AudioClipEditor ();
~AudioClipEditor ();
void set_region (boost::shared_ptr<ARDOUR::AudioRegion>);
private:
std::vector<ArdourWaveView::WaveView *> waves;
void drop_waves ();
void size_allocate (Gtk::Allocation const &);
void set_wave_heights (int);
};

View File

@ -38,6 +38,8 @@
#include "ui_config.h"
#include "utils.h"
#include "audio_clip_editor.h"
#include "pbd/i18n.h"
#define PX_SCALE(px) std::max ((float)px, rintf ((float)px* UIConfiguration::instance ().get_ui_scale ()))