* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include <algorithm>
+
#include <gtkmm.h>
#include "ardour/dB.h"
#include "widgets/ardour_dropdown.h"
#include "widgets/slider_controller.h"
+#include "stripable_colorpicker.h"
#include "ardour_dialog.h"
#include "luadialog.h"
#include "splash.h"
Gtk::HSeparator _sep;
};
+class LuaColorPicker : public LuaDialogWidget
+{
+public:
+ LuaColorPicker (std::string const& key)
+ : LuaDialogWidget (key, "", 0, 1)
+ {}
+
+ Gtk::Widget* widget ()
+ {
+ return &_cs;
+ }
+ void assign (luabridge::LuaRef* rv) const {
+ uint32_t rgba = ARDOUR_UI_UTILS::gdk_color_to_rgba(_cs.get_color());
+ (*rv)[_key] = rgba;
+ }
+protected:
+ Gtk::ColorButton _cs;
+};
+
class LuaDialogCheckbox : public LuaDialogWidget
{
public:
void populate (Gtk::Menu_Helpers::MenuList& items, luabridge::LuaRef values, std::string const& dflt)
{
using namespace Gtk::Menu_Helpers;
+ std::vector<std::string> keys;
+
for (luabridge::Iterator i (values); !i.isNil (); ++i) {
if (!i.key ().isString ()) { continue; }
- std::string key = i.key ().cast<std::string> ();
- if (i.value ().isTable ()) {
+ keys.push_back (i.key ().cast<std::string> ());
+ }
+
+ std::sort (keys.begin(), keys.end());
+
+ for (std::vector<std::string>::const_iterator i = keys.begin (); i != keys.end(); ++i) {
+ std::string key = *i;
+
+ if (values[key].isTable ()) {
Gtk::Menu* menu = Gtk::manage (new Gtk::Menu);
items.push_back (MenuElem (key, *menu));
- populate (menu->items (), i.value (), dflt);
+ populate (menu->items (), values[key], dflt);
continue;
}
- luabridge::LuaRef* ref = new luabridge::LuaRef (i.value ());
+ luabridge::LuaRef* ref = new luabridge::LuaRef (values[key]);
_refs.push_back (ref);
- items.push_back (MenuElem (i.key ().cast<std::string> (),
+ items.push_back (MenuElem (key,
sigc::bind (sigc::mem_fun (*this, &LuaDialogDropDown::dd_select), key, ref)));
if (!_rv || key == dflt) {
switch (a) {
case Gtk::FILE_CHOOSER_ACTION_OPEN:
case Gtk::FILE_CHOOSER_ACTION_SAVE:
- if (Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR|Glib::FILE_TEST_EXISTS)) {
- _fc.set_filename (path);
- }
- break;
case Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER:
- if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) {
- _fc.set_filename (path);
- }
+ _fc.set_filename (path);
break;
case Gtk::FILE_CHOOSER_ACTION_CREATE_FOLDER:
break;
path = i.value ()["path"].cast<std::string> ();
}
w = new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, path);
+ } else if (type == "color") {
+ w = new LuaColorPicker (key);
}
if (w) {
Gtk::Table* table = Gtk::manage (new Gtk::Table ());
table->set_col_spacings (20);
table->set_row_spacings (8);
- _ad.get_vbox ()->pack_start (*table);
+ table->signal_size_allocate ().connect (sigc::mem_fun (this, &Dialog::table_size_alloc));
+
+ _scroller.set_shadow_type(Gtk::SHADOW_NONE);
+ _scroller.set_border_width(0);
+ _scroller.add (*table);
+ _scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_NEVER);
+
+ _ad.get_vbox ()->pack_start (_scroller);
int row = 0;
int last_end = -1;
luabridge::push (L, rv);
return 1;
}
+
+void
+Dialog::table_size_alloc (Gtk::Allocation& allocation)
+{
+ /* XXX: consider using 0.75 * screen-height instead of 512 */
+ if (allocation.get_height () > 512) {
+ _scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+ _ad.set_size_request (-1, 512);
+ }
+}