Skip to content

Commit

Permalink
Enable track-wide color coding (LMMS#5573)
Browse files Browse the repository at this point in the history
* Enable track-wide color coding

* Add support for automation tracks

* Allow saving & loading track colors

* Allow track color to be reset to default

* Partially migrate common settings to Track.cpp, fix bug

* Completely migrate local TCO color functions to TCO class, fix bug

* Set QColorDialog colors to better colors

* Color the side of the track according to TCO colors

* Disable color gradient when muted

* Change selection color to depend on TCO color

* Fix breaking builds

* Bug fix

* Fix another bug where BB track colors wouldn't load

* Restore changed demo to original state

* Fix BB Editor bug

* Fix breaking builds

* Allow random color picking

* Fix copy-paste bug

* Change how color is painted on a track

* Cleanup, and implement per-pattern colors

* Cleanup comments

* Migrate some functions

* Remove redundant function

* Rename some functions

* Migrate duplicates to superclass

* Use ColorChooser and reorder some includes

* Change how colors are saved

* Fix some formatting

* Fix some code

* Change how clip colors work

* Fix some unexpected behaviors

* Fix note border coloring being green on colored tracks

* Change name of an option

* Remove redundant code

* Fix ghost changes

* Remove colorRgb

* Rename backgroundColor, remove some variables we don't use

* Remove a redundant variable

* Migrate some duplicates to superclass

* Check for nullpointer

* Remove redundant variable

* Update some logic

* Change how muted colors are displayed

* Change how dark muted tracks become

* Place setModified() in appropriate places

* Make getColorForDisplay() function

* Change how colors are organised and saved

* Remove m_useStyleColor

* Remove a comment

* Quick changes

* Change how colors are saved

* Remove redundant stuff

* Remove redundant stuff pt. 2

* Change how colors are copied

* Fixes pt. 3

* Fixes pt. 4

* Change spaces to tabs

* Fix pseudochanges

* Remove s_lastTCOColor

* Fix pseudochanges pt. 2

* Fix breaking builds

* Add files via upload

* Add comments (again)
  • Loading branch information
ryuukumar authored Oct 20, 2020
1 parent 247c895 commit 35e48f3
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 192 deletions.
Binary file not shown.
5 changes: 3 additions & 2 deletions include/AutomationPatternView.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@

#include <QStaticText>

#include "AutomationPattern.h"
#include "Song.h"
#include "SongEditor.h"
#include "Track.h"

class AutomationPattern;


class AutomationPatternView : public TrackContentObjectView
{
Expand Down
52 changes: 0 additions & 52 deletions include/BBTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,11 @@ class BBTCO : public TrackContentObject
return( "bbtco" );
}

unsigned int color() const
{
return( m_color.rgb() );
}

QColor colorObj() const
{
return m_color;
}

void setColor( const QColor & c )
{
m_color = QColor( c );
}

void setUseStyleColor( bool b )
{
m_useStyleColor = b;
}

int bbTrackIndex();

TrackContentObjectView * createView( TrackView * _tv ) override;

private:
QColor m_color;
bool m_useStyleColor;


friend class BBTCOView;
Expand All @@ -92,11 +70,6 @@ class BBTCOView : public TrackContentObjectView
BBTCOView( TrackContentObject * _tco, TrackView * _tv );
virtual ~BBTCOView() = default;

QColor color() const
{
return( m_bbTCO->m_color );
}
void setColor( QColor _new_color );

public slots:
void update() override;
Expand All @@ -105,8 +78,6 @@ protected slots:
void openInBBEditor();
void resetName();
void changeName();
void changeColor();
void resetColor();


protected:
Expand Down Expand Up @@ -162,27 +133,6 @@ class LMMS_EXPORT BBTrack : public Track
m_disabledTracks.removeAll( _track );
}

static void setLastTCOColor( const QColor & c )
{
if( ! s_lastTCOColor )
{
s_lastTCOColor = new QColor( c );
}
else
{
*s_lastTCOColor = QColor( c );
}
}

static void clearLastTCOColor()
{
if( s_lastTCOColor )
{
delete s_lastTCOColor;
}
s_lastTCOColor = NULL;
}

protected:
inline QString nodeName() const override
{
Expand All @@ -196,8 +146,6 @@ class LMMS_EXPORT BBTrack : public Track
typedef QMap<BBTrack *, int> infoMap;
static infoMap s_infoMap;

static QColor * s_lastTCOColor;

friend class BBTrackView;

} ;
Expand Down
53 changes: 52 additions & 1 deletion include/Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ class LMMS_EXPORT TrackContentObject : public Model, public JournallingObject
{
return m_autoResize;
}

QColor color() const
{
return m_color;
}

void setColor( const QColor & c )
{
m_color = c;
}

bool hasColor();

void useCustomClipColor( bool b );

bool usesCustomClipColor()
{
return m_useCustomClipColor;
}

virtual void movePosition( const MidiTime & pos );
virtual void changeLength( const MidiTime & length );
Expand All @@ -154,6 +173,8 @@ class LMMS_EXPORT TrackContentObject : public Model, public JournallingObject

MidiTime startTimeOffset() const;
void setStartTimeOffset( const MidiTime &startTimeOffset );

void updateColor();

// Will copy the state of a TCO to another TCO
static void copyStateTo( TrackContentObject *src, TrackContentObject *dst );
Expand All @@ -166,6 +187,7 @@ public slots:
void lengthChanged();
void positionChanged();
void destroyedTCO();
void trackColorChanged();


private:
Expand All @@ -189,6 +211,9 @@ public slots:

bool m_selectViewOnCreate;

QColor m_color;
bool m_useCustomClipColor;

friend class TrackContentObjectView;

} ;
Expand Down Expand Up @@ -264,11 +289,16 @@ class TrackContentObjectView : public selectableObject, public ModelView
// some metadata to be written to the clipboard.
static void remove( QVector<TrackContentObjectView *> tcovs );
static void toggleMute( QVector<TrackContentObjectView *> tcovs );

QColor getColorForDisplay( QColor );

public slots:
virtual bool close();
void remove();
void update() override;

void changeClipColor();
void useTrackColor();

protected:
enum ContextMenuAction
Expand Down Expand Up @@ -486,6 +516,10 @@ private slots:
void cloneTrack();
void removeTrack();
void updateMenu();
void changeTrackColor();
void randomTrackColor();
void resetTrackColor();
void useTrackColor();
void toggleRecording(bool on);
void recordingOn();
void recordingOff();
Expand All @@ -503,6 +537,9 @@ private slots:

signals:
void trackRemovalScheduled( TrackView * t );
void colorChanged( QColor & c );
void colorParented();
void colorReset();

} ;

Expand Down Expand Up @@ -635,7 +672,16 @@ class LMMS_EXPORT Track : public Model, public JournallingObject
{
return m_processingLock.tryLock();
}


QColor color()
{
return m_color;
}
bool useColor()
{
return m_hasColor;
}

BoolModel* getMutedModel();

public slots:
Expand All @@ -647,6 +693,8 @@ public slots:

void toggleSolo();

void trackColorChanged( QColor & c );
void trackColorReset();

private:
TrackContainer* m_trackContainer;
Expand All @@ -665,6 +713,9 @@ public slots:
tcoVector m_trackContentObjects;

QMutex m_processingLock;

QColor m_color;
bool m_hasColor;

friend class TrackView;

Expand Down
11 changes: 11 additions & 0 deletions src/core/AutomationPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ void AutomationPattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.setAttribute( "prog", QString::number( progressionType() ) );
_this.setAttribute( "tens", QString::number( getTension() ) );
_this.setAttribute( "mute", QString::number( isMuted() ) );

if( usesCustomClipColor() )
{
_this.setAttribute( "color", color().name() );
}

for( timeMap::const_iterator it = m_timeMap.begin();
it != m_timeMap.end(); ++it )
Expand Down Expand Up @@ -593,6 +598,12 @@ void AutomationPattern::loadSettings( const QDomElement & _this )
m_idsToResolve << element.attribute( "id" ).toInt();
}
}

if( _this.hasAttribute( "color" ) )
{
useCustomClipColor( true );
setColor( _this.attribute( "color" ) );
}

int len = _this.attribute( "len" ).toInt();
if( len <= 0 )
Expand Down
Loading

0 comments on commit 35e48f3

Please sign in to comment.