Skip to content

Commit

Permalink
New loop marker shortcuts, attempt 2 (LMMS#6382)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
  • Loading branch information
Spekular and DomClark authored Dec 25, 2023
1 parent ce722dd commit 4eba656
Show file tree
Hide file tree
Showing 11 changed files with 286 additions and 115 deletions.
Binary file added data/themes/classic/cursor_select_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/classic/cursor_select_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,25 @@ lmms--gui--TimeLineWidget {
background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #8796a7, stop: 1.0 #3e454e );

qproperty-inactiveLoopColor: rgba( 52, 63, 53, 64 );
qproperty-inactiveLoopColor: rgba( 52, 63, 53, 64 );
qproperty-inactiveLoopBrush: rgba( 255, 255, 255, 32 );
qproperty-inactiveLoopInnerColor: rgba( 255, 255, 255, 32 );
qproperty-inactiveLoopHandleColor: rgba( 192, 192, 192, 100 );
qproperty-activeLoopColor: rgba( 52, 63, 53, 255 );
qproperty-activeLoopBrush: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #378d59, stop: 1.0 #297e36 );
qproperty-activeLoopInnerColor: rgba( 74, 155, 100, 255 );
qproperty-activeLoopHandleColor: rgba( 192, 192, 192, 200 );

/* Width of loop marker handles (when handle mode is active) */
qproperty-loopHandleWidth: 8;

qproperty-barLineColor: rgb( 192, 192, 192 );
qproperty-barNumberColor: rgb( 192, 192, 192 );

/* Cursor hotspots for loop marker adjustment */
qproperty-mouseHotspotSelLeft: 0px 16px;
qproperty-mouseHotspotSelRight: 32px 16px;
}

QTreeView {
Expand Down
Binary file added data/themes/default/cursor_select_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/cursor_select_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -704,23 +704,32 @@ lmms--gui--TimeLineWidget {
/* Properties for the loop indicator rectangle in inactive state:
- LoopColor: Color of the outermost border
- LoopBrush: Brush to paint the main portion of the rectangle
- LoopInnerColor: Color used to paint the inlayed border */
- LoopInnerColor: Color used to paint the inlayed border
- LoopHandleColor: Color used to paint loop marker handles */
qproperty-inactiveLoopColor: #3B424A;
qproperty-inactiveLoopBrush: #3B424A;
qproperty-inactiveLoopInnerColor: #3B424A;
qproperty-inactiveLoopHandleColor: rgba( 192, 192, 192, 100 );

/* Properties for the loop indicator rectangle in active state.
See above for detailed description. */
qproperty-activeLoopColor: #21A14F;
qproperty-activeLoopBrush: #21A14F;
qproperty-activeLoopInnerColor: #21A14F;
qproperty-activeLoopHandleColor: rgba( 192, 192, 192, 200 );

/* Vertical padding for the loop indicator rectangle.
A value of zero draws the rectangle at the full height of the widget. */
qproperty-loopRectangleVerticalPadding: 1;
/* Width of loop marker handles (when handle mode is active) */
qproperty-loopHandleWidth: 8;

qproperty-barLineColor: rgb( 192, 192, 192 );
qproperty-barNumberColor: rgb( 192, 192, 192 );

/* Cursor hotspots for loop marker adjustment */
qproperty-mouseHotspotSelLeft: 0px 16px;
qproperty-mouseHotspotSelRight: 32px 16px;
}

lmms--gui--TrackContainerView QLabel
Expand Down
3 changes: 3 additions & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private slots:
void toggleMMPZ(bool enabled);
void toggleDisableBackup(bool enabled);
void toggleOpenLastProject(bool enabled);
void loopMarkerModeChanged();
void setLanguage(int lang);

// Performance settings widget.
Expand Down Expand Up @@ -147,6 +148,8 @@ private slots:
bool m_MMPZ;
bool m_disableBackup;
bool m_openLastProject;
QString m_loopMarkerMode;
QComboBox* m_loopMarkerComboBox;
QString m_lang;
QStringList m_languages;

Expand Down
96 changes: 70 additions & 26 deletions include/TimeLineWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#ifndef LMMS_GUI_TIMELINE_WIDGET_H
#define LMMS_GUI_TIMELINE_WIDGET_H

#include <array>

#include <QBrush>
#include <QSize>
#include <QWidget>

#include "Song.h"
Expand Down Expand Up @@ -57,10 +61,15 @@ class TimeLineWidget : public QWidget
Q_PROPERTY( QColor inactiveLoopColor READ getInactiveLoopColor WRITE setInactiveLoopColor )
Q_PROPERTY( QBrush inactiveLoopBrush READ getInactiveLoopBrush WRITE setInactiveLoopBrush )
Q_PROPERTY( QColor inactiveLoopInnerColor READ getInactiveLoopInnerColor WRITE setInactiveLoopInnerColor )
Q_PROPERTY(QColor inactiveLoopHandleColor MEMBER m_inactiveLoopHandleColor)
Q_PROPERTY( QColor activeLoopColor READ getActiveLoopColor WRITE setActiveLoopColor )
Q_PROPERTY( QBrush activeLoopBrush READ getActiveLoopBrush WRITE setActiveLoopBrush )
Q_PROPERTY( QColor activeLoopInnerColor READ getActiveLoopInnerColor WRITE setActiveLoopInnerColor )
Q_PROPERTY(QColor activeLoopHandleColor MEMBER m_activeLoopHandleColor)
Q_PROPERTY( int loopRectangleVerticalPadding READ getLoopRectangleVerticalPadding WRITE setLoopRectangleVerticalPadding )
Q_PROPERTY(int loopHandleWidth MEMBER m_loopHandleWidth)
Q_PROPERTY(QSize mouseHotspotSelLeft READ mouseHotspotSelLeft WRITE setMouseHotspotSelLeft)
Q_PROPERTY(QSize mouseHotspotSelRight READ mouseHotspotSelRight WRITE setMouseHotspotSelRight)

enum class AutoScrollState
{
Expand Down Expand Up @@ -99,6 +108,28 @@ class TimeLineWidget : public QWidget
inline int const & getLoopRectangleVerticalPadding() const { return m_loopRectangleVerticalPadding; }
inline void setLoopRectangleVerticalPadding(int const & loopRectangleVerticalPadding) { m_loopRectangleVerticalPadding = loopRectangleVerticalPadding; }

auto mouseHotspotSelLeft() const -> QSize
{
const auto point = m_cursorSelectLeft.hotSpot();
return QSize{point.x(), point.y()};
}

void setMouseHotspotSelLeft(const QSize& s)
{
m_cursorSelectLeft = QCursor{m_cursorSelectLeft.pixmap(), s.width(), s.height()};
}

auto mouseHotspotSelRight() const -> QSize
{
const auto point = m_cursorSelectRight.hotSpot();
return QSize{point.x(), point.y()};
}

void setMouseHotspotSelRight(const QSize& s)
{
m_cursorSelectRight = QCursor{m_cursorSelectRight.pixmap(), s.width(), s.height()};
}

inline Song::PlayPos & pos()
{
return( m_pos );
Expand Down Expand Up @@ -143,51 +174,64 @@ public slots:
void mousePressEvent( QMouseEvent * _me ) override;
void mouseMoveEvent( QMouseEvent * _me ) override;
void mouseReleaseEvent( QMouseEvent * _me ) override;

void contextMenuEvent(QContextMenuEvent* event) override;

private:
enum class Action
{
NoAction,
MovePositionMarker,
MoveLoopBegin,
MoveLoopEnd,
MoveLoop,
SelectSongClip,
};

auto getClickedTime(int xPosition) const -> TimePos;
auto getLoopAction(QMouseEvent* event) const -> Action;
auto actionCursor(Action action) const -> QCursor;

QPixmap m_posMarkerPixmap = embed::getIconPixmap("playpos_marker");

QColor m_inactiveLoopColor;
QBrush m_inactiveLoopBrush;
QColor m_inactiveLoopInnerColor;
QColor m_inactiveLoopColor = QColor{52, 63, 53, 64};
QBrush m_inactiveLoopBrush = QColor{255, 255, 255, 32};
QColor m_inactiveLoopInnerColor = QColor{255, 255, 255, 32};
QColor m_inactiveLoopHandleColor = QColor{255, 255, 255, 32};

QColor m_activeLoopColor;
QBrush m_activeLoopBrush;
QColor m_activeLoopInnerColor;
QColor m_activeLoopColor = QColor{52, 63, 53, 255};
QBrush m_activeLoopBrush = QColor{55, 141, 89};
QColor m_activeLoopInnerColor = QColor{74, 155, 100, 255};
QColor m_activeLoopHandleColor = QColor{74, 155, 100, 255};

int m_loopRectangleVerticalPadding;
int m_loopRectangleVerticalPadding = 1;
int m_loopHandleWidth = 5;

QColor m_barLineColor;
QColor m_barNumberColor;
QColor m_barLineColor = QColor{192, 192, 192};
QColor m_barNumberColor = m_barLineColor.darker(120);

AutoScrollState m_autoScroll;
QCursor m_cursorSelectLeft = QCursor{embed::getIconPixmap("cursor_select_left"), 0, 16};
QCursor m_cursorSelectRight = QCursor{embed::getIconPixmap("cursor_select_right"), 32, 16};

bool m_changedPosition;
AutoScrollState m_autoScroll = AutoScrollState::Enabled;

// Width of the unused region on the widget's left (above track labels or piano)
int m_xOffset;
int m_posMarkerX;
float m_ppb;
float m_snapSize;
float m_snapSize = 1.f;
Song::PlayPos & m_pos;
Timeline* m_timeline;
// Leftmost position visible in parent editor
const TimePos & m_begin;
const Song::PlayMode m_mode;
// When in MoveLoop mode we need the initial positions. Storing only the latest
// position allows for unquantized drag but fails when toggling quantization.
std::array<TimePos, 2> m_oldLoopPos;
TimePos m_dragStartPos;

TextFloat * m_hint;
TextFloat* m_hint = nullptr;
int m_initalXSelect;


enum class Action
{
NoAction,
MovePositionMarker,
MoveLoopBegin,
MoveLoopEnd,
SelectSongClip,
} m_action;

int m_moveXOff;
Action m_action = Action::NoAction;
};

} // namespace lmms::gui
Expand Down
2 changes: 1 addition & 1 deletion src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ void SongEditor::updatePosition( const TimePos & t )
m_scrollBack = false;
}

const int x = m_timeLine->markerX(t) + 8;
const int x = m_timeLine->markerX(t);
if( x >= trackOpWidth + widgetWidth -1 )
{
m_positionLine->show();
Expand Down
Loading

0 comments on commit 4eba656

Please sign in to comment.