2014-03-23 01:07:54 -07:00
|
|
|
#pragma once
|
|
|
|
|
2015-01-03 03:03:04 -08:00
|
|
|
#include "vertical-scroll-area.hpp"
|
2014-03-23 01:07:54 -07:00
|
|
|
#include <obs.hpp>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class QFormLayout;
|
|
|
|
class OBSPropertiesView;
|
2014-06-27 19:55:47 -07:00
|
|
|
class QLabel;
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2014-09-30 06:36:50 -07:00
|
|
|
typedef obs_properties_t *(*PropertiesReloadCallback)(void *obj);
|
|
|
|
typedef void (*PropertiesUpdateCallback)(void *obj,
|
|
|
|
obs_data_t *settings);
|
2014-03-23 01:07:54 -07:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
class WidgetInfo : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
OBSPropertiesView *view;
|
2014-09-25 17:44:05 -07:00
|
|
|
obs_property_t *property;
|
2014-03-23 01:07:54 -07:00
|
|
|
QWidget *widget;
|
|
|
|
|
|
|
|
void BoolChanged(const char *setting);
|
|
|
|
void IntChanged(const char *setting);
|
|
|
|
void FloatChanged(const char *setting);
|
|
|
|
void TextChanged(const char *setting);
|
2014-06-27 19:55:47 -07:00
|
|
|
bool PathChanged(const char *setting);
|
2014-03-23 01:07:54 -07:00
|
|
|
void ListChanged(const char *setting);
|
2014-07-19 12:00:14 -07:00
|
|
|
bool ColorChanged(const char *setting);
|
2014-08-17 05:50:30 -07:00
|
|
|
bool FontChanged(const char *setting);
|
2014-05-30 02:44:14 -07:00
|
|
|
void ButtonClicked();
|
2014-03-23 01:07:54 -07:00
|
|
|
|
|
|
|
public:
|
2014-09-25 17:44:05 -07:00
|
|
|
inline WidgetInfo(OBSPropertiesView *view_, obs_property_t *prop,
|
2014-03-23 01:07:54 -07:00
|
|
|
QWidget *widget_)
|
|
|
|
: view(view_), property(prop), widget(widget_)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void ControlChanged();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-01-03 03:03:04 -08:00
|
|
|
class OBSPropertiesView : public VScrollArea {
|
2014-03-23 01:07:54 -07:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
friend class WidgetInfo;
|
|
|
|
|
2014-09-30 06:32:50 -07:00
|
|
|
using properties_delete_t = decltype(&obs_properties_destroy);
|
|
|
|
using properties_t =
|
|
|
|
std::unique_ptr<obs_properties_t, properties_delete_t>;
|
|
|
|
|
2014-03-23 01:07:54 -07:00
|
|
|
private:
|
2015-02-03 20:48:29 -08:00
|
|
|
QWidget *widget = nullptr;
|
2014-09-30 06:32:50 -07:00
|
|
|
properties_t properties;
|
2014-03-23 01:07:54 -07:00
|
|
|
OBSData settings;
|
2015-02-03 20:48:29 -08:00
|
|
|
void *obj = nullptr;
|
2015-02-03 20:50:37 -08:00
|
|
|
std::string type;
|
2014-09-30 06:36:50 -07:00
|
|
|
PropertiesReloadCallback reloadCallback;
|
2015-02-03 20:48:29 -08:00
|
|
|
PropertiesUpdateCallback callback = nullptr;
|
2014-04-24 01:43:54 -07:00
|
|
|
int minSize;
|
2014-03-23 01:07:54 -07:00
|
|
|
std::vector<std::unique_ptr<WidgetInfo>> children;
|
2014-04-24 01:43:54 -07:00
|
|
|
std::string lastFocused;
|
2015-02-03 20:48:29 -08:00
|
|
|
QWidget *lastWidget = nullptr;
|
2014-04-04 00:30:37 -07:00
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
QWidget *NewWidget(obs_property_t *prop, QWidget *widget,
|
2014-03-23 01:07:54 -07:00
|
|
|
const char *signal);
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
QWidget *AddCheckbox(obs_property_t *prop);
|
|
|
|
QWidget *AddText(obs_property_t *prop);
|
|
|
|
void AddPath(obs_property_t *prop, QFormLayout *layout, QLabel **label);
|
|
|
|
QWidget *AddInt(obs_property_t *prop);
|
|
|
|
QWidget *AddFloat(obs_property_t *prop);
|
|
|
|
QWidget *AddList(obs_property_t *prop, bool &warning);
|
|
|
|
QWidget *AddButton(obs_property_t *prop);
|
|
|
|
void AddColor(obs_property_t *prop, QFormLayout *layout, QLabel *&label);
|
|
|
|
void AddFont(obs_property_t *prop, QFormLayout *layout, QLabel *&label);
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
void AddProperty(obs_property_t *property, QFormLayout *layout);
|
2014-03-23 01:07:54 -07:00
|
|
|
|
2014-08-27 18:18:26 -07:00
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
|
2014-04-24 01:43:54 -07:00
|
|
|
public slots:
|
2014-09-30 06:36:50 -07:00
|
|
|
void ReloadProperties();
|
2014-04-24 01:43:54 -07:00
|
|
|
void RefreshProperties();
|
2015-02-03 20:53:37 -08:00
|
|
|
void SignalChanged();
|
2014-04-24 01:43:54 -07:00
|
|
|
|
2014-08-27 18:18:26 -07:00
|
|
|
signals:
|
|
|
|
void PropertiesResized();
|
2015-02-03 20:53:37 -08:00
|
|
|
void Changed();
|
2014-08-27 18:18:26 -07:00
|
|
|
|
2014-03-23 01:07:54 -07:00
|
|
|
public:
|
2014-09-30 06:36:50 -07:00
|
|
|
OBSPropertiesView(OBSData settings, void *obj,
|
|
|
|
PropertiesReloadCallback reloadCallback,
|
|
|
|
PropertiesUpdateCallback callback,
|
2014-04-24 01:43:54 -07:00
|
|
|
int minSize = 0);
|
2015-02-03 20:50:37 -08:00
|
|
|
OBSPropertiesView(OBSData settings, const char *type,
|
|
|
|
PropertiesReloadCallback reloadCallback,
|
|
|
|
int minSize = 0);
|
2014-03-23 01:07:54 -07:00
|
|
|
};
|