Skip to content

Commit

Permalink
Changed bar lines to follow snap size (#7034)
Browse files Browse the repository at this point in the history
* Added lines in between bars
* Changed bar lines to follow snap size
* Changed default zoom and quantization value
* Added constants for line widths
* Added QSS configuration for new grid line colors
* Tied line widths to QSS properties
* Changed default quantization to 1/4
* Removed clear() from destructor model
* Removed destructor in ComboBoxModel.h
* Changed member set/get functions to pass by value
* Updated signal connection with newer syntax
  • Loading branch information
BoredGuy1 authored and Rossmaxx committed May 21, 2024
1 parent 28b7f35 commit 5dcada0
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 50 deletions.
24 changes: 17 additions & 7 deletions data/themes/classic/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,24 @@ lmms--gui--TrackView > QWidget {

/* autoscroll, loop, stop behaviour toggle buttons */

/* track background colors */
/* track background config */
lmms--gui--TrackContentWidget {
qproperty-darkerColor: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 rgb( 50, 50, 50 ), stop:0.33 rgb( 20, 20, 20 ), stop:1 rgb( 15, 15, 15 ) );
qproperty-lighterColor: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 rgb( 50, 50, 50 ), stop:0.33 rgb( 40, 40, 40 ), stop:1 rgb( 30, 30, 30 ) );
qproperty-gridColor: rgba( 0, 0, 0, 160 );
qproperty-embossColor: rgba( 140, 140, 140, 64 );
/* colors */
qproperty-darkerColor: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(50, 50, 50), stop:0.33 rgb(20, 20, 20), stop:1 rgb(15, 15, 15));
qproperty-lighterColor: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(50, 50, 50), stop:0.33 rgb(40, 40, 40), stop:1 rgb(30, 30, 30));
qproperty-coarseGridColor: rgba(0, 0, 0, 160);
qproperty-fineGridColor: rgba(0, 0, 0, 80);
qproperty-horizontalColor: rgba(0, 0, 0, 160);
qproperty-embossColor: rgba(140, 140, 140, 64);

/* line widths */
qproperty-coarseGridWidth: 2;
qproperty-fineGridWidth: 1;
qproperty-horizontalWidth: 1;
qproperty-embossWidth: 0;

/* positive offset shifts emboss to the right */
qproperty-embossOffset: 0;
}


Expand Down
18 changes: 15 additions & 3 deletions data/themes/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,24 @@ lmms--gui--TrackView > QWidget {

/* autoscroll, loop, stop behaviour toggle buttons */

/* track background colors */
/* track background config */
lmms--gui--TrackContentWidget {
/* colors */
qproperty-darkerColor: #0C0E0F;
qproperty-lighterColor: #14151A;
qproperty-gridColor: #262B30;
qproperty-embossColor: rgba( 0, 0, 0, 0 );
qproperty-coarseGridColor: #3C444C;
qproperty-fineGridColor: #262B30;
qproperty-horizontalColor: #3C444C;
qproperty-embossColor: rgba(0, 0, 0, 0);

/* line widths */
qproperty-coarseGridWidth: 2;
qproperty-fineGridWidth: 1;
qproperty-horizontalWidth: 1;
qproperty-embossWidth: 0;

/* positive offset shifts emboss to the right */
qproperty-embossOffset: 0;
}


Expand Down
5 changes: 0 additions & 5 deletions include/ComboBoxModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ class LMMS_EXPORT ComboBoxModel : public IntModel
{
}

~ComboBoxModel() override
{
clear();
}

void addItem( QString item, std::unique_ptr<PixmapLoader> loader = nullptr );

void replaceItem(std::size_t index, QString item, std::unique_ptr<PixmapLoader> loader = nullptr);
Expand Down
1 change: 1 addition & 0 deletions include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ private slots:

signals:
void pixelsPerBarChanged(float);
void proportionalSnapChanged();
} ;


Expand Down
2 changes: 1 addition & 1 deletion include/TrackContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public slots:


protected:
static const int DEFAULT_PIXELS_PER_BAR = 16;
static const int DEFAULT_PIXELS_PER_BAR = 128;

void resizeEvent( QResizeEvent * ) override;

Expand Down
61 changes: 48 additions & 13 deletions include/TrackContentWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,24 @@ class TrackContentWidget : public QWidget, public JournallingObject
Q_OBJECT

// qproperties for track background gradients
Q_PROPERTY( QBrush darkerColor READ darkerColor WRITE setDarkerColor )
Q_PROPERTY( QBrush lighterColor READ lighterColor WRITE setLighterColor )
Q_PROPERTY( QBrush gridColor READ gridColor WRITE setGridColor )
Q_PROPERTY( QBrush embossColor READ embossColor WRITE setEmbossColor )
Q_PROPERTY(QBrush darkerColor READ darkerColor WRITE setDarkerColor)
Q_PROPERTY(QBrush lighterColor READ lighterColor WRITE setLighterColor)
Q_PROPERTY(QBrush coarseGridColor READ coarseGridColor WRITE setCoarseGridColor)
Q_PROPERTY(QBrush fineGridColor READ fineGridColor WRITE setFineGridColor)
Q_PROPERTY(QBrush horizontalColor READ horizontalColor WRITE setHorizontalColor)
Q_PROPERTY(QBrush embossColor READ embossColor WRITE setEmbossColor)

Q_PROPERTY(int coarseGridWidth READ coarseGridWidth WRITE setCoarseGridWidth)
Q_PROPERTY(int fineGridWidth READ fineGridWidth WRITE setFineGridWidth)
Q_PROPERTY(int horizontalWidth READ horizontalWidth WRITE setHorizontalWidth)
Q_PROPERTY(int embossWidth READ embossWidth WRITE setEmbossWidth)

Q_PROPERTY(int embossOffset READ embossOffset WRITE setEmbossOffset)

public:
TrackContentWidget( TrackView * parent );
~TrackContentWidget() override = default;

/*! \brief Updates the background tile pixmap. */
void updateBackground();

void addClipView( ClipView * clipv );
void removeClipView( ClipView * clipv );
void removeClipView( int clipNum )
Expand All @@ -82,17 +88,37 @@ class TrackContentWidget : public QWidget, public JournallingObject

QBrush darkerColor() const;
QBrush lighterColor() const;
QBrush gridColor() const;
QBrush coarseGridColor() const;
QBrush fineGridColor() const;
QBrush horizontalColor() const;
QBrush embossColor() const;

void setDarkerColor( const QBrush & c );
void setLighterColor( const QBrush & c );
void setGridColor( const QBrush & c );
void setEmbossColor( const QBrush & c);
int coarseGridWidth() const;
int fineGridWidth() const;
int horizontalWidth() const;
int embossWidth() const;

int embossOffset() const;

void setDarkerColor(const QBrush & c);
void setLighterColor(const QBrush & c);
void setCoarseGridColor(const QBrush & c);
void setFineGridColor(const QBrush & c);
void setHorizontalColor(const QBrush & c);
void setEmbossColor(const QBrush & c);

void setCoarseGridWidth(int c);
void setFineGridWidth(int c);
void setHorizontalWidth(int c);
void setEmbossWidth(int c);

void setEmbossOffset(int c);

public slots:
void update();
void changePosition( const lmms::TimePos & newPos = TimePos( -1 ) );
/*! \brief Updates the background tile pixmap. */
void updateBackground();

protected:
enum class ContextMenuAction
Expand Down Expand Up @@ -140,8 +166,17 @@ public slots:
// qproperty fields
QBrush m_darkerColor;
QBrush m_lighterColor;
QBrush m_gridColor;
QBrush m_coarseGridColor;
QBrush m_fineGridColor;
QBrush m_horizontalColor;
QBrush m_embossColor;

int m_coarseGridWidth;
int m_fineGridWidth;
int m_horizontalWidth;
int m_embossWidth;

int m_embossOffset;
} ;


Expand Down
6 changes: 4 additions & 2 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace lmms::gui
namespace
{

constexpr int MIN_PIXELS_PER_BAR = 2;
constexpr int MIN_PIXELS_PER_BAR = 4;
constexpr int MAX_PIXELS_PER_BAR = 400;
constexpr int ZOOM_STEPS = 200;

Expand Down Expand Up @@ -263,7 +263,7 @@ SongEditor::SongEditor( Song * song ) :
m_snappingModel->addItem(QString("1/%1 Bar").arg(1 / bars));
}
}
m_snappingModel->setInitValue( m_snappingModel->findText( "1 Bar" ) );
m_snappingModel->setInitValue( m_snappingModel->findText( "1/4 Bar" ) );

setFocusPolicy( Qt::StrongFocus );
setFocus();
Expand Down Expand Up @@ -447,6 +447,8 @@ void SongEditor::toggleProportionalSnap()
{
m_proportionalSnap = !m_proportionalSnap;
m_timeLine->setSnapSize(getSnapSize());

emit proportionalSnapChanged();
}


Expand Down
Loading

0 comments on commit 5dcada0

Please sign in to comment.