UI rework (#44)

* rework general tab UI

* rework audio tab UI

* rework media tab UI

* rework time tab UI

* rework random tab UI

* rework window tab UI

* rework sreen region tab UI

* rework sequence tab UI

* rework transition tab UI

* adjust log messages to new format

* fix include path and warning

* highlight widgets to guide users (can be disabled)

* add helper frame for screen region tab

* rename main SceneSwitcher widget to AdvSceneSwitcher to resolve naming conflicts with the frontend tools on certain platforms (e.g. Debian 10)

* add media state 'any'

* adjust media switch handling to support vlc source
This commit is contained in:
WarmUpTill
2020-10-31 16:25:44 +01:00
committed by GitHub
parent 7edb6eb6c1
commit 214821b69f
35 changed files with 3975 additions and 4131 deletions

View File

@@ -1,63 +1,44 @@
#pragma once
#include <QDialog>
#include <memory>
#include <vector>
#include <string>
#ifdef BUILD_OUT_OF_TREE
#include "../../forms/ui_advanced-scene-switcher.h"
#else
#include "ui_advanced-scene-switcher.h"
#endif
#include "switcher-data-structs.hpp"
#include "volume-control.hpp"
#define blog(level, msg, ...) blog(level, "[adv-ss] " msg, ##__VA_ARGS__)
class QCloseEvent;
/*******************************************************************************
* Advanced Scene Switcher window
*******************************************************************************/
class SceneSwitcher : public QDialog {
class AdvSceneSwitcher : public QDialog {
Q_OBJECT
public:
std::unique_ptr<Ui_SceneSwitcher> ui;
VolControl *volMeter = nullptr;
std::unique_ptr<Ui_AdvSceneSwitcher> ui;
bool loading = true;
SceneSwitcher(QWidget *parent);
AdvSceneSwitcher(QWidget *parent);
void closeEvent(QCloseEvent *event) override;
void SetStarted();
void SetStopped();
int FindByData(const QString &window);
int ScreenRegionFindByData(const QString &region);
int PauseScenesFindByData(const QString &scene);
int PauseWindowsFindByData(const QString &window);
int IgnoreWindowsFindByData(const QString &window);
int SceneSequenceFindByData(const QString &scene1);
int SceneTransitionsFindByData(const QString &scene1,
const QString &scene2);
int DefaultTransitionsFindByData(const QString &scene);
int executableFindByData(const QString &exe);
int IgnoreIdleWindowsFindByData(const QString &window);
int randomFindByData(const QString &scene);
int timeFindByData(const timeTrigger &trigger, const QTime &time);
int audioFindByData(const QString &source, const int &volume);
void UpdateNonMatchingScene(const QString &name);
void UpdateAutoStopScene(const QString &name);
void UpdateAutoStartScene(const QString &name);
void UpdateIdleDataTransition(const QString &name);
void UpdateIdleDataScene(const QString &name);
void SetAudioVolumeMeter(const QString &name);
void loadUI();
void populateSceneSelection(QComboBox *sel, bool addPrevious);
void populateTransitionSelection(QComboBox *sel);
void populateWindowSelection(QComboBox *sel);
void setupGeneralTab();
void setupTitleTab();
void setupExecutableTab();
@@ -73,12 +54,31 @@ public:
void setupAudioTab();
void setTabOrder();
static void populateSceneSelection(QComboBox *sel,
bool addPrevious = false,
bool addSelect = true);
static void populateTransitionSelection(QComboBox *sel,
bool addSelect = true);
static void populateWindowSelection(QComboBox *sel,
bool addSelect = true);
static void populateAudioSelection(QComboBox *sel,
bool addSelect = true);
static void populateMediaSelection(QComboBox *sel,
bool addSelect = true);
static void populateProcessSelection(QComboBox *sel,
bool addSelect = true);
QMetaObject::Connection PulseWidget(QWidget *widget, QColor endColor,
QColor = QColor(0, 0, 0, 0),
QString specifier = "QLabel ");
bool listMoveUp(QListWidget *list);
bool listMoveDown(QListWidget *list);
public slots:
void on_switches_currentRowChanged(int idx);
void on_up_clicked();
void on_down_clicked();
void on_add_clicked();
void on_remove_clicked();
void on_windowUp_clicked();
void on_windowDown_clicked();
void on_windowAdd_clicked();
void on_windowRemove_clicked();
void on_noMatchDontSwitch_clicked();
void on_noMatchSwitch_clicked();
void on_noMatchRandomSwitch_clicked();
@@ -88,7 +88,8 @@ public slots:
void on_toggleStartButton_clicked();
void on_tabMoved(int from, int to);
void on_screenRegions_currentRowChanged(int idx);
void on_screenRegionSwitches_currentRowChanged(int idx);
void on_showFrame_clicked();
void on_screenRegionAdd_clicked();
void on_screenRegionRemove_clicked();
void on_screenRegionUp_clicked();
@@ -106,14 +107,12 @@ public slots:
void on_ignoreWindowsAdd_clicked();
void on_ignoreWindowsRemove_clicked();
void on_sceneSequences_currentRowChanged(int idx);
void on_sceneSequenceAdd_clicked();
void on_sceneSequenceRemove_clicked();
void on_sceneSequenceSave_clicked();
void on_sceneSequenceLoad_clicked();
void on_sceneSequenceUp_clicked();
void on_sceneSequenceDown_clicked();
void on_sceneSequenceDelayUnits_currentIndexChanged(int index);
void on_autoStopSceneCheckBox_stateChanged(int state);
void on_autoStopScenes_currentTextChanged(const QString &text);
@@ -123,16 +122,19 @@ public slots:
void on_autoStartScenes_currentTextChanged(const QString &text);
void on_verboseLogging_stateChanged(int state);
void on_uiHintsDisable_stateChanged(int state);
void on_exportSettings_clicked();
void on_importSettings_clicked();
void on_sceneTransitions_currentRowChanged(int idx);
void on_transitionsAdd_clicked();
void on_transitionsRemove_clicked();
void on_defaultTransitions_currentRowChanged(int idx);
void on_transitionsUp_clicked();
void on_transitionsDown_clicked();
void on_defaultTransitionsAdd_clicked();
void on_defaultTransitionsRemove_clicked();
void on_defaultTransitionsUp_clicked();
void on_defaultTransitionsDown_clicked();
void on_transitionOverridecheckBox_stateChanged(int state);
void on_browseButton_clicked();
@@ -146,7 +148,6 @@ public slots:
void on_executableDown_clicked();
void on_executableAdd_clicked();
void on_executableRemove_clicked();
void on_executables_currentRowChanged(int idx);
void on_idleCheckBox_stateChanged(int state);
void on_idleTransitions_currentTextChanged(const QString &text);
@@ -158,7 +159,6 @@ public slots:
void on_randomAdd_clicked();
void on_randomRemove_clicked();
void on_randomScenesList_currentRowChanged(int idx);
void on_fileAdd_clicked();
void on_fileRemove_clicked();
@@ -167,14 +167,11 @@ public slots:
void on_fileUp_clicked();
void on_fileDown_clicked();
void on_mediaSwitches_currentRowChanged(int idx);
void on_mediaAdd_clicked();
void on_mediaRemove_clicked();
void on_mediaUp_clicked();
void on_mediaDown_clicked();
void on_mediaTimeRestrictions_currentIndexChanged(int idx);
void on_timeSwitches_currentRowChanged(int idx);
void on_timeAdd_clicked();
void on_timeRemove_clicked();
void on_timeUp_clicked();
@@ -184,8 +181,6 @@ public slots:
void on_audioRemove_clicked();
void on_audioUp_clicked();
void on_audioDown_clicked();
void on_audioSwitches_currentRowChanged(int idx);
void on_audioSources_currentTextChanged(const QString &text);
void on_priorityUp_clicked();
void on_priorityDown_clicked();
@@ -226,13 +221,6 @@ bool isInFocus(const QString &executable);
/********************************************************************************
* Sceneswitch helper
********************************************************************************/
struct obs_weak_source;
typedef struct obs_weak_source obs_weak_source_t;
typedef struct transitionData {
std::string name = "";
int duration = 0;
} transitionData;
void setNextTransition(OBSWeakSource &targetScene, obs_source_t *currentSource,
OBSWeakSource &transition,

View File

@@ -1,115 +1,65 @@
#pragma once
#include <string>
#include "utility.hpp"
#include <QSpinBox>
#include "switch-generic.hpp"
#include "volume-control.hpp"
constexpr auto audio_func = 8;
constexpr auto default_priority_8 = audio_func;
struct AudioSwitch : virtual SceneSwitcherEntry {
OBSWeakSource audioSource;
int volumeThreshold;
float peak;
std::string audioSwitchStr;
obs_volmeter_t *volmeter;
OBSWeakSource audioSource = nullptr;
int volumeThreshold = 0;
float peak = -1;
obs_volmeter_t *volmeter = nullptr;
const char *getType() { return "audio"; }
bool initialized();
bool valid();
static void setVolumeLevel(void *data,
const float magnitude[MAX_AUDIO_CHANNELS],
const float peak[MAX_AUDIO_CHANNELS],
const float inputPeak[MAX_AUDIO_CHANNELS])
{
UNUSED_PARAMETER(magnitude);
UNUSED_PARAMETER(inputPeak);
AudioSwitch *s = static_cast<AudioSwitch *>(data);
const float inputPeak[MAX_AUDIO_CHANNELS]);
void resetVolmeter();
s->peak = peak[0];
for (int i = 1; i < MAX_AUDIO_CHANNELS; i++)
if (peak[i] > s->peak)
s->peak = peak[i];
}
bool valid()
{
return (usePreviousScene || WeakSourceValid(scene)) &&
WeakSourceValid(audioSource) &&
WeakSourceValid(transition);
}
inline AudioSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
OBSWeakSource audioSource_, int volumeThreshold_,
bool usePreviousScene_, std::string audioSwitchStr_)
: SceneSwitcherEntry(scene_, transition_, usePreviousScene_),
audioSource(audioSource_),
volumeThreshold(volumeThreshold_),
audioSwitchStr(audioSwitchStr_)
{
volmeter = obs_volmeter_create(OBS_FADER_LOG);
obs_volmeter_add_callback(volmeter, setVolumeLevel, this);
obs_source_t *as = obs_weak_source_get_source(audioSource);
if (!obs_volmeter_attach_source(volmeter, as)) {
const char *name = obs_source_get_name(as);
blog(LOG_WARNING,
"failed to attach volmeter to source %s", name);
}
obs_source_release(as);
}
AudioSwitch(const AudioSwitch &other)
: SceneSwitcherEntry(other.scene, other.transition,
other.usePreviousScene),
audioSource(other.audioSource),
volumeThreshold(other.volumeThreshold),
audioSwitchStr(other.audioSwitchStr)
{
volmeter = obs_volmeter_create(OBS_FADER_LOG);
obs_volmeter_add_callback(volmeter, setVolumeLevel, this);
obs_source_t *as =
obs_weak_source_get_source(other.audioSource);
if (!obs_volmeter_attach_source(volmeter, as)) {
const char *name = obs_source_get_name(as);
blog(LOG_WARNING,
"failed to attach volmeter to source %s", name);
}
obs_source_release(as);
}
AudioSwitch(AudioSwitch &&other)
: SceneSwitcherEntry(other.scene, other.transition,
other.usePreviousScene),
audioSource(other.audioSource),
volumeThreshold(other.volumeThreshold),
audioSwitchStr(other.audioSwitchStr),
volmeter(other.volmeter)
{
other.volmeter = nullptr;
}
inline ~AudioSwitch()
{
obs_volmeter_remove_callback(volmeter, setVolumeLevel, this);
obs_volmeter_destroy(volmeter);
}
AudioSwitch &operator=(const AudioSwitch &other)
{
return *this = AudioSwitch(other);
}
AudioSwitch &operator=(AudioSwitch &&other) noexcept
{
if (this == &other) {
return *this;
}
obs_volmeter_destroy(volmeter);
volmeter = other.volmeter;
other.volmeter = nullptr;
return *this;
}
AudioSwitch(){};
AudioSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
OBSWeakSource audioSource_, int volumeThreshold_,
bool usePreviousScene_);
AudioSwitch(const AudioSwitch &other);
AudioSwitch(AudioSwitch &&other);
~AudioSwitch();
AudioSwitch &operator=(const AudioSwitch &other);
AudioSwitch &operator=(AudioSwitch &&other) noexcept;
friend void swap(AudioSwitch &first, AudioSwitch &second);
};
static inline QString MakeAudioSwitchName(const QString &scene,
const QString &transition,
const QString &audioSrouce,
const int &volume);
class AudioSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
AudioSwitchWidget(AudioSwitch *s);
void UpdateVolmeterSource();
AudioSwitch *getSwitchData();
void setSwitchData(AudioSwitch *s);
static void swapSwitchData(AudioSwitchWidget *as1,
AudioSwitchWidget *as2);
private slots:
void SourceChanged(const QString &text);
void VolumeThresholdChanged(int vol);
private:
QComboBox *audioSources;
QSpinBox *audioVolumeThreshold;
VolControl *volMeter;
QLabel *whenLabel;
QLabel *aboveLabel;
QLabel *switchLabel;
QLabel *usingLabel;
AudioSwitch *switchData;
};

View File

@@ -1,20 +1,19 @@
#pragma once
#include <string>
#include "utility.hpp"
#include <QCheckBox>
#include "switch-generic.hpp"
constexpr auto exe_func = 3;
constexpr auto default_priority_3 = exe_func;
struct ExecutableSceneSwitch : SceneSwitcherEntry {
QString exe;
bool inFocus;
struct ExecutableSwitch : SceneSwitcherEntry {
QString exe = "";
bool inFocus = false;
const char *getType() { return "exec"; }
inline ExecutableSceneSwitch(OBSWeakSource scene_,
OBSWeakSource transition_,
const QString &exe_, bool inFocus_)
inline ExecutableSwitch(){};
inline ExecutableSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
const QString &exe_, bool inFocus_)
: SceneSwitcherEntry(scene_, transition_),
exe(exe_),
inFocus(inFocus_)
@@ -22,7 +21,28 @@ struct ExecutableSceneSwitch : SceneSwitcherEntry {
}
};
static inline QString MakeSwitchNameExecutable(const QString &scene,
const QString &value,
const QString &transition,
bool inFocus);
class ExecutableSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
ExecutableSwitchWidget(ExecutableSwitch *s);
ExecutableSwitch *getSwitchData();
void setSwitchData(ExecutableSwitch *s);
static void swapSwitchData(ExecutableSwitchWidget *s1,
ExecutableSwitchWidget *s2);
private slots:
void ProcessChanged(const QString &text);
void FocusChanged(int state);
private:
QComboBox *processes;
QCheckBox *requiresFocus;
QLabel *whenLabel;
QLabel *switchLabel;
QLabel *usingLabel;
ExecutableSwitch *switchData;
};

View File

@@ -1,6 +1,4 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
constexpr auto read_file_func = 0;

View File

@@ -1,48 +1,50 @@
#pragma once
#include <string>
#include <obs.hpp>
#include <QComboBox>
struct SceneSwitcherEntry {
OBSWeakSource scene;
OBSWeakSource transition;
bool usePreviousScene;
virtual bool valid()
{
return (usePreviousScene || WeakSourceValid(scene)) &&
WeakSourceValid(transition);
}
OBSWeakSource scene = nullptr;
OBSWeakSource transition = nullptr;
bool usePreviousScene = false;
virtual const char *getType() = 0;
virtual bool initialized();
virtual bool valid();
virtual void logMatch();
// TODO
//virtual bool checkMatch() = 0;
virtual void logMatch()
{
obs_source_t *s = obs_weak_source_get_source(scene);
const char *sceneName = obs_source_get_name(s);
obs_source_release(s);
blog(LOG_INFO,
"Advanced Scene Switcher match for '%s' - switch to scene '%s'",
getType(), sceneName);
}
inline SceneSwitcherEntry() : usePreviousScene(false) {}
inline SceneSwitcherEntry() {}
inline SceneSwitcherEntry(OBSWeakSource scene_,
OBSWeakSource transition_,
bool usePreviousScene_)
bool usePreviousScene_ = false)
: scene(scene_),
transition(transition_),
usePreviousScene(usePreviousScene_)
{
}
inline SceneSwitcherEntry(OBSWeakSource scene_,
OBSWeakSource transition_)
: scene(scene_),
transition(transition_),
usePreviousScene(false)
{
}
virtual ~SceneSwitcherEntry() {}
};
class SwitchWidget : public QWidget {
Q_OBJECT
public:
SwitchWidget(SceneSwitcherEntry *s, bool usePreviousScene = true);
virtual SceneSwitcherEntry *getSwitchData();
virtual void setSwitchData(SceneSwitcherEntry *s);
static void swapSwitchData(SwitchWidget *s1, SwitchWidget *s2);
private slots:
void SceneChanged(const QString &text);
void TransitionChanged(const QString &text);
protected:
bool loading = true;
QComboBox *scenes;
QComboBox *transitions;
SceneSwitcherEntry *switchData;
};

View File

@@ -1,6 +1,4 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
constexpr auto default_idle_time = 60;

View File

@@ -1,6 +1,4 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
constexpr auto media_func = 6;
@@ -15,36 +13,67 @@ typedef enum {
} time_restriction;
struct MediaSwitch : SceneSwitcherEntry {
OBSWeakSource source;
obs_media_state state;
time_restriction restriction;
int64_t time;
bool matched;
std::string mediaSwitchStr;
OBSWeakSource source = nullptr;
obs_media_state state = OBS_MEDIA_STATE_NONE;
bool anyState = false;
time_restriction restriction = TIME_RESTRICTION_NONE;
int64_t time = 0;
std::atomic<bool> stopped = false;
std::atomic<bool> ended = false;
const char *getType() { return "meida"; }
// workaround to enable use of "ended" to specify end of VLC playlist
bool previousStateEnded = false;
bool valid()
{
return (usePreviousScene || WeakSourceValid(scene)) &&
WeakSourceValid(source) && WeakSourceValid(transition);
}
const char *getType() { return "media"; }
bool initialized();
bool valid();
void clearSignalHandler();
void resetSignalHandler();
static void MediaStopped(void *data, calldata_t *);
static void MediaEnded(void *data, calldata_t *);
inline MediaSwitch(){};
inline MediaSwitch(OBSWeakSource scene_, OBSWeakSource source_,
OBSWeakSource transition_, obs_media_state state_,
time_restriction restriction_, uint64_t time_,
bool usePreviousScene_, std::string mediaSwitchStr_)
: SceneSwitcherEntry(scene_, transition_, usePreviousScene_),
source(source_),
state(state_),
restriction(restriction_),
time(time_),
mediaSwitchStr(mediaSwitchStr_)
{
}
bool usePreviousScene_);
MediaSwitch(const MediaSwitch &other);
MediaSwitch(MediaSwitch &&other);
~MediaSwitch();
MediaSwitch &operator=(const MediaSwitch &other);
MediaSwitch &operator=(MediaSwitch &&other) noexcept;
friend void swap(MediaSwitch &first, MediaSwitch &second);
};
static inline QString
MakeMediaSwitchName(const QString &source, const QString &scene,
const QString &transition, obs_media_state state,
time_restriction restriction, uint64_t time);
class MediaSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
MediaSwitchWidget(MediaSwitch *s);
MediaSwitch *getSwitchData();
void setSwitchData(MediaSwitch *s);
static void swapSwitchData(MediaSwitchWidget *s1,
MediaSwitchWidget *s2);
private slots:
void SourceChanged(const QString &text);
void StateChanged(int index);
void TimeRestrictionChanged(int index);
void TimeChanged(int time);
private:
QComboBox *meidaSources;
QComboBox *states;
QComboBox *timeRestrictions;
QSpinBox *time;
QLabel *whenLabel;
QLabel *stateLabel;
QLabel *andLabel;
QLabel *switchLabel;
QLabel *usingLabel;
MediaSwitch *switchData;
};

View File

@@ -1,23 +1,39 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
struct RandomSwitch : SceneSwitcherEntry {
double delay;
std::string randomSwitchStr;
double delay = 0.0;
const char *getType() { return "random"; }
inline RandomSwitch() {}
inline RandomSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
double delay_, std::string str)
: SceneSwitcherEntry(scene_, transition_),
delay(delay_),
randomSwitchStr(str)
double delay_)
: SceneSwitcherEntry(scene_, transition_), delay(delay_)
{
}
};
static inline QString MakeRandomSwitchName(const QString &scene,
const QString &transition,
double &delay);
class RandomSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
RandomSwitchWidget(RandomSwitch *s);
RandomSwitch *getSwitchData();
void setSwitchData(RandomSwitch *s);
static void swapSwitchData(RandomSwitchWidget *s1,
RandomSwitchWidget *s2);
private slots:
void DelayChanged(double d);
private:
QDoubleSpinBox *delay;
QLabel *switchLabel;
QLabel *usingLabel;
QLabel *forLabel;
RandomSwitch *switchData;
};

View File

@@ -1,32 +1,62 @@
#pragma once
#include <string>
#include "utility.hpp"
#include <QSpinBox>
#include "switch-generic.hpp"
constexpr auto screen_region_func = 4;
constexpr auto default_priority_4 = screen_region_func;
struct ScreenRegionSwitch : SceneSwitcherEntry {
int minX, minY, maxX, maxY;
std::string regionStr;
int minX = 0, minY = 0, maxX = 0, maxY = 0;
const char *getType() { return "region"; }
inline ScreenRegionSwitch(){};
inline ScreenRegionSwitch(OBSWeakSource scene_,
OBSWeakSource transition_, int minX_,
int minY_, int maxX_, int maxY_,
std::string regionStr_)
int minY_, int maxX_, int maxY_)
: SceneSwitcherEntry(scene_, transition_),
minX(minX_),
minY(minY_),
maxX(maxX_),
maxY(maxY_),
regionStr(regionStr_)
maxY(maxY_)
{
}
};
static inline QString MakeScreenRegionSwitchName(const QString &scene,
const QString &transition,
int minX, int minY, int maxX,
int maxY);
class ScreenRegionWidget : public SwitchWidget {
Q_OBJECT
public:
ScreenRegionWidget(ScreenRegionSwitch *s);
ScreenRegionSwitch *getSwitchData();
void setSwitchData(ScreenRegionSwitch *s);
static void swapSwitchData(ScreenRegionWidget *s1,
ScreenRegionWidget *s2);
void showFrame();
void hideFrame();
private slots:
void MinXChanged(int pos);
void MinYChanged(int pos);
void MaxXChanged(int pos);
void MaxYChanged(int pos);
private:
QSpinBox *minX;
QSpinBox *minY;
QSpinBox *maxX;
QSpinBox *maxY;
QFrame helperFrame;
QLabel *cursorLabel;
QLabel *xLabel;
QLabel *switchLabel;
QLabel *usingLabel;
ScreenRegionSwitch *switchData;
void drawFrame();
};

View File

@@ -0,0 +1,64 @@
#pragma once
#include "switch-generic.hpp"
constexpr auto round_trip_func = 1;
constexpr auto default_priority_1 = round_trip_func;
typedef enum {
SECONDS,
MINUTES,
HOURS,
} delay_units;
struct SceneSequenceSwitch : SceneSwitcherEntry {
OBSWeakSource startScene = nullptr;
double delay = 0;
int delayMultiplier = 1;
const char *getType() { return "sequence"; }
bool initialized();
bool valid();
void logSleep(int dur);
inline SceneSequenceSwitch(){};
inline SceneSequenceSwitch(OBSWeakSource startScene_,
OBSWeakSource scene_,
OBSWeakSource transition_, double delay_,
int delayMultiplier_, bool usePreviousScene_)
: SceneSwitcherEntry(scene_, transition_, usePreviousScene_),
startScene(startScene_),
delay(delay_),
delayMultiplier(delayMultiplier_)
{
}
};
class SequenceWidget : public SwitchWidget {
Q_OBJECT
public:
SequenceWidget(SceneSequenceSwitch *s);
SceneSequenceSwitch *getSwitchData();
void setSwitchData(SceneSequenceSwitch *s);
static void swapSwitchData(SequenceWidget *s1, SequenceWidget *s2);
void UpdateDelay();
private slots:
void DelayChanged(double delay);
void DelayUnitsChanged(int idx);
void StartSceneChanged(const QString &text);
private:
QDoubleSpinBox *delay;
QComboBox *delayUnits;
QComboBox *startScenes;
QLabel *whenLabel;
QLabel *switchLabel;
QLabel *afterLabel;
QLabel *usingLabel;
SceneSequenceSwitch *switchData;
};

View File

@@ -1,7 +1,6 @@
#pragma once
#include <string>
#include <QDateTime>
#include "utility.hpp"
#include <QTimeEdit>
#include "switch-generic.hpp"
constexpr auto time_func = 7;
@@ -20,24 +19,43 @@ typedef enum {
} timeTrigger;
struct TimeSwitch : SceneSwitcherEntry {
timeTrigger trigger;
QTime time;
std::string timeSwitchStr;
timeTrigger trigger = ANY_DAY;
QTime time = QTime();
const char *getType() { return "time"; }
inline TimeSwitch(){};
inline TimeSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
timeTrigger trigger_, QTime time_,
bool usePreviousScene_, std::string timeSwitchStr_)
bool usePreviousScene_)
: SceneSwitcherEntry(scene_, transition_, usePreviousScene_),
trigger(trigger_),
time(time_),
timeSwitchStr(timeSwitchStr_)
time(time_)
{
}
};
static inline QString MakeTimeSwitchName(const QString &scene,
const QString &transition,
const timeTrigger &trigger,
const QTime &time);
class TimeSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
TimeSwitchWidget(TimeSwitch *s);
TimeSwitch *getSwitchData();
void setSwitchData(TimeSwitch *s);
static void swapSwitchData(TimeSwitchWidget *s1, TimeSwitchWidget *s2);
private slots:
void TriggerChanged(int index);
void TimeChanged(const QTime &time);
private:
QComboBox *triggers;
QTimeEdit *time;
QLabel *atLabel;
QLabel *switchLabel;
QLabel *usingLabel;
TimeSwitch *switchData;
};

View File

@@ -1,47 +1,71 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
struct SceneTransition : SceneSwitcherEntry {
OBSWeakSource scene2;
std::string sceneTransitionStr;
OBSWeakSource scene2 = nullptr;
const char *getType() { return "transition"; }
bool initialized();
bool valid();
bool valid()
{
return (WeakSourceValid(scene) && WeakSourceValid(scene2)) &&
WeakSourceValid(transition);
}
inline SceneTransition(){};
inline SceneTransition(OBSWeakSource scene_, OBSWeakSource scene2_,
OBSWeakSource transition_,
std::string sceneTransitionStr_)
: SceneSwitcherEntry(scene_, transition_),
scene2(scene2_),
sceneTransitionStr(sceneTransitionStr_)
OBSWeakSource transition_)
: SceneSwitcherEntry(scene_, transition_), scene2(scene2_)
{
}
};
static inline QString MakeSceneTransitionName(const QString &scene1,
const QString &scene2,
const QString &transition);
struct DefaultSceneTransition : SceneSwitcherEntry {
std::string sceneTransitionStr;
const char *getType() { return "def_transition"; }
inline DefaultSceneTransition(){};
inline DefaultSceneTransition(OBSWeakSource scene_,
OBSWeakSource transition_,
std::string sceneTransitionStr_)
: SceneSwitcherEntry(scene_, transition_),
sceneTransitionStr(sceneTransitionStr_)
OBSWeakSource transition_)
: SceneSwitcherEntry(scene_, transition_)
{
}
};
static inline QString MakeDefaultSceneTransitionName(const QString &scene,
const QString &transition);
class TransitionSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
TransitionSwitchWidget(SceneTransition *s);
SceneTransition *getSwitchData();
void setSwitchData(SceneTransition *s);
static void swapSwitchData(TransitionSwitchWidget *s1,
TransitionSwitchWidget *s2);
private slots:
void Scene2Changed(const QString &text);
private:
QComboBox *scenes2;
QLabel *switchLabel;
QLabel *toLabel;
QLabel *usingLabel;
SceneTransition *switchData;
};
class DefTransitionSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
DefTransitionSwitchWidget(DefaultSceneTransition *s);
DefaultSceneTransition *getSwitchData();
void setSwitchData(DefaultSceneTransition *s);
static void swapSwitchData(DefTransitionSwitchWidget *s1,
DefTransitionSwitchWidget *s2);
private:
QLabel *whenLabel;
QLabel *switchLabel;
DefaultSceneTransition *switchData;
};

View File

@@ -1,22 +1,21 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
constexpr auto window_title_func = 5;
constexpr auto default_priority_5 = window_title_func;
struct WindowSceneSwitch : SceneSwitcherEntry {
std::string window;
bool fullscreen;
bool maximized;
bool focus;
struct WindowSwitch : SceneSwitcherEntry {
std::string window = "";
bool fullscreen = false;
bool maximized = false;
bool focus = true;
const char *getType() { return "window"; }
inline WindowSceneSwitch(OBSWeakSource scene_, const char *window_,
OBSWeakSource transition_, bool fullscreen_,
bool maximized_, bool focus_)
inline WindowSwitch() {}
inline WindowSwitch(OBSWeakSource scene_, const char *window_,
OBSWeakSource transition_, bool fullscreen_,
bool maximized_, bool focus_)
: SceneSwitcherEntry(scene_, transition_),
window(window_),
fullscreen(fullscreen_),
@@ -26,8 +25,28 @@ struct WindowSceneSwitch : SceneSwitcherEntry {
}
};
static inline QString MakeWindowSwitchName(const QString &scene,
const QString &value,
const QString &transition,
bool fullscreen, bool maximized,
bool focus);
class WindowSwitchWidget : public SwitchWidget {
Q_OBJECT
public:
WindowSwitchWidget(WindowSwitch *s);
WindowSwitch *getSwitchData();
void setSwitchData(WindowSwitch *s);
static void swapSwitchData(WindowSwitchWidget *s1,
WindowSwitchWidget *s2);
private slots:
void WindowChanged(const QString &text);
void FullscreenChanged(int state);
void MaximizedChanged(int state);
void FocusChanged(int state);
private:
QComboBox *windows;
QCheckBox *fullscreen;
QCheckBox *maximized;
QCheckBox *focused;
WindowSwitch *switchData;
};

View File

@@ -1,7 +1,7 @@
#pragma once
#include <condition_variable>
#include <string>
#include <vector>
#include <deque>
#include <mutex>
#include <QDateTime>
#include <QThread>
@@ -17,7 +17,7 @@
#include "switch-time.hpp"
#include "switch-transitions.hpp"
#include "switch-window.hpp"
#include "swtich-sequence.hpp"
#include "switch-sequence.hpp"
constexpr auto default_interval = 300;
constexpr auto previous_scene_name = "Previous Scene";
@@ -30,6 +30,12 @@ typedef enum {
RECORINDGSTREAMING = 2
} AutoStartType;
typedef struct transitionData {
std::string name = "";
int duration = 0;
} transitionData;
class SwitcherThread;
/********************************************************************************
@@ -45,6 +51,8 @@ struct SwitcherData {
std::condition_variable transitionCv;
bool stop = false;
bool verbose = false;
bool disableHints = false;
bool showFrame = false;
bool tansitionOverrideOverride = false;
int interval = default_interval;
@@ -57,11 +65,11 @@ struct SwitcherData {
NoMatch switchIfNotMatching = NO_SWITCH;
StartupBehavior startupBehavior = PERSIST;
std::vector<WindowSceneSwitch> windowSwitches;
std::deque<WindowSwitch> windowSwitches;
std::vector<std::string> ignoreIdleWindows;
std::string lastTitle;
std::vector<ScreenRegionSwitch> screenRegionSwitches;
std::deque<ScreenRegionSwitch> screenRegionSwitches;
std::vector<OBSWeakSource> pauseScenesSwitches;
@@ -69,17 +77,17 @@ struct SwitcherData {
std::vector<std::string> ignoreWindowsSwitches;
std::vector<SceneSequenceSwitch> sceneSequenceSwitches;
int sceneSequenceMultiplier = 1;
std::deque<SceneSequenceSwitch> sceneSequenceSwitches;
std::vector<RandomSwitch> randomSwitches;
std::deque<RandomSwitch> randomSwitches;
IdleData idleData;
FileIOData fileIO;
IdleData idleData;
std::vector<FileSwitch> fileSwitches;
CURL *curl = nullptr;
std::vector<ExecutableSceneSwitch> executableSwitches;
std::deque<ExecutableSwitch> executableSwitches;
bool autoStopEnable = false;
OBSWeakSource autoStopScene;
@@ -89,15 +97,16 @@ struct SwitcherData {
OBSWeakSource autoStartScene;
bool autoStartedRecently = false;
std::vector<SceneTransition> sceneTransitions;
std::vector<DefaultSceneTransition> defaultSceneTransitions;
std::deque<SceneTransition> sceneTransitions;
std::deque<DefaultSceneTransition> defaultSceneTransitions;
bool changedDefTransitionRecently = false;
std::vector<MediaSwitch> mediaSwitches;
std::deque<MediaSwitch> mediaSwitches;
std::vector<TimeSwitch> timeSwitches;
std::deque<TimeSwitch> timeSwitches;
QDateTime liveTime;
std::vector<AudioSwitch> audioSwitches;
std::deque<AudioSwitch> audioSwitches;
std::vector<int> functionNamesByPriority = std::vector<int>{
default_priority_0, default_priority_1, default_priority_2,
@@ -150,8 +159,8 @@ struct SwitcherData {
void autoStartStreamRecording();
bool checkPause();
void checkSceneSequence(bool &match, OBSWeakSource &scene,
OBSWeakSource &transition,
std::unique_lock<std::mutex> &lock);
OBSWeakSource &transition,
std::unique_lock<std::mutex> &lock);
void checkIdleSwitch(bool &match, OBSWeakSource &scene,
OBSWeakSource &transition);
void checkWindowTitleSwitch(bool &match, OBSWeakSource &scene,

View File

@@ -1,44 +0,0 @@
#pragma once
#include <string>
#include "utility.hpp"
#include "switch-generic.hpp"
constexpr auto round_trip_func = 1;
constexpr auto default_priority_1 = round_trip_func;
struct SceneSequenceSwitch : SceneSwitcherEntry {
OBSWeakSource startScene;
double delay;
std::string sceneSequenceStr;
const char *getType() { return "sequence"; }
bool valid()
{
return WeakSourceValid(startScene) &&
(usePreviousScene || WeakSourceValid(scene)) &&
WeakSourceValid(transition);
}
void logSleep(int dur)
{
blog(LOG_INFO, "Advanced Scene Switcher sequence sleep %d",
dur);
}
inline SceneSequenceSwitch(OBSWeakSource startScene_,
OBSWeakSource scene_,
OBSWeakSource transition_, double delay_,
bool usePreviousScene_, std::string str)
: SceneSwitcherEntry(scene_, transition_, usePreviousScene_),
startScene(startScene_),
delay(delay_),
sceneSequenceStr(str)
{
}
};
static inline QString MakeSceneSequenceSwitchName(const QString &scene1,
const QString &scene2,
const QString &transition,
double delay);