Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New loop marker shortcuts, attempt 2 #6382

Merged
merged 19 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from 15 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
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
72 changes: 59 additions & 13 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,66 @@ 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_inactiveLoopHandleColor = QColor{255, 255, 255, 32};

QColor m_activeLoopColor;
QBrush m_activeLoopBrush;
QColor m_activeLoopInnerColor;
QColor m_activeLoopHandleColor = QColor{74, 155, 100, 255};

int m_loopRectangleVerticalPadding;
int m_loopHandleWidth = 5;

QColor m_barLineColor;
QColor m_barNumberColor;

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

AutoScrollState m_autoScroll;

bool m_changedPosition;

// 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;
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;
int m_initalXSelect;


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

int m_moveXOff;
Action m_action;
};

} // 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
Loading