/* === E N T R Y P O I N T ================================================= */ studio::Widget_NavView::Widget_NavView(CanvasView::LooseHandle cv) :canvview(cv), adj_zoom(Gtk::Adjustment::create(0,-4,4,1,2)), scrolling(false), surface(new synfig::Surface), cairo_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1)) { attach(drawto,0,4,0,1); attach(*manage(new Gtk::HSeparator),0,4,1,2,Gtk::SHRINK|Gtk::FILL,Gtk::SHRINK|Gtk::FILL); //zooming stuff attach(zoom_print,0,1,2,3,Gtk::SHRINK|Gtk::FILL,Gtk::SHRINK|Gtk::FILL); zoom_print.set_size_request(40,-1); Gtk::HScale *s = manage(new Gtk::HScale(adj_zoom)); s->set_draw_value(false); //s->set_update_policy(Gtk::UPDATE_DELAYED); //s->signal_event().connect(sigc::mem_fun(*this,&Dock_Navigator::on_scroll_event)); attach(*s,1,4,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL); show_all(); adj_zoom->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_NavView::on_number_modify)); if(cv) { drawto.signal_draw().connect(sigc::mem_fun(*this,&Widget_NavView::on_drawto_draw)); drawto.signal_event().connect(sigc::mem_fun(*this,&Widget_NavView::on_mouse_event)); drawto.add_events(Gdk::BUTTON_MOTION_MASK|Gdk::BUTTON_PRESS_MASK); //get_canvas_view()->canvas_interface()->signal_dirty_preview() // .connect(sigc::mem_fun(*this,&Widget_NavView::on_dirty_preview)); get_canvas_view()->work_area->signal_rendering() .connect(sigc::mem_fun(*this,&Widget_NavView::on_dirty_preview)); get_canvas_view()->work_area->signal_view_window_changed() .connect(sigc::mem_fun(*this,&Widget_NavView::on_workarea_view_change)); //update with this canvas' view on_workarea_view_change(); dirty = true; queue_draw(); } adj_zoom->set_value(0); }
void ArgTable::insertArg (thArg *arg) { if (arg == NULL) return; int row = args_++; Gtk::Label *label = manage(new Gtk::Label((arg->label().length() > 0) ? arg->label() : arg->name())); Gtk::HScale *slider = manage(new Gtk::HScale(arg->min(),arg->max(),.0001)); Gtk::Adjustment *argAdjust = slider->get_adjustment(); slider->set_draw_value(false); slider->signal_value_changed().connect( sigc::bind<Gtk::HScale *, thArg *>( sigc::mem_fun(*this, &ArgTable::sliderChanged), slider, arg)); arg->signal_arg_changed().connect( sigc::bind<Gtk::HScale *>( sigc::mem_fun(*this, &ArgTable::argChanged), slider)); slider->set_value((*arg)[0]); Gtk::SpinButton *valEntry = manage(new Gtk::SpinButton( *argAdjust, .0001, 4)); if (args_ > rows_) { resize(args_, 3); rows_ = args_; } attach(*label, 0, 1, row, row+1, Gtk::SHRINK, Gtk::SHRINK); attach(*slider, 1, 2, row, row+1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); attach(*valEntry, 2, 3, row, row+1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL); }
void JointVelocityControlWidget::init(ref<BasicEnvironment> env, ref<Robot> robot, Int index, ref<ControlInterface> interface) { velInterface = interface; // Joint velocity controls Gtk::VBox* jointControlBox = new Gtk::VBox(false,5); Int dof = velInterface->inputSize(); velAdjustments.clear(); for(Int j=0; j<dof; j++) { Gtk::HBox* hbox = new Gtk::HBox(); Gtk::Label* label = new Gtk::Label(base::intToString(j)+":"); hbox->pack_start(*manage(label), Gtk::PACK_SHRINK,5); Gtk::Adjustment* adj = new Gtk::Adjustment(0,-3,3,0.01,0.1); velAdjustments.push_back(adj); Gtk::HScale* scale = new Gtk::HScale(*manage(adj)); scale->set_draw_value(true); scale->set_digits(2); scale->set_value_pos(Gtk::POS_LEFT); scale->set_update_policy(Gtk::UPDATE_CONTINUOUS); scale->set_size_request(100,-1); hbox->pack_end(*manage(scale)); jointControlBox->pack_start(*manage(hbox),false,false); adj->signal_value_changed().connect( SigC::bind<Int>( SigC::slot(*this, &JointVelocityControlWidget::jointVelScaleChanged ), j) ); } pack_start(*manage(jointControlBox)); }
void PrefPage::appendSlider(const std::string& name, const std::string& registryKey, bool drawValue, double value, double lower, double upper, double step_increment, double page_increment, double page_size) { // Create a new adjustment with the boundaries <lower> and <upper> and all the increments Gtk::Adjustment* adj = Gtk::manage(new Gtk::Adjustment(value, lower, upper, step_increment, page_increment, page_size)); // Connect the registry key to this adjustment registry::bindPropertyToBufferedKey(adj->property_value(), registryKey, _registryBuffer, _resetValuesSignal); // scale Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment(0.0, 0.5, 1.0, 0.0)); alignment->show(); Gtk::HScale* scale = Gtk::manage(new Gtk::HScale(*adj)); scale->set_value_pos(Gtk::POS_LEFT); scale->show(); alignment->add(*scale); scale->set_draw_value(drawValue); scale->set_digits((step_increment < 1.0f) ? 2 : 0); appendNamedWidget(name, *alignment); }
/*! Constructor * \param[in] el the configuration element to display * \param[in] differ shall the changes be applied later using apply_changes()? */ ConfigElement::ConfigElement(crn::ConfigElement &el, bool differ): value(el.GetValue()), tmpvalue(el.GetValue()) { if (!value) throw crn::ExceptionUninitialized(_("The element was not initialized.")); if (differ) tmpvalue = crn::Clone(*value); if (std::dynamic_pointer_cast<crn::Int>(tmpvalue)) typ = U"Int"; else if (std::dynamic_pointer_cast<crn::Real>(tmpvalue)) typ = U"Real"; else if (std::dynamic_pointer_cast<crn::Prop3>(tmpvalue)) typ = U"Prop3"; else if (std::dynamic_pointer_cast<crn::String>(tmpvalue)) typ = U"String"; else if (std::dynamic_pointer_cast<crn::StringUTF8>(tmpvalue)) typ = U"StringUTF8"; else if (std::dynamic_pointer_cast<crn::Path>(tmpvalue)) typ = U"Path"; Gtk::Label *lab = Gtk::manage(new Gtk::Label(el.GetName().CStr())); lab->show(); pack_start(*lab, false, true, 2); if (typ == U"Prop3") { Prop3 *p = Gtk::manage(new Prop3(Gtk::ICON_SIZE_BUTTON, el.GetValue<crn::Prop3>())); p->signal_value_changed().connect(sigc::mem_fun(this, &ConfigElement::on_p3_changed)); p->show(); pack_start(*p, true, true, 2); } else if (!el.GetAllowedValues().IsEmpty()) { // any Int, Real, String, StringUTF8 or Path Gtk::ComboBoxText *cb = Gtk::manage(new Gtk::ComboBoxText); const std::vector<crn::StringUTF8> values(el.GetAllowedValues<crn::StringUTF8>()); for (const crn::StringUTF8 &val : values) #ifdef CRN_USING_GTKMM3 cb->append(val.CStr()); #else /* CRN_USING_GTKMM3 */ cb->append_text(val.CStr()); #endif /* CRN_USING_GTKMM3 */ cb->set_active_text(el.GetValue<crn::StringUTF8>().CStr()); cb->signal_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_combo_changed), cb)); cb->show(); pack_start(*cb, true, true, 2); } else if (typ == U"Int") { if (el.HasMinValue() && el.HasMaxValue()) { // has finite range, use a slider #ifdef CRN_USING_GTKMM3 auto *s = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); s->set_range(el.GetMinValue<int>(), el.GetMaxValue<int>() + 1); s->set_increments(1, 1); #else Gtk::HScale *s = Gtk::manage(new Gtk::HScale(el.GetMinValue<int>(), el.GetMaxValue<int>() + 1, 1)); #endif s->set_value(el.GetValue<int>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_range_changed), s)); s->show(); pack_start(*s, true, true, 2); } else { // has at least one infinite (maxed) bound, use a spin button Gtk::SpinButton *s = Gtk::manage(new Gtk::SpinButton); int m = std::numeric_limits<int>::min(), M = std::numeric_limits<int>::max(); if (el.HasMinValue()) m = el.GetMinValue<int>(); if (el.HasMaxValue()) M = el.GetMaxValue<int>(); s->set_range(m, M); s->set_increments(1, 10); s->set_value(el.GetValue<int>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_spin_changed), s)); s->show(); pack_start(*s, true, true, 2); } } else if (typ == U"Real") { if (el.HasMinValue() && el.HasMaxValue()) { // has finite range, use a slider #ifdef CRN_USING_GTKMM3 auto *s = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); s->set_range(el.GetMinValue<double>(), el.GetMaxValue<double>() + 0.01); s->set_increments(0.01, 0.01); #else Gtk::HScale *s = Gtk::manage(new Gtk::HScale(el.GetMinValue<double>(), el.GetMaxValue<double>() + 0.01, 0.01)); #endif s->set_digits(2); s->set_value(el.GetValue<double>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_range_changed), s)); s->show(); pack_start(*s, true, true, 2); } else { // has at least one infinite (maxed) bound, use a spin button Gtk::SpinButton *s = Gtk::manage(new Gtk::SpinButton(0, 2)); double m = -std::numeric_limits<double>::max(), M = std::numeric_limits<double>::max(); if (el.HasMinValue()) m = el.GetMinValue<double>(); if (el.HasMaxValue()) M = el.GetMaxValue<double>(); s->set_range(m, M); s->set_increments(0.01, 1); s->set_value(el.GetValue<double>()); s->signal_value_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_spin_changed), s)); s->show(); pack_start(*s, true, true, 2); } } else // string types { Gtk::Entry *e = Gtk::manage(new Gtk::Entry); e->set_text(el.GetValue<crn::StringUTF8>().CStr()); e->signal_changed().connect(sigc::bind(sigc::mem_fun(this, &ConfigElement::on_entry_changed), e)); e->show(); pack_start(*e, true, true, 2); } lab = Gtk::manage(new Gtk::Label("?")); lab->show(); lab->set_tooltip_text(el.GetDescription().CStr()); pack_start(*lab, false, true, 2); }
// Construct main widgets Gtk::Widget& OverlayDialog::createWidgets() { Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 12)); // "Use image" checkbox _useImageBtn = Gtk::manage(new Gtk::CheckButton(_("Use background image"))); _useImageBtn->set_active(registry::getValue<bool>(RKEY_OVERLAY_VISIBLE)); _useImageBtn->signal_toggled().connect( sigc::mem_fun(*this, &OverlayDialog::toggleUseImage) ); vbox->pack_start(*_useImageBtn, false, false, 0); // Other widgets are in a table, which is indented with respect to the // Use Image checkbox, and becomes enabled/disabled with it. _subTable = Gtk::manage(new Gtk::Table(8, 2, false)); _subTable->set_row_spacings(12); _subTable->set_col_spacings(12); // Image file Gtk::Label* imageLabel = Gtk::manage(new gtkutil::LeftAlignedLabel( std::string("<b>") + _("Image file") + "</b>")); _subTable->attach(*imageLabel, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); // File chooser _fileChooserBtn = Gtk::manage( new Gtk::FileChooserButton(_("Choose image"), Gtk::FILE_CHOOSER_ACTION_OPEN) ); _fileChooserBtn->signal_selection_changed().connect( sigc::mem_fun(*this, &OverlayDialog::_onFileSelection) ); _subTable->attach(*_fileChooserBtn, 1, 2, 0, 1); // Transparency slider Gtk::Label* transpLabel = Gtk::manage(new gtkutil::LeftAlignedLabel( std::string("<b>") + _("Transparency") + "</b>")); _subTable->attach(*transpLabel, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); Gtk::HScale* transSlider = Gtk::manage(new Gtk::HScale(0, 1, 0.01)); registry::bindPropertyToKey(transSlider->get_adjustment()->property_value(), RKEY_OVERLAY_TRANSPARENCY); transSlider->signal_value_changed().connect(sigc::mem_fun(*this, &OverlayDialog::_onScrollChange)); _subTable->attach(*transSlider, 1, 2, 1, 2); // Image size slider Gtk::Label* sizeLabel = Gtk::manage(new gtkutil::LeftAlignedLabel( std::string("<b>") + _("Image scale") + "</b>")); _subTable->attach(*sizeLabel, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL); Gtk::HScale* scale = Gtk::manage(new Gtk::HScale(0, 20, 0.01)); registry::bindPropertyToKey(scale->get_adjustment()->property_value(), RKEY_OVERLAY_SCALE); scale->signal_value_changed().connect(sigc::mem_fun(*this, &OverlayDialog::_onScrollChange)); _subTable->attach(*scale, 1, 2, 2, 3); // Translation X slider _subTable->attach(*Gtk::manage(new gtkutil::LeftAlignedLabel( std::string("<b>") + _("Horizontal offset") + "</b>")), 0, 1, 3, 4, Gtk::FILL, Gtk::FILL); Gtk::HScale* transx = Gtk::manage(new Gtk::HScale(-20, 20, 0.01)); registry::bindPropertyToKey(transx->get_adjustment()->property_value(), RKEY_OVERLAY_TRANSLATIONX); transx->signal_value_changed().connect(sigc::mem_fun(*this, &OverlayDialog::_onScrollChange)); _subTable->attach(*transx, 1, 2, 3, 4); // Translation Y slider _subTable->attach(*Gtk::manage(new gtkutil::LeftAlignedLabel( std::string("<b>") + _("Vertical offset") + "</b>")), 0, 1, 4, 5, Gtk::FILL, Gtk::FILL); Gtk::HScale* transy = Gtk::manage(new Gtk::HScale(-20, 20, 0.01)); registry::bindPropertyToKey(transy->get_adjustment()->property_value(), RKEY_OVERLAY_TRANSLATIONY); transy->signal_value_changed().connect(sigc::mem_fun(*this, &OverlayDialog::_onScrollChange)); _subTable->attach(*transy, 1, 2, 4, 5); // Options list _subTable->attach(*Gtk::manage(new gtkutil::LeftAlignedLabel( std::string("<b>") + _("Options") + "</b>")), 0, 1, 5, 6, Gtk::FILL, Gtk::FILL); Gtk::CheckButton* keepAspect = Gtk::manage(new Gtk::CheckButton(_("Keep aspect ratio"))); registry::bindPropertyToKey(keepAspect->property_active(), RKEY_OVERLAY_PROPORTIONAL); keepAspect->signal_toggled().connect( sigc::mem_fun(GlobalSceneGraph(), &scene::Graph::sceneChanged) ); _subTable->attach(*keepAspect, 1, 2, 5, 6); Gtk::CheckButton* scaleWithViewport = Gtk::manage(new Gtk::CheckButton(_("Zoom image with viewport"))); registry::bindPropertyToKey(scaleWithViewport->property_active(), RKEY_OVERLAY_SCALE_WITH_XY); scaleWithViewport->signal_toggled().connect( sigc::mem_fun(GlobalSceneGraph(), &scene::Graph::sceneChanged) ); _subTable->attach(*scaleWithViewport, 1, 2, 6, 7); Gtk::CheckButton* panWithViewport = Gtk::manage(new Gtk::CheckButton(_("Pan image with viewport"))); registry::bindPropertyToKey(panWithViewport->property_active(), RKEY_OVERLAY_PAN_WITH_XY); panWithViewport->signal_toggled().connect( sigc::mem_fun(GlobalSceneGraph(), &scene::Graph::sceneChanged) ); _subTable->attach(*panWithViewport, 1, 2, 7, 8); // Pack table into vbox and return vbox->pack_start(*Gtk::manage(new gtkutil::LeftAlignment(*_subTable, 18, 1.0)), true, true, 0); return *vbox; }
void set_opacity(Real x) { opacity_hscl.set_value(x); }
Real get_opacity()const { return opacity_hscl.get_value(); }
void settingsCallback() { _focalLength = _focalLengthSlider.get_value(); _focalWidth = _focalWidthSlider.get_value(); }
bool addWidgets(Gtk::Box* iBox) { if (mBox != NULL) return false; mBox = Gtk::manage(new Gtk::VBox()); Gtk::Box* box = Gtk::manage(new Gtk::HBox()); mToggleButton = Gtk::manage(new Gtk::ToggleButton(" ")); Gdk::Color color; color.set_rgb_p(mAttributes.mColor[0], mAttributes.mColor[1], mAttributes.mColor[2]); mToggleButton->modify_bg(Gtk::STATE_ACTIVE, color); color.set_rgb_p((mAttributes.mColor[0]+1)/2, (mAttributes.mColor[1]+1)/2, (mAttributes.mColor[2]+1)/2); mToggleButton->modify_bg(Gtk::STATE_PRELIGHT, color); color.set_rgb_p(0.8, 0.8, 0.8); mToggleButton->modify_bg(Gtk::STATE_NORMAL, color); mToggleButton->signal_toggled().connect (sigc::mem_fun(*this, &Helper::onToggleButton)); mToggleButton->set_active(true); box->pack_start(*(mToggleButton), false, false); Gtk::Label* label = Gtk::manage(new Gtk::Label(mAttributes.mLabel)); box->pack_start(*label, false, false); if (mViewId != 1) { Gtk::Button* cancelButton = Gtk::manage(new Gtk::Button("X")); box->pack_start(*cancelButton, false, false); cancelButton->signal_clicked().connect (sigc::mem_fun(*this, &Helper::onRemoveButton)); } Gtk::Button* button = Gtk::manage(new Gtk::Button("save")); button->signal_clicked().connect (sigc::mem_fun(*this, &Helper::onSaveButton)); box->pack_start(*button, false, false); mBox->pack_start(*box, false, false); box = Gtk::manage(new Gtk::HBox()); std::vector<int> ids; std::vector<std::string> labels; ids = { MeshRenderer::ColorModeFlat, MeshRenderer::ColorModeHeight, MeshRenderer::ColorModeRange, MeshRenderer::ColorModeNormal, MeshRenderer::ColorModeCamera }; labels = { "Flat", "Height", "Range", "Normal", "Camera" }; Gtk::ComboBox* combo = gtkmm::RendererBase::createCombo(mAttributes.mColorMode, labels, ids); combo->signal_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*combo, false, false); ids = { MeshRenderer::MeshModePoints, MeshRenderer::MeshModeWireframe, MeshRenderer::MeshModeFilled }; labels = { "Points", "Wireframe", "Filled" }; combo = gtkmm::RendererBase::createCombo(mAttributes.mMeshMode, labels, ids); combo->signal_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*combo, false, false); Gtk::HScale* slider = gtkmm::RendererBase::createSlider(mAttributes.mPointSize, 0.1, 10, 0.1); slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*slider, true, true); mBox->pack_start(*box, false, false); box = Gtk::manage(new Gtk::HBox()); label = Gtk::manage(new Gtk::Label("Z Rng")); box->pack_start(*label,false,false); slider = gtkmm::RendererBase::createSlider(mAttributes.mMinZ, -1, 2, 0.01); slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*slider, true, true); slider = gtkmm::RendererBase::createSlider(mAttributes.mMaxZ, -1, 2, 0.01); slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();}); box->pack_start(*slider, true, true); mBox->pack_start(*box, false, false); mBox->pack_start(*Gtk::manage(new Gtk::HSeparator())); mBox->show_all(); iBox->pack_start(*mBox, false, false); return true; }
void settingsCallback() { _radius = _radiusSlider.get_value(); }