mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 23:35:03 +01:00
Templates: basic support for columns in the script dialog.
This commit is contained in:
parent
ba5c19be4c
commit
d7cd457bdf
2 changed files with 48 additions and 29 deletions
|
|
@ -515,6 +515,13 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
||||||
std::string title = i.value ()["title"].cast<std::string> ();
|
std::string title = i.value ()["title"].cast<std::string> ();
|
||||||
std::string type = i.value ()["type"].cast<std::string> ();
|
std::string type = i.value ()["type"].cast<std::string> ();
|
||||||
|
|
||||||
|
std::string key;
|
||||||
|
if (i.value ()["key"].isString ()) {
|
||||||
|
key = i.value ()["key"].cast<std::string> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaDialogWidget *widge;
|
||||||
|
|
||||||
if (type == "heading") {
|
if (type == "heading") {
|
||||||
Gtk::AlignmentEnum xalign = Gtk::ALIGN_CENTER;
|
Gtk::AlignmentEnum xalign = Gtk::ALIGN_CENTER;
|
||||||
if (i.value ()["align"].isString ()) {
|
if (i.value ()["align"].isString ()) {
|
||||||
|
|
@ -525,25 +532,19 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
||||||
xalign = Gtk::ALIGN_RIGHT;
|
xalign = Gtk::ALIGN_RIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogLabel (title, xalign));
|
widge = new LuaDialogLabel (title, xalign);
|
||||||
continue;
|
} else if (type == "checkbox") {
|
||||||
}
|
|
||||||
|
|
||||||
if (!i.value ()["key"].isString ()) { continue; }
|
|
||||||
std::string key = i.value ()["key"].cast<std::string> ();
|
|
||||||
|
|
||||||
if (type == "checkbox") {
|
|
||||||
bool dflt = false;
|
bool dflt = false;
|
||||||
if (i.value ()["default"].isBoolean ()) {
|
if (i.value ()["default"].isBoolean ()) {
|
||||||
dflt = i.value ()["default"].cast<bool> ();
|
dflt = i.value ()["default"].cast<bool> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogCheckbox (key, title, dflt));
|
widge = new LuaDialogCheckbox (key, title, dflt);
|
||||||
} else if (type == "entry") {
|
} else if (type == "entry") {
|
||||||
std::string dflt;
|
std::string dflt;
|
||||||
if (i.value ()["default"].isString ()) {
|
if (i.value ()["default"].isString ()) {
|
||||||
dflt = i.value ()["default"].cast<std::string> ();
|
dflt = i.value ()["default"].cast<std::string> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogEntry (key, title, dflt));
|
widge = new LuaDialogEntry (key, title, dflt);
|
||||||
} else if (type == "radio") {
|
} else if (type == "radio") {
|
||||||
std::string dflt;
|
std::string dflt;
|
||||||
if (!i.value ()["values"].isTable ()) {
|
if (!i.value ()["values"].isTable ()) {
|
||||||
|
|
@ -552,13 +553,13 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
||||||
if (i.value ()["default"].isString ()) {
|
if (i.value ()["default"].isString ()) {
|
||||||
dflt = i.value ()["default"].cast<std::string> ();
|
dflt = i.value ()["default"].cast<std::string> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogRadio (key, title, i.value ()["values"], dflt));
|
widge = new LuaDialogRadio (key, title, i.value ()["values"], dflt);
|
||||||
} else if (type == "fader") {
|
} else if (type == "fader") {
|
||||||
double dflt = 0;
|
double dflt = 0;
|
||||||
if (i.value ()["default"].isNumber ()) {
|
if (i.value ()["default"].isNumber ()) {
|
||||||
dflt = i.value ()["default"].cast<double> ();
|
dflt = i.value ()["default"].cast<double> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogFader (key, title, dflt));
|
widge = new LuaDialogFader (key, title, dflt);
|
||||||
} else if (type == "slider") {
|
} else if (type == "slider") {
|
||||||
double lower, upper, dflt;
|
double lower, upper, dflt;
|
||||||
int digits = 0;
|
int digits = 0;
|
||||||
|
|
@ -574,7 +575,7 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
||||||
if (i.value ()["digits"].isNumber ()) {
|
if (i.value ()["digits"].isNumber ()) {
|
||||||
digits = i.value ()["digits"].cast<int> ();
|
digits = i.value ()["digits"].cast<int> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogSlider (key, title, lower, upper, dflt, digits, i.value ()["scalepoints"]));
|
widge = new LuaDialogSlider (key, title, lower, upper, dflt, digits, i.value ()["scalepoints"]);
|
||||||
} else if (type == "number") {
|
} else if (type == "number") {
|
||||||
double lower, upper, dflt, step;
|
double lower, upper, dflt, step;
|
||||||
int digits = 0;
|
int digits = 0;
|
||||||
|
|
@ -595,7 +596,7 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
||||||
if (i.value ()["digits"].isNumber ()) {
|
if (i.value ()["digits"].isNumber ()) {
|
||||||
digits = i.value ()["digits"].cast<int> ();
|
digits = i.value ()["digits"].cast<int> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogSpinBox (key, title, lower, upper, dflt, step, digits));
|
widge = new LuaDialogSpinBox (key, title, lower, upper, dflt, step, digits);
|
||||||
} else if (type == "dropdown") {
|
} else if (type == "dropdown") {
|
||||||
std::string dflt;
|
std::string dflt;
|
||||||
if (!i.value ()["values"].isTable ()) {
|
if (!i.value ()["values"].isTable ()) {
|
||||||
|
|
@ -604,43 +605,57 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr)
|
||||||
if (i.value ()["default"].isString ()) {
|
if (i.value ()["default"].isString ()) {
|
||||||
dflt = i.value ()["default"].cast<std::string> ();
|
dflt = i.value ()["default"].cast<std::string> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaDialogDropDown (key, title, i.value ()["values"], dflt));
|
widge = new LuaDialogDropDown (key, title, i.value ()["values"], dflt);
|
||||||
} else if (type == "file") {
|
} else if (type == "file") {
|
||||||
std::string path;
|
std::string path;
|
||||||
if (i.value ()["path"].isString ()) {
|
if (i.value ()["path"].isString ()) {
|
||||||
path = i.value ()["path"].cast<std::string> ();
|
path = i.value ()["path"].cast<std::string> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_OPEN, path));
|
widge = new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_OPEN, path);
|
||||||
} else if (type == "folder") {
|
} else if (type == "folder") {
|
||||||
std::string path;
|
std::string path;
|
||||||
if (i.value ()["path"].isString ()) {
|
if (i.value ()["path"].isString ()) {
|
||||||
path = i.value ()["path"].cast<std::string> ();
|
path = i.value ()["path"].cast<std::string> ();
|
||||||
}
|
}
|
||||||
_widgets.push_back (new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, path));
|
widge = new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (widge) {
|
||||||
|
_widgets.push_back(widge);
|
||||||
|
|
||||||
|
if (i.value ()["col"].isNumber ()) {
|
||||||
|
widge->set_col ( i.value ()["col"].cast<int> () );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ad.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
_ad.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
_ad.add_button (Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
|
_ad.add_button (Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
|
||||||
|
|
||||||
Gtk::Table* table = Gtk::manage (new Gtk::Table ());
|
Gtk::Table* table = Gtk::manage (new Gtk::Table ());
|
||||||
table->set_col_spacings (4);
|
table->set_col_spacings (20);
|
||||||
table->set_row_spacings (8);
|
table->set_row_spacings (8);
|
||||||
_ad.get_vbox ()->pack_start (*table);
|
_ad.get_vbox ()->pack_start (*table);
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
for (DialogWidgets::const_iterator i = _widgets.begin (); i != _widgets.end (); ++i) {
|
for (DialogWidgets::const_iterator i = _widgets.begin (); i != _widgets.end (); ++i) {
|
||||||
std::string const& label = (*i)->label ();
|
int col = (*i)->col();
|
||||||
|
if (col <= 0)
|
||||||
|
++row;
|
||||||
|
|
||||||
|
std::string const& label = (*i)->label ();
|
||||||
if (!label.empty ()) {
|
if (!label.empty ()) {
|
||||||
Gtk::Label* lbl = Gtk::manage (new Gtk::Label (label + ":", Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
|
Gtk::HBox* hb = Gtk::manage (new Gtk::HBox());
|
||||||
table->attach (*lbl, 0, 1, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
|
Gtk::Label* lbl = Gtk::manage (new Gtk::Label (label + ":", Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
|
||||||
table->attach (*((*i)->widget ()), 1, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
|
hb->set_spacing(4);
|
||||||
|
hb->pack_start( *lbl, true, false);
|
||||||
|
hb->pack_start( (*((*i)->widget ())), true, false);
|
||||||
|
table->attach (*hb, col+0, col+1, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
|
||||||
} else if ((*i)->key ().empty ()) {
|
} else if ((*i)->key ().empty ()) {
|
||||||
table->attach (*((*i)->widget ()), 0, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
|
table->attach (*((*i)->widget ()), col+0, col+1, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
|
||||||
} else {
|
} else {
|
||||||
table->attach (*((*i)->widget ()), 1, 2, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
|
table->attach (*((*i)->widget ()), col+0, col+1, row, row + 1, Gtk::FILL | Gtk::EXPAND, Gtk::SHRINK);
|
||||||
}
|
}
|
||||||
++row;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,20 +53,24 @@ private:
|
||||||
|
|
||||||
class LuaDialogWidget {
|
class LuaDialogWidget {
|
||||||
public:
|
public:
|
||||||
LuaDialogWidget (std::string const& key, std::string const& label)
|
LuaDialogWidget (std::string const& key, std::string const& label, int col = 0)
|
||||||
: _key (key), _label (label)
|
: _key (key), _label (label), _col (col)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~LuaDialogWidget () {}
|
virtual ~LuaDialogWidget () {}
|
||||||
|
|
||||||
virtual Gtk::Widget* widget () = 0;
|
virtual Gtk::Widget* widget () = 0;
|
||||||
virtual void assign (luabridge::LuaRef* rv) const = 0;
|
virtual void assign (luabridge::LuaRef* rv) const = 0;
|
||||||
std::string const& label () const { return _label; }
|
std::string const& label () const { return _label; }
|
||||||
std::string const& key () const { return _key; }
|
std::string const& key () const { return _key; }
|
||||||
|
int const& col () const { return _col; }
|
||||||
|
|
||||||
|
void set_col (int col) { _col = col; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string _key;
|
std::string _key;
|
||||||
std::string _label;
|
std::string _label;
|
||||||
|
int _col;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue