@@ -31,7 +31,7 @@
|
||||
#include "ThreadableJob.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <optional>
|
||||
#include <QColor>
|
||||
|
||||
namespace lmms
|
||||
@@ -76,18 +76,13 @@ class MixerChannel : public ThreadableJob
|
||||
bool requiresProcessing() const override { return true; }
|
||||
void unmuteForSolo();
|
||||
|
||||
|
||||
void setColor (QColor newColor)
|
||||
{
|
||||
m_color = newColor;
|
||||
m_hasColor = true;
|
||||
}
|
||||
|
||||
// TODO C++17 and above: use std::optional instead
|
||||
QColor m_color;
|
||||
bool m_hasColor;
|
||||
std::optional<QColor> m_color;
|
||||
|
||||
|
||||
std::atomic_int m_dependenciesMet;
|
||||
void incrementDeps();
|
||||
void processed();
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "AutomatableModel.h"
|
||||
#include "JournallingObject.h"
|
||||
#include "lmms_basics.h"
|
||||
#include <optional>
|
||||
|
||||
|
||||
namespace lmms
|
||||
@@ -191,11 +192,11 @@ public:
|
||||
|
||||
QColor color()
|
||||
{
|
||||
return m_color;
|
||||
return m_color.value();
|
||||
}
|
||||
bool useColor()
|
||||
{
|
||||
return m_hasColor;
|
||||
return m_color.has_value();
|
||||
}
|
||||
|
||||
bool isMutedBeforeSolo() const
|
||||
@@ -241,8 +242,7 @@ private:
|
||||
|
||||
QMutex m_processingLock;
|
||||
|
||||
QColor m_color;
|
||||
bool m_hasColor;
|
||||
std::optional<QColor> m_color;
|
||||
|
||||
friend class gui::TrackView;
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ MixerChannel::MixerChannel( int idx, Model * _parent ) :
|
||||
m_lock(),
|
||||
m_channelIndex( idx ),
|
||||
m_queued( false ),
|
||||
m_hasColor( false ),
|
||||
m_dependenciesMet(0)
|
||||
{
|
||||
BufferManager::clear( m_buffer, Engine::audioEngine()->framesPerPeriod() );
|
||||
@@ -722,6 +721,7 @@ void Mixer::clearChannel(mix_ch_t index)
|
||||
ch->m_volumeModel.setDisplayName( ch->m_name + ">" + tr( "Volume" ) );
|
||||
ch->m_muteModel.setDisplayName( ch->m_name + ">" + tr( "Mute" ) );
|
||||
ch->m_soloModel.setDisplayName( ch->m_name + ">" + tr( "Solo" ) );
|
||||
ch->m_color = std::nullopt;
|
||||
|
||||
// send only to master
|
||||
if( index > 0)
|
||||
@@ -759,7 +759,7 @@ void Mixer::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
ch->m_soloModel.saveSettings( _doc, mixch, "soloed" );
|
||||
mixch.setAttribute( "num", i );
|
||||
mixch.setAttribute( "name", ch->m_name );
|
||||
if( ch->m_hasColor ) mixch.setAttribute( "color", ch->m_color.name() );
|
||||
if (ch->m_color.has_value()) { mixch.setAttribute("color", ch->m_color->name()); }
|
||||
|
||||
// add the channel sends
|
||||
for (const auto& send : ch->m_sends)
|
||||
@@ -807,8 +807,7 @@ void Mixer::loadSettings( const QDomElement & _this )
|
||||
m_mixerChannels[num]->m_name = mixch.attribute( "name" );
|
||||
if( mixch.hasAttribute( "color" ) )
|
||||
{
|
||||
m_mixerChannels[num]->m_hasColor = true;
|
||||
m_mixerChannels[num]->m_color.setNamedColor( mixch.attribute( "color" ) );
|
||||
m_mixerChannels[num]->m_color = QColor(mixch.attribute("color"));
|
||||
}
|
||||
|
||||
m_mixerChannels[num]->m_fxChain.restoreState( mixch.firstChildElement(
|
||||
|
||||
@@ -65,9 +65,8 @@ Track::Track( Type type, TrackContainer * tc ) :
|
||||
m_soloModel( false, this, tr( "Solo" ) ), /*!< For controlling track soloing */
|
||||
m_simpleSerializingMode( false ),
|
||||
m_clips(), /*!< The clips (segments) */
|
||||
m_color( 0, 0, 0 ),
|
||||
m_hasColor( false )
|
||||
{
|
||||
m_color(std::nullopt)
|
||||
{
|
||||
m_trackContainer->addTrack( this );
|
||||
m_height = -1;
|
||||
}
|
||||
@@ -209,9 +208,9 @@ void Track::saveSettings( QDomDocument & doc, QDomElement & element )
|
||||
element.setAttribute( "trackheight", m_height );
|
||||
}
|
||||
|
||||
if( m_hasColor )
|
||||
if (m_color.has_value())
|
||||
{
|
||||
element.setAttribute( "color", m_color.name() );
|
||||
element.setAttribute("color", m_color->name());
|
||||
}
|
||||
|
||||
QDomElement tsDe = doc.createElement( nodeName() );
|
||||
@@ -636,14 +635,13 @@ void Track::toggleSolo()
|
||||
|
||||
void Track::setColor(const QColor& c)
|
||||
{
|
||||
m_hasColor = true;
|
||||
m_color = c;
|
||||
emit colorChanged();
|
||||
}
|
||||
|
||||
void Track::resetColor()
|
||||
{
|
||||
m_hasColor = false;
|
||||
m_color = std::nullopt;
|
||||
emit colorChanged();
|
||||
}
|
||||
|
||||
@@ -653,4 +651,4 @@ BoolModel *Track::getMutedModel()
|
||||
return &m_mutedModel;
|
||||
}
|
||||
|
||||
} // namespace lmms
|
||||
} // namespace lmms
|
||||
|
||||
@@ -174,9 +174,9 @@ void MixerLine::drawMixerLine( QPainter* p, const MixerLine *mixerLine, bool isA
|
||||
int width = mixerLine->rect().width();
|
||||
int height = mixerLine->rect().height();
|
||||
|
||||
if( channel->m_hasColor && !muted )
|
||||
if (channel->m_color.has_value() && !muted)
|
||||
{
|
||||
p->fillRect( mixerLine->rect(), channel->m_color.darker( isActive ? 120 : 150 ) );
|
||||
p->fillRect(mixerLine->rect(), channel->m_color->darker(isActive ? 120 : 150));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -435,7 +435,7 @@ void MixerLine::setStrokeInnerInactive( const QColor & c )
|
||||
void MixerLine::selectColor()
|
||||
{
|
||||
auto channel = Engine::mixer()->mixerChannel( m_channelIndex );
|
||||
auto new_color = ColorChooser(this).withPalette(ColorChooser::Palette::Mixer)->getColor(channel->m_color);
|
||||
auto new_color = ColorChooser(this).withPalette(ColorChooser::Palette::Mixer)->getColor(channel->m_color.value_or(backgroundActive().color()));
|
||||
if(!new_color.isValid()) { return; }
|
||||
channel->setColor (new_color);
|
||||
Engine::getSong()->setModified();
|
||||
@@ -446,7 +446,7 @@ void MixerLine::selectColor()
|
||||
// Disable the usage of color on this mixer line
|
||||
void MixerLine::resetColor()
|
||||
{
|
||||
Engine::mixer()->mixerChannel( m_channelIndex )->m_hasColor = false;
|
||||
Engine::mixer()->mixerChannel(m_channelIndex)->m_color = std::nullopt;
|
||||
Engine::getSong()->setModified();
|
||||
update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user