diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2017-05-05 16:52:19 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2017-05-05 16:52:19 +0000 |
| commit | bec0359a0d5b3f7db96417f003927c282c18a9f4 (patch) | |
| tree | e45fa17927826da138e233499060e3142de86899 /src/ui | |
| parent | Update to trunk (diff) | |
| parent | merge lpeUpdDefaultParams (diff) | |
| download | inkscape-bec0359a0d5b3f7db96417f003927c282c18a9f4.tar.gz inkscape-bec0359a0d5b3f7db96417f003927c282c18a9f4.zip | |
Update to trunk
(bzr r13645.1.174)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/ui/clipboard.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/export.cpp | 9 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 7 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.cpp | 62 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.h | 5 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 58 | ||||
| -rw-r--r-- | src/ui/event-debug.h | 132 | ||||
| -rw-r--r-- | src/ui/object-edit.cpp | 70 | ||||
| -rw-r--r-- | src/ui/tools/calligraphic-tool.cpp | 3 | ||||
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 8 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 3 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 953 | ||||
| -rw-r--r-- | src/ui/tools/zoom-tool.cpp | 20 | ||||
| -rw-r--r-- | src/ui/view/edit-widget-interface.h | 3 | ||||
| -rw-r--r-- | src/ui/widget/color-scales.cpp | 1 | ||||
| -rw-r--r-- | src/ui/widget/rotateable.cpp | 1 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 10 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.h | 3 |
20 files changed, 766 insertions, 587 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 259a06013..389e8902a 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -177,6 +177,7 @@ set(ui_SRC control-types.h dialog-events.h draw-anchor.h + event-debug.h icon-names.h interface.h object-edit.h diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 734640584..3cc8ac098 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -708,7 +708,7 @@ void ClipboardManagerImpl::_copySelection(ObjectSet *selection) // (we're dealing with unattached representations, so we write to their attributes // instead of using sp_item_set_transform) SPUse *use=dynamic_cast<SPUse *>(item); - if( use && selection->includes(use->get_original()) ){//we are copying something whose parent is also copied (!) + if( use && use->get_original() && use->get_original()->parent ){//we are copying something whose parent is also copied (!) transform = ((SPItem*)(use->get_original()->parent))->i2doc_affine().inverse() * transform; } gchar *transform_str = sp_svg_transform_write(transform ); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index b7207fd50..1bb952de4 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -978,9 +978,7 @@ void Export::onExport () SPNamedView *nv = desktop->getNamedView(); SPDocument *doc = desktop->getDocument(); - Geom::Affine rot = doc->getRoot()->c2p; - doc->getRoot()->c2p = doc->getRoot()->rotation.inverse() * doc->getRoot()->c2p; - doc->ensureUpToDate(); + bool exportSuccessful = false; bool hide = hide_export.get_active (); @@ -1005,7 +1003,6 @@ void Export::onExport () if (num < 1) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No items selected.")); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1097,7 +1094,6 @@ void Export::onExport () if (filename.empty()) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You have to enter a filename.")); sp_ui_error_dialog(_("You have to enter a filename")); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1114,7 +1110,6 @@ void Export::onExport () if (!((x1 > x0) && (y1 > y0) && (width > 0) && (height > 0))) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The chosen area to be exported is invalid.")); sp_ui_error_dialog(_("The chosen area to be exported is invalid")); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1137,7 +1132,6 @@ void Export::onExport () g_free(safeDir); g_free(error); - doc->getRoot()->c2p *= doc->getRoot()->rotation; return; } @@ -1287,7 +1281,6 @@ void Export::onExport () } } } - doc->getRoot()->c2p *= doc->getRoot()->rotation; } // end of sp_export_export_clicked() /// Called when Browse button is clicked diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index c5e8a6de6..646439613 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1310,6 +1310,9 @@ void InkscapePreferences::initPageBehavior() _steps_zoom.init ( "/options/zoomincrement/value", 101.0, 500.0, 1.0, 1.0, M_SQRT2, true, true); _page_steps.add_line( false, _("_Zoom in/out by:"), _steps_zoom, _("%"), _("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false); + _steps_rotate.init ( "/options/rotateincrement/value", 1, 90, 1.0, 5.0, 15, false, false); + _page_steps.add_line( false, _("_Rotate canvas by:"), _steps_rotate, _("degrees"), + _("Rotate canvas clockwise and counter-clockwise by this amount."), false); this->AddPage(_page_steps, _("Steps"), iter_behavior, PREFS_PAGE_BEHAVIOR_STEPS); // Clones options @@ -1408,6 +1411,10 @@ void InkscapePreferences::initPageRendering() _rendering_cache_size.init("/options/renderingcache/size", 0.0, 4096.0, 1.0, 32.0, 64.0, true, false); _page_rendering.add_line( false, _("Rendering _cache size:"), _rendering_cache_size, C_("mebibyte (2^20 bytes) abbreviation","MiB"), _("Set the amount of memory per document which can be used to store rendered parts of the drawing for later reuse; set to zero to disable caching"), false); + // rendering tile multiplier + _rendering_tile_multiplier.init("/options/rendering/tile-multiplier", 1.0, 64.0, 1.0, 4.0, 1.0, true, false); + _page_rendering.add_line( false, _("Rendering tile multiplier:"), _rendering_tile_multiplier, _("requires restart"), _("Set the relative size of tiles used to render the canvas. The larger the value, the bigger the tile size."), false); + /* blur quality */ _blur_quality_best.init ( _("Best quality (slowest)"), "/options/blurquality/value", BLUR_QUALITY_BEST, false, 0); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 781b5e48e..e6ba4e4b2 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -215,6 +215,7 @@ protected: UI::Widget::PrefSpinUnit _steps_scale; UI::Widget::PrefSpinUnit _steps_inset; UI::Widget::PrefSpinButton _steps_zoom; + UI::Widget::PrefSpinButton _steps_rotate; UI::Widget::PrefRadioButton _t_sel_trans_obj; UI::Widget::PrefRadioButton _t_sel_trans_outl; @@ -294,6 +295,7 @@ protected: UI::Widget::PrefCombo _switcher_style; UI::Widget::PrefCheckButton _rendering_image_outline; UI::Widget::PrefSpinButton _rendering_cache_size; + UI::Widget::PrefSpinButton _rendering_tile_multiplier; UI::Widget::PrefSpinButton _filter_multi_threaded; UI::Widget::PrefCheckButton _trans_scale_stroke; diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e5becdb5c..bb9b61504 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -19,7 +19,7 @@ #include "livepatheffect-editor.h" #include "desktop.h" - +#include <gtkmm/expander.h> #include "document.h" #include "document-undo.h" #include "helper/action.h" @@ -47,16 +47,21 @@ namespace Dialog { /*#################### * Callback functions */ + + void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data) { LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data); lpeeditor->lpe_list_locked = false; - lpeeditor->onSelectionChanged(selection, true); + lpeeditor->lpe_changed = true; + lpeeditor->onSelectionChanged(selection); } -static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data) +void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data) { + LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data); + lpeeditor->lpe_list_locked = false; lpeeditor->onSelectionChanged(selection); } @@ -80,6 +85,7 @@ LivePathEffectEditor::LivePathEffectEditor() : UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT), deskTrack(), lpe_list_locked(false), + lpe_changed(true), effectwidget(NULL), status_label("", Gtk::ALIGN_CENTER), effectcontrol_frame(""), @@ -190,11 +196,22 @@ LivePathEffectEditor::~LivePathEffectEditor() void LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) { - if ( ! effect.upd_params ) { + if (!effect.upd_params && !lpe_changed) { + lpe_changed = false; return; } + bool expanderopen = false; + Gtk::Widget * defaultswidget = effect.defaultParamSet(); if (effectwidget) { + if (defaultswidget) { + Gtk::Expander * expander = NULL; + std::vector<Gtk::Widget *> childs = dynamic_cast<Gtk::Box *> (effectwidget)->get_children(); + std::vector<Gtk::Widget *> childs_default = dynamic_cast<Gtk::Box *> (childs[childs.size()-1])->get_children(); + if ((expander = dynamic_cast<Gtk::Expander *>(childs_default[childs_default.size()-1]))){ + expanderopen = expander->get_expanded(); + } + } effectcontrol_vbox.remove(*effectwidget); delete effectwidget; effectwidget = NULL; @@ -204,6 +221,15 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) effectwidget = effect.newWidget(); if (effectwidget) { + + if (defaultswidget) { + Gtk::Expander * expander = NULL; + std::vector<Gtk::Widget *> childs_default = dynamic_cast<Gtk::Box *> (defaultswidget)->get_children(); + if ((expander = dynamic_cast<Gtk::Expander *>(childs_default[childs_default.size()-1]))){ + expander->set_expanded(expanderopen); + } + dynamic_cast<Gtk::Box *> (effectwidget)->pack_start(*defaultswidget, true, true); + } effectcontrol_vbox.pack_start(*effectwidget, true, true); } button_remove.show(); @@ -212,6 +238,8 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) effectcontrol_frame.show(); effectcontrol_vbox.show_all_children(); // fixme: add resizing of dialog + effect.upd_params = false; + lpe_changed = false; } void @@ -254,16 +282,15 @@ LivePathEffectEditor::set_sensitize_all(bool sensitive) } void -LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel, bool upd_params) +LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) { if (lpe_list_locked) { // this was triggered by selecting a row in the list, so skip reloading lpe_list_locked = false; return; } - - effectlist_store->clear(); current_lpeitem = NULL; + effectlist_store->clear(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); @@ -278,9 +305,6 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel, bool upd_para if ( lpeitem->hasPathEffect() ) { Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); if (lpe) { - if (upd_params) { - lpe->upd_params = true; - } showParams(*lpe); lpe_list_locked = true; selectInList(lpe); @@ -484,18 +508,12 @@ LivePathEffectEditor::onRemove() SPItem *item = sel->singleItem(); SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item); if ( lpeitem ) { - if (current_lperef && current_lperef->lpeobject) { - LivePathEffect::Effect * effect = current_lperef->lpeobject->get_lpe(); - if (effect) { - effect->upd_params = true; - } - } lpeitem->removeCurrentPathEffect(false); - + current_lperef = NULL; DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Remove path effect") ); - - effect_list_reload(lpeitem); + lpe_list_locked = false; + onSelectionChanged(sel); } } @@ -512,7 +530,7 @@ void LivePathEffectEditor::onUp() DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect up") ); - + effect_list_reload(lpeitem); } } @@ -529,7 +547,6 @@ void LivePathEffectEditor::onDown() DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect down") ); - effect_list_reload(lpeitem); } } @@ -554,7 +571,7 @@ void LivePathEffectEditor::on_effect_selection_changed() current_lperef = lperef; LivePathEffect::Effect * effect = lperef->lpeobject->get_lpe(); if (effect) { - effect->upd_params = true; + lpe_changed = true; showParams(*effect); } } @@ -563,6 +580,7 @@ void LivePathEffectEditor::on_effect_selection_changed() void LivePathEffectEditor::on_visibility_toggled( Glib::ustring const& str ) { + Gtk::TreeModel::Children::iterator iter = effectlist_view.get_model()->get_iter(str); Gtk::TreeModel::Row row = *iter; diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index a7c749ef3..7f6f56fd2 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -45,7 +45,7 @@ public: static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); } - void onSelectionChanged(Inkscape::Selection *sel, bool upd_params = false); + void onSelectionChanged(Inkscape::Selection *sel); void onSelectionModified(Inkscape::Selection *sel); virtual void on_effect_selection_changed(); void setDesktop(SPDesktop *desktop); @@ -96,7 +96,7 @@ private: }; bool lpe_list_locked; - + bool lpe_changed; //Inkscape::UI::Widget::ComboBoxEnum<LivePathEffect::EffectType> combo_effecttype; Gtk::Widget * effectwidget; @@ -126,6 +126,7 @@ private: LivePathEffect::LPEObjectReference * current_lperef; friend void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data); + friend void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data); LivePathEffectEditor(LivePathEffectEditor const &d); LivePathEffectEditor& operator=(LivePathEffectEditor const &d); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 740ff4f39..e9a13620b 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -57,7 +57,10 @@ #include <librevenge-stream/librevenge-stream.h> using librevenge::RVNGFileStream; + using librevenge::RVNGString; using librevenge::RVNGStringVector; + using librevenge::RVNGPropertyList; + using librevenge::RVNGSVGDrawingGenerator; #else #include <libwpd-stream/libwpd-stream.h> @@ -451,6 +454,31 @@ void SymbolsDialog::iconChanged() { } #ifdef WITH_LIBVISIO + +#if WITH_LIBVISIO01 +// Extend libvisio's native RVNGSVGDrawingGenerator with support for extracting stencil names (to be used as ID/title) +class REVENGE_API RVNGSVGDrawingGenerator_WithTitle : public RVNGSVGDrawingGenerator { + public: + RVNGSVGDrawingGenerator_WithTitle(RVNGStringVector &output, RVNGStringVector &titles, const RVNGString &nmSpace) + : RVNGSVGDrawingGenerator(output, nmSpace) + , _titles(titles) + {} + + void startPage(const RVNGPropertyList &propList) + { + RVNGSVGDrawingGenerator::startPage(propList); + if (propList["draw:name"]) { + _titles.append(propList["draw:name"]->getStr()); + } else { + _titles.append(""); + } + } + + private: + RVNGStringVector &_titles; +}; +#endif + // Read Visio stencil files SPDocument* read_vss( gchar* fullname, Glib::ustring name ) { @@ -472,8 +500,9 @@ SPDocument* read_vss( gchar* fullname, Glib::ustring name ) { } RVNGStringVector output; + RVNGStringVector titles; #if WITH_LIBVISIO01 - librevenge::RVNGSVGDrawingGenerator generator(output, "svg"); + RVNGSVGDrawingGenerator_WithTitle generator(output, titles, "svg"); if (!libvisio::VisioDocument::parseStencils(&input, &generator)) { #else @@ -488,7 +517,7 @@ SPDocument* read_vss( gchar* fullname, Glib::ustring name ) { // prepare a valid title for the symbol file Glib::ustring title = Glib::Markup::escape_text(name); - // prepare a valid id prefix for the symbols (unfortunately libvisio doesn't give us a name) + // prepare a valid id prefix for symbols libvisio doesn't give us a name for Glib::RefPtr<Glib::Regex> regex1 = Glib::Regex::create("[^a-zA-Z0-9_-]"); Glib::ustring id = regex1->replace(name, 0, "_", Glib::REGEX_MATCH_PARTIAL); @@ -505,25 +534,30 @@ SPDocument* read_vss( gchar* fullname, Glib::ustring name ) { tmpSVGOutput += "</title>\n"; tmpSVGOutput += " <defs>\n"; - // Each "symbol" is in it's own SVG file, we wrap with <symbol> and merge into one file. + // Each "symbol" is in its own SVG file, we wrap with <symbol> and merge into one file. for (unsigned i=0; i<output.size(); ++i) { std::stringstream ss; - ss << i; + if (titles.size() == output.size() && titles[i] != "") { + // TODO: Do we need to check for duplicated titles? + ss << regex1->replace(titles[i].cstr(), 0, "_", Glib::REGEX_MATCH_PARTIAL); + } else { + ss << id << "_" << i; + } + + tmpSVGOutput += " <symbol id=\"" + ss.str() + "\">\n"; - tmpSVGOutput += " <symbol id=\""; - tmpSVGOutput += id; - tmpSVGOutput += "_"; - tmpSVGOutput += ss.str(); - tmpSVGOutput += "\">\n"; +#if WITH_LIBVISIO01 + if (titles.size() == output.size() && titles[i] != "") { + tmpSVGOutput += " <title>" + Glib::ustring(RVNGString::escapeXML(titles[i].cstr()).cstr()) + "</title>\n"; + } +#endif std::istringstream iss( output[i].cstr() ); std::string line; while( std::getline( iss, line ) ) { - // std::cout << line << std::endl; if( line.find( "svg:svg" ) == std::string::npos ) { - tmpSVGOutput += line; - tmpSVGOutput += "\n"; + tmpSVGOutput += " " + line + "\n"; } } diff --git a/src/ui/event-debug.h b/src/ui/event-debug.h new file mode 100644 index 000000000..dd33ca0e3 --- /dev/null +++ b/src/ui/event-debug.h @@ -0,0 +1,132 @@ +#ifndef SEEN_UI_EVENT_DEBUG_H +#define SEEN_UI_EVENT_DEBUG_H + +/** + * @file + * Dump event data. + */ +/* + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <gtk/gtk.h> +#include <glibmm/ustring.h> + +// See: https://developer.gnome.org/gdk3/stable/gdk3-Events.html + +inline void ui_dump_event (GdkEvent *event, Glib::ustring const &prefix, bool merge = true) { + + static GdkEventType old_type = GDK_NOTHING; + static unsigned count = 0; + + // Doesn't usually help to dump a zillion events of the same type (e.g. GDK_MOTION_NOTIFY). + ++count; + if (merge && event->type == old_type) { + if ( count == 1 ) { + std::cout << prefix << " ... ditto" << std::endl; + } + return; + } + count = 0; + old_type = event->type; + + std::cout << prefix << ": "; + + switch (event->type) { + + case GDK_KEY_PRESS: + std::cout << "GDK_KEY_PRESS: " << event->key.hardware_keycode << std::endl; + break; + case GDK_KEY_RELEASE: + std::cout << "GDK_KEY_RELEASE: " << event->key.hardware_keycode << std::endl; + break; + + case GDK_BUTTON_PRESS: + std::cout << "GDK_BUTTON_PRESS: " << event->button.button << std::endl; + break; + case GDK_2BUTTON_PRESS: + std::cout << "GDK_2BUTTON_PRESS: " << event->button.button << std::endl; + break; + case GDK_3BUTTON_PRESS: + std::cout << "GDK_3BUTTON_PRESS: " << event->button.button << std::endl; + break; + case GDK_BUTTON_RELEASE: + std::cout << "GDK_BUTTON_RELEASE: " << event->button.button << std::endl; + break; + + case GDK_SCROLL: + std::cout << "GDK_SCROLL" << std::endl; + break; + + case GDK_MOTION_NOTIFY: + std::cout << "GDK_MOTION_NOTIFY" << std::endl; + break; + case GDK_ENTER_NOTIFY: + std::cout << "GDK_ENTER_NOTIFY" << std::endl; + break; + case GDK_LEAVE_NOTIFY: + std::cout << "GDK_LEAVE_NOTIFY" << std::endl; + break; + + case GDK_TOUCH_BEGIN: + std::cout << "GDK_TOUCH_BEGIN" << std::endl; + break; + case GDK_TOUCH_UPDATE: + std::cout << "GDK_TOUCH_UPDATE" << std::endl; + break; + case GDK_TOUCH_END: + std::cout << "GDK_TOUCH_END" << std::endl; + break; + case GDK_TOUCH_CANCEL: + std::cout << "GDK_TOUCH_CANCEL" << std::endl; + break; + +#if GTK_CHECK_VERSION(3,18,0) + + case GDK_TOUCHPAD_SWIPE: + std::cout << "GDK_TOUCHPAD_SWIPE" << std::endl; + break; + case GDK_TOUCHPAD_PINCH: + std::cout << "GDK_TOUCHPAD_PINCH" << std::endl; + break; + +#endif + +#if GTK_CHECK_VERSION(3,22,0) + + case GDK_PAD_BUTTON_PRESS: + std::cout << "GDK_PAD_BUTTON_PRESS" << std::endl; + break; + case GDK_PAD_BUTTON_RELEASE: + std::cout << "GDK_PAD_BUTTON_RELEASE" << std::endl; + break; + case GDK_PAD_RING: + std::cout << "GDK_PAD_RING" << std::endl; + break; + case GDK_PAD_STRIP: + std::cout << "GDK_PAD_STRIP" << std::endl; + break; + case GDK_PAD_GROUP_MODE: + std::cout << "GDK_PAD_GROUP_MODE" << std::endl; + break; + +#endif + + default: + std::cout << "GDK event not recognized!" << std::endl; + break; + } +} + +#endif // SEEN_UI_EVENT_DEBUG_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp index b11a61710..c1d85a896 100644 --- a/src/ui/object-edit.cpp +++ b/src/ui/object-edit.cpp @@ -782,6 +782,12 @@ public: virtual void knot_click(unsigned int state); }; +class ArcKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + /* * return values: * 1 : inside @@ -983,6 +989,30 @@ ArcKnotHolderEntityRY::knot_click(unsigned int state) } } +void +ArcKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast<SPGenericEllipse *>(item); + g_assert(ge != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + ge->cx = s[Geom::X]; + ge->cy = s[Geom::Y]; + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +ArcKnotHolderEntityCenter::knot_get() const +{ + SPGenericEllipse const *ge = dynamic_cast<SPGenericEllipse *>(item); + g_assert(ge != NULL); + + return Geom::Point(ge->cx.computed, ge->cy.computed); +} + + ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : KnotHolder(desktop, item, relhandler) { @@ -990,6 +1020,7 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea ArcKnotHolderEntityRY *entity_ry = new ArcKnotHolderEntityRY(); ArcKnotHolderEntityStart *entity_start = new ArcKnotHolderEntityStart(); ArcKnotHolderEntityEnd *entity_end = new ArcKnotHolderEntityEnd(); + ArcKnotHolderEntityCenter *entity_center = new ArcKnotHolderEntityCenter(); entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, _("Adjust ellipse <b>width</b>, with <b>Ctrl</b> to make circle"), @@ -1011,10 +1042,15 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea "ellipse for arc, <b>outside</b> for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Move the ellipse"), + SP_KNOT_SHAPE_CROSS); + entity.push_back(entity_rx); entity.push_back(entity_ry); entity.push_back(entity_start); entity.push_back(entity_end); + entity.push_back(entity_center); add_pattern_knotholder(); } @@ -1035,6 +1071,12 @@ public: virtual void knot_click(unsigned int state); }; +class StarKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + void StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) { @@ -1092,6 +1134,17 @@ StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origi } } +void +StarKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPStar *star = dynamic_cast<SPStar *>(item); + g_assert(star != NULL); + + star->center = snap_knot_position(p, state); + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + Geom::Point StarKnotHolderEntity1::knot_get() const { @@ -1115,6 +1168,17 @@ StarKnotHolderEntity2::knot_get() const return sp_star_get_xy(star, SP_STAR_POINT_KNOT2, 0); } +Geom::Point +StarKnotHolderEntityCenter::knot_get() const +{ + g_assert(item != NULL); + + SPStar const *star = dynamic_cast<SPStar const *>(item); + g_assert(star != NULL); + + return star->center; +} + static void sp_star_knot_click(SPItem *item, unsigned int state) { @@ -1166,6 +1230,12 @@ StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRel entity.push_back(entity2); } + StarKnotHolderEntityCenter *entity_center = new StarKnotHolderEntityCenter(); + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Move the star"), + SP_KNOT_SHAPE_CROSS); + entity.push_back(entity_center); + add_pattern_knotholder(); } diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index c2b86b538..7228a52bc 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -60,6 +60,7 @@ #include "verbs.h" #include "ui/tools/calligraphic-tool.h" +#include "ui/tools/freehand-base.h" using Inkscape::DocumentUndo; @@ -771,6 +772,8 @@ bool CalligraphicTool::root_handler(GdkEvent* event) { this->message_context->clear(); ret = TRUE; + } else if (!this->dragging && event->button.button == 1 && !this->space_panning){ + spdc_create_single_dot(this, this->desktop->w2d(motion_w), "/tools/calligraphic", event->button.state); } break; } diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 056c723ee..4af70a816 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -913,7 +913,8 @@ static void spdc_free_colors(FreehandBase *dc) } void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) { - g_return_if_fail(!strcmp(tool, "/tools/freehand/pen") || !strcmp(tool, "/tools/freehand/pencil")); + g_return_if_fail(!strcmp(tool, "/tools/freehand/pen") || !strcmp(tool, "/tools/freehand/pencil") + || !strcmp(tool, "/tools/calligraphic") ); Glib::ustring tool_path = tool; SPDesktop *desktop = ec->desktop; @@ -937,7 +938,8 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too // unset stroke and set fill color to former stroke color gchar * str; - str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8); + str = strcmp(tool, "/tools/calligraphic") ? g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8) + : g_strdup_printf("fill:#%06x;stroke:#%06x;", sp_desktop_get_color_tool(desktop, tool, true) >> 8, sp_desktop_get_color_tool(desktop, tool, false) >> 8); repr->setAttribute("style", str); g_free(str); @@ -948,6 +950,8 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too Geom::Affine const i2d (item->i2dt_affine ()); Geom::Point pp = pt * i2d.inverse(); double rad = 0.5 * prefs->getDouble(tool_path + "/dot-size", 3.0); + if (!strcmp(tool, "/tools/calligraphic")) + rad = 0.1 * prefs->getDouble(tool_path + "/width", 3.0) / desktop->current_zoom(); if (event_state & GDK_MOD1_MASK) { // TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size // as specified in prefs. Very simple, but it might be sufficient in practice. If not, diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 8561e234f..0c948c91c 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -297,9 +297,8 @@ void sp_update_helperpath() { Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); selectedNodesPositions.push_back(n->position()); } - lpe->setSelectedNodePos(selectedNodesPositions); + lpe->setSelectedNodePoints(selectedNodesPositions); lpe->setCurrentZoom(desktop->current_zoom()); - SPCurve *c = new SPCurve(); SPCurve *cc = new SPCurve(); std::vector<Geom::PathVector> cs = lpe->getCanvasIndicators(SP_LPE_ITEM(selection->singleItem())); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 8c7f54d14..3d755eadc 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -22,12 +22,21 @@ #include "shortcuts.h" #include "file.h" + +#include "ui/interface.h" +#include "ui/event-debug.h" +#include "ui/tool/control-point.h" +#include "ui/shape-editor.h" #include "ui/tools/tool-base.h" +#include "ui/tools-switch.h" +#include "ui/tools/lpe-tool.h" #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> #include "display/sp-canvas.h" +#include "display/sp-canvas-group.h" +#include "display/canvas-rotate.h" #include "xml/node-event-vector.h" #include "sp-cursor.h" #include "desktop.h" @@ -36,16 +45,11 @@ #include "desktop-style.h" #include "sp-namedview.h" #include "selection.h" -#include "ui/interface.h" #include "macros.h" -#include "ui/tools-switch.h" #include "message-context.h" #include "gradient-drag.h" #include "rubberband.h" #include "selcue.h" -#include "ui/tools/lpe-tool.h" -#include "ui/tool/control-point.h" -#include "ui/shape-editor.h" #include "sp-guide.h" #include "knot-ptr.h" @@ -94,7 +98,6 @@ ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, boo , _grdrag(NULL) , shape_editor(NULL) , space_panning(false) - , rotating_mode(false) , _delayed_snap_event(NULL) , _dse_callback_in_process(false) , desktop(NULL) @@ -324,134 +327,120 @@ static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration, } bool ToolBase::root_handler(GdkEvent* event) { + + // ui_dump_event (event, "ToolBase::root_handler"); static Geom::Point button_w; static unsigned int panning = 0; static unsigned int panning_cursor = 0; static unsigned int zoom_rb = 0; - static double angle = 0; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); /// @todo REmove redundant /value in preference keys tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); bool allow_panning = prefs->getBool("/options/spacebarpans/value"); - int rotation_snap = 180.0/prefs->getInt("/options/rotationsnapsperpi/value", 12); gint ret = FALSE; switch (event->type) { - case GDK_2BUTTON_PRESS: - if (panning) { - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); + case GDK_2BUTTON_PRESS: + if (panning) { + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); + ret = TRUE; + } else { + /* sp_desktop_dialog(); */ + } + break; + + case GDK_BUTTON_PRESS: + // save drag origin + xp = (gint) event->button.x; + yp = (gint) event->button.y; + within_tolerance = true; + + button_w = Geom::Point(event->button.x, event->button.y); + + switch (event->button.button) { + case 1: + if (this->space_panning) { + // When starting panning, make sure there are no snap events pending because these might disable the panning again + if (_uses_snap) { + sp_event_context_discard_delayed_snap_event(this); + } + panning = 1; + + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK + | GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK, NULL, + event->button.time - 1); + ret = TRUE; - } else { - /* sp_desktop_dialog(); */ } break; - case GDK_BUTTON_PRESS: - // save drag origin - xp = (gint) event->button.x; - yp = (gint) event->button.y; - within_tolerance = true; + case 2: + if (event->button.state & GDK_CONTROL_MASK) { + // On screen canvas rotation preview + + // Grab background before doing anything else + sp_canvas_rotate_start (SP_CANVAS_ROTATE(desktop->canvas_rotate), + desktop->canvas->_backing_store); + sp_canvas_item_ungrab (desktop->acetate, event->button.time); + sp_canvas_item_show (desktop->canvas_rotate); + sp_canvas_item_grab (desktop->canvas_rotate, + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK, + NULL, event->button.time ); + // sp_canvas_item_hide (desktop->drawing); + + } else if (event->button.state & GDK_SHIFT_MASK) { + zoom_rb = 2; + } else { + // When starting panning, make sure there are no snap events pending because these might disable the panning again + if (_uses_snap) { + sp_event_context_discard_delayed_snap_event(this); + } + panning = 2; - button_w = Geom::Point(event->button.x, event->button.y); - switch (event->button.button) { - case 1: - if (this->space_panning) { - // When starting panning, make sure there are no snap events pending because these might disable the panning again - if (_uses_snap) { - sp_event_context_discard_delayed_snap_event(this); - } - panning = 1; + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK, + NULL, event->button.time - 1); - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK, NULL, - event->button.time - 1); + } - ret = TRUE; - } - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - break; + ret = TRUE; + break; - case 2: - if (event->button.state & GDK_CONTROL_MASK) { - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); - desktop->canvas->startRotateTo(desktop->namedview->document_rotation); - this->rotating_mode = true; - this->message_context->set(Inkscape::INFORMATION_MESSAGE, - _("<b>MMB + mouse move</b> to rotate canvas, use modifiers on screen to change snaps")); - } else { - if (event->button.state & GDK_SHIFT_MASK) { - zoom_rb = 2; - } else { - // When starting panning, make sure there are no snap events pending because these might disable the panning again - if (_uses_snap) { - sp_event_context_discard_delayed_snap_event(this); - } - panning = 2; - - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK, NULL, - event->button.time - 1); - } - ret = TRUE; + case 3: + if ((event->button.state & GDK_SHIFT_MASK) || (event->button.state & GDK_CONTROL_MASK)) { + // When starting panning, make sure there are no snap events pending because these might disable the panning again + if (_uses_snap) { + sp_event_context_discard_delayed_snap_event(this); } - ret = TRUE; - break; - - case 3: - if ((event->button.state & GDK_SHIFT_MASK) || (event->button.state & GDK_CONTROL_MASK)) { - // When starting panning, make sure there are no snap events pending because these might disable the panning again - if (_uses_snap) { - sp_event_context_discard_delayed_snap_event(this); - } - panning = 3; + panning = 3; - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK - | GDK_POINTER_MOTION_HINT_MASK, NULL, - event->button.time); + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK + | GDK_POINTER_MOTION_HINT_MASK, NULL, + event->button.time); - ret = TRUE; - } else if( !this->space_panning) { - sp_event_root_menu_popup(desktop, NULL, event); - } ret = TRUE; - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - break; - - default: - break; + } else { + sp_event_root_menu_popup(desktop, NULL, event); } break; - case GDK_MOTION_NOTIFY: - if (this->rotating_mode) { - button_w = Geom::Point(event->motion.x, event->motion.y); - Geom::Point const motion_dt(desktop->doc2dt(desktop->w2d(button_w))); - Geom::Rect view = desktop->get_display_area(); - Geom::Point view_center = desktop->doc2dt(view.midpoint()); - Geom::Ray center_ray(motion_dt, view_center); - angle = Geom::deg_from_rad(center_ray.angle()) - 90; - if (event->motion.state & GDK_SHIFT_MASK && event->motion.state & GDK_CONTROL_MASK) { - angle = 0; - } else if(event->motion.state & GDK_CONTROL_MASK) { - angle = floor(angle/rotation_snap) * rotation_snap; - } else if (event->motion.state & GDK_SHIFT_MASK) { - angle = desktop->namedview->document_rotation; - } else if (event->motion.state & GDK_MOD1_MASK) { - //Decimal raw angle - } else { - angle = floor(angle); - } - desktop->canvas->rotateTo(angle); - } else if (panning == 4 && !xp && !yp ) { + default: + break; + } + break; + + case GDK_MOTION_NOTIFY: + if (panning) { + if (panning == 4 && !xp && !yp ) { // <Space> + mouse panning started, save location and grab canvas xp = event->motion.x; yp = event->motion.y; @@ -463,465 +452,430 @@ bool ToolBase::root_handler(GdkEvent* event) { | GDK_POINTER_MOTION_HINT_MASK, NULL, event->motion.time - 1); } - if (panning && !this->rotating_mode) { - if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) - || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK)) - || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) { - /* Gdk seems to lose button release for us sometimes :-( */ - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); - ret = TRUE; - } else { - if (within_tolerance && (abs((gint) event->motion.x - xp) - < tolerance) && (abs((gint) event->motion.y - yp) - < tolerance)) { - // do not drag if we're within tolerance from origin - break; - } - - // Once the user has moved farther than tolerance from - // the original location (indicating they intend to move - // the object, not click), then always process the motion - // notify coordinates as given (no snapping back to origin) - within_tolerance = false; - - // gobble subsequent motion events to prevent "sticking" - // when scrolling is slow - gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning - == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK)); - - if (panning_cursor == 0) { - panning_cursor = 1; - this->sp_event_context_set_cursor(GDK_FLEUR); - } - - Geom::Point const motion_w(event->motion.x, event->motion.y); - Geom::Point const moved_w(motion_w - button_w); - this->desktop->scroll_relative(moved_w, true); // we're still scrolling, do not redraw - ret = TRUE; - } - } else if (zoom_rb) { - Geom::Point const motion_w(event->motion.x, event->motion.y); - Geom::Point const motion_dt(desktop->w2d(motion_w)); + if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) + || (panning == 1 && !(event->motion.state & GDK_BUTTON1_MASK)) + || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) { + /* Gdk seems to lose button release for us sometimes :-( */ + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); + ret = TRUE; + } else { if (within_tolerance && (abs((gint) event->motion.x - xp) < tolerance) && (abs((gint) event->motion.y - yp) < tolerance)) { - break; // do not drag if we're within tolerance from origin + // do not drag if we're within tolerance from origin + break; } - // Once the user has moved farther than tolerance from the original location - // (indicating they intend to move the object, not click), then always process the - // motion notify coordinates as given (no snapping back to origin) + // Once the user has moved farther than tolerance from + // the original location (indicating they intend to move + // the object, not click), then always process the motion + // notify coordinates as given (no snapping back to origin) within_tolerance = false; - if (Inkscape::Rubberband::get(desktop)->is_started()) { - Inkscape::Rubberband::get(desktop)->move(motion_dt); - } else { - Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt); - } + // gobble subsequent motion events to prevent "sticking" + // when scrolling is slow + gobble_motion_events(panning == 2 ? GDK_BUTTON2_MASK : (panning + == 1 ? GDK_BUTTON1_MASK : GDK_BUTTON3_MASK)); - if (zoom_rb == 2) { - gobble_motion_events(GDK_BUTTON2_MASK); + if (panning_cursor == 0) { + panning_cursor = 1; + this->sp_event_context_set_cursor(GDK_FLEUR); } - } - break; - case GDK_BUTTON_RELEASE: - if (this->rotating_mode && event->button.button == 2) { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const moved_w(motion_w - button_w); + this->desktop->scroll_relative(moved_w, true); // we're still scrolling, do not redraw ret = TRUE; - if (desktop->canvas->endRotateTo()) { - sp_repr_set_svg_double(desktop->namedview->getRepr(), "inkscape:document-rotation", angle); - } + } + } else if (zoom_rb) { + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const motion_dt(desktop->w2d(motion_w)); + + if (within_tolerance && (abs((gint) event->motion.x - xp) + < tolerance) && (abs((gint) event->motion.y - yp) + < tolerance)) { + break; // do not drag if we're within tolerance from origin + } + + // Once the user has moved farther than tolerance from the original location + // (indicating they intend to move the object, not click), then always process the + // motion notify coordinates as given (no snapping back to origin) + within_tolerance = false; + + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->move(motion_dt); } else { - xp = yp = 0; - if (panning_cursor == 1) { - panning_cursor = 0; - GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); - gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); - } + Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt); + } - if (within_tolerance && (panning || zoom_rb)) { - zoom_rb = 0; + if (zoom_rb == 2) { + gobble_motion_events(GDK_BUTTON2_MASK); + } + } + break; - if (panning) { - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), - event->button.time); - } + case GDK_BUTTON_RELEASE: - Geom::Point const event_w(event->button.x, event->button.y); - Geom::Point const event_dt(desktop->w2d(event_w)); + xp = yp = 0; - double const zoom_inc = prefs->getDoubleLimited( - "/options/zoomincrement/value", M_SQRT2, 1.01, 10); + if (panning_cursor == 1) { + panning_cursor = 0; + GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); + gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); + } - desktop->zoom_relative_keep_point(event_dt, (event->button.state - & GDK_SHIFT_MASK) ? 1 / zoom_inc : zoom_inc); + if (within_tolerance && (panning || zoom_rb)) { + zoom_rb = 0; - desktop->updateNow(); - ret = TRUE; - } else if (panning == event->button.button) { - panning = 0; - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), - event->button.time); + if (panning) { + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->button.time); + } - // in slow complex drawings, some of the motion events are lost; - // to make up for this, we scroll it once again to the button-up event coordinates - // (i.e. canvas will always get scrolled all the way to the mouse release point, - // even if few intermediate steps were visible) - Geom::Point const motion_w(event->button.x, event->button.y); - Geom::Point const moved_w(motion_w - button_w); + Geom::Point const event_w(event->button.x, event->button.y); + Geom::Point const event_dt(desktop->w2d(event_w)); - this->desktop->scroll_relative(moved_w); - desktop->updateNow(); - ret = TRUE; - } else if (zoom_rb == event->button.button) { - zoom_rb = 0; + double const zoom_inc = prefs->getDoubleLimited( + "/options/zoomincrement/value", M_SQRT2, 1.01, 10); - Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle(); - Inkscape::Rubberband::get(desktop)->stop(); + desktop->zoom_relative_keep_point(event_dt, (event->button.state + & GDK_SHIFT_MASK) ? 1 / zoom_inc : zoom_inc); - if (b && !within_tolerance) { - desktop->set_display_area(*b, 10); - } + desktop->updateNow(); + ret = TRUE; + } else if (panning == event->button.button) { + panning = 0; + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->button.time); + + // in slow complex drawings, some of the motion events are lost; + // to make up for this, we scroll it once again to the button-up event coordinates + // (i.e. canvas will always get scrolled all the way to the mouse release point, + // even if few intermediate steps were visible) + Geom::Point const motion_w(event->button.x, event->button.y); + Geom::Point const moved_w(motion_w - button_w); + + this->desktop->scroll_relative(moved_w); + desktop->updateNow(); + ret = TRUE; + } else if (zoom_rb == event->button.button) { + zoom_rb = 0; - ret = TRUE; - } - if (this->rotating_mode && event->button.button != 3) { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - ret = TRUE; - desktop->canvas->endRotateTo(); - } - } - break; + Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle(); + Inkscape::Rubberband::get(desktop)->stop(); - case GDK_KEY_PRESS: { - double const acceleration = prefs->getDoubleLimited( - "/options/scrollingacceleration/value", 0, 0, 6); - int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", - 10, 0, 1000); - - if (this->rotating_mode && - get_group0_keyval(&event->key) != GDK_KEY_space && - get_group0_keyval(&event->key) != GDK_KEY_Shift_L && - get_group0_keyval(&event->key) != GDK_KEY_Shift_R && - get_group0_keyval(&event->key) != GDK_KEY_Control_L && - get_group0_keyval(&event->key) != GDK_KEY_Control_R && - get_group0_keyval(&event->key) != GDK_KEY_Alt_L && - get_group0_keyval(&event->key) != GDK_KEY_Alt_R ) - { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - ret = TRUE; - desktop->canvas->endRotateTo(); - break; + if (b && !within_tolerance) { + desktop->set_display_area(*b, 10); } - switch (get_group0_keyval(&event->key)) { - // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets - // in the editing window). So we resteal them back and run our regular shortcut - // invoker on them. - unsigned int shortcut; - case GDK_KEY_Tab: - case GDK_KEY_ISO_Left_Tab: - case GDK_KEY_F1: - shortcut = get_group0_keyval(&event->key); - - if (event->key.state & GDK_SHIFT_MASK) { - shortcut |= SP_SHORTCUT_SHIFT_MASK; - } + ret = TRUE; + } + break; - if (event->key.state & GDK_CONTROL_MASK) { - shortcut |= SP_SHORTCUT_CONTROL_MASK; - } + case GDK_KEY_PRESS: { + double const acceleration = prefs->getDoubleLimited( + "/options/scrollingacceleration/value", 0, 0, 6); + int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", + 10, 0, 1000); + + switch (get_group0_keyval(&event->key)) { + // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets + // in the editing window). So we resteal them back and run our regular shortcut + // invoker on them. + unsigned int shortcut; + case GDK_KEY_Tab: + case GDK_KEY_ISO_Left_Tab: + case GDK_KEY_F1: + shortcut = get_group0_keyval(&event->key); + + if (event->key.state & GDK_SHIFT_MASK) { + shortcut |= SP_SHORTCUT_SHIFT_MASK; + } - if (event->key.state & GDK_MOD1_MASK) { - shortcut |= SP_SHORTCUT_ALT_MASK; - } + if (event->key.state & GDK_CONTROL_MASK) { + shortcut |= SP_SHORTCUT_CONTROL_MASK; + } - ret = sp_shortcut_invoke(shortcut, desktop); - break; + if (event->key.state & GDK_MOD1_MASK) { + shortcut |= SP_SHORTCUT_ALT_MASK; + } - case GDK_KEY_Q: - case GDK_KEY_q: - if (desktop->quick_zoomed()) { - ret = TRUE; - } - if (!MOD__SHIFT(event) && !MOD__CTRL(event) && !MOD__ALT(event)) { - desktop->zoom_quick(true); - ret = TRUE; - } - break; + ret = sp_shortcut_invoke(shortcut, desktop); + break; - case GDK_KEY_W: - case GDK_KEY_w: - case GDK_KEY_F4: - /* Close view */ - if (MOD__CTRL_ONLY(event)) { - sp_ui_close_view(NULL); - ret = TRUE; - } - break; + case GDK_KEY_Q: + case GDK_KEY_q: + if (desktop->quick_zoomed()) { + ret = TRUE; + } + if (!MOD__SHIFT(event) && !MOD__CTRL(event) && !MOD__ALT(event)) { + desktop->zoom_quick(true); + ret = TRUE; + } + break; - case GDK_KEY_Left: // Ctrl Left - case GDK_KEY_KP_Left: - case GDK_KEY_KP_4: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + case GDK_KEY_W: + case GDK_KEY_w: + case GDK_KEY_F4: + /* Close view */ + if (MOD__CTRL_ONLY(event)) { + sp_ui_close_view(NULL); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(i, 0)); - ret = TRUE; - } - break; + case GDK_KEY_Left: // Ctrl Left + case GDK_KEY_KP_Left: + case GDK_KEY_KP_4: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Up: // Ctrl Up - case GDK_KEY_KP_Up: - case GDK_KEY_KP_8: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(i, 0)); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(0, i)); - ret = TRUE; - } - break; + case GDK_KEY_Up: // Ctrl Up + case GDK_KEY_KP_Up: + case GDK_KEY_KP_8: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Right: // Ctrl Right - case GDK_KEY_KP_Right: - case GDK_KEY_KP_6: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(0, i)); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(-i, 0)); - ret = TRUE; - } - break; + case GDK_KEY_Right: // Ctrl Right + case GDK_KEY_KP_Right: + case GDK_KEY_KP_6: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Down: // Ctrl Down - case GDK_KEY_KP_Down: - case GDK_KEY_KP_2: - if (MOD__CTRL_ONLY(event)) { - int i = (int) floor(key_scroll * accelerate_scroll(event, - acceleration, desktop->getCanvas())); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(-i, 0)); + ret = TRUE; + } + break; - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); - this->desktop->scroll_relative(Geom::Point(0, -i)); - ret = TRUE; - } - break; + case GDK_KEY_Down: // Ctrl Down + case GDK_KEY_KP_Down: + case GDK_KEY_KP_2: + if (MOD__CTRL_ONLY(event)) { + int i = (int) floor(key_scroll * accelerate_scroll(event, + acceleration, desktop->getCanvas())); - case GDK_KEY_Menu: - sp_event_root_menu_popup(desktop, NULL, event); + gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + this->desktop->scroll_relative(Geom::Point(0, -i)); ret = TRUE; - break; + } + break; - case GDK_KEY_F10: - if (MOD__SHIFT_ONLY(event)) { - sp_event_root_menu_popup(desktop, NULL, event); - ret = TRUE; - } - break; + case GDK_KEY_Menu: + sp_event_root_menu_popup(desktop, NULL, event); + ret = TRUE; + break; - case GDK_KEY_space: -// if (event->key.state & GDK_CONTROL_MASK) { -// sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); -// desktop->canvas->startRotateTo(desktop->namedview->document_rotation); -// this->rotating_mode = true; -// this->message_context->set(Inkscape::INFORMATION_MESSAGE, -// _("<b>Space+mouse move</b> to rotate canvas, use modifiers on screen to change snaps")); -// } else { - within_tolerance = true; - xp = yp = 0; - if (!allow_panning) break; - panning = 4; - this->space_panning = true; - this->message_context->set(Inkscape::INFORMATION_MESSAGE, - _("<b>Space+mouse move</b> to pan canvas")); -// } + case GDK_KEY_F10: + if (MOD__SHIFT_ONLY(event)) { + sp_event_root_menu_popup(desktop, NULL, event); ret = TRUE; - break; + } + break; - case GDK_KEY_z: - case GDK_KEY_Z: - if (MOD__ALT_ONLY(event)) { - desktop->zoom_grab_focus(); - ret = TRUE; - } - break; + case GDK_KEY_space: + within_tolerance = true; + xp = yp = 0; + if (!allow_panning) break; + panning = 4; + this->space_panning = true; + this->message_context->set(Inkscape::INFORMATION_MESSAGE, + _("<b>Space+mouse move</b> to pan canvas")); - default: - break; - } - } + ret = TRUE; break; - case GDK_KEY_RELEASE: - if (this->rotating_mode && - get_group0_keyval(&event->key) != GDK_KEY_space && - get_group0_keyval(&event->key) != GDK_KEY_Shift_L && - get_group0_keyval(&event->key) != GDK_KEY_Shift_R && - get_group0_keyval(&event->key) != GDK_KEY_Control_L && - get_group0_keyval(&event->key) != GDK_KEY_Control_R && - get_group0_keyval(&event->key) != GDK_KEY_Alt_L && - get_group0_keyval(&event->key) != GDK_KEY_Alt_R ) - { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; + case GDK_KEY_z: + case GDK_KEY_Z: + if (MOD__ALT_ONLY(event)) { + desktop->zoom_grab_focus(); ret = TRUE; - desktop->canvas->endRotateTo(); - break; } + break; - // Stop panning on any key release - if (this->space_panning) { - this->space_panning = false; - this->message_context->clear(); + default: + break; } + } + break; - if (panning) { - panning = 0; - xp = yp = 0; + case GDK_KEY_RELEASE: + // Stop panning on any key release + if (this->space_panning) { + this->space_panning = false; + this->message_context->clear(); + } - sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), - event->key.time); + if (panning) { + panning = 0; + xp = yp = 0; + + sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), + event->key.time); + + desktop->updateNow(); + } + + if (panning_cursor == 1) { + panning_cursor = 0; + GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); + gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); + } + + switch (get_group0_keyval(&event->key)) { + case GDK_KEY_space: + if (within_tolerance) { + // Space was pressed, but not panned + sp_toggle_selector(desktop); - desktop->updateNow(); + // Be careful, sp_toggle_selector will delete ourselves. + // Thus, make sure we return immediately. + return true; } - if (panning_cursor == 1) { - panning_cursor = 0; - GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); - gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); + break; + + case GDK_KEY_Q: + case GDK_KEY_q: + if (desktop->quick_zoomed()) { + desktop->zoom_quick(false); + ret = TRUE; } + break; - switch (get_group0_keyval(&event->key)) { - case GDK_KEY_space: -// if (this->rotating_mode) { -// desktop->canvas->clearRotateTo(); -// this->rotating_mode = false; -// ret = TRUE; -// if (desktop->canvas->endRotateTo()) { -// sp_repr_set_svg_double(desktop->namedview->getRepr(), "inkscape:document-rotation", angle); -// } -// } - if (within_tolerance) { - // Space was pressed, but not panned - sp_toggle_selector(desktop); - - // Be careful, sp_toggle_selector will delete ourselves. - // Thus, make sure we return immediately. - return true; - } + default: + break; + } + break; + + case GDK_SCROLL: { + bool ctrl = (event->scroll.state & GDK_CONTROL_MASK); + bool shift = (event->scroll.state & GDK_SHIFT_MASK); + bool wheelzooms = prefs->getBool("/options/wheelzooms/value"); + + int const wheel_scroll = prefs->getIntLimited( + "/options/wheelscroll/value", 40, 0, 1000); + + // Size of smooth-scrolls (only used in GTK+ 3) + gdouble delta_x = 0; + gdouble delta_y = 0; + + if (ctrl & shift) { + /* ctrl + shift, rotate */ + + double rotate_inc = prefs->getDoubleLimited( + "/options/rotateincrement/value", 15, 1, 90, "°" ); + rotate_inc *= M_PI/180.0; + + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + // Do nothing break; - case GDK_KEY_Q: - case GDK_KEY_q: - if (desktop->quick_zoomed()) { - desktop->zoom_quick(false); - ret = TRUE; - } + case GDK_SCROLL_DOWN: + rotate_inc = -rotate_inc; break; default: + rotate_inc = 0.0; break; } - break; - case GDK_SCROLL: { - if (this->rotating_mode) { - desktop->canvas->clearRotateTo(); - this->rotating_mode = false; - desktop->canvas->endRotateTo(); + if (rotate_inc != 0.0) { + Geom::Point const scroll_dt = desktop->point(); + desktop->rotate_relative_keep_point(scroll_dt, rotate_inc); } - bool ctrl = (event->scroll.state & GDK_CONTROL_MASK); - bool wheelzooms = prefs->getBool("/options/wheelzooms/value"); - - int const wheel_scroll = prefs->getIntLimited( - "/options/wheelscroll/value", 40, 0, 1000); - // Size of smooth-scrolls (only used in GTK+ 3) - gdouble delta_x = 0; - gdouble delta_y = 0; + } else if (event->scroll.state & GDK_SHIFT_MASK) { + /* shift + wheel, pan left--right */ - /* shift + wheel, pan left--right */ - if (event->scroll.state & GDK_SHIFT_MASK) { - switch (event->scroll.direction) { - case GDK_SCROLL_UP: - desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); - break; + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); + break; - case GDK_SCROLL_DOWN: - desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); - break; + case GDK_SCROLL_DOWN: + desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); + break; - default: - break; - } + default: + break; + } - /* ctrl + wheel, zoom in--out */ - } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) { - double rel_zoom; - double const zoom_inc = prefs->getDoubleLimited( - "/options/zoomincrement/value", M_SQRT2, 1.01, 10); + } else if ((ctrl && !wheelzooms) || (!ctrl && wheelzooms)) { + /* ctrl + wheel, zoom in--out */ + double rel_zoom; + double const zoom_inc = prefs->getDoubleLimited( + "/options/zoomincrement/value", M_SQRT2, 1.01, 10); - switch (event->scroll.direction) { - case GDK_SCROLL_UP: - rel_zoom = zoom_inc; - break; + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + rel_zoom = zoom_inc; + break; - case GDK_SCROLL_DOWN: - rel_zoom = 1 / zoom_inc; - break; + case GDK_SCROLL_DOWN: + rel_zoom = 1 / zoom_inc; + break; - default: - rel_zoom = 0.0; - break; - } + default: + rel_zoom = 0.0; + break; + } - if (rel_zoom != 0.0) { - Geom::Point const scroll_dt = desktop->point(); - desktop->zoom_relative_keep_point(scroll_dt, rel_zoom); - } + if (rel_zoom != 0.0) { + Geom::Point const scroll_dt = desktop->point(); + desktop->zoom_relative_keep_point(scroll_dt, rel_zoom); + } - /* no modifier, pan up--down (left--right on multiwheel mice?) */ - } else { - switch (event->scroll.direction) { - case GDK_SCROLL_UP: - desktop->scroll_relative(Geom::Point(0, wheel_scroll)); - break; + /* no modifier, pan up--down (left--right on multiwheel mice?) */ + } else { + switch (event->scroll.direction) { + case GDK_SCROLL_UP: + desktop->scroll_relative(Geom::Point(0, wheel_scroll)); + break; - case GDK_SCROLL_DOWN: - desktop->scroll_relative(Geom::Point(0, -wheel_scroll)); - break; + case GDK_SCROLL_DOWN: + desktop->scroll_relative(Geom::Point(0, -wheel_scroll)); + break; - case GDK_SCROLL_LEFT: - desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); - break; + case GDK_SCROLL_LEFT: + desktop->scroll_relative(Geom::Point(wheel_scroll, 0)); + break; - case GDK_SCROLL_RIGHT: - desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); - break; + case GDK_SCROLL_RIGHT: + desktop->scroll_relative(Geom::Point(-wheel_scroll, 0)); + break; - case GDK_SCROLL_SMOOTH: - gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); - desktop->scroll_relative(Geom::Point(delta_x, delta_y)); - break; - } + case GDK_SCROLL_SMOOTH: + gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); + desktop->scroll_relative(Geom::Point(delta_x, delta_y)); + break; } - break; } - default: - break; + break; } + default: + break; + } + return ret; } @@ -1255,47 +1209,6 @@ sp_event_context_get_shape_editor(ToolBase *ec) { return ec->shape_editor; } -void event_context_print_event_info(GdkEvent *event, bool print_return) { - switch (event->type) { - case GDK_BUTTON_PRESS: - g_print("GDK_BUTTON_PRESS"); - break; - case GDK_2BUTTON_PRESS: - g_print("GDK_2BUTTON_PRESS"); - break; - case GDK_3BUTTON_PRESS: - g_print("GDK_3BUTTON_PRESS"); - break; - - case GDK_MOTION_NOTIFY: - g_print("GDK_MOTION_NOTIFY"); - break; - case GDK_ENTER_NOTIFY: - g_print("GDK_ENTER_NOTIFY"); - break; - - case GDK_LEAVE_NOTIFY: - g_print("GDK_LEAVE_NOTIFY"); - break; - case GDK_BUTTON_RELEASE: - g_print("GDK_BUTTON_RELEASE"); - break; - - case GDK_KEY_PRESS: - g_print("GDK_KEY_PRESS: %d", get_group0_keyval(&event->key)); - break; - case GDK_KEY_RELEASE: - g_print("GDK_KEY_RELEASE: %d", get_group0_keyval(&event->key)); - break; - default: - //g_print ("even type not recognized"); - break; - } - - if (print_return) { - g_print("\n"); - } -} /** * Analyses the current event, calculates the mouse speed, turns snapping off (temporarily) if the diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index ca42d2d6f..d40d2e969 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -103,12 +103,14 @@ bool ZoomTool::root_handler(GdkEvent* event) { desktop->zoom_relative_keep_point(button_dt, zoom_rel); ret = true; } - - sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), - GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - this->grabbed = SP_CANVAS_ITEM(desktop->acetate); + sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), + GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, + NULL, event->button.time); + + this->grabbed = SP_CANVAS_ITEM(desktop->acetate); break; } @@ -156,10 +158,10 @@ bool ZoomTool::root_handler(GdkEvent* event) { Inkscape::Rubberband::get(desktop)->stop(); - if (this->grabbed) { - sp_canvas_item_ungrab(this->grabbed, event->button.time); - this->grabbed = NULL; - } + if (this->grabbed) { + sp_canvas_item_ungrab(this->grabbed, event->button.time); + this->grabbed = NULL; + } xp = yp = 0; escaped = false; diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index fcba0c6da..c93b1f0ee 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -128,6 +128,9 @@ struct EditWidgetInterface /// The zoom display will get the keyboard focus. virtual void letZoomGrabFocus() = 0; + /// Temporarily block signals and update rotation display + virtual void updateRotation() = 0; + /// In auxiliary toolbox, set focus to widget having specific id virtual void setToolboxFocusTo (const gchar *) = 0; diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp index 89913b01b..4023d227c 100644 --- a/src/ui/widget/color-scales.cpp +++ b/src/ui/widget/color-scales.cpp @@ -48,6 +48,7 @@ ColorScales::ColorScales(SelectedColor &color, SPColorScalesMode mode) , _rangeLimit(255.0) , _updating(FALSE) , _dragging(FALSE) + , _mode(SP_COLOR_SCALES_MODE_NONE) { for (gint i = 0; i < 5; i++) { _l[i] = 0; diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index e0de22335..0e290730d 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -34,6 +34,7 @@ Rotateable::Rotateable(): signal_button_press_event().connect(sigc::mem_fun(*this, &Rotateable::on_click)); signal_motion_notify_event().connect(sigc::mem_fun(*this, &Rotateable::on_motion)); signal_button_release_event().connect(sigc::mem_fun(*this, &Rotateable::on_release)); + gtk_widget_add_events(GTK_WIDGET(gobj()), GDK_SCROLL_MASK); signal_scroll_event().connect(sigc::mem_fun(*this, &Rotateable::on_scroll)); } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 0370d55db..65d68195c 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1380,13 +1380,8 @@ RotateableStrokeWidth::value_adjust(double current, double by, guint /*modifier* { double newval; // by is -1..1 - if (by < 0) { - // map negative 0..-1 to current..0 - newval = current * (1 + by); - } else { - // map positive 0..1 to current..4*current - newval = current * (1 + by) * (1 + by); - } + double max_f = 50; // maximum width is (current * max_f), minimum - zero + newval = current * (std::exp(std::log(max_f-1) * (by+1)) - 1) / (max_f-2); SPCSSAttr *css = sp_repr_css_attr_new (); if (final && newval < 1e-6) { @@ -1394,6 +1389,7 @@ RotateableStrokeWidth::value_adjust(double current, double by, guint /*modifier* // if it's not final, leave it a chance to increase again (which is not possible with "none") sp_repr_css_set_property (css, "stroke", "none"); } else { + newval = Inkscape::Util::Quantity::convert(newval, parent->_sw_unit, "px"); Inkscape::CSSOStringStream os; os << newval; sp_repr_css_set_property (css, "stroke-width", os.str().c_str()); diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index efac29f73..065d745f0 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -131,6 +131,7 @@ public: guint _mode[2]; double current_stroke_width; + Inkscape::Util::Unit const *_sw_unit; // points to object in UnitTable, do not delete protected: SPDesktop *_desktop; @@ -271,8 +272,6 @@ protected: void on_popup_preset(int i); Gtk::MenuItem _popup_sw_remove; - Inkscape::Util::Unit const *_sw_unit; /// points to object in UnitTable, do not delete - void *_drop[2]; bool _dropEnabled[2]; }; |
