looper/backends/ui/gtk/options_window.hpp

40 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <gtkmm.h>
#include <any>
#include <typeindex>
#include <set>
#include <options.hpp>
class UIBackendColumns : public Glib::Object {
public:
Glib::ustring backendId;
Glib::ustring backendName;
static Glib::RefPtr<UIBackendColumns> create(const Glib::ustring &id, const Glib::ustring &name);
protected:
UIBackendColumns(const Glib::ustring &id, const Glib::ustring &name);
};
class OptionsWindow : public Gtk::Window {
int mainBoxRow = 0;
Gtk::Box rootBox;
Gtk::Box btnBox;
Gtk::Button okBtn;
Gtk::Button cancelBtn;
Gtk::Button saveBtn;
Gtk::Button revertBtn;
Gtk::Label needsRestartLabel;
Gtk::Grid mainBox;
std::vector<Gtk::Widget*> optionWidgets;
std::set<std::string> modifiableOptions;
sigc::signal<void(std::string)> optionChanged;
bool savedOptionRequiresRestart = false;
void revert();
void save();
void add_option(Glib::ustring title, Gtk::Widget *widget, std::string key);
public:
template<class T>
void change_option(std::string key, T value) {
Looper::Options::set_option<T>(key, value);
optionChanged.emit(key);
}
OptionsWindow();
~OptionsWindow();
};