Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/InstrumentTrackView.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ private slots:

void handleConfigChange(QString cls, QString attr, QString value);

private:
static QPixmap determinePixmap(InstrumentTrack* instrumentTrack);

private:
InstrumentTrackWindow * m_window;
Expand Down
6 changes: 1 addition & 5 deletions include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,7 @@ class LMMS_EXPORT Track : public Model, public JournallingObject
BoolModel* getMutedModel();

public slots:
virtual void setName( const QString & newName )
{
m_name = newName;
emit nameChanged();
}
virtual void setName(const QString& newName);

void setMutedBeforeSolo(const bool muted)
{
Expand Down
3 changes: 2 additions & 1 deletion include/TrackLabelButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ public slots:
void mousePressEvent( QMouseEvent * _me ) override;
void mouseDoubleClickEvent( QMouseEvent * _me ) override;
void mouseReleaseEvent( QMouseEvent * _me ) override;
void paintEvent( QPaintEvent * _pe ) override;
void resizeEvent( QResizeEvent * _re ) override;

private:
bool isInCompactMode() const;

private:
TrackView * m_trackView;
Expand Down
3 changes: 3 additions & 0 deletions include/TrackView.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ public slots:
void mousePressEvent( QMouseEvent * me ) override;
void mouseMoveEvent( QMouseEvent * me ) override;
void mouseReleaseEvent( QMouseEvent * me ) override;
void wheelEvent(QWheelEvent* we) override;
void paintEvent( QPaintEvent * pe ) override;
void resizeEvent( QResizeEvent * re ) override;

private:
void resizeToHeight(int height);

private:
enum class Action
Expand Down
15 changes: 15 additions & 0 deletions src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,4 +637,19 @@ BoolModel *Track::getMutedModel()
return &m_mutedModel;
}

void Track::setName(const QString& newName)
{
if (m_name != newName)
{
m_name = newName;

if (auto song = Engine::getSong())
{
song->setModified();
}

emit nameChanged();
}
}

} // namespace lmms
5 changes: 3 additions & 2 deletions src/gui/clips/MidiClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
namespace lmms::gui
{

constexpr int BeatStepButtonOffset = 4;

MidiClipView::MidiClipView( MidiClip* clip, TrackView* parent ) :
ClipView( clip, parent ),
Expand Down Expand Up @@ -246,7 +247,7 @@ void MidiClipView::mousePressEvent( QMouseEvent * _me )
{
bool displayPattern = fixedClips() || (pixelsPerBar() >= 96 && m_legacySEPattern);
if (_me->button() == Qt::LeftButton && m_clip->m_clipType == MidiClip::Type::BeatClip && displayPattern
&& _me->y() > height() - m_stepBtnOff.height())
&& _me->y() > BeatStepButtonOffset && _me->y() < BeatStepButtonOffset + m_stepBtnOff.height())

// when mouse button is pressed in pattern mode

Expand Down Expand Up @@ -478,7 +479,7 @@ void MidiClipView::paintEvent( QPaintEvent * )

// figure out x and y coordinates for step graphic
const int x = BORDER_WIDTH + static_cast<int>(it * w / steps);
const int y = height() - m_stepBtnOff.height() - 1;
const int y = BeatStepButtonOffset;

if (n)
{
Expand Down
32 changes: 30 additions & 2 deletions src/gui/tracks/InstrumentTrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "Mixer.h"
#include "MixerView.h"
#include "GuiApplication.h"
#include "Instrument.h"
#include "InstrumentTrack.h"
#include "InstrumentTrackWindow.h"
#include "MainWindow.h"
Expand All @@ -62,7 +63,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV

m_tlb = new TrackLabelButton( this, getTrackSettingsWidget() );
m_tlb->setCheckable( true );
m_tlb->setIcon( embed::getIconPixmap( "instrument_track" ) );
m_tlb->setIcon(determinePixmap(_it));
m_tlb->show();

connect( m_tlb, SIGNAL(toggled(bool)),
Expand Down Expand Up @@ -142,14 +143,18 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV
m_activityIndicator->setFixedSize(8, 28);
m_activityIndicator->show();

auto layout = new QHBoxLayout(getTrackSettingsWidget());
auto masterLayout = new QVBoxLayout(getTrackSettingsWidget());
masterLayout->setContentsMargins(0, 1, 0, 0);
auto layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(m_tlb);
layout->addWidget(m_mixerChannelNumber);
layout->addWidget(m_activityIndicator);
layout->addWidget(m_volumeKnob);
layout->addWidget(m_panningKnob);
masterLayout->addLayout(layout);
masterLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));

connect( m_activityIndicator, SIGNAL(pressed()),
this, SLOT(activityIndicatorPressed()));
Expand Down Expand Up @@ -393,4 +398,27 @@ QMenu * InstrumentTrackView::createMixerMenu(QString title, QString newMixerLabe
}


QPixmap InstrumentTrackView::determinePixmap(InstrumentTrack* instrumentTrack)
{
if (instrumentTrack)
{
Instrument* instrument = instrumentTrack->instrument();

if (instrument && instrument->descriptor())
{
const PixmapLoader* pl = instrument->key().isValid()
? instrument->key().logo()
: instrument->descriptor()->logo;

if (pl)
{
return pl->pixmap();
}
}
}

return embed::getIconPixmap("instrument_track");
}


} // namespace lmms::gui
6 changes: 5 additions & 1 deletion src/gui/tracks/SampleTrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ SampleTrackView::SampleTrackView( SampleTrack * _t, TrackContainerView* tcv ) :
m_activityIndicator->setFixedSize(8, 28);
m_activityIndicator->show();

auto layout = new QHBoxLayout(getTrackSettingsWidget());
auto masterLayout = new QVBoxLayout(getTrackSettingsWidget());
masterLayout->setContentsMargins(0, 1, 0, 0);
auto layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(m_tlb);
layout->addWidget(m_mixerChannelNumber);
layout->addWidget(m_activityIndicator);
layout->addWidget(m_volumeKnob);
layout->addWidget(m_panningKnob);
masterLayout->addLayout(layout);
masterLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));

connect(_t, SIGNAL(playingChanged()), this, SLOT(updateIndicator()));

Expand Down
46 changes: 8 additions & 38 deletions src/gui/tracks/TrackLabelButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@

#include "ConfigManager.h"
#include "embed.h"
#include "Engine.h"
#include "Instrument.h"
#include "InstrumentTrack.h"
#include "RenameDialog.h"
#include "Song.h"
#include "TrackRenameLineEdit.h"
#include "TrackView.h"
#include "Track.h"

namespace lmms::gui
{
Expand All @@ -53,7 +50,7 @@ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) :
m_renameLineEdit = new TrackRenameLineEdit( this );
m_renameLineEdit->hide();

if( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() )
if (isInCompactMode())
{
setFixedSize( 32, 29 );
}
Expand All @@ -77,15 +74,14 @@ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) :

void TrackLabelButton::rename()
{
if( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() )
if (isInCompactMode())
{
QString txt = m_trackView->getTrack()->name();
RenameDialog renameDlg( txt );
renameDlg.exec();
if( txt != text() )
{
m_trackView->getTrack()->setName( txt );
Engine::getSong()->setModified();
}
}
else
Expand All @@ -103,7 +99,7 @@ void TrackLabelButton::rename()

void TrackLabelButton::renameFinished()
{
if( !( ConfigManager::inst()->value( "ui", "compacttrackbuttons" ).toInt() ) )
if (!isInCompactMode())
{
m_renameLineEdit->clearFocus();
m_renameLineEdit->hide();
Expand All @@ -113,7 +109,6 @@ void TrackLabelButton::renameFinished()
{
setText( elideName( m_renameLineEdit->text() ) );
m_trackView->getTrack()->setName( m_renameLineEdit->text() );
Engine::getSong()->setModified();
}
}
}
Expand Down Expand Up @@ -185,35 +180,6 @@ void TrackLabelButton::mouseReleaseEvent( QMouseEvent *_me )



void TrackLabelButton::paintEvent( QPaintEvent * _pe )
{
if( m_trackView->getTrack()->type() == Track::Type::Instrument )
{
auto it = dynamic_cast<InstrumentTrack*>(m_trackView->getTrack());
const PixmapLoader * pl;
auto get_logo = [](InstrumentTrack* it) -> const PixmapLoader*
{
return it->instrument()->key().isValid()
? it->instrument()->key().logo()
: it->instrument()->descriptor()->logo;
};
if( it && it->instrument() &&
it->instrument()->descriptor() &&
( pl = get_logo(it) ) )
{
if( pl->pixmapName() != m_iconName )
{
m_iconName = pl->pixmapName();
setIcon( pl->pixmap() );
}
}
}
QToolButton::paintEvent( _pe );
}




void TrackLabelButton::resizeEvent(QResizeEvent *_re)
{
setText( elideName( m_trackView->getTrack()->displayName() ) );
Expand All @@ -237,5 +203,9 @@ QString TrackLabelButton::elideName( const QString &name )
return elidedName;
}

bool TrackLabelButton::isInCompactMode() const
{
return ConfigManager::inst()->value("ui", "compacttrackbuttons").toInt();
}

} // namespace lmms::gui
28 changes: 25 additions & 3 deletions src/gui/tracks/TrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ void TrackView::mouseMoveEvent( QMouseEvent * me )
}
else if( m_action == Action::Resize )
{
setFixedHeight( qMax<int>( me->y(), MINIMAL_TRACK_HEIGHT ) );
m_trackContainerView->realignTracks();
m_track->setHeight( height() );
resizeToHeight(me->y());
}

if( height() < DEFAULT_TRACK_HEIGHT )
Expand All @@ -393,6 +391,22 @@ void TrackView::mouseReleaseEvent( QMouseEvent * me )
QWidget::mouseReleaseEvent( me );
}

void TrackView::wheelEvent(QWheelEvent* we)
{
we->accept();

const int deltaY = we->angleDelta().y();
int const direction = deltaY < 0 ? -1 : 1;

auto const modKeys = we->modifiers();
int stepSize = modKeys == Qt::ControlModifier ? 1 : modKeys == Qt::ShiftModifier ? 5 : 0;

if (stepSize != 0)
{
resizeToHeight(height() + stepSize * direction);
}
}




Expand Down Expand Up @@ -445,4 +459,12 @@ void TrackView::setIndicatorMute(FadeButton* indicator, bool muted)
}


void TrackView::resizeToHeight(int h)
{
setFixedHeight(qMax<int>(h, MINIMAL_TRACK_HEIGHT));
m_trackContainerView->realignTracks();
m_track->setHeight(height());
}


} // namespace lmms::gui