Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
239d917
Automatic FX-mixer strip management #1215
spechtstatt May 15, 2022
2fb21b7
mend
spechtstatt May 20, 2022
c2bdf8a
made buildable
spechtstatt May 20, 2022
1e27fff
solve check issues
spechtstatt May 20, 2022
c6b2944
solve check issues
spechtstatt May 20, 2022
90f26ce
refactoring naming, removed unused methods, some optimization
spechtstatt May 21, 2022
2ba4982
Automatic mixer strip management #1215 - fix some issues with track n…
spechtstatt May 24, 2022
d1c5c29
Automatic mixer strip management #1215 - applied review recommendations
spechtstatt May 24, 2022
38cf295
Automatic mixer strip management #1215 - bugfix for 'frozen' mixer li…
spechtstatt May 24, 2022
5572288
Automatic mixer strip management #1215 - bugfix for broken mixer move
spechtstatt May 24, 2022
f7ed9be
make text/color changes work also from the mixer line side
spechtstatt Jun 2, 2022
fc785fd
button for enabling/disabling the functionality in the mixer
spechtstatt Jun 3, 2022
a7d0f68
Provide two-way linking, Prepared additional settings
spechtstatt Jun 10, 2022
76b0f50
Improved settings menu and added icons
spechtstatt Jun 11, 2022
dd139bf
Refactored setttings - set inactive alpha
spechtstatt Jun 11, 2022
e2c49ca
fixed settings menu - lambda capture for settings behaves strange
spechtstatt Jun 12, 2022
f8cec55
refactored settings menu - reduced redundancy
spechtstatt Jun 12, 2022
98b48ff
check also for channel send before deletion
spechtstatt Jun 12, 2022
c2c2acd
auto link text style update is now working correctly (was no SLOT)
spechtstatt Jun 13, 2022
14044ed
made buildable
spechtstatt Jun 23, 2022
8db4113
enable auto track linking when assigning new channel to track
spechtstatt Jul 10, 2022
b6e6e7a
update mixer line style after auto link is disabled
spechtstatt Jul 10, 2022
5e4d20a
made buildable
spechtstatt Jul 16, 2022
e2e7f8b
update mixerline style after autotrack link global enable/disable
spechtstatt Jul 16, 2022
477a433
auto sorting seems to work now but more testing needed
spechtstatt Jul 17, 2022
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
Prev Previous commit
Next Next commit
fixed settings menu - lambda capture for settings behaves strange
  • Loading branch information
spechtstatt committed Jul 16, 2022
commit e2c49caaee3959097a31bbba1601ec3d387ece26
35 changes: 35 additions & 0 deletions include/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,31 @@ class LMMS_EXPORT Mixer : public Model, public JournallingObject
return linkColor && !linkName;
}

bool getAsBoolOrDefault(const QString & text, bool defaultValue)
{
return (bool)getIntInRangeOrDefault(text, 0,1,defaultValue);
}

LinkMode getAsLinkModeOrCurrent(const QString & text)
{
return (LinkMode) getIntInRangeOrDefault(text,(int)LinkMode::OneToOne, (int)LinkMode::OneToMany,(int)linkMode);
}

AutoSort getAsAutoSortOrCurrent(const QString & text)
{
return (AutoSort) getIntInRangeOrDefault(text,(int)AutoSort::Disabled, (int)AutoSort::PatternLinked,(int)sort);
}

AutoAdd getAsAutoAddPatternEditorOrCurrent(const QString & text)
{
return (AutoAdd) getIntInRangeOrDefault(text,(int)AutoAdd::Disabled, (int)AutoAdd::UseFirstTrackOnly,(int)autoAddPatternEditor);
}

AutoAdd getAsAutoAddSongEditorOrCurrent(const QString & text)
{
return (AutoAdd) getIntInRangeOrDefault(text,(int)AutoAdd::Disabled, (int)AutoAdd::Separate,(int)autoAddSongEditor);
}

autoTrackLinkSettings()
{
enabled = false;
Expand All @@ -207,6 +232,16 @@ class LMMS_EXPORT Mixer : public Model, public JournallingObject
autoAddSongEditor = AutoAdd::Separate;
sort = AutoSort::Disabled;
}

private:
int getIntInRangeOrDefault(const QString & text, int lower, int upper, int defaultValue)
{
if (text == nullptr || text.isEmpty()) return defaultValue;
auto asInt = text.toInt();
if (asInt < lower || asInt >upper) return defaultValue;
return asInt;
}

};


Expand Down
1 change: 1 addition & 0 deletions include/MixerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ private slots:
void updateAutoTrackSortOrder(bool autoSort = true);
void deleteChannelInternal(int index);
void setAutoLinkTrackConfig(bool enabled);
void updateAutoLinkTrackConfigBtn(bool enabled);
void setAutoTrackConstraints();
void trackStyleToChannel(Track * track, MixerChannel * channel);
void channelStyleToTrack(MixerChannel * channel, Track * track);
Expand Down
29 changes: 17 additions & 12 deletions src/core/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,27 @@ void Mixer::toggleAutoTrackLink(int index)

Mixer::autoTrackLinkSettings Mixer::getAutoLinkTrackSettings()
{
autoTrackLinkSettings settings;
autoTrackLinkSettings settings = autoTrackLinkSettings();
auto cfg = ConfigManager::inst();
auto enabledAsString = cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX);
if (!enabledAsString.isEmpty())
{
settings.enabled = enabledAsString.toInt();
settings.linkColor = cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_linkColor").toInt();
settings.linkName = cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_linkName").toInt();
settings.autoDelete = cfg->value(AUTOTRACK_CONFIGID,AUTOTRACK_CONFIGPREFIX+"_autoDelete").toInt();
settings.linkMode = (autoTrackLinkSettings::LinkMode)
(cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_linkMode").toInt());
settings.autoAddPatternEditor = (autoTrackLinkSettings::AutoAdd)
(cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_autoAddPatternEditor").toInt());
settings.autoAddSongEditor = (autoTrackLinkSettings::AutoAdd)
(cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_autoAddSongEditor").toInt());
settings.sort = (autoTrackLinkSettings::AutoSort) (cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_sort").toInt());
settings.enabled = settings.getAsBoolOrDefault(
enabledAsString, settings.enabled);
settings.linkColor =settings.getAsBoolOrDefault(
cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_linkColor"),settings.linkColor);
settings.linkName = settings.getAsBoolOrDefault(
cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_linkName"),settings.linkName);
settings.autoDelete = settings.getAsBoolOrDefault(
cfg->value(AUTOTRACK_CONFIGID,AUTOTRACK_CONFIGPREFIX+"_autoDelete"),settings.autoDelete);
settings.linkMode = settings.getAsLinkModeOrCurrent(
cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_linkMode"));
settings.autoAddPatternEditor = settings.getAsAutoAddPatternEditorOrCurrent(
cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_autoAddPatternEditor"));
settings.autoAddSongEditor = settings.getAsAutoAddSongEditorOrCurrent(
cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_autoAddSongEditor"));
settings.sort = settings.getAsAutoSortOrCurrent(
cfg->value(AUTOTRACK_CONFIGID, AUTOTRACK_CONFIGPREFIX+"_sort"));
}
return settings;
}
Expand Down
76 changes: 52 additions & 24 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ MixerView::MixerView() :
m_toogleAutoLinkTrackConfigBtn = new QPushButton(this);
m_toogleAutoLinkTrackConfigBtn->setToolTip(tr("Enable/Disable auto track link"));
connect( m_toogleAutoLinkTrackConfigBtn, SIGNAL(clicked()), this, SLOT(toogleAutoLinkTrackConfig()));
setAutoLinkTrackConfig(Engine::mixer()->getAutoLinkTrackSettings().enabled);
updateAutoLinkTrackConfigBtn(Engine::mixer()->getAutoLinkTrackSettings().enabled);
bl->addWidget(m_toogleAutoLinkTrackConfigBtn, 0, Qt::AlignTop );


Expand Down Expand Up @@ -190,6 +190,8 @@ MixerView::MixerView() :

// we want to receive dataChanged-signals in order to update
setModel( m );

setAutoTrackConstraints();
}

MixerView::~MixerView()
Expand Down Expand Up @@ -221,37 +223,42 @@ void MixerView::updateMenu()
//QMenu* patternEditorMenu = settingsMenu->addMenu(tr("Pattern Editor"));

auto mix = Engine::mixer();
auto settings =mix->getAutoLinkTrackSettings();
// remark: capturing "settings" (also as pointer) does not work as expected
auto settings = mix->getAutoLinkTrackSettings();

linkStyleMenu->addAction( tr("Name and color") +
(settings.linkNameAndColor() ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.linkName = true;
settings.linkColor = true;
mix->saveAutoLinkTrackSettings(settings);
});
linkStyleMenu->addAction( tr("Color only") +
(settings.linkColorOnly() ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.linkName = false;
settings.linkColor = true;
mix->saveAutoLinkTrackSettings(settings);
});

linkModeMenu->addAction( tr("One track to one channel") +
(settings.linkMode == Mixer::autoTrackLinkSettings::LinkMode::OneToOne ? " *" :""),
this, [this, &settings, &mix]()
this, [this, mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.linkMode = Mixer::autoTrackLinkSettings::LinkMode::OneToOne;
mix->saveAutoLinkTrackSettings(settings);
setAutoTrackConstraints();
});
linkModeMenu->addAction( tr("Multiple tracks to one channel") +
(settings.linkMode == Mixer::autoTrackLinkSettings::LinkMode::OneToMany ? " *" :""),
this, [this,&settings, &mix]()
this, [this, mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.linkMode = Mixer::autoTrackLinkSettings::LinkMode::OneToMany;
mix->saveAutoLinkTrackSettings(settings);
setAutoTrackConstraints();
Expand All @@ -269,23 +276,26 @@ void MixerView::updateMenu()

sortAutoMenu->addAction(tr("Disabled") +
(settings.sort == Mixer::autoTrackLinkSettings::AutoSort::Disabled ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.sort = Mixer::autoTrackLinkSettings::AutoSort::Disabled;
mix->saveAutoLinkTrackSettings(settings);
});
sortAutoMenu->addAction( tr("Song Editor -> Pattern Editor") +
(settings.sort == Mixer::autoTrackLinkSettings::AutoSort::LinkedPattern ? " *" :""),
this, [this, &settings, &mix]()
this, [this, mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.sort = Mixer::autoTrackLinkSettings::AutoSort::LinkedPattern;
mix->saveAutoLinkTrackSettings(settings);
updateAutoTrackSortOrder();
});
sortAutoMenu->addAction( tr("Pattern Editor - > Song Editor") +
(settings.sort == Mixer::autoTrackLinkSettings::AutoSort::PatternLinked ? " *" :""),
this, [this, &settings, &mix]()
this, [this, mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.sort = Mixer::autoTrackLinkSettings::AutoSort::PatternLinked;
mix->saveAutoLinkTrackSettings(settings);
updateAutoTrackSortOrder();
Expand All @@ -296,22 +306,25 @@ void MixerView::updateMenu()

addAutoMenu->addAction( tr("Disabled") +
(settings.autoAddPatternEditor == Mixer::autoTrackLinkSettings::AutoAdd::Disabled ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.autoAddPatternEditor = Mixer::autoTrackLinkSettings::AutoAdd::Disabled;
mix->saveAutoLinkTrackSettings(settings);
});
addAutoMenu->addAction( tr("Each separate") +
(settings.autoAddPatternEditor == Mixer::autoTrackLinkSettings::AutoAdd::Separate ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.autoAddPatternEditor = Mixer::autoTrackLinkSettings::AutoAdd::Separate;
mix->saveAutoLinkTrackSettings(settings);
});
addAutoMenu->addAction( tr("Use first track's channel") +
(settings.autoAddPatternEditor == Mixer::autoTrackLinkSettings::AutoAdd::UseFirstTrackOnly ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.autoAddPatternEditor = Mixer::autoTrackLinkSettings::AutoAdd::UseFirstTrackOnly;
mix->saveAutoLinkTrackSettings(settings);
});
Expand All @@ -321,30 +334,34 @@ void MixerView::updateMenu()

addAutoMenu->addAction( tr("Disabled") +
(settings.autoAddSongEditor == Mixer::autoTrackLinkSettings::AutoAdd::Disabled ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.autoAddSongEditor = Mixer::autoTrackLinkSettings::AutoAdd::Disabled;
mix->saveAutoLinkTrackSettings(settings);
});
addAutoMenu->addAction( tr("Each separate") +
(settings.autoAddSongEditor == Mixer::autoTrackLinkSettings::AutoAdd::Separate ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.autoAddSongEditor = Mixer::autoTrackLinkSettings::AutoAdd::Separate;
mix->saveAutoLinkTrackSettings(settings);
});

deleteAutoMenu->addAction( tr("Disabled") +
(!settings.autoDelete ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.autoDelete = false;
mix->saveAutoLinkTrackSettings(settings);
});
deleteAutoMenu->addAction( tr("Enabled") +
(settings.autoDelete ? " *" :""),
this, [&settings, &mix]()
this, [mix]()
{
auto settings = mix->getAutoLinkTrackSettings();
settings.autoDelete = true;
mix->saveAutoLinkTrackSettings(settings);
});
Expand Down Expand Up @@ -458,21 +475,27 @@ void MixerView::setAutoTrackConstraints()
{
auto mix = Engine::mixer();
auto settings =mix->getAutoLinkTrackSettings();
if (!settings.enabled) return;
std::vector<int> usedChannelCounts = mix->getUsedChannelCounts();
bool wasModified = false;
for(unsigned long i = 0; i < usedChannelCounts.size(); i++)
{
// no more linked tracks or too many linked tracks
if (usedChannelCounts[i] == 0 || (usedChannelCounts[i] > 1 &&
settings.linkMode == Mixer::autoTrackLinkSettings::LinkMode::OneToOne))
if (settings.enabled)
{
mix->mixerChannel(i)->m_autoTrackLinkModel.setValue(false);
m_mixerChannelViews[i]->m_mixerLine->autoTrackLinkChanged();
wasModified = true;
// no more linked tracks or too many linked tracks
if (usedChannelCounts[i] == 0 || (usedChannelCounts[i] > 1 &&
settings.linkMode == Mixer::autoTrackLinkSettings::LinkMode::OneToOne))
{
mix->mixerChannel(i)->m_autoTrackLinkModel.setValue(false);
m_mixerChannelViews[i]->m_mixerLine->autoTrackLinkChanged();
wasModified = true;
}
}
// update mixer lines in both cases (enabling/disabling)
m_mixerChannelViews[i]->m_mixerLine->autoTrackLinkChanged();
}
if (!settings.enabled) return;

// make sure that the tracks are updated according to the auto link settings
mix->processAssignedTracks([this](Track * track, IntModel *, MixerChannel * channel)
mutable {
if (channel != nullptr)
Expand Down Expand Up @@ -529,12 +552,17 @@ void MixerView::setAutoLinkTrackConfig(bool enabled)
{
auto mix = Engine::mixer();
auto settings =mix->getAutoLinkTrackSettings();
updateAutoLinkTrackConfigBtn(enabled);
settings.enabled = enabled;
mix->saveAutoLinkTrackSettings(settings);
m_toogleAutoLinkTrackConfigBtn->setIcon(enabled ? embed::getIconPixmap( "auto_link_active" ) : embed::getIconPixmap( "auto_link_inactive" ));
setAutoTrackConstraints();
}

void MixerView::updateAutoLinkTrackConfigBtn(bool enabled)
{
m_toogleAutoLinkTrackConfigBtn->setIcon(enabled ? embed::getIconPixmap( "auto_link_active" ) : embed::getIconPixmap( "auto_link_inactive" ));
}

void MixerView::toogleAutoLinkTrackConfig()
{
auto mix = Engine::mixer();
Expand Down