Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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;
}