// create stackboxes with switch controller for port name void Widget::make_switch_box(Gtk::Box *box, Glib::ustring label, PortIndex port_name) { Gxw::Switch *regler = static_cast<Gxw::Switch*>( get_controller_by_port(port_name)); if (regler) { Gtk::Label* pr = new Gtk::Label(label, 0); pr->set_name("amplabel"); // use label images instead simple string labes /*Glib::ustring label_image = GX_LV2_STYLE_DIR; label_image += "/"+plug_name+"-"; label_image += label; label_image += "-label.png"; Gtk::Image *pr = new Gtk::Image(label_image);*/ regler->cp_configure("switch", label, 0, 1, 1); regler->set_name(plug_name); regler->set_base_name( "button" ); Gtk::VBox* b1 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b1), Gtk::PACK_EXPAND_PADDING); box->pack_start( *Gtk::manage(pr),Gtk::PACK_SHRINK); box->pack_start(*regler,Gtk::PACK_SHRINK); Gtk::VBox* b2 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b2), Gtk::PACK_EXPAND_PADDING); regler->signal_toggled().connect(sigc::bind(sigc::mem_fun( *this, &Widget::on_value_changed), port_name)); } }
// create stackboxes with controllers for port name void Widget::make_controller_box(Gtk::Box *box, Glib::ustring label, float min, float max, float digits, PortIndex port_name) { Gxw::Regler *regler = static_cast<Gxw::Regler*>( get_controller_by_port(port_name)); if (regler) { Gtk::Label* pr = new Gtk::Label(label, 0); pr->set_name("amplabel"); // use label images instead simple string labes /*Glib::ustring label_image = GX_LV2_STYLE_DIR; label_image += "/"; label_image += label; label_image += "-label.png"; Gtk::Image *pr = new Gtk::Image(label_image);*/ Gtk::VBox* b1 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b1), Gtk::PACK_EXPAND_PADDING); box->pack_end( *Gtk::manage(pr),Gtk::PACK_SHRINK); regler->cp_configure("KNOB", label, min, max, digits); regler->set_show_value(false); regler->set_name(plug_name); box->pack_start(*regler,Gtk::PACK_SHRINK); Gtk::VBox* b2 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b2), Gtk::PACK_EXPAND_PADDING); regler->signal_value_changed().connect(sigc::bind(sigc::mem_fun( *this, &Widget::on_value_changed), port_name)); } }
// create stackboxes with controllers for port name void Widget::make_controller_box(Gtk::Box *box, Glib::ustring label, Glib::ustring labela, float min, float max, float digits, PortIndex port_name, bool show_value) { Gxw::Regler *regler = static_cast<Gxw::Regler*>( get_controller_by_port(port_name)); if (regler) { Gtk::Label* pr = new Gtk::Label(label, 0); pr->set_name("amplabel"); Gtk::VBox* b1 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b1), Gtk::PACK_EXPAND_PADDING); box->pack_start( *Gtk::manage(pr),Gtk::PACK_SHRINK); regler->cp_configure("KNOB", label, min, max, digits); regler->set_show_value(show_value); regler->set_name(plug_name); regler->set_tooltip_text(labela); box->pack_start(*regler,Gtk::PACK_SHRINK); Gtk::VBox* b2 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b2), Gtk::PACK_EXPAND_PADDING); regler->signal_value_changed().connect(sigc::bind(sigc::mem_fun( *this, &Widget::on_value_changed), port_name)); } }
// create stackboxes with controllers for port name void Widget::make_log_controller_box(Gtk::Box *box, Glib::ustring label, float min, float max, float digits, PortIndex port_name, bool show_value) { Gxw::Regler *regler = static_cast<Gxw::Regler*>( get_controller_by_port(port_name)); if (regler) { Gtk::Label* pr = new Gtk::Label(label, 0); pr->set_name("amplabel"); Gtk::VBox* b1 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b1), Gtk::PACK_EXPAND_PADDING); box->pack_start( *Gtk::manage(pr),Gtk::PACK_SHRINK); double up = log10(max); double step = log10(digits); regler->cp_configure("", label, log10(min), up, step); int prec = 0; float d = log10((digits-1)*max); if (up > 0) { prec = up; if (d < 0) { prec -= floor(d); } } else if (d < 0) { prec = -floor(d); } regler->signal_format_value().connect( sigc::bind( sigc::ptr_fun(logarithmic_format_value), prec)); regler->signal_input_value().connect( sigc::ptr_fun(logarithmic_input_value)); regler->set_show_value(show_value); regler->set_name(plug_name); box->pack_start(*regler,Gtk::PACK_SHRINK); Gtk::VBox* b2 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b2), Gtk::PACK_EXPAND_PADDING); regler->signal_value_changed().connect(sigc::bind(sigc::mem_fun( *this, &Widget::on_value_changed), port_name)); } }
// create stackboxes with switch controller for internal use only void Widget::make_switch_box(Gtk::Box *box, Glib::ustring label) { Gxw::Switch *regler = static_cast<Gxw::Switch*>( &m_switch); if (regler) { Gtk::Label* pr = new Gtk::Label(label, 0); pr->set_name("amplabel"); regler->cp_configure("switch", label, 0, 1, 1); regler->set_name(plug_name); regler->set_base_name( "button" ); Gtk::VBox* b1 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b1), Gtk::PACK_EXPAND_PADDING); box->pack_start( *Gtk::manage(pr),Gtk::PACK_SHRINK); box->pack_start(*regler,Gtk::PACK_SHRINK); Gtk::VBox* b2 = new Gtk::VBox(); box->pack_start( *Gtk::manage(b2), Gtk::PACK_EXPAND_PADDING); } }
//------------------------------------------------------------------------------ void mforms::gtk::ToolBarImpl::set_item_text(mforms::ToolBarItem *item, const std::string &label) { const mforms::ToolBarItemType type = item->get_type(); switch (type) { case mforms::TextActionItem: case mforms::ActionItem: case mforms::SegmentedToggleItem: case mforms::ToggleItem: case mforms::SwitcherItem: { Gtk::Button *btn = cast<Gtk::Button *>(item->get_data_ptr()); if (type == mforms::SwitcherItem) { btn->set_label(label); btn->get_style_context()->add_class("SwitcherItem"); } else btn->add_label(label); btn->set_name(label); break; } case mforms::TitleItem: case mforms::LabelItem: { Gtk::Label *lbl = cast<Gtk::Label *>(item->get_data_ptr()); if (lbl) { lbl->set_markup("<small>" + label + "</small>"); lbl->set_name(label); } break; } case mforms::FlatSelectorItem: case mforms::SelectorItem: { Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr()); if (ct) ct->set_active_text(label); break; } case mforms::ColorSelectorItem: { Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr()); if (combo) { Glib::RefPtr<Gtk::TreeModel> model = combo->get_model(); if (model) { const Gtk::TreeModel::Children children = model->children(); const Gtk::TreeIter last = children.end(); Gtk::TreeRow row; for (Gtk::TreeIter it = children.begin(); it != last; ++it) { row = *it; if (row.get_value(color_combo_columns->color) == label) { combo->set_active(it); break; } } } } break; } case mforms::SearchFieldItem: case mforms::TextEntryItem: { Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr()); if (e) e->set_text(label); break; } case mforms::SeparatorItem: case mforms::ExpanderItem: case mforms::ImageBoxItem: break; } }