point.cpp revision 64caa91f2899a6648503a75dc7310841955b74fd
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_CPP
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby * Released under GNU GPL, read the file 'COPYING' for more information
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby// needed for on-canvas editting:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby#define LPEPOINTPARAM_DEBUG // undefine to disable all on-canvas editing code for PointParam
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyPointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyPointParam::param_readSVGValue(const gchar * strvalue)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby gchar ** strarray = g_strsplit(strvalue, ",", 2);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby success += sp_svg_number_read_d(strarray[1], &newy);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return true;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby return false;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyPointParam::param_newWidget(Gtk::Tooltips * tooltips)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Inkscape::UI::Widget::RegisteredPoint * pointwdg = Gtk::manage(
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby new Inkscape::UI::Widget::RegisteredPoint( param_label,
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby pButton->signal_clicked().connect(sigc::mem_fun(*this, &PointParam::on_button_click));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby static_cast<Gtk::HBox*>(hbox)->pack_start(*pButton, true, true);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby static_cast<Gtk::HBox*>(hbox)->show_all_children();
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby tooltips->set_tip(*pButton, _("Edit on-canvas"));
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyPointParam::param_setValue(Geom::Point newpoint)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby *dynamic_cast<Geom::Point *>( this ) = newpoint;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyPointParam::param_set_and_write_new_value (Geom::Point newpoint)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyPointParam::param_editOncanvas(SPItem * item, SPDesktop * dt)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby // If not already in nodecontext, goto it!
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby shape_editor->set_item_lpe_point_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str());
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin MaltbyPointParam::param_transform_multiply(Geom::Matrix const& postmul, bool /*set*/)
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby param_set_and_write_new_value( (*this) * postmul );
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby// CALLBACKS:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby SPItem * item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby} /* namespace LivePathEffect */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby} /* namespace Inkscape */
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby Local Variables:
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby c-file-style:"stroustrup"
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby indent-tabs-mode:nil
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby fill-column:99
f6e214c7418f43af38bd8c3a557e3d0a1d311cfaGavin Maltby// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :