Split BB Track classes into separate files (#5985)
This commit is contained in:
55
include/BBTCO.h
Normal file
55
include/BBTCO.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* BBTCO.h
|
||||
*
|
||||
* Copyright (c) 2004-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 BB_TCO_H
|
||||
#define BB_TCO_H
|
||||
|
||||
#include "TrackContentObjectView.h"
|
||||
|
||||
|
||||
class BBTCO : public TrackContentObject
|
||||
{
|
||||
public:
|
||||
BBTCO( Track * _track );
|
||||
virtual ~BBTCO() = default;
|
||||
|
||||
void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
|
||||
void loadSettings( const QDomElement & _this ) override;
|
||||
inline QString nodeName() const override
|
||||
{
|
||||
return( "bbtco" );
|
||||
}
|
||||
|
||||
int bbTrackIndex();
|
||||
|
||||
TrackContentObjectView * createView( TrackView * _tv ) override;
|
||||
|
||||
private:
|
||||
friend class BBTCOView;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
66
include/BBTCOView.h
Normal file
66
include/BBTCOView.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* BBTCOView.h
|
||||
*
|
||||
* Copyright (c) 2004-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 BB_TCO_VIEW_H
|
||||
#define BB_TCO_VIEW_H
|
||||
|
||||
#include "BBTCO.h"
|
||||
|
||||
#include <QStaticText>
|
||||
|
||||
|
||||
class BBTCOView : public TrackContentObjectView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BBTCOView( TrackContentObject * _tco, TrackView * _tv );
|
||||
virtual ~BBTCOView() = default;
|
||||
|
||||
|
||||
public slots:
|
||||
void update() override;
|
||||
|
||||
protected slots:
|
||||
void openInBBEditor();
|
||||
void resetName();
|
||||
void changeName();
|
||||
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent * pe ) override;
|
||||
void mouseDoubleClickEvent( QMouseEvent * _me ) override;
|
||||
void constructContextMenu( QMenu * ) override;
|
||||
|
||||
|
||||
private:
|
||||
BBTCO * m_bbTCO;
|
||||
QPixmap m_paintPixmap;
|
||||
|
||||
QStaticText m_staticTextName;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -27,77 +27,16 @@
|
||||
#ifndef BB_TRACK_H
|
||||
#define BB_TRACK_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMap>
|
||||
#include <QStaticText>
|
||||
|
||||
#include "TrackContentObjectView.h"
|
||||
#include <QtCore/QMap>
|
||||
|
||||
#include "BBTCOView.h"
|
||||
#include "Track.h"
|
||||
#include "TrackView.h"
|
||||
|
||||
class TrackLabelButton;
|
||||
class TrackContainer;
|
||||
|
||||
|
||||
class BBTCO : public TrackContentObject
|
||||
{
|
||||
public:
|
||||
BBTCO( Track * _track );
|
||||
virtual ~BBTCO() = default;
|
||||
|
||||
void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
|
||||
void loadSettings( const QDomElement & _this ) override;
|
||||
inline QString nodeName() const override
|
||||
{
|
||||
return( "bbtco" );
|
||||
}
|
||||
|
||||
int bbTrackIndex();
|
||||
|
||||
TrackContentObjectView * createView( TrackView * _tv ) override;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
friend class BBTCOView;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
class BBTCOView : public TrackContentObjectView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BBTCOView( TrackContentObject * _tco, TrackView * _tv );
|
||||
virtual ~BBTCOView() = default;
|
||||
|
||||
|
||||
public slots:
|
||||
void update() override;
|
||||
|
||||
protected slots:
|
||||
void openInBBEditor();
|
||||
void resetName();
|
||||
void changeName();
|
||||
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent * pe ) override;
|
||||
void mouseDoubleClickEvent( QMouseEvent * _me ) override;
|
||||
void constructContextMenu( QMenu * ) override;
|
||||
|
||||
|
||||
private:
|
||||
BBTCO * m_bbTCO;
|
||||
QPixmap m_paintPixmap;
|
||||
|
||||
QStaticText m_staticTextName;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
class LMMS_EXPORT BBTrack : public Track
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -149,34 +88,6 @@ private:
|
||||
static infoMap s_infoMap;
|
||||
|
||||
friend class BBTrackView;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
class BBTrackView : public TrackView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BBTrackView( BBTrack* bbt, TrackContainerView* tcv );
|
||||
virtual ~BBTrackView();
|
||||
|
||||
bool close() override;
|
||||
|
||||
const BBTrack * getBBTrack() const
|
||||
{
|
||||
return( m_bbTrack );
|
||||
}
|
||||
|
||||
|
||||
public slots:
|
||||
void clickedTrackLabel();
|
||||
|
||||
|
||||
private:
|
||||
BBTrack * m_bbTrack;
|
||||
TrackLabelButton * m_trackLabel;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
61
include/BBTrackView.h
Normal file
61
include/BBTrackView.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* BBTrackView.h
|
||||
*
|
||||
* Copyright (c) 2004-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 BB_TRACK_VIEW_H
|
||||
#define BB_TRACK_VIEW_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
#include "BBTrack.h"
|
||||
#include "TrackView.h"
|
||||
|
||||
|
||||
class BBTrackView : public TrackView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BBTrackView( BBTrack* bbt, TrackContainerView* tcv );
|
||||
virtual ~BBTrackView();
|
||||
|
||||
bool close() override;
|
||||
|
||||
const BBTrack * getBBTrack() const
|
||||
{
|
||||
return( m_bbTrack );
|
||||
}
|
||||
|
||||
|
||||
public slots:
|
||||
void clickedTrackLabel();
|
||||
|
||||
|
||||
private:
|
||||
BBTrack * m_bbTrack;
|
||||
TrackLabelButton * m_trackLabel;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
111
src/core/BBTCO.cpp
Normal file
111
src/core/BBTCO.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* BBTCO.cpp - implementation of class bbTCO
|
||||
*
|
||||
* Copyright (c) 2004-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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "BBTCO.h"
|
||||
|
||||
#include <QDomElement>
|
||||
|
||||
#include "BBTrack.h"
|
||||
#include "BBTrackContainer.h"
|
||||
#include "Engine.h"
|
||||
|
||||
|
||||
BBTCO::BBTCO( Track * _track ) :
|
||||
TrackContentObject( _track )
|
||||
{
|
||||
bar_t t = Engine::getBBTrackContainer()->lengthOfBB( bbTrackIndex() );
|
||||
if( t > 0 )
|
||||
{
|
||||
saveJournallingState( false );
|
||||
changeLength( TimePos( t, 0 ) );
|
||||
restoreJournallingState();
|
||||
}
|
||||
setAutoResize( false );
|
||||
}
|
||||
|
||||
void BBTCO::saveSettings( QDomDocument & doc, QDomElement & element )
|
||||
{
|
||||
element.setAttribute( "name", name() );
|
||||
if( element.parentNode().nodeName() == "clipboard" )
|
||||
{
|
||||
element.setAttribute( "pos", -1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
element.setAttribute( "pos", startPosition() );
|
||||
}
|
||||
element.setAttribute( "len", length() );
|
||||
element.setAttribute( "muted", isMuted() );
|
||||
if( usesCustomClipColor() )
|
||||
{
|
||||
element.setAttribute( "color", color().name() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCO::loadSettings( const QDomElement & element )
|
||||
{
|
||||
setName( element.attribute( "name" ) );
|
||||
if( element.attribute( "pos" ).toInt() >= 0 )
|
||||
{
|
||||
movePosition( element.attribute( "pos" ).toInt() );
|
||||
}
|
||||
changeLength( element.attribute( "len" ).toInt() );
|
||||
if( element.attribute( "muted" ).toInt() != isMuted() )
|
||||
{
|
||||
toggleMute();
|
||||
}
|
||||
|
||||
// for colors saved in 1.3-onwards
|
||||
if( element.hasAttribute( "color" ) && !element.hasAttribute( "usestyle" ) )
|
||||
{
|
||||
useCustomClipColor( true );
|
||||
setColor( element.attribute( "color" ) );
|
||||
}
|
||||
|
||||
// for colors saved before 1.3
|
||||
else
|
||||
{
|
||||
if( element.hasAttribute( "color" ) )
|
||||
{ setColor( QColor( element.attribute( "color" ).toUInt() ) ); }
|
||||
|
||||
// usestyle attribute is no longer used
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int BBTCO::bbTrackIndex()
|
||||
{
|
||||
return dynamic_cast<BBTrack *>( getTrack() )->index();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TrackContentObjectView * BBTCO::createView( TrackView * _tv )
|
||||
{
|
||||
return new BBTCOView( this, _tv );
|
||||
}
|
||||
@@ -6,6 +6,7 @@ set(LMMS_SRCS
|
||||
core/AutomationNode.cpp
|
||||
core/BandLimitedWave.cpp
|
||||
core/base64.cpp
|
||||
core/BBTCO.cpp
|
||||
core/BBTrackContainer.cpp
|
||||
core/BufferManager.cpp
|
||||
core/Clipboard.cpp
|
||||
|
||||
191
src/gui/BBTCOView.cpp
Normal file
191
src/gui/BBTCOView.cpp
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* BBTCOView.cpp
|
||||
*
|
||||
* Copyright (c) 2004-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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "BBTCOView.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
|
||||
#include "BBEditor.h"
|
||||
#include "BBTrackContainer.h"
|
||||
#include "gui_templates.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "MainWindow.h"
|
||||
#include "RenameDialog.h"
|
||||
#include "Song.h"
|
||||
#include "ToolTip.h"
|
||||
|
||||
BBTCOView::BBTCOView( TrackContentObject * _tco, TrackView * _tv ) :
|
||||
TrackContentObjectView( _tco, _tv ),
|
||||
m_bbTCO( dynamic_cast<BBTCO *>( _tco ) ),
|
||||
m_paintPixmap()
|
||||
{
|
||||
connect( _tco->getTrack(), SIGNAL( dataChanged() ),
|
||||
this, SLOT( update() ) );
|
||||
|
||||
setStyle( QApplication::style() );
|
||||
}
|
||||
|
||||
void BBTCOView::constructContextMenu( QMenu * _cm )
|
||||
{
|
||||
QAction * a = new QAction( embed::getIconPixmap( "bb_track" ),
|
||||
tr( "Open in Beat+Bassline-Editor" ),
|
||||
_cm );
|
||||
_cm->insertAction( _cm->actions()[0], a );
|
||||
connect( a, SIGNAL( triggered( bool ) ),
|
||||
this, SLOT( openInBBEditor() ) );
|
||||
_cm->insertSeparator( _cm->actions()[1] );
|
||||
_cm->addSeparator();
|
||||
_cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ),
|
||||
this, SLOT( resetName() ) );
|
||||
_cm->addAction( embed::getIconPixmap( "edit_rename" ),
|
||||
tr( "Change name" ),
|
||||
this, SLOT( changeName() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::mouseDoubleClickEvent( QMouseEvent * )
|
||||
{
|
||||
openInBBEditor();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::paintEvent( QPaintEvent * )
|
||||
{
|
||||
QPainter painter( this );
|
||||
|
||||
if( !needsUpdate() )
|
||||
{
|
||||
painter.drawPixmap( 0, 0, m_paintPixmap );
|
||||
return;
|
||||
}
|
||||
|
||||
setNeedsUpdate( false );
|
||||
|
||||
if (m_paintPixmap.isNull() || m_paintPixmap.size() != size())
|
||||
{
|
||||
m_paintPixmap = QPixmap(size());
|
||||
}
|
||||
|
||||
QPainter p( &m_paintPixmap );
|
||||
|
||||
QLinearGradient lingrad( 0, 0, 0, height() );
|
||||
QColor c = getColorForDisplay( painter.background().color() );
|
||||
|
||||
lingrad.setColorAt( 0, c.lighter( 130 ) );
|
||||
lingrad.setColorAt( 1, c.lighter( 70 ) );
|
||||
|
||||
// paint a black rectangle under the pattern to prevent glitches with transparent backgrounds
|
||||
p.fillRect( rect(), QColor( 0, 0, 0 ) );
|
||||
|
||||
if( gradient() )
|
||||
{
|
||||
p.fillRect( rect(), lingrad );
|
||||
}
|
||||
else
|
||||
{
|
||||
p.fillRect( rect(), c );
|
||||
}
|
||||
|
||||
// bar lines
|
||||
const int lineSize = 3;
|
||||
p.setPen( c.darker( 200 ) );
|
||||
|
||||
bar_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
|
||||
if( m_bbTCO->length() > TimePos::ticksPerBar() && t > 0 )
|
||||
{
|
||||
for( int x = static_cast<int>( t * pixelsPerBar() );
|
||||
x < width() - 2;
|
||||
x += static_cast<int>( t * pixelsPerBar() ) )
|
||||
{
|
||||
p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize );
|
||||
p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ),
|
||||
x, rect().bottom() - TCO_BORDER_WIDTH );
|
||||
}
|
||||
}
|
||||
|
||||
// pattern name
|
||||
paintTextLabel(m_bbTCO->name(), p);
|
||||
|
||||
// inner border
|
||||
p.setPen( c.lighter( 130 ) );
|
||||
p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH,
|
||||
rect().bottom() - TCO_BORDER_WIDTH );
|
||||
|
||||
// outer border
|
||||
p.setPen( c.darker( 300 ) );
|
||||
p.drawRect( 0, 0, rect().right(), rect().bottom() );
|
||||
|
||||
// draw the 'muted' pixmap only if the pattern was manualy muted
|
||||
if( m_bbTCO->isMuted() )
|
||||
{
|
||||
const int spacing = TCO_BORDER_WIDTH;
|
||||
const int size = 14;
|
||||
p.drawPixmap( spacing, height() - ( size + spacing ),
|
||||
embed::getIconPixmap( "muted", size, size ) );
|
||||
}
|
||||
|
||||
p.end();
|
||||
|
||||
painter.drawPixmap( 0, 0, m_paintPixmap );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::openInBBEditor()
|
||||
{
|
||||
Engine::getBBTrackContainer()->setCurrentBB( m_bbTCO->bbTrackIndex() );
|
||||
|
||||
gui->mainWindow()->toggleBBEditorWin( true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::resetName() { m_bbTCO->setName(""); }
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::changeName()
|
||||
{
|
||||
QString s = m_bbTCO->name();
|
||||
RenameDialog rename_dlg( s );
|
||||
rename_dlg.exec();
|
||||
m_bbTCO->setName( s );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBTCOView::update()
|
||||
{
|
||||
ToolTip::add(this, m_bbTCO->name());
|
||||
|
||||
TrackContentObjectView::update();
|
||||
}
|
||||
76
src/gui/BBTrackView.cpp
Normal file
76
src/gui/BBTrackView.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* BBTrackView.cpp
|
||||
*
|
||||
* Copyright (c) 2004-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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "BBTrackView.h"
|
||||
|
||||
#include "BBEditor.h"
|
||||
#include "BBTrackContainer.h"
|
||||
#include "Engine.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "TrackLabelButton.h"
|
||||
|
||||
BBTrackView::BBTrackView( BBTrack * _bbt, TrackContainerView* tcv ) :
|
||||
TrackView( _bbt, tcv ),
|
||||
m_bbTrack( _bbt )
|
||||
{
|
||||
setFixedHeight( 32 );
|
||||
// drag'n'drop with bb-tracks only causes troubles (and makes no sense
|
||||
// too), so disable it
|
||||
setAcceptDrops( false );
|
||||
|
||||
m_trackLabel = new TrackLabelButton( this, getTrackSettingsWidget() );
|
||||
m_trackLabel->setIcon( embed::getIconPixmap( "bb_track" ) );
|
||||
m_trackLabel->move( 3, 1 );
|
||||
m_trackLabel->show();
|
||||
connect( m_trackLabel, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( clickedTrackLabel() ) );
|
||||
setModel( _bbt );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BBTrackView::~BBTrackView()
|
||||
{
|
||||
gui->getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool BBTrackView::close()
|
||||
{
|
||||
gui->getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] );
|
||||
return TrackView::close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTrackView::clickedTrackLabel()
|
||||
{
|
||||
Engine::getBBTrackContainer()->setCurrentBB( m_bbTrack->index() );
|
||||
gui->getBBEditor()->parentWidget()->show();
|
||||
gui->getBBEditor()->setFocus( Qt::ActiveWindowFocusReason );
|
||||
}
|
||||
@@ -9,6 +9,8 @@ SET(LMMS_SRCS
|
||||
gui/AutomationTrackView.cpp
|
||||
gui/ControllerConnectionDialog.cpp
|
||||
gui/ControllerDialog.cpp
|
||||
gui/BBTCOView.cpp
|
||||
gui/BBTrackView.cpp
|
||||
gui/EffectControlDialog.cpp
|
||||
gui/EffectSelectDialog.cpp
|
||||
gui/embed.cpp
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* BBTrack.cpp - implementation of class BBTrack and bbTCO
|
||||
* BBTrack.cpp - implementation of class BBTrack
|
||||
*
|
||||
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
@@ -27,264 +27,15 @@
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
|
||||
#include "BBEditor.h"
|
||||
#include "BBTrackContainer.h"
|
||||
#include "embed.h"
|
||||
#include "Engine.h"
|
||||
#include "gui_templates.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Mixer.h"
|
||||
#include "RenameDialog.h"
|
||||
#include "BBTrackView.h"
|
||||
#include "Song.h"
|
||||
#include "SongEditor.h"
|
||||
#include "ToolTip.h"
|
||||
#include "TrackLabelButton.h"
|
||||
|
||||
|
||||
|
||||
BBTrack::infoMap BBTrack::s_infoMap;
|
||||
|
||||
|
||||
BBTCO::BBTCO( Track * _track ) :
|
||||
TrackContentObject( _track )
|
||||
{
|
||||
bar_t t = Engine::getBBTrackContainer()->lengthOfBB( bbTrackIndex() );
|
||||
if( t > 0 )
|
||||
{
|
||||
saveJournallingState( false );
|
||||
changeLength( TimePos( t, 0 ) );
|
||||
restoreJournallingState();
|
||||
}
|
||||
setAutoResize( false );
|
||||
}
|
||||
|
||||
void BBTCO::saveSettings( QDomDocument & doc, QDomElement & element )
|
||||
{
|
||||
element.setAttribute( "name", name() );
|
||||
if( element.parentNode().nodeName() == "clipboard" )
|
||||
{
|
||||
element.setAttribute( "pos", -1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
element.setAttribute( "pos", startPosition() );
|
||||
}
|
||||
element.setAttribute( "len", length() );
|
||||
element.setAttribute( "muted", isMuted() );
|
||||
if( usesCustomClipColor() )
|
||||
{
|
||||
element.setAttribute( "color", color().name() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCO::loadSettings( const QDomElement & element )
|
||||
{
|
||||
setName( element.attribute( "name" ) );
|
||||
if( element.attribute( "pos" ).toInt() >= 0 )
|
||||
{
|
||||
movePosition( element.attribute( "pos" ).toInt() );
|
||||
}
|
||||
changeLength( element.attribute( "len" ).toInt() );
|
||||
if( element.attribute( "muted" ).toInt() != isMuted() )
|
||||
{
|
||||
toggleMute();
|
||||
}
|
||||
|
||||
// for colors saved in 1.3-onwards
|
||||
if( element.hasAttribute( "color" ) && !element.hasAttribute( "usestyle" ) )
|
||||
{
|
||||
useCustomClipColor( true );
|
||||
setColor( element.attribute( "color" ) );
|
||||
}
|
||||
|
||||
// for colors saved before 1.3
|
||||
else
|
||||
{
|
||||
if( element.hasAttribute( "color" ) )
|
||||
{ setColor( QColor( element.attribute( "color" ).toUInt() ) ); }
|
||||
|
||||
// usestyle attribute is no longer used
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int BBTCO::bbTrackIndex()
|
||||
{
|
||||
return dynamic_cast<BBTrack *>( getTrack() )->index();
|
||||
}
|
||||
|
||||
|
||||
|
||||
TrackContentObjectView * BBTCO::createView( TrackView * _tv )
|
||||
{
|
||||
return new BBTCOView( this, _tv );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BBTCOView::BBTCOView( TrackContentObject * _tco, TrackView * _tv ) :
|
||||
TrackContentObjectView( _tco, _tv ),
|
||||
m_bbTCO( dynamic_cast<BBTCO *>( _tco ) ),
|
||||
m_paintPixmap()
|
||||
{
|
||||
connect( _tco->getTrack(), SIGNAL( dataChanged() ),
|
||||
this, SLOT( update() ) );
|
||||
|
||||
setStyle( QApplication::style() );
|
||||
}
|
||||
|
||||
void BBTCOView::constructContextMenu( QMenu * _cm )
|
||||
{
|
||||
QAction * a = new QAction( embed::getIconPixmap( "bb_track" ),
|
||||
tr( "Open in Beat+Bassline-Editor" ),
|
||||
_cm );
|
||||
_cm->insertAction( _cm->actions()[0], a );
|
||||
connect( a, SIGNAL( triggered( bool ) ),
|
||||
this, SLOT( openInBBEditor() ) );
|
||||
_cm->insertSeparator( _cm->actions()[1] );
|
||||
_cm->addSeparator();
|
||||
_cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ),
|
||||
this, SLOT( resetName() ) );
|
||||
_cm->addAction( embed::getIconPixmap( "edit_rename" ),
|
||||
tr( "Change name" ),
|
||||
this, SLOT( changeName() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::mouseDoubleClickEvent( QMouseEvent * )
|
||||
{
|
||||
openInBBEditor();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::paintEvent( QPaintEvent * )
|
||||
{
|
||||
QPainter painter( this );
|
||||
|
||||
if( !needsUpdate() )
|
||||
{
|
||||
painter.drawPixmap( 0, 0, m_paintPixmap );
|
||||
return;
|
||||
}
|
||||
|
||||
setNeedsUpdate( false );
|
||||
|
||||
if (m_paintPixmap.isNull() || m_paintPixmap.size() != size())
|
||||
{
|
||||
m_paintPixmap = QPixmap(size());
|
||||
}
|
||||
|
||||
QPainter p( &m_paintPixmap );
|
||||
|
||||
QLinearGradient lingrad( 0, 0, 0, height() );
|
||||
QColor c = getColorForDisplay( painter.background().color() );
|
||||
|
||||
lingrad.setColorAt( 0, c.lighter( 130 ) );
|
||||
lingrad.setColorAt( 1, c.lighter( 70 ) );
|
||||
|
||||
// paint a black rectangle under the pattern to prevent glitches with transparent backgrounds
|
||||
p.fillRect( rect(), QColor( 0, 0, 0 ) );
|
||||
|
||||
if( gradient() )
|
||||
{
|
||||
p.fillRect( rect(), lingrad );
|
||||
}
|
||||
else
|
||||
{
|
||||
p.fillRect( rect(), c );
|
||||
}
|
||||
|
||||
// bar lines
|
||||
const int lineSize = 3;
|
||||
p.setPen( c.darker( 200 ) );
|
||||
|
||||
bar_t t = Engine::getBBTrackContainer()->lengthOfBB( m_bbTCO->bbTrackIndex() );
|
||||
if( m_bbTCO->length() > TimePos::ticksPerBar() && t > 0 )
|
||||
{
|
||||
for( int x = static_cast<int>( t * pixelsPerBar() );
|
||||
x < width() - 2;
|
||||
x += static_cast<int>( t * pixelsPerBar() ) )
|
||||
{
|
||||
p.drawLine( x, TCO_BORDER_WIDTH, x, TCO_BORDER_WIDTH + lineSize );
|
||||
p.drawLine( x, rect().bottom() - ( TCO_BORDER_WIDTH + lineSize ),
|
||||
x, rect().bottom() - TCO_BORDER_WIDTH );
|
||||
}
|
||||
}
|
||||
|
||||
// pattern name
|
||||
paintTextLabel(m_bbTCO->name(), p);
|
||||
|
||||
// inner border
|
||||
p.setPen( c.lighter( 130 ) );
|
||||
p.drawRect( 1, 1, rect().right() - TCO_BORDER_WIDTH,
|
||||
rect().bottom() - TCO_BORDER_WIDTH );
|
||||
|
||||
// outer border
|
||||
p.setPen( c.darker( 300 ) );
|
||||
p.drawRect( 0, 0, rect().right(), rect().bottom() );
|
||||
|
||||
// draw the 'muted' pixmap only if the pattern was manualy muted
|
||||
if( m_bbTCO->isMuted() )
|
||||
{
|
||||
const int spacing = TCO_BORDER_WIDTH;
|
||||
const int size = 14;
|
||||
p.drawPixmap( spacing, height() - ( size + spacing ),
|
||||
embed::getIconPixmap( "muted", size, size ) );
|
||||
}
|
||||
|
||||
p.end();
|
||||
|
||||
painter.drawPixmap( 0, 0, m_paintPixmap );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::openInBBEditor()
|
||||
{
|
||||
Engine::getBBTrackContainer()->setCurrentBB( m_bbTCO->bbTrackIndex() );
|
||||
|
||||
gui->mainWindow()->toggleBBEditorWin( true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::resetName() { m_bbTCO->setName(""); }
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTCOView::changeName()
|
||||
{
|
||||
QString s = m_bbTCO->name();
|
||||
RenameDialog rename_dlg( s );
|
||||
rename_dlg.exec();
|
||||
m_bbTCO->setName( s );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BBTCOView::update()
|
||||
{
|
||||
ToolTip::add(this, m_bbTCO->name());
|
||||
|
||||
TrackContentObjectView::update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
BBTrack::BBTrack( TrackContainer* tc ) :
|
||||
Track( Track::BBTrack, tc )
|
||||
{
|
||||
@@ -489,57 +240,4 @@ void BBTrack::swapBBTracks( Track * _track1, Track * _track2 )
|
||||
s_infoMap[t2] );
|
||||
Engine::getBBTrackContainer()->setCurrentBB( s_infoMap[t1] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BBTrackView::BBTrackView( BBTrack * _bbt, TrackContainerView* tcv ) :
|
||||
TrackView( _bbt, tcv ),
|
||||
m_bbTrack( _bbt )
|
||||
{
|
||||
setFixedHeight( 32 );
|
||||
// drag'n'drop with bb-tracks only causes troubles (and makes no sense
|
||||
// too), so disable it
|
||||
setAcceptDrops( false );
|
||||
|
||||
m_trackLabel = new TrackLabelButton( this, getTrackSettingsWidget() );
|
||||
m_trackLabel->setIcon( embed::getIconPixmap( "bb_track" ) );
|
||||
m_trackLabel->move( 3, 1 );
|
||||
m_trackLabel->show();
|
||||
connect( m_trackLabel, SIGNAL( clicked( bool ) ),
|
||||
this, SLOT( clickedTrackLabel() ) );
|
||||
setModel( _bbt );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BBTrackView::~BBTrackView()
|
||||
{
|
||||
gui->getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool BBTrackView::close()
|
||||
{
|
||||
gui->getBBEditor()->removeBBView( BBTrack::s_infoMap[m_bbTrack] );
|
||||
return TrackView::close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BBTrackView::clickedTrackLabel()
|
||||
{
|
||||
Engine::getBBTrackContainer()->setCurrentBB( m_bbTrack->index() );
|
||||
gui->getBBEditor()->parentWidget()->show();
|
||||
gui->getBBEditor()->setFocus( Qt::ActiveWindowFocusReason );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user