mirror of
https://github.com/LMMS/lmms.git
synced 2025-12-30 10:08:00 -05:00
* Simplify TrackLabelButton Remove the dependency to `Instrument` and `InstrumentTrack` from `TrackLabelButton`. The icon of an `InstrumentTrackView` is now determined in the class `InstrumentTrackView` itself using the new static method `determinePixmap`. This enables the removal of the overridden `paintEvent` method from `TrackLabelButton`. It was also attempted to keep a non-static member function version and to use the `InstrumentTrackView`'s model with a cast. However, this did not work because 'setModel' is executed as the very last step in the constructor, i.e. the model is not already set when `determinePixmap` is called. Pulling it to the top is too risky right now. * Add helper method isInCompactMode Add the helper method `isInCompactMode` which knows how to use the `ConfigManager` to determine if the option for compact track buttons is enabled. This removes duplicate code with intricate knowledge of the keys under which compact mode is stored. * Set song as modified when track name changes Extend `Track::setName` to set the song as modified whenever the track name changes. This moves the update into a core class and enables the removal of the dependencies to `Engine` and `Song` from the GUI class `TrackLabelButton`. Also add a check if the name is really changed and only perform the actions if that's the case. To make this work the implementation of `setName` had to be moved from the header into the implementation file. * Keep instrument and sample content at top on resize Keep the content of the instrument and sample track at the top of the widget if the widget is resized. This is also fixes a bug where the `TrackLabelButton` does not react anymore when the size is increased. Technically the layout with the actual widgets is put into another vertical layout with a spacer that consumes all remaining space at the bottom. * Vertical track resizing via mouse wheel Enable to vertically resize tracks using the mouse wheel. Scrolling the mouse wheel over the track view with the control key pressed will increase/decrease the height by one pixel per wheel event. Pressing the shift key will increase/decrease in steps of five pixels. Extract code that can be shared between the existing and the new way to resize the track into the private helper method `resizeToHeight`. * Render beat pattern step buttons at the top Render the step buttons of beat patterns at the top instead of at the bottom so that they stay aligned with the other elements to the left of them (buttons, knobs, etc). Set the y offset to 4 so that the step buttons are vertically aligned with the other elements. The previous calculation lead to a minimum offset of 6 which always made the step buttons look misaligned. Introduce the new static variable `BeatStepButtonOffset` which ensures that the rendering and the evaluation of mouse clicks do not go out of sync.
183 lines
3.8 KiB
C++
183 lines
3.8 KiB
C++
/*
|
|
* TrackView.h - declaration of TrackView class
|
|
*
|
|
* 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 LMMS_GUI_TRACK_VIEW_H
|
|
#define LMMS_GUI_TRACK_VIEW_H
|
|
|
|
#include <QWidget>
|
|
|
|
#include "JournallingObject.h"
|
|
#include "ModelView.h"
|
|
#include "TrackContentWidget.h"
|
|
#include "TrackOperationsWidget.h"
|
|
|
|
class QMenu;
|
|
|
|
namespace lmms
|
|
{
|
|
|
|
class Track;
|
|
class Clip;
|
|
|
|
|
|
namespace gui
|
|
{
|
|
|
|
class FadeButton;
|
|
class TrackContainerView;
|
|
|
|
|
|
const int DEFAULT_SETTINGS_WIDGET_WIDTH = 256;
|
|
const int TRACK_OP_WIDTH = 78;
|
|
// This shaves 150-ish pixels off track buttons,
|
|
// ruled from config: ui.compacttrackbuttons
|
|
const int DEFAULT_SETTINGS_WIDGET_WIDTH_COMPACT = 128;
|
|
const int TRACK_OP_WIDTH_COMPACT = 62;
|
|
|
|
|
|
class TrackView : public QWidget, public ModelView, public JournallingObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
TrackView( Track * _track, TrackContainerView* tcv );
|
|
~TrackView() override = default;
|
|
|
|
inline const Track * getTrack() const
|
|
{
|
|
return m_track;
|
|
}
|
|
|
|
inline Track * getTrack()
|
|
{
|
|
return m_track;
|
|
}
|
|
|
|
inline TrackContainerView* trackContainerView()
|
|
{
|
|
return m_trackContainerView;
|
|
}
|
|
|
|
inline TrackOperationsWidget * getTrackOperationsWidget()
|
|
{
|
|
return &m_trackOperationsWidget;
|
|
}
|
|
|
|
inline QWidget * getTrackSettingsWidget()
|
|
{
|
|
return &m_trackSettingsWidget;
|
|
}
|
|
|
|
inline TrackContentWidget * getTrackContentWidget()
|
|
{
|
|
return &m_trackContentWidget;
|
|
}
|
|
|
|
bool isMovingTrack() const
|
|
{
|
|
return m_action == Action::Move;
|
|
}
|
|
|
|
virtual void update();
|
|
|
|
// Create a menu for assigning/creating channels for this track
|
|
// Currently instrument track and sample track supports it
|
|
virtual QMenu * createMixerMenu(QString title, QString newMixerLabel);
|
|
|
|
|
|
public slots:
|
|
virtual bool close();
|
|
|
|
|
|
protected:
|
|
void modelChanged() override;
|
|
|
|
void saveSettings( QDomDocument& doc, QDomElement& element ) override
|
|
{
|
|
Q_UNUSED(doc)
|
|
Q_UNUSED(element)
|
|
}
|
|
|
|
void loadSettings( const QDomElement& element ) override
|
|
{
|
|
Q_UNUSED(element)
|
|
}
|
|
|
|
QString nodeName() const override
|
|
{
|
|
return "trackview";
|
|
}
|
|
|
|
|
|
void dragEnterEvent( QDragEnterEvent * dee ) override;
|
|
void dropEvent( QDropEvent * de ) override;
|
|
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
|
|
{
|
|
None,
|
|
Move,
|
|
Resize
|
|
} ;
|
|
|
|
Track * m_track;
|
|
TrackContainerView * m_trackContainerView;
|
|
|
|
TrackOperationsWidget m_trackOperationsWidget;
|
|
QWidget m_trackSettingsWidget;
|
|
TrackContentWidget m_trackContentWidget;
|
|
|
|
Action m_action;
|
|
|
|
virtual FadeButton * getActivityIndicator()
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
void setIndicatorMute(FadeButton* indicator, bool muted);
|
|
|
|
friend class TrackLabelButton;
|
|
|
|
|
|
private slots:
|
|
void createClipView( lmms::Clip * clip );
|
|
void muteChanged();
|
|
|
|
} ;
|
|
|
|
|
|
} // namespace gui
|
|
|
|
} // namespace lmms
|
|
|
|
#endif // LMMS_GUI_TRACK_VIEW_H
|