From eb14db54bc397cb1563755227553411955dde5e7 Mon Sep 17 00:00:00 2001 From: Spekular Date: Fri, 16 Apr 2021 12:45:06 +0200 Subject: [PATCH] Split BB Track classes into separate files (#5985) --- include/BBTCO.h | 55 +++++++ include/BBTCOView.h | 66 +++++++++ include/BBTrack.h | 95 +------------ include/BBTrackView.h | 61 ++++++++ src/core/BBTCO.cpp | 111 +++++++++++++++ src/core/CMakeLists.txt | 1 + src/gui/BBTCOView.cpp | 191 +++++++++++++++++++++++++ src/gui/BBTrackView.cpp | 76 ++++++++++ src/gui/CMakeLists.txt | 2 + src/tracks/BBTrack.cpp | 308 +--------------------------------------- 10 files changed, 569 insertions(+), 397 deletions(-) create mode 100644 include/BBTCO.h create mode 100644 include/BBTCOView.h create mode 100644 include/BBTrackView.h create mode 100644 src/core/BBTCO.cpp create mode 100644 src/gui/BBTCOView.cpp create mode 100644 src/gui/BBTrackView.cpp diff --git a/include/BBTCO.h b/include/BBTCO.h new file mode 100644 index 000000000..8a0ba49bd --- /dev/null +++ b/include/BBTCO.h @@ -0,0 +1,55 @@ +/* + * BBTCO.h + * + * Copyright (c) 2004-2014 Tobias Doerffel + * + * 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 \ No newline at end of file diff --git a/include/BBTCOView.h b/include/BBTCOView.h new file mode 100644 index 000000000..13c65ba58 --- /dev/null +++ b/include/BBTCOView.h @@ -0,0 +1,66 @@ +/* + * BBTCOView.h + * + * Copyright (c) 2004-2014 Tobias Doerffel + * + * 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 + + +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 \ No newline at end of file diff --git a/include/BBTrack.h b/include/BBTrack.h index 4197a88da..da578ffc8 100644 --- a/include/BBTrack.h +++ b/include/BBTrack.h @@ -27,77 +27,16 @@ #ifndef BB_TRACK_H #define BB_TRACK_H -#include -#include -#include -#include "TrackContentObjectView.h" +#include + +#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; - } ; diff --git a/include/BBTrackView.h b/include/BBTrackView.h new file mode 100644 index 000000000..86c10cd30 --- /dev/null +++ b/include/BBTrackView.h @@ -0,0 +1,61 @@ +/* + * BBTrackView.h + * + * Copyright (c) 2004-2014 Tobias Doerffel + * + * 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 + +#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 \ No newline at end of file diff --git a/src/core/BBTCO.cpp b/src/core/BBTCO.cpp new file mode 100644 index 000000000..f6e760ca0 --- /dev/null +++ b/src/core/BBTCO.cpp @@ -0,0 +1,111 @@ +/* + * BBTCO.cpp - implementation of class bbTCO + * + * Copyright (c) 2004-2014 Tobias Doerffel + * + * 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 + + #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( getTrack() )->index(); +} + + + +TrackContentObjectView * BBTCO::createView( TrackView * _tv ) +{ + return new BBTCOView( this, _tv ); +} \ No newline at end of file diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index dca1cdc34..29d6b3148 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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 diff --git a/src/gui/BBTCOView.cpp b/src/gui/BBTCOView.cpp new file mode 100644 index 000000000..a09f1bd0c --- /dev/null +++ b/src/gui/BBTCOView.cpp @@ -0,0 +1,191 @@ +/* + * BBTCOView.cpp + * + * Copyright (c) 2004-2014 Tobias Doerffel + * + * 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 +#include + +#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( _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( t * pixelsPerBar() ); + x < width() - 2; + x += static_cast( 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(); +} \ No newline at end of file diff --git a/src/gui/BBTrackView.cpp b/src/gui/BBTrackView.cpp new file mode 100644 index 000000000..83feb4d8d --- /dev/null +++ b/src/gui/BBTrackView.cpp @@ -0,0 +1,76 @@ +/* + * BBTrackView.cpp + * + * Copyright (c) 2004-2014 Tobias Doerffel + * + * 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 ); +} \ No newline at end of file diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 7ad5dcb76..04af171db 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -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 diff --git a/src/tracks/BBTrack.cpp b/src/tracks/BBTrack.cpp index 1460d5eef..354412e02 100644 --- a/src/tracks/BBTrack.cpp +++ b/src/tracks/BBTrack.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 * @@ -27,264 +27,15 @@ #include #include -#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( 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( _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( t * pixelsPerBar() ); - x < width() - 2; - x += static_cast( 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 ); -} +} \ No newline at end of file