mirror of
https://github.com/LMMS/lmms.git
synced 2026-01-21 21:07:56 -05:00
Put the elements of the `TrackOperationsWidget` into layouts. These are: * The grip that can be used to move tracks * The gear icon that opens the operations menu * The mute button * The solo button The grip that can be used to move tracks around is extracted into its own class called `TrackGrip`. This has several advantages: * It can be put into a layout. * It can render itself at arbitrary sizes by simply repeating its pattern pixmap. * It can be used in a much more object-oriented way because it emits signals when it is grabbed and released. * It is responsible for locally updating its cursor state. The default cursor of the grip now is an open hand which indicates to the users that it can be grabbed. While being grabbed the cursor now is a closed hand. ## Technical details The class `TrackOperationsWidget` now holds an instance of `TrackGrip` and provides a getter to retrieve it. This getter is used by `TrackView` to connect to the two new signals `grabbed` and `released`. The method `TrackOperationsWidget::paintEvent` now only paints the background as it does not need to paint the grip anymore. The `TrackView` now handles the grabbing and release of the grip in `TrackView::onTrackGripGrabbed` and `TrackView::onTrackGripReleased`. Because the events and cursor states are now handled by `TrackGrip` this code could be removed from `TrackView::mousePressEvent`. There was a comment in `TrackView` which indicated that the `TrackOperationsWidget` had to be updated when the track is moved and released because it would hide some elements during the move. The comment and the corresponding code was removed because the operations widget does not hide its elements during moves (this was already the state before the changes made by this commit). Adjust the style sheets of the classic and default themes with regards to the `QPushButton` that's used to show the gear menu in the `TrackOperationsWidget`. The `>` has been removed because the `QPushButton` is not a direct decendent of the `TrackOperationsWidget` anymore. ### Wrapping of `PixmapButton` in `QWidget` The PixmapButtons that are used in `TrackOperationsWidget` current have to be wrapped into a `QWidget`. This is necessary due to some strange effect where the PixmapButtons are resized to a size that's larger than their minimum/fixed size when the method `show` is called in `TrackContainerView::realignTracks`. Specifically, with the default theme the buttons are resized from their minimum size of (16, 14) to (26, 26). This then makes them behave not as expected in layouts. The resizing is not done for QWidgets. Therefore we wrap the PixmapButton in a QWidget which is set to a fixed size that will be able to show the active and inactive pixmap. We can then use the QWidget in layouts without any disturbances. The resizing only seems to affect the track view hierarchy and is triggered by Qt's internal mechanisms. For example the buttons in the mixer view do not seem to be affected. If you want to debug this simply override "PixmapButton::resizeEvent" and trigger a break point in there, e.g. whenever the new size is not (16, 14). ### More layout-friendly PixmapButton Make the `PixmapButton` more friendly for layouts by implementing `minimumSizeHint`. It returns a size that accommodate to show the active and the inactive pixmap. Also make `sizeHint` return the minimum size hint. The previous implementation would have made layouts jump when the pixmap is toggled with pixmaps of different sizes.
184 lines
3.8 KiB
C++
184 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();
|
|
void onTrackGripGrabbed();
|
|
void onTrackGripReleased();
|
|
} ;
|
|
|
|
|
|
} // namespace gui
|
|
|
|
} // namespace lmms
|
|
|
|
#endif // LMMS_GUI_TRACK_VIEW_H
|