Files
lmms/include/SampleClip.h
regulus79 25e8b640d8 Update Sample Length when Loading New Sample via Double-Click (#7898)
This PR makes it so that when you double-click on a sample clip and select a new sample, it will automatically update the length of the clip, as long as the clip has auto-resize enabled.
2025-06-02 00:42:02 -04:00

114 lines
2.5 KiB
C++

/*
* SampleClip.h
*
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* 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 (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef LMMS_SAMPLE_CLIP_H
#define LMMS_SAMPLE_CLIP_H
#include <memory>
#include "Clip.h"
#include "Sample.h"
namespace lmms
{
class SampleBuffer;
namespace gui
{
class SampleClipView;
} // namespace gui
class SampleClip : public Clip
{
Q_OBJECT
mapPropertyFromModel(bool,isRecord,setRecord,m_recordModel);
public:
SampleClip(Track* track, Sample sample, bool isPlaying);
SampleClip(Track* track);
~SampleClip() override;
SampleClip& operator=( const SampleClip& that ) = delete;
void changeLength( const TimePos & _length ) override;
const QString& sampleFile() const;
bool hasSampleFileLoaded(const QString & filename) const;
void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
void loadSettings( const QDomElement & _this ) override;
inline QString nodeName() const override
{
return "sampleclip";
}
Sample& sample()
{
return m_sample;
}
TimePos sampleLength() const;
void setSampleStartFrame( f_cnt_t startFrame );
void setSamplePlayLength( f_cnt_t length );
gui::ClipView * createView( gui::TrackView * _tv ) override;
bool isPlaying() const;
void setIsPlaying(bool isPlaying);
void setSampleBuffer(std::shared_ptr<const SampleBuffer> sb);
SampleClip* clone() override
{
return new SampleClip(*this);
}
public slots:
void setSampleFile(const QString& sf);
void updateLength();
void toggleRecord();
void playbackPositionChanged();
void updateTrackClips();
protected:
SampleClip( const SampleClip& orig );
private:
Sample m_sample;
BoolModel m_recordModel;
bool m_isPlaying;
friend class gui::SampleClipView;
signals:
void sampleChanged();
void wasReversed();
} ;
} // namespace lmms
#endif // LMMS_SAMPLE_CLIP_H