Skip to content

Commit

Permalink
Recover preset values from drymode (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
aroffringa authored Oct 11, 2019
1 parent ef504f4 commit 63871e2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ find_package(Threads REQUIRED)
find_library(AUBIO_LIBRARY NAMES aubio)
find_path(AUBIO_INCLUDE_DIR NAMES aubio/aubio.h)

set(CMAKE_CXX_FLAGS "-O3 -Wall -DNDEBUG -march=native -std=c++14")
set(CMAKE_CXX_FLAGS "-O3 -Wall -DNDEBUG -march=native -std=c++17")
set(CMAKE_C_FLAGS "-O3 -Wall -DNDEBUG -march=native")

include_directories(${GTKMM_INCLUDE_DIRS})
Expand Down
16 changes: 16 additions & 0 deletions gui/showwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ShowWindow::ShowWindow(std::unique_ptr<DmxDevice> device) :
_miDryMode("Dry mode"),
_miCancelDryMode("Cancel dry mode"),
_miSwapModes("Swap modes"),
_miRecover("Recover"),
_miBlackOutAndDryMode("Black-out with dry mode"),
_miBlackOut("Black-out"),
_miProtectBlackout("Protect black-out"),
Expand Down Expand Up @@ -255,6 +256,10 @@ void ShowWindow::createMenu()
_miSwapModes.signal_activate().connect(sigc::mem_fun(*this, &ShowWindow::onMISwapModesClicked));
_menuDesign.append(_miSwapModes);

_miRecover.set_sensitive(false);
_miRecover.signal_activate().connect(sigc::mem_fun(*this, &ShowWindow::onMIRecoverClicked));
_menuDesign.append(_miRecover);

_menuDesign.append(_miDesignSep1);

_miProtectBlackout.signal_activate().connect([&]() { onMIProtectedBlackOut(); });
Expand Down Expand Up @@ -428,6 +433,7 @@ void ShowWindow::updateDryModeState()
bool dryMode = _miDryMode.get_active();
_miCancelDryMode.set_sensitive(dryMode);
_miSwapModes.set_sensitive(dryMode);
_miRecover.set_sensitive(dryMode);
_miBlackOutAndDryMode.set_sensitive(!dryMode);
_miOpen.set_sensitive(!dryMode);
_miSave.set_sensitive(!dryMode);
Expand Down Expand Up @@ -505,6 +511,16 @@ void ShowWindow::onMISwapModesClicked()
}
}

void ShowWindow::onMIRecoverClicked()
{
if(_backgroundManagement)
{
_management->Recover(*_backgroundManagement);
for(std::unique_ptr<FaderWindow>& fw : _faderWindows)
fw->ReloadValues();
}
}

void ShowWindow::onMIBlackOutAndDryMode()
{
_miDryMode.set_active(false);
Expand Down
2 changes: 2 additions & 0 deletions gui/showwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ShowWindow : public Gtk::Window, public EventTransmitter {
void onMIDryModeClicked();
void onMICancelDryModeClicked();
void onMISwapModesClicked();
void onMIRecoverClicked();
void onMIBlackOutAndDryMode();
void onMIBlackOut();
void onMIProtectedBlackOut();
Expand Down Expand Up @@ -123,6 +124,7 @@ class ShowWindow : public Gtk::Window, public EventTransmitter {
Gtk::CheckMenuItem _miDryMode;
Gtk::MenuItem _miCancelDryMode;
Gtk::MenuItem _miSwapModes;
Gtk::MenuItem _miRecover;
Gtk::MenuItem _miBlackOutAndDryMode;
Gtk::MenuItem _miBlackOut;
Gtk::CheckMenuItem _miProtectBlackout;
Expand Down
17 changes: 17 additions & 0 deletions theatre/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,3 +641,20 @@ void Management::BlackOut()
p->SetValue(ControlValue::Zero());
}
}

void Management::Recover(Management& other)
{
std::scoped_lock<std::mutex, std::mutex> lock(other._mutex, _mutex);
for(const std::unique_ptr<PresetValue>& p : other._presetValues)
{
std::string path = p->Controllable().FullPath();
FolderObject* object = GetObjectFromPathIfExists(path);
Controllable* control = dynamic_cast<Controllable*>(object);
if(control)
{
PresetValue* value = GetPresetValue(*control, p->InputIndex());
if(value)
value->SetValue(p->Value());
}
}
}
2 changes: 2 additions & 0 deletions theatre/management.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class Management {

void BlackOut();

void Recover(Management& other);

private:
struct ManagementThread {
Management *parent;
Expand Down

0 comments on commit 63871e2

Please sign in to comment.