unique_ptr<IInputWidgetProxy> DisneyMaterialLayerUI::create_colormap_input_widgets(const Dictionary& metadata) { QLineEdit* line_edit = new QLineEdit(m_content_widget); line_edit->setMaximumWidth(120); DoubleSlider* slider = new DoubleSlider(Qt::Horizontal, m_content_widget); slider->setRange(0.0, 1.0); slider->setPageStep(0.1); new MouseWheelFocusEventFilter(slider); new LineEditDoubleSliderAdaptor(line_edit, slider); connect(slider, SIGNAL(valueChanged(int)), SIGNAL(signal_apply())); if (should_be_focused(metadata)) { line_edit->selectAll(); line_edit->setFocus(); } const string name = metadata.get<string>("name"); QHBoxLayout* layout = new QHBoxLayout(); layout->setSpacing(6); layout->addWidget(line_edit); layout->addWidget(slider); layout->addWidget(create_texture_button(name)); layout->addWidget(create_expression_button(name)); m_content_layout->addRow(create_label(metadata), layout); unique_ptr<IInputWidgetProxy> widget_proxy(new LineEditProxy(line_edit)); widget_proxy->set(metadata.strings().get<string>("value")); return std::move(widget_proxy); }
auto_ptr<IInputWidgetProxy> EntityEditor::create_numeric_input_widgets(const Dictionary& metadata) { QLineEdit* line_edit = new QLineEdit(m_parent); line_edit->setMaximumWidth(60); DoubleSlider* slider = new DoubleSlider(Qt::Horizontal, m_parent); const double min_value = metadata.get<double>("min_value"); const double max_value = metadata.get<double>("max_value"); slider->setRange(min_value, max_value); slider->setPageStep((max_value - min_value) / 10.0); new MouseWheelFocusEventFilter(slider); new LineEditDoubleSliderAdaptor(line_edit, slider); connect(slider, SIGNAL(valueChanged(int)), SLOT(slot_apply())); if (should_be_focused(metadata)) { line_edit->selectAll(); line_edit->setFocus(); } QHBoxLayout* layout = new QHBoxLayout(); layout->setSpacing(6); layout->addWidget(line_edit); layout->addWidget(slider); m_form_layout->addRow(create_label(metadata), layout); auto_ptr<IInputWidgetProxy> widget_proxy(new LineEditProxy(line_edit)); widget_proxy->set(metadata.strings().get<string>("value")); return widget_proxy; }
auto_ptr<IInputWidgetProxy> EntityEditor::create_colormap_input_widgets(const Dictionary& metadata) { QLineEdit* line_edit = new QLineEdit(m_parent); line_edit->setMaximumWidth(120); const double min_value = 0.0; const double max_value = 1.0; DoubleSlider* slider = new DoubleSlider(Qt::Horizontal, m_parent); slider->setRange(min_value, max_value); slider->setPageStep((max_value - min_value) / 10.0); new MouseWheelFocusEventFilter(slider); // Connect the line edit and the slider together. LineEditDoubleSliderAdaptor* adaptor = new LineEditDoubleSliderAdaptor(line_edit, slider); connect( slider, SIGNAL(valueChanged(const double)), adaptor, SLOT(slot_set_line_edit_value(const double))); connect( line_edit, SIGNAL(textChanged(const QString&)), adaptor, SLOT(slot_set_slider_value(const QString&))); connect( line_edit, SIGNAL(editingFinished()), adaptor, SLOT(slot_apply_slider_value())); const string name = metadata.get<string>("name"); QWidget* bind_button = new QPushButton("Bind", m_parent); bind_button->setObjectName("bind_entity_button"); bind_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(bind_button, SIGNAL(clicked()), m_entity_picker_bind_signal_mapper, SLOT(map())); m_entity_picker_bind_signal_mapper->setMapping(bind_button, QString::fromStdString(name)); connect(slider, SIGNAL(valueChanged(int)), SLOT(slot_apply())); if (should_be_focused(metadata)) { line_edit->selectAll(); line_edit->setFocus(); } QHBoxLayout* layout = new QHBoxLayout(); layout->setSpacing(6); layout->addWidget(line_edit); layout->addWidget(slider); layout->addWidget(bind_button); m_form_layout->addRow(create_label(metadata), layout); auto_ptr<IInputWidgetProxy> widget_proxy(new LineEditProxy(line_edit)); if (metadata.strings().exist("default")) widget_proxy->set(metadata.strings().get<string>("default")); return widget_proxy; }
ColorMapInputWidget::ColorMapInputWidget(QWidget* parent) : QStackedWidget(parent) { m_line_edit = new QLineEdit(this); m_line_edit->setMaximumWidth(120); connect(m_line_edit, SIGNAL(returnPressed()), SIGNAL(signal_changed())); DoubleSlider* slider = new DoubleSlider(Qt::Horizontal, this); slider->setRange(0.0, 1.0); slider->setPageStep(0.1); new MouseWheelFocusEventFilter(slider); new LineEditDoubleSliderAdaptor(m_line_edit, slider); connect(slider, SIGNAL(valueChanged(int)), SIGNAL(signal_changed())); QWidget* bind_button = new QPushButton("Bind", this); bind_button->setObjectName("bind_entity_button"); bind_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(bind_button, SIGNAL(clicked()), SIGNAL(signal_bind_button_clicked())); QWidget* line_edit_button_group = new QWidget(this); QHBoxLayout* line_edit_button_group_layout = new QHBoxLayout(); line_edit_button_group_layout->setMargin(0); line_edit_button_group_layout->setSpacing(6); line_edit_button_group_layout->addWidget(m_line_edit); line_edit_button_group_layout->addWidget(slider); line_edit_button_group_layout->addWidget(bind_button); line_edit_button_group->setLayout(line_edit_button_group_layout); m_entity_button = new QPushButton(this); QPushButton* unbind_button = new QPushButton("Unbind", this); unbind_button->setObjectName("unbind_entity_button"); unbind_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(unbind_button, SIGNAL(clicked()), SLOT(slot_unbind())); connect(unbind_button, SIGNAL(clicked()), SIGNAL(signal_changed())); QWidget* entity_button_group = new QWidget(this); QHBoxLayout* entity_button_group_layout = new QHBoxLayout(); entity_button_group_layout->setMargin(0); entity_button_group_layout->setSpacing(6); entity_button_group_layout->addWidget(m_entity_button); entity_button_group_layout->addWidget(unbind_button); entity_button_group->setLayout(entity_button_group_layout); addWidget(line_edit_button_group); addWidget(entity_button_group); }