Esempio n. 1
0
		FileChooserExtra(int init_x, int init_y) {
			Gtk::Label *lbl;

			resize = Gtk::manage(new Gtk::CheckButton("Save options (requires re-render)"));
			resize->set_active(false);
			pack_start(*resize);
			resize->signal_toggled().connect(sigc::mem_fun(*this, &FileChooserExtra::do_toggle));

			inner = Gtk::manage(new Gtk::HBox());

			lbl = Gtk::manage(new Gtk::Label("X resolution", 0.9, 0.5));
			inner->pack_start(*lbl);
			f_x = Gtk::manage(new Util::HandyEntry<int>());
			f_x->set_activates_default(true);
			inner->pack_start(*f_x);

			lbl = Gtk::manage(new Gtk::Label("Y resolution", 0.9, 0.5));
			inner->pack_start(*lbl);
			f_y = Gtk::manage(new Util::HandyEntry<int>());
			f_y->set_activates_default(true);
			inner->pack_start(*f_y);

			antialias = Gtk::manage(new Gtk::CheckButton("Antialias"));
			antialias->set_active(false);
			inner->pack_start(*antialias);

			do_hud = Gtk::manage(new Gtk::CheckButton("Render HUD"));
			do_hud->set_active(false);
			inner->pack_start(*do_hud);

			f_x->update(init_x);
			f_y->update(init_y);

			pack_start(*inner);
			show_all();
			resize->show();
			inner->hide();
		}
  ImageEditorFE(grt::Module *m, bec::GRTManager *grtm, const grt::BaseListRef &args)
    : PluginEditorBase(m, grtm, args)
    , _be(grtm, workbench_model_ImageFigureRef::cast_from(args[0]))
    , _xml(0)
    , _image(0)
  {
    set_border_width(8);
    
    _xml= Gtk::Builder::create_from_file(grtm->get_data_file_path("modules/data/editor_image.glade"));

    Gtk::Widget *widget;
    _xml->get_widget("editor_image_hbox", widget);

    Gtk::Button *button(0);
    _xml->get_widget("browse_button", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ImageEditorFE::browse_file));

    _xml->get_widget("reset_size_button", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ImageEditorFE::reset_aspect));

    Gtk::CheckButton *check;
    _xml->get_widget("aspect_check", check);
    check->signal_toggled().connect(sigc::mem_fun(this, &ImageEditorFE::aspect_toggled));
    
    Gtk::Entry *entry;
    _xml->get_widget("width_entry", entry);
    entry->signal_activate().connect(sigc::mem_fun(this, &ImageEditorFE::width_changed));
    _xml->get_widget("height_entry", entry);
    entry->signal_activate().connect(sigc::mem_fun(this, &ImageEditorFE::height_changed));

    _xml->get_widget("image", _image);
    
    widget->reparent(*this);

    show_all();
    
    refresh_form_data();
  }
Esempio n. 3
0
// 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;
}
Esempio n. 4
0
void Settings::connect_to_ui (Builder &builder)
{
  // connect gcode configurable text sections
  GCode.m_impl->connectToUI (builder);

  // first setup ranges on spinbuttons ...
  for (uint i = 0; i < G_N_ELEMENTS (spin_ranges); i++) {
    Gtk::SpinButton *spin = NULL;
    builder->get_widget (spin_ranges[i].widget, spin);
    if (!spin)
      std::cerr << "missing spin button of name '" << spin_ranges[i].widget << "'\n";
    else {
      spin->set_range (spin_ranges[i].min, spin_ranges[i].max);
      spin->set_increments (spin_ranges[i].inc, spin_ranges[i].inc_page);
    }
  }
  // Ranges on [HV]Range widgets
  for (uint i = 0; i < G_N_ELEMENTS (ranges); i++) {
    Gtk::Range *range = NULL;
    builder->get_widget (ranges[i].widget, range);
    if (!range)
      std::cerr << "missing range slider of name '" << ranges[i].widget << "'\n";
    else {
      range->set_range (ranges[i].min, ranges[i].max);
      range->set_increments (ranges[i].inc, ranges[i].inc_page);
    }
  }

  // connect widget / values from our table
  for (uint i = 0; i < G_N_ELEMENTS (settings); i++) {
    const char *glade_name = settings[i].glade_name;

    if (!glade_name)
      continue;

    switch (settings[i].type) {
    case T_BOOL: {
      Gtk::CheckButton *check = NULL;
      builder->get_widget (glade_name, check);
      if (check)
	check->signal_toggled().connect
          (sigc::bind(sigc::bind(sigc::mem_fun(*this, &Settings::get_from_gui), i), builder));
      break;
    }
    case T_INT:
    case T_FLOAT: {
      Gtk::Widget *w = NULL;
      builder->get_widget (glade_name, w);
      if (!w) {
        std::cerr << "Missing user interface item " << glade_name << "\n";
        break;
      }
      Gtk::SpinButton *spin = dynamic_cast<Gtk::SpinButton *>(w);
      if (spin) {
        spin->signal_value_changed().connect
          (sigc::bind(sigc::bind(sigc::mem_fun(*this, &Settings::get_from_gui), i), builder));
        break;
      }
      Gtk::Range *range = dynamic_cast<Gtk::Range *>(w);
      if (range) {
        range->signal_value_changed().connect
          (sigc::bind(sigc::bind(sigc::mem_fun(*this, &Settings::get_from_gui), i), builder));
        break;
      }
      break;
    }
    case T_STRING: // unimplemented
      break;
    default:
      break;
    }
  }

  // Slicing.ShrinkQuality
  Gtk::ComboBox *combo = NULL;
  builder->get_widget ("Slicing.ShrinkQuality", combo);
  if (combo) {
    Glib::RefPtr<Gtk::ListStore> model;
    Gtk::TreeModelColumnRecord record;
    Gtk::TreeModelColumn<Glib::ustring> column;
    record.add (column);
    model = Gtk::ListStore::create(record);
    model->append()->set_value (0, Glib::ustring("Fast"));
    model->append()->set_value (0, Glib::ustring("Logick"));
    combo->set_model (model);
    combo->pack_start (column);

    combo->signal_changed().connect
      (sigc::bind(sigc::mem_fun(*this, &Settings::get_shrink_from_gui), builder));
  }

  // Colour selectors
  for (uint i = 0; i < G_N_ELEMENTS (colour_selectors); i++) {
    const char *glade_name = colour_selectors[i].glade_name;
    Gdk::Color c;
    Gtk::ColorButton *w = NULL;

    if (!glade_name)
      continue;

    builder->get_widget (glade_name, w);
    if (!w) continue;

    w->signal_color_set().connect
          (sigc::bind(sigc::bind(sigc::mem_fun(*this,
            &Settings::get_colour_from_gui), i), builder));
  }

  // Serial port speed
  Gtk::ComboBoxEntry *portspeed = NULL;
  builder->get_widget ("Hardware.SerialSpeed", portspeed);
  if (portspeed) {
    const guint32 speeds[] = {
        9600, 19200, 38400, 57600, 115200, 230400, 576000
    };

    Glib::RefPtr<Gtk::ListStore> model;
    Gtk::TreeModelColumnRecord record;
    Gtk::TreeModelColumn<Glib::ustring> column;
    record.add (column);
    model = Gtk::ListStore::create(record);
    for (guint i = 0; i < G_N_ELEMENTS(speeds); i++) {
      std::ostringstream val;
      val << speeds[i];
      model->append()->set_value (0, Glib::ustring(val.str()));
    }
    portspeed->set_model (model);
    portspeed->set_text_column (0);

    portspeed->signal_changed().connect
      (sigc::bind(sigc::mem_fun(*this, &Settings::get_port_speed_from_gui), builder));
  }

  /* Update UI with defaults */
  m_signal_update_settings_gui.emit();
}
Esempio n. 5
0
	void CamSettingsPage::AttachSignals()
	{						
		// Create a timer
		SetTimerConnection(
			Glib::signal_timeout().connect( sigc::mem_fun(*this, &CamSettingsPage::OnTimer), sk_timeout ));
		
		// Attach all the various camera properties
		// In general, all the functions here are bound using sigc::bind
		// to attach additional parameters, such as the property being modified,
		// as well as widget itself
		for ( unsigned int i = 0; i < sk_numProps; i++ )
		{					
			Gtk::CheckButton* pAuto = m_widgetPropArray[i].pAuto;
			Gtk::CheckButton* pOnOff = m_widgetPropArray[i].pOnOff;
			Gtk::CheckButton* pOnePush = m_widgetPropArray[i].pOnePush;
			Gtk::Adjustment* pAdjustment1 = m_widgetPropArray[i].pAdjustment1;
            Gtk::Adjustment* pAdjustment2 = m_widgetPropArray[i].pAdjustment2;
			
			if ( pAuto != 0 )
			{
				pAuto->signal_toggled().connect( 
					sigc::bind<PropertyType, Gtk::CheckButton*>( 
						sigc::mem_fun(*this, &CamSettingsPage::OnAutoClicked), 
						(PropertyType)i, 
						pAuto ) );
			}
			
			if ( pOnOff != 0 )
			{
				pOnOff->signal_toggled().connect( 
					sigc::bind<PropertyType, Gtk::CheckButton*>( 
						sigc::mem_fun(*this, &CamSettingsPage::OnOnOffClicked), 
						(PropertyType)i, 
						pOnOff ) );			
			}
			
			if ( pOnePush != 0 )
			{
				pOnePush->signal_toggled().connect( 
					sigc::bind<PropertyType, Gtk::CheckButton*>( 
						sigc::mem_fun(*this, &CamSettingsPage::OnOnePushClicked), 
						(PropertyType)i, 
						pOnePush ) );			
			}		
			
			if ( pAdjustment1 != 0 )
			{
				pAdjustment1->signal_value_changed().connect( 
					sigc::bind<PropertyType, Gtk::Adjustment*>( 
						sigc::mem_fun(*this, &CamSettingsPage::OnHScroll), 
						(PropertyType)i, 
						pAdjustment1 ) );
			}			

            if ( pAdjustment2 != 0 )
            {
                pAdjustment2->signal_value_changed().connect( 
                    sigc::bind<PropertyType, Gtk::Adjustment*>( 
                    sigc::mem_fun(*this, &CamSettingsPage::OnHScroll), 
                    (PropertyType)i, 
                    pAdjustment2 ) );
            }	
		}
		
		// Attach power check box
		m_pCheckbuttonPower->signal_toggled().connect( 
			sigc::bind<Gtk::CheckButton*>( 
				sigc::mem_fun(*this, &CamSettingsPage::OnPowerClicked), 
				m_pCheckbuttonPower ) );

        // Attach abs mode check box
        m_pCheckbuttonAbsMode->signal_toggled().connect( 
            sigc::bind<Gtk::CheckButton*>( 
            sigc::mem_fun(*this, &CamSettingsPage::OnAbsModeClicked), 
            m_pCheckbuttonAbsMode ) );
	}
Esempio n. 6
0
void setCheckButtonCallback(string cb, sigc::slot<void> sig ) {
    Gtk::CheckButton* cbut;
    VRGuiBuilder()->get_widget(cb, cbut);
    cbut->signal_toggled().connect(sig);
}