diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-03-01 22:16:20 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-03-01 22:16:20 +0000 |
| commit | c4a09144149f9a435c271e133ab19546680c273e (patch) | |
| tree | 0ed4007da8302d14f7d4a91c53794f5715d41c8d /src | |
| parent | update to trunk (diff) | |
| parent | Fix for crash when cycle-selecting. (diff) | |
| download | inkscape-c4a09144149f9a435c271e133ab19546680c273e.tar.gz inkscape-c4a09144149f9a435c271e133ab19546680c273e.zip | |
update to trunk
(bzr r11950.1.263)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/nr-filter-gaussian.cpp | 21 | ||||
| -rw-r--r-- | src/display/nr-filter-offset.cpp | 16 | ||||
| -rw-r--r-- | src/ui/tools/dropper-tool.cpp | 4 | ||||
| -rw-r--r-- | src/ui/tools/select-tool.cpp | 66 | ||||
| -rw-r--r-- | src/ui/tools/select-tool.h | 1 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 18 |
6 files changed, 76 insertions, 50 deletions
diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index b96e24cbc..24960af78 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -568,12 +568,21 @@ void FilterGaussian::render_cairo(FilterSlot &slot) return; } - Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); + // Handle bounding box case. + double dx = _deviation_x; + double dy = _deviation_y; + if( slot.get_units().get_primitive_units() == SP_FILTER_UNITS_OBJECTBOUNDINGBOX ) { + Geom::OptRect const bbox = slot.get_units().get_item_bbox(); + if( bbox ) { + dx *= (*bbox).width(); + dy *= (*bbox).height(); + } + } - int w_orig = ink_cairo_surface_get_width(in); - int h_orig = ink_cairo_surface_get_height(in); - double deviation_x_orig = _deviation_x * trans.expansionX(); - double deviation_y_orig = _deviation_y * trans.expansionY(); + Geom::Affine trans = slot.get_units().get_matrix_user2pb(); + + double deviation_x_orig = dx * trans.expansionX(); + double deviation_y_orig = dy * trans.expansionY(); cairo_format_t fmt = cairo_image_surface_get_format(in); int bytes_per_pixel = 0; switch (fmt) { @@ -595,6 +604,8 @@ void FilterGaussian::render_cairo(FilterSlot &slot) int x_step = 1 << _effect_subsample_step_log2(deviation_x_orig, quality); int y_step = 1 << _effect_subsample_step_log2(deviation_y_orig, quality); bool resampling = x_step > 1 || y_step > 1; + int w_orig = ink_cairo_surface_get_width(in); + int h_orig = ink_cairo_surface_get_height(in); int w_downsampled = resampling ? static_cast<int>(ceil(static_cast<double>(w_orig)/x_step))+1 : w_orig; int h_downsampled = resampling ? static_cast<int>(ceil(static_cast<double>(h_orig)/y_step))+1 : h_orig; double deviation_x = deviation_x_orig / x_step; diff --git a/src/display/nr-filter-offset.cpp b/src/display/nr-filter-offset.cpp index 01d6ffe56..af1081abe 100644 --- a/src/display/nr-filter-offset.cpp +++ b/src/display/nr-filter-offset.cpp @@ -40,8 +40,20 @@ void FilterOffset::render_cairo(FilterSlot &slot) cairo_t *ct = cairo_create(out); - Geom::Affine trans = slot.get_units().get_matrix_primitiveunits2pb(); - Geom::Point offset(dx, dy); + // Handle bounding box case + double x = dx; + double y = dy; + if( slot.get_units().get_primitive_units() == SP_FILTER_UNITS_OBJECTBOUNDINGBOX ) { + Geom::OptRect bbox = slot.get_units().get_item_bbox(); + if( bbox ) { + x *= (*bbox).width(); + y *= (*bbox).height(); + } + } + + Geom::Affine trans = slot.get_units().get_matrix_user2pb(); + + Geom::Point offset(x, y); offset *= trans; offset[X] -= trans[4]; offset[Y] -= trans[5]; diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index e9e2d6c39..99d42a211 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -336,6 +336,10 @@ bool DropperTool::root_handler(GdkEvent* event) { if (prefs->getBool("/tools/dropper/onetimepick", false)) { prefs->setBool("/tools/dropper/onetimepick", false); sp_toggle_dropper(desktop); + + // sp_toggle_dropper will delete ourselves. + // Thus, make sure we return immediately. + return true; } ret = TRUE; diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 85bc3fd4a..83bef17c9 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -125,7 +125,6 @@ SelectTool::SelectTool() //static bool within_tolerance = false; static bool is_cycling = false; static bool moved_while_cycling = false; -ToolBase *prev_event_context = NULL; SelectTool::~SelectTool() { @@ -441,24 +440,20 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele } } +void SelectTool::sp_select_context_reset_opacities() { + for (GList *l = this->cycling_items; l != NULL; l = g_list_next(l)) { + Inkscape::DrawingItem *arenaitem = SP_ITEM(l->data)->get_arenaitem(this->desktop->dkey); + arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(SP_ITEM(l->data)->style->opacity.value)); + } -static void -sp_select_context_reset_opacities(ToolBase *event_context) -{ - // SPDesktop *desktop = event_context->desktop; - SelectTool *sc = SP_SELECT_CONTEXT(event_context); - Inkscape::DrawingItem *arenaitem; - for (GList *l = sc->cycling_items; l != NULL; l = g_list_next(l)) { - arenaitem = SP_ITEM(l->data)->get_arenaitem(event_context->desktop->dkey); - arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(SP_ITEM(l->data)->style->opacity.value)); - } - g_list_free(sc->cycling_items); - g_list_free(sc->cycling_items_selected_before); - g_list_free(sc->cycling_items_cmp); - sc->cycling_items = NULL; - sc->cycling_items_selected_before = NULL; - sc->cycling_cur_item = NULL; - sc->cycling_items_cmp = NULL; + g_list_free(this->cycling_items); + g_list_free(this->cycling_items_selected_before); + g_list_free(this->cycling_items_cmp); + + this->cycling_items = NULL; + this->cycling_items_selected_before = NULL; + this->cycling_cur_item = NULL; + this->cycling_items_cmp = NULL; } bool SelectTool::root_handler(GdkEvent* event) { @@ -545,11 +540,9 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_MOTION_NOTIFY: { - if (is_cycling) - { - moved_while_cycling = true; - prev_event_context = this; - } + if (is_cycling) { + moved_while_cycling = true; + } tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); @@ -811,14 +804,12 @@ bool SelectTool::root_handler(GdkEvent* event) { GdkEventScroll *scroll_event = (GdkEventScroll*) event; if (scroll_event->state & GDK_MOD1_MASK) { // alt modified pressed - if (moved_while_cycling) - { - moved_while_cycling = false; - sp_select_context_reset_opacities(prev_event_context); - prev_event_context = NULL; - } + if (moved_while_cycling) { + moved_while_cycling = false; + this->sp_select_context_reset_opacities(); + } - is_cycling = true; + is_cycling = true; bool shift_pressed = scroll_event->state & GDK_SHIFT_MASK; @@ -1205,18 +1196,15 @@ bool SelectTool::root_handler(GdkEvent* event) { Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_RECT); } } else { - if (alt) { // TODO: Should we have a variable like is_cycling or is it harmless to run this piece of code each time? + if (alt) { // quit cycle-selection and reset opacities - if (is_cycling) - { - sp_select_context_reset_opacities(this); - is_cycling = false; - } - + if (is_cycling) { + this->sp_select_context_reset_opacities(); + is_cycling = false; + } } } - } // set cursor to default. if (!desktop->isWaitingCursor()) { // Do we need to reset the cursor here on key release ? @@ -1224,7 +1212,7 @@ bool SelectTool::root_handler(GdkEvent* event) { //gdk_window_set_cursor(window, event_context->cursor); } break; - + } default: break; } diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h index 81763e8b1..edc4069a2 100644 --- a/src/ui/tools/select-tool.h +++ b/src/ui/tools/select-tool.h @@ -64,6 +64,7 @@ public: private: bool sp_select_context_abort(); void sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed); + void sp_select_context_reset_opacities(); }; } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index dc10e9388..99b72c386 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -739,10 +739,12 @@ bool ToolBase::root_handler(GdkEvent* event) { if (within_tolerance == true) { // Space was pressed, but not panned sp_toggle_selector(desktop); - ret = TRUE; + + // Be careful, sp_toggle_selector will delete ourselves. + // Thus, make sure we return immediately. + return true; } - within_tolerance = false; break; case GDK_KEY_Q: @@ -975,10 +977,18 @@ gint sp_event_context_root_handler(ToolBase * event_context, gint sp_event_context_virtual_root_handler(ToolBase * event_context, GdkEvent * event) { gint ret = false; + if (event_context) { - ret = event_context->root_handler(event); - set_event_location(event_context->desktop, event); + // The root handler also handles pressing the space key. + // This will toggle the current tool and delete the current one. + // Thus, save a pointer to the desktop before calling it. + SPDesktop* desktop = event_context->desktop; + + ret = event_context->root_handler(event); + + set_event_location(desktop, event); } + return ret; } |
