Skip to content

Commit

Permalink
Add else actions toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
Destroy666x authored and WarmUpTill committed Dec 9, 2023
1 parent cde111d commit 1f31b81
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 3 deletions.
2 changes: 2 additions & 0 deletions data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ AdvSceneSwitcher.macroTab.currentDockButtonText.unpause="Unpause button text:"
AdvSceneSwitcher.macroTab.currentDockStatusText.true="Conditions true text:"
AdvSceneSwitcher.macroTab.currentDockStatusText.false="Conditions false text:"
AdvSceneSwitcher.macroTab.currentDockHighlightIfExecuted="Highlight dock if macro actions were recently executed"
AdvSceneSwitcher.macroTab.toggleElseActions.hide.tooltip="Hide else actions"
AdvSceneSwitcher.macroTab.toggleElseActions.show.tooltip="Show else actions"

AdvSceneSwitcher.macroDock.pause="Pause"
AdvSceneSwitcher.macroDock.unpause="Unpause"
Expand Down
11 changes: 11 additions & 0 deletions data/res/images/DarkNotEqual.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions data/res/images/LightNotEqual.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions forms/advanced-scene-switcher.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,22 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="toggleElseActions">
<property name="maximumSize">
<size>
<width>22</width>
<height>16777215</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand Down
17 changes: 17 additions & 0 deletions src/advanced-scene-switcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ void AdvSceneSwitcher::LoadUI()
loading = false;
}

bool AdvSceneSwitcher::eventFilter(QObject *obj, QEvent *event)
{
auto eventType = event->type();
if (obj == ui->macroElseActions && eventType == QEvent::Resize) {
QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);

if (resizeEvent->size().height() == 0) {
SetElseActionsStateToHidden();
return QDialog::eventFilter(obj, event);
}

SetElseActionsStateToVisible();
}

return QDialog::eventFilter(obj, event);
}

/******************************************************************************
* Saving and loading
******************************************************************************/
Expand Down
8 changes: 7 additions & 1 deletion src/advanced-scene-switcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class AdvSceneSwitcher : public QDialog {
void RestoreWindowGeo();
void CheckFirstTimeSetup();

protected:
bool eventFilter(QObject *obj, QEvent *event) override;

/* --- Begin of general tab section --- */
public:
void SetupGeneralTab();
Expand Down Expand Up @@ -115,6 +118,7 @@ public slots:
void on_actionUp_clicked();
void on_actionDown_clicked();
void on_actionBottom_clicked();
void on_toggleElseActions_clicked();
void on_elseActionAdd_clicked();
void on_elseActionRemove_clicked();
void on_elseActionTop_clicked();
Expand Down Expand Up @@ -146,6 +150,8 @@ public slots:
void MaximizeElseActions();
void MinimizeConditions();
void MaximizeConditions();
void SetElseActionsStateToHidden();
void SetElseActionsStateToVisible();
void MacroActionSelectionChanged(int idx);
void MacroActionReorder(int to, int target);
void AddMacroAction(int idx);
Expand Down Expand Up @@ -334,7 +340,7 @@ public slots:
void on_timeUp_clicked();
void on_timeDown_clicked();

// Video tab
// Audio tab
public:
void SetupAudioTab();
public slots:
Expand Down
32 changes: 30 additions & 2 deletions src/macro-core/macro-tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,7 @@ void AdvSceneSwitcher::MacroSelectionAboutToChange()
// actions nor elseActions being visible when the condition <-> action
// splitter is moved
if (elsePos[0] == 0 && elsePos[1] == 0) {
macro->SetElseActionSplitterPosition(QList<int>()
<< 999999 << 0);
maximizeFirstSplitterEntry(ui->macroElseActionSplitter);
return;
}
macro->SetElseActionSplitterPosition(
Expand Down Expand Up @@ -790,6 +789,8 @@ bool shouldRestoreSplitter(const QList<int> &pos)

void AdvSceneSwitcher::SetupMacroTab()
{
ui->macroElseActions->installEventFilter(this);

if (switcher->macros.size() == 0 && !switcher->disableHints) {
addPulse = PulseWidget(ui->macroAdd, QColor(Qt::green));
}
Expand Down Expand Up @@ -862,6 +863,8 @@ void AdvSceneSwitcher::SetupMacroTab()
SetButtonIcon(ui->conditionTop, (pathPrefix + "DoubleUp.svg").c_str());
SetButtonIcon(ui->conditionBottom,
(pathPrefix + "DoubleDown.svg").c_str());
SetButtonIcon(ui->toggleElseActions,
(pathPrefix + "NotEqual.svg").c_str());

// Reserve more space for macro edit area than for the macro list
ui->macroListMacroEditSplitter->setStretchFactor(0, 1);
Expand Down Expand Up @@ -1100,6 +1103,31 @@ void AdvSceneSwitcher::MaximizeConditions()
MinimizeActions();
}

void AdvSceneSwitcher::on_toggleElseActions_clicked()
{
auto elsePosition = ui->macroElseActionSplitter->sizes();
if (elsePosition[1] == 0) {
centerSplitterPosition(ui->macroElseActionSplitter);
return;
}

maximizeFirstSplitterEntry(ui->macroElseActionSplitter);
}

void AdvSceneSwitcher::SetElseActionsStateToHidden()
{
ui->toggleElseActions->setToolTip(obs_module_text(
"AdvSceneSwitcher.macroTab.toggleElseActions.show.tooltip"));
ui->toggleElseActions->setChecked(false);
}

void AdvSceneSwitcher::SetElseActionsStateToVisible()
{
ui->toggleElseActions->setToolTip(obs_module_text(
"AdvSceneSwitcher.macroTab.toggleElseActions.hide.tooltip"));
ui->toggleElseActions->setChecked(true);
}

bool AdvSceneSwitcher::MacroTabIsInFocus()
{
return isActiveWindow() && isAncestorOf(focusWidget()) &&
Expand Down

0 comments on commit 1f31b81

Please sign in to comment.