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

Enable mixer color-coding #5589

Merged
merged 22 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions include/FxLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class FxLine : public QWidget

public slots:
void renameChannel();
void resetColor();
void changeColor();
void randomColor();

private slots:
void renameFinished();
Expand Down
5 changes: 5 additions & 0 deletions include/FxMixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include <atomic>

#include <QColor>

class FxRoute;
typedef QVector<FxRoute *> FxRouteVector;

Expand Down Expand Up @@ -69,6 +71,9 @@ class FxChannel : public ThreadableJob

bool requiresProcessing() const override { return true; }
void unmuteForSolo();

QColor m_color;
bool m_hasColor;
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved


std::atomic_int m_dependenciesMet;
Expand Down
8 changes: 8 additions & 0 deletions src/core/FxMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ FxChannel::FxChannel( int idx, Model * _parent ) :
m_lock(),
m_channelIndex( idx ),
m_queued( false ),
m_hasColor( false ),
m_dependenciesMet(0)
{
BufferManager::clear( m_buffer, Engine::mixer()->framesPerPeriod() );
Expand Down Expand Up @@ -741,6 +742,8 @@ void FxMixer::saveSettings( QDomDocument & _doc, QDomElement & _this )
ch->m_soloModel.saveSettings( _doc, fxch, "soloed" );
fxch.setAttribute( "num", i );
fxch.setAttribute( "name", ch->m_name );
fxch.setAttribute( "hascolor", ch->m_hasColor );
fxch.setAttribute( "mixercolor", ch->m_color.rgb() );
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved

// add the channel sends
for( int si = 0; si < ch->m_sends.size(); ++si )
Expand Down Expand Up @@ -786,6 +789,11 @@ void FxMixer::loadSettings( const QDomElement & _this )
m_fxChannels[num]->m_muteModel.loadSettings( fxch, "muted" );
m_fxChannels[num]->m_soloModel.loadSettings( fxch, "soloed" );
m_fxChannels[num]->m_name = fxch.attribute( "name" );
if( fxch.hasAttribute( "hascolor" ) )
{
m_fxChannels[num]->m_hasColor = fxch.attribute( "hascolor" ).toInt();
m_fxChannels[num]->m_color.setRgb( fxch.attribute( "mixercolor" ).toUInt() );
}

m_fxChannels[num]->m_fxChain.restoreState( fxch.firstChildElement(
m_fxChannels[num]->m_fxChain.nodeName() ) );
Expand Down
76 changes: 75 additions & 1 deletion src/gui/widgets/FxLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

#include "FxLine.h"

#include <cstdlib>
#include <ctime>

ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
#include <QColorDialog>
#include <QGraphicsProxyWidget>

#include "CaptionMenu.h"
Expand Down Expand Up @@ -120,6 +124,10 @@ FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex ) :
proxyWidget->setPos( 8, 145 );

connect( m_renameLineEdit, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) );

ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
connect( &Engine::fxMixer()->effectChannel( m_channelIndex )->m_muteModel, SIGNAL( dataChanged() ), this, SLOT( update() ) );

srand( time( 0 ) );
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
}


Expand Down Expand Up @@ -148,6 +156,7 @@ void FxLine::setChannelIndex( int index )
void FxLine::drawFxLine( QPainter* p, const FxLine *fxLine, bool isActive, bool sendToThis, bool receiveFromThis )
{
QString name = Engine::fxMixer()->effectChannel( m_channelIndex )->m_name;
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
bool muted = Engine::fxMixer()->effectChannel( m_channelIndex )->m_muteModel.value();
QString elidedName = elideName( name );
if( !m_inRename && m_renameLineEdit->text() != elidedName )
{
Expand All @@ -157,7 +166,13 @@ void FxLine::drawFxLine( QPainter* p, const FxLine *fxLine, bool isActive, bool
int width = fxLine->rect().width();
int height = fxLine->rect().height();

p->fillRect( fxLine->rect(), isActive ? fxLine->backgroundActive() : p->background() );
QColor color = muted ? ( isActive ? fxLine->backgroundActive().color() : p->background().color() )
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
: ( Engine::fxMixer()->effectChannel( m_channelIndex )->m_hasColor ? ( isActive ? Engine::fxMixer()->effectChannel( m_channelIndex )->m_color.darker( 120 )
: Engine::fxMixer()->effectChannel( m_channelIndex )->m_color.darker( 150 ) )
: ( isActive ? fxLine->backgroundActive().color()
: p->background().color() ) );

p->fillRect( fxLine->rect(), color );
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved

// inner border
p->setPen( isActive ? fxLine->strokeInnerActive() : fxLine->strokeInnerInactive() );
Expand Down Expand Up @@ -238,6 +253,11 @@ void FxLine::contextMenuEvent( QContextMenuEvent * )
contextMenu->addSeparator();
}
contextMenu->addAction( embed::getIconPixmap( "cancel" ), tr( "Remove &unused channels" ), this, SLOT( removeUnusedChannels() ) );

ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
contextMenu->addSeparator();
contextMenu->addAction( embed::getIconPixmap( "colorize" ), tr( "Set channel color" ), this, SLOT( changeColor() ) );
contextMenu->addAction( embed::getIconPixmap( "colorize" ), tr( "Remove channel color" ), this, SLOT( resetColor() ) );
contextMenu->addAction( embed::getIconPixmap( "colorize" ), tr( "Pick random channel color" ), this, SLOT( randomColor() ) );
contextMenu->exec( QCursor::pos() );
delete contextMenu;
}
Expand Down Expand Up @@ -395,3 +415,57 @@ void FxLine::setStrokeInnerInactive( const QColor & c )
{
m_strokeInnerInactive = c;
}

void FxLine::changeColor()
{
QColorDialog colorDialog( Engine::fxMixer()->effectChannel( m_channelIndex )->m_color );
Spekular marked this conversation as resolved.
Show resolved Hide resolved
QColor buffer( 0, 0, 0 );

for( int i = 0; i < 48; i += 6 )
{
for( int j = 0; j < 6; j++ )
{
buffer.setHsl( qMax( 0, 44 * ( i / 6 ) - 1 ), 150 - 20 * j, 140 - 10 * j );
colorDialog.setStandardColor( i + j, buffer );
}

}
ryuukumar marked this conversation as resolved.
Show resolved Hide resolved

ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
QColor new_color = colorDialog.getColor( Engine::fxMixer()->effectChannel( m_channelIndex )->m_color );
if( ! new_color.isValid() )
{ return; }

ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
Engine::fxMixer()->effectChannel( m_channelIndex )->m_color = new_color;
Engine::fxMixer()->effectChannel( m_channelIndex )->m_hasColor = true;

ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
update();
}

void FxLine::resetColor()
{
Engine::fxMixer()->effectChannel( m_channelIndex )->m_hasColor = false;
update();
}

void FxLine::randomColor()
{
int index = rand() % 48;
QColor buffer( 0, 0, 0 );

ryuukumar marked this conversation as resolved.
Show resolved Hide resolved
for( int i = 0; i < 48; i += 6 )
Spekular marked this conversation as resolved.
Show resolved Hide resolved
{
for( int j = 0; j < 6; j++ )
{
if( i + j + 1 == index )
{
buffer.setHsl( qMax( 0, 44 * ( i / 6 ) - 1 ), 150 - 20 * j, 140 - 10 * j );
break;
}
}

}

Engine::fxMixer()->effectChannel( m_channelIndex )->m_color = buffer;
Engine::fxMixer()->effectChannel( m_channelIndex )->m_hasColor = true;
update();
}