"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gui/editors/SongEditor.cpp" between
lmms_1.2.0.tar.xz and lmms_1.2.1.tar.xz

About: LMMS (Linux MultiMedia Studio) is a sound generation system (creation of melodies and beats, synthesis and mixing of sounds, arranging of samples; full MIDI support).

SongEditor.cpp  (lmms_1.2.0.tar.xz):SongEditor.cpp  (lmms_1.2.1.tar.xz)
skipping to change at line 54 skipping to change at line 54
#include "MainWindow.h" #include "MainWindow.h"
#include "MeterDialog.h" #include "MeterDialog.h"
#include "Mixer.h" #include "Mixer.h"
#include "TextFloat.h" #include "TextFloat.h"
#include "TimeLineWidget.h" #include "TimeLineWidget.h"
#include "ToolTip.h" #include "ToolTip.h"
#include "VisualizationWidget.h" #include "VisualizationWidget.h"
#include "TimeDisplayWidget.h" #include "TimeDisplayWidget.h"
#include "AudioDevice.h" #include "AudioDevice.h"
#include "PianoRoll.h" #include "PianoRoll.h"
#include "Track.h"
positionLine::positionLine( QWidget * parent ) : positionLine::positionLine( QWidget * parent ) :
QWidget( parent ) QWidget( parent )
{ {
setFixedWidth( 1 ); setFixedWidth( 1 );
setAttribute( Qt::WA_NoSystemBackground, true ); setAttribute( Qt::WA_NoSystemBackground, true );
} }
void positionLine::paintEvent( QPaintEvent * pe ) void positionLine::paintEvent( QPaintEvent * pe )
{ {
skipping to change at line 77 skipping to change at line 78
const QVector<double> SongEditor::m_zoomLevels = const QVector<double> SongEditor::m_zoomLevels =
{ 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f, 16.0f }; { 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f, 16.0f };
SongEditor::SongEditor( Song * song ) : SongEditor::SongEditor( Song * song ) :
TrackContainerView( song ), TrackContainerView( song ),
m_song( song ), m_song( song ),
m_zoomingModel(new ComboBoxModel()), m_zoomingModel(new ComboBoxModel()),
m_scrollBack( false ), m_scrollBack( false ),
m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toIn t() ), m_smoothScroll( ConfigManager::inst()->value( "ui", "smoothscroll" ).toIn t() ),
m_mode(DrawMode) m_mode(DrawMode),
m_origin(),
m_scrollPos(),
m_mousePos(),
m_rubberBandStartTrackview(0),
m_rubberbandStartMidipos(0),
m_currentZoomingValue(m_zoomingModel->value()),
m_trackHeadWidth(ConfigManager::inst()->value("ui", "compacttrackbuttons"
).toInt()==1
? DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT
+ TRACK_OP_WIDTH_COMPACT
: DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_
OP_WIDTH),
m_selectRegion(false)
{ {
m_zoomingModel->setParent(this); m_zoomingModel->setParent(this);
// create time-line // create time-line
int widgetTotal = ConfigManager::inst()->value( "ui", m_timeLine = new TimeLineWidget( m_trackHeadWidth, 32,
"compacttrackbuttons" ).t
oInt()==1 ?
DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT + TRACK_OP_WIDTH_COMPACT :
DEFAULT_SETTINGS_WIDGET_WIDTH + TRACK_OP_WIDTH;
m_timeLine = new TimeLineWidget( widgetTotal, 32,
pixelsPerTact(), pixelsPerTact(),
m_song->m_playPos[Song::Mode_PlaySong], m_song->m_playPos[Song::Mode_PlaySong],
m_currentPosition, this ); m_currentPosition, this );
connect( this, SIGNAL( positionChanged( const MidiTime & ) ), connect( this, SIGNAL( positionChanged( const MidiTime & ) ),
m_song->m_playPos[Song::Mode_PlaySong].m_timeLine , m_song->m_playPos[Song::Mode_PlaySong].m_timeLine ,
SLOT( updatePosition( const MidiTime & ) ) ); SLOT( updatePosition( const MidiTime & ) ) );
connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ), connect( m_timeLine, SIGNAL( positionChanged( const MidiTime & ) ),
this, SLOT( updatePosition( const MidiTime & ) ) ); this, SLOT( updatePosition( const MidiTime & ) ) );
connect( m_timeLine, SIGNAL( regionSelectedFromPixels( int, int ) ), connect( m_timeLine, SIGNAL( regionSelectedFromPixels( int, int ) ),
this, SLOT( selectRegionFromPixels( int, int ) ) ); this, SLOT( selectRegionFromPixels( int, int ) ) );
skipping to change at line 232 skipping to change at line 239
m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); m_leftRightScroll = new QScrollBar( Qt::Horizontal, this );
m_leftRightScroll->setMinimum( 0 ); m_leftRightScroll->setMinimum( 0 );
m_leftRightScroll->setMaximum( 0 ); m_leftRightScroll->setMaximum( 0 );
m_leftRightScroll->setSingleStep( 1 ); m_leftRightScroll->setSingleStep( 1 );
m_leftRightScroll->setPageStep( 20 ); m_leftRightScroll->setPageStep( 20 );
static_cast<QVBoxLayout *>( layout() )->addWidget( m_leftRightScroll ); static_cast<QVBoxLayout *>( layout() )->addWidget( m_leftRightScroll );
connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ),
this, SLOT( scrolled( int ) ) ); this, SLOT( scrolled( int ) ) );
connect( m_song, SIGNAL( lengthChanged( int ) ), connect( m_song, SIGNAL( lengthChanged( int ) ),
this, SLOT( updateScrollBar( int ) ) ); this, SLOT( updateScrollBar( int ) ) );
connect(m_leftRightScroll, SIGNAL(valueChanged(int)),this, SLOT(updateRub
berband()));
connect(contentWidget()->verticalScrollBar(), SIGNAL(valueChanged(int)),t
his, SLOT(updateRubberband()));
connect(m_timeLine, SIGNAL(selectionFinished()), this, SLOT(stopSelectReg
ion()));
// Set up zooming model // Set up zooming model
for( float const & zoomLevel : m_zoomLevels ) for( float const & zoomLevel : m_zoomLevels )
{ {
m_zoomingModel->addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) ); m_zoomingModel->addItem( QString( "%1\%" ).arg( zoomLevel * 100 ) );
} }
m_zoomingModel->setInitValue( m_zoomingModel->setInitValue(
m_zoomingModel->findText( "100%" ) ); m_zoomingModel->findText( "100%" ) );
connect( m_zoomingModel, SIGNAL( dataChanged() ), connect( m_zoomingModel, SIGNAL( dataChanged() ),
this, SLOT( zoomingChanged() ) ); this, SLOT( zoomingChanged() ) );
skipping to change at line 274 skipping to change at line 284
hq ? Mixer::qualitySettings::Mode_HighQuality : hq ? Mixer::qualitySettings::Mode_HighQuality :
Mixer::qualitySettings::Mode_Draft ) ); Mixer::qualitySettings::Mode_Draft ) );
} }
void SongEditor::scrolled( int new_pos ) void SongEditor::scrolled( int new_pos )
{ {
update(); update();
emit positionChanged( m_currentPosition = MidiTime( new_pos, 0 ) ); emit positionChanged( m_currentPosition = MidiTime( new_pos, 0 ) );
} }
void SongEditor::selectRegionFromPixels(int xStart, int xEnd)
{
if (!m_selectRegion)
{
m_selectRegion = true;
//deselect all tcos
for (auto &it : findChildren<selectableObject *>()) { it->setSele
cted(false); }
rubberBand()->setEnabled(true);
rubberBand()->show();
//we save the position of scrollbars, mouse position and zooming
level
m_origin = QPoint(xStart, 0);
m_scrollPos = QPoint(m_leftRightScroll->value(), contentWidget()-
>verticalScrollBar()->value());
m_currentZoomingValue = zoomingModel()->value();
//calculate the song position where the mouse was clicked
m_rubberbandStartMidipos = MidiTime((xStart - m_trackHeadWidth)
/ pixelsPerTact() * MidiTime::ticksPerTact())
+ m_currentPosition;
m_rubberBandStartTrackview = 0;
}
//the current mouse position within the borders of song editor
m_mousePos = QPoint(qMax(m_trackHeadWidth, qMin(xEnd, width()))
, std::numeric_limits<int>::max()
);
updateRubberband();
}
void SongEditor::stopSelectRegion()
{
m_selectRegion = false;
}
void SongEditor::updateRubberband()
{
if (rubberBandActive())
{
int originX = m_origin.x();
//take care of the zooming
if (m_currentZoomingValue != m_zoomingModel->value())
{
originX = m_trackHeadWidth + (originX - m_trackHeadWidth)
* m_zoomLevels[m_zoomingModel->value()] /
m_zoomLevels[m_currentZoomingValue];
}
//take care of the scrollbar position
int hs = (m_leftRightScroll->value() - m_scrollPos.x()) * pixelsP
erTact();
int vs = contentWidget()->verticalScrollBar()->value() - m_scroll
Pos.y();
//the adjusted origin point
QPoint origin = QPoint(qMax(originX - hs, m_trackHeadWidth), m_or
igin.y() - vs);
//paint the rubber band rect
rubberBand()->setGeometry(QRect(origin,
c
ontentWidget()->mapFromParent(QPoint(m_mousePos.x(), m_mousePos.y()))
)
.normalized());
//the index of the TrackView the mouse is hover
int rubberBandTrackview = trackIndexFromSelectionPoint(m_mousePos
.y());
//the miditime the mouse is hover
MidiTime rubberbandMidipos = MidiTime((qMin(m_mousePos.x(), width
()) - m_trackHeadWidth)
/ pixelsPerTact() * MidiTime::ticksPerTact())
+ m_currentPosition;
//are tcos in the rect of selection?
for (auto &it : findChildren<selectableObject *>())
{
TrackContentObjectView * tco = dynamic_cast<TrackContentO
bjectView*>(it);
if (tco)
{
auto indexOfTrackView = trackViews().indexOf(tco-
>getTrackView());
bool isBeetweenRubberbandViews = indexOfTrackView
>= qMin(m_rubberBandStartTrackview, rubberBandTrackview)
&& indexOfTrackView <= qMax(m_rubberBandStartTrackview, rubberBandTrack
view);
bool isBeetweenRubberbandMidiPos = tco->getTrackC
ontentObject()->endPosition() >= qMin(m_rubberbandStartMidipos, rubberbandMidipo
s)
&& tco->getTrackContentObject()->startPosition() <= qMax(m_rubberbandSt
artMidipos, rubberbandMidipos);
it->setSelected(isBeetweenRubberbandViews && isBe
etweenRubberbandMidiPos);
}
}
}
}
void SongEditor::setEditMode( EditMode mode ) void SongEditor::setEditMode( EditMode mode )
{ {
m_mode = mode; m_mode = mode;
} }
void SongEditor::setEditModeDraw() void SongEditor::setEditModeDraw()
{ {
setEditMode(DrawMode); setEditMode(DrawMode);
} }
skipping to change at line 367 skipping to change at line 461
} }
else else
{ {
we->ignore(); we->ignore();
return; return;
} }
we->accept(); we->accept();
} }
void SongEditor::closeEvent( QCloseEvent * ce ) void SongEditor::closeEvent( QCloseEvent * ce )
{ {
if( parentWidget() ) if( parentWidget() )
{ {
parentWidget()->hide(); parentWidget()->hide();
} }
else else
{ {
hide(); hide();
} }
ce->ignore(); ce->ignore();
} }
void SongEditor::mousePressEvent(QMouseEvent *me)
{
if (allowRubberband())
{
//we save the position of scrollbars, mouse position and zooming
level
m_scrollPos = QPoint(m_leftRightScroll->value(), contentWidget()-
>verticalScrollBar()->value());
m_origin = contentWidget()->mapFromParent(QPoint(me->pos().x(), m
e->pos().y()));
m_currentZoomingValue = zoomingModel()->value();
//paint the rubberband
rubberBand()->setEnabled(true);
rubberBand()->setGeometry(QRect(m_origin, QSize()));
rubberBand()->show();
//the trackView(index) and the miditime where the mouse was click
ed
m_rubberBandStartTrackview = trackIndexFromSelectionPoint(me->y()
);
m_rubberbandStartMidipos = MidiTime((me->x() - m_trackHeadWidth)
/ pixelsPerTact() * MidiTime::ticksPerTact())
+ m_currentPosition;
}
QWidget::mousePressEvent(me);
}
void SongEditor::mouseMoveEvent(QMouseEvent *me)
{
m_mousePos = me->pos();
updateRubberband();
QWidget::mouseMoveEvent(me);
}
void SongEditor::mouseReleaseEvent(QMouseEvent *me)
{
rubberBand()->hide();
rubberBand()->setEnabled(false);
QWidget::mouseReleaseEvent(me);
}
void SongEditor::setMasterVolume( int new_val ) void SongEditor::setMasterVolume( int new_val )
{ {
updateMasterVolumeFloat( new_val ); updateMasterVolumeFloat( new_val );
if( !m_mvsStatus->isVisible() && !m_song->m_loadingProject if( !m_mvsStatus->isVisible() && !m_song->m_loadingProject
&& m_masterVolumeSlider->showStatus() ) && m_masterVolumeSlider->showStatus() )
{ {
m_mvsStatus->moveGlobal( m_masterVolumeSlider, m_mvsStatus->moveGlobal( m_masterVolumeSlider,
QPoint( m_masterVolumeSlider->width() + 2, -2 ) ); QPoint( m_masterVolumeSlider->width() + 2, -2 ) );
skipping to change at line 536 skipping to change at line 667
m_positionLine->setFixedHeight( height() ); m_positionLine->setFixedHeight( height() );
} }
void SongEditor::zoomingChanged() void SongEditor::zoomingChanged()
{ {
setPixelsPerTact( m_zoomLevels[m_zoomingModel->value()] * DEFAULT_PIXELS_ PER_TACT ); setPixelsPerTact( m_zoomLevels[m_zoomingModel->value()] * DEFAULT_PIXELS_ PER_TACT );
m_song->m_playPos[Song::Mode_PlaySong].m_timeLine-> m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->
setPixelsPerTact( pixelsPerTact() ); setPixelsPerTact( pixelsPerTact() );
realignTracks(); realignTracks();
updateRubberband();
} }
bool SongEditor::allowRubberband() const bool SongEditor::allowRubberband() const
{ {
return m_mode == SelectMode; return m_mode == SelectMode;
} }
int SongEditor::trackIndexFromSelectionPoint(int yPos)
{
const TrackView * tv = trackViewAt(yPos - m_timeLine->height());
return tv ? indexOfTrackView(tv)
: yPos < m_timeLine->height() ? 0
: trackViews().count();
}
int SongEditor::indexOfTrackView(const TrackView *tv)
{
return static_cast<int>(std::distance(trackViews().begin(),
std::find(trackViews().begin(), trackViews().end(), tv)));
}
ComboBoxModel *SongEditor::zoomingModel() const ComboBoxModel *SongEditor::zoomingModel() const
{ {
return m_zoomingModel; return m_zoomingModel;
} }
SongEditorWindow::SongEditorWindow(Song* song) : SongEditorWindow::SongEditorWindow(Song* song) :
Editor(Engine::mixer()->audioDev()->supportsCapture()), Editor(Engine::mixer()->audioDev()->supportsCapture()),
m_editor(new SongEditor(song)) m_editor(new SongEditor(song))
{ {
setWindowTitle( tr( "Song-Editor" ) ); setWindowTitle( tr( "Song-Editor" ) );
 End of changes. 9 change blocks. 
9 lines changed or deleted 195 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)