From 457a6606406c6b5830fc6990866b1d2cd847602b Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 23 Feb 2014 19:48:29 -0500 Subject: fix typos in page-sizer (Bug 1240308) Fixed bugs: - https://launchpad.net/bugs/1240308 (bzr r13052) --- src/ui/widget/page-sizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b13567adb..b35f35403 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -555,7 +555,7 @@ PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity { double smaller = w.quantity; double larger = h.quantity; - if ( h < w ) { + if ( h.quantity < w.quantity ) { smaller = h.quantity; larger = w.quantity; } @@ -568,7 +568,7 @@ PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity double smallX = Inkscape::Util::Quantity::convert(paper.smaller, paper.unit, w.unit); double largeX = Inkscape::Util::Quantity::convert(paper.larger, paper.unit, w.unit); - g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); + g_return_val_if_fail(smallX < largeX + 0.001, _paperSizeListStore->children().end()); if ((std::abs(smaller - smallX) <= 0.1) && (std::abs(larger - largeX) <= 0.1) ) { -- cgit v1.2.3 From f6060c9447e6f2e5a70e957c19bd4eb1ae4babef Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Feb 2014 20:32:07 +0100 Subject: inspired by r13052, fix up the code to hopefully work when someone has different units for height and width of the page. Fixed bugs: - https://launchpad.net/bugs/1240308 (bzr r13053) --- src/ui/widget/page-sizer.cpp | 32 ++++++++++++++++++-------------- src/util/units.cpp | 13 ++++++++++--- src/util/units.h | 8 +++++++- 3 files changed, 35 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b35f35403..eae0d4a95 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -547,36 +547,40 @@ PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr) /** * Returns an iterator pointing to a row in paperSizeListStore which - * contains a paper of the specified size (specified in px), or + * contains a paper of the specified size, or * paperSizeListStore->children().end() if no such paper exists. + * + * The code is not tested for the case where w and h have different units. */ Gtk::ListStore::iterator PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h) const { - double smaller = w.quantity; - double larger = h.quantity; - if ( h.quantity < w.quantity ) { - smaller = h.quantity; larger = w.quantity; + using Inkscape::Util::Quantity; + using std::swap; + + // The code below assumes that w < h, so make sure that's the case: + if ( h < w ) { + swap(h,w); } - g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end()); + g_return_val_if_fail(w <= h, _paperSizeListStore->children().end()); std::map::const_iterator iter; for (iter = _paperSizeTable.begin() ; iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; - double smallX = Inkscape::Util::Quantity::convert(paper.smaller, paper.unit, w.unit); - double largeX = Inkscape::Util::Quantity::convert(paper.larger, paper.unit, w.unit); + Quantity smallX (paper.smaller, paper.unit); + Quantity largeX (paper.larger, paper.unit); - g_return_val_if_fail(smallX < largeX + 0.001, _paperSizeListStore->children().end()); + g_return_val_if_fail(smallX.quantity < largeX.quantity + 0.001, _paperSizeListStore->children().end()); - if ((std::abs(smaller - smallX) <= 0.1) && - (std::abs(larger - largeX) <= 0.1) ) { - Gtk::ListStore::iterator p; + if ( are_near(w, smallX, 0.1) && are_near(h, largeX, 0.1) ) { + Gtk::ListStore::iterator p = _paperSizeListStore->children().begin(); + Gtk::ListStore::iterator pend = _paperSizeListStore->children().end(); // We need to search paperSizeListStore explicitly for the // specified paper size because it is sorted in a different // way than paperSizeTable (which is sorted alphabetically) - for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); ++p) { + for ( ; p != pend; ++p) { if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) { return p; } @@ -601,7 +605,7 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing() SPDocument *doc; SPNamedView *nv; Inkscape::XML::Node *nv_repr; - + if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP)) && (nv = sp_document_namedview(doc, 0)) && (nv_repr = nv->getRepr())) { diff --git a/src/util/units.cpp b/src/util/units.cpp index 40cce028d..d2053f60b 100644 --- a/src/util/units.cpp +++ b/src/util/units.cpp @@ -505,16 +505,23 @@ double Quantity::convert(double from_dist, char const *from, char const *to) return convert(from_dist, unit_table.getUnit(from), unit_table.getUnit(to)); } -bool Quantity::operator<(Quantity const &other) const +bool Quantity::operator<(Quantity const &rhs) const { - if (unit->type != other.unit->type) { + if (unit->type != rhs.unit->type) { g_warning("Incompatible units"); return false; } - return quantity < other.value(unit); + return quantity < rhs.value(unit); } bool Quantity::operator==(Quantity const &other) const { + /** \fixme This is overly strict. I think we should change this to: + if (unit->type != other.unit->type) { + g_warning("Incompatible units"); + return false; + } + return are_near(quantity, other.value(unit)); + */ return (*unit == *other.unit) && (quantity == other.quantity); } diff --git a/src/util/units.h b/src/util/units.h index 597371369..efe1dbec7 100644 --- a/src/util/units.h +++ b/src/util/units.h @@ -16,6 +16,7 @@ #include #include #include +#include <2geom/coord.h> #include "svg/svg-length.h" #include "unordered-containers.h" @@ -112,10 +113,15 @@ public: static double convert(double from_dist, char const *from, char const *to); /** Comparison operators. */ - bool operator<(Quantity const &other) const; + bool operator<(Quantity const &rhs) const; bool operator==(Quantity const &other) const; }; +inline bool are_near(Quantity const &a, Quantity const &b, double eps=Geom::EPSILON) +{ + return Geom::are_near(a.quantity, b.value(a.unit), eps); +} + class UnitTable { public: /** -- cgit v1.2.3 From 5033a179a05667c0de3ba2cd81595f435edbc85b Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Feb 2014 21:01:23 +0100 Subject: Set the order of resize handles back to what they were before r12400. Now it's possible again to access all handles for horizontal lines + geometric bbox Fixed bugs: - https://launchpad.net/bugs/1204193 (bzr r13054) --- src/seltrans-handles.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/seltrans-handles.cpp b/src/seltrans-handles.cpp index 6dd94d297..2f9fb9076 100644 --- a/src/seltrans-handles.cpp +++ b/src/seltrans-handles.cpp @@ -17,22 +17,22 @@ SPSelTransHandle const hands[] = { //center handle will be 0 so we can reference it quickly. {HANDLE_CENTER, SP_ANCHOR_CENTER, GDK_CROSSHAIR, 12, 0.5, 0.5}, //handle-type anchor-nudge cursor image x y - {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1}, - {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5}, - {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0}, - {HANDLE_STRETCH, SP_ANCHOR_E, GDK_LEFT_SIDE, 2, 0, 0.5}, {HANDLE_SCALE, SP_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, 0, 1}, + {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1}, {HANDLE_SCALE, SP_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, 1, 1}, + {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5}, {HANDLE_SCALE, SP_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, 1, 0}, + {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0}, {HANDLE_SCALE, SP_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, 0, 0}, - {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1}, - {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5}, - {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0}, - {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5}, + {HANDLE_STRETCH, SP_ANCHOR_E, GDK_LEFT_SIDE, 2, 0, 0.5}, {HANDLE_ROTATE, SP_ANCHOR_SE, GDK_EXCHANGE, 4, 0, 1}, + {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1}, {HANDLE_ROTATE, SP_ANCHOR_SW, GDK_EXCHANGE, 5, 1, 1}, + {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5}, {HANDLE_ROTATE, SP_ANCHOR_NW, GDK_EXCHANGE, 6, 1, 0}, + {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0}, {HANDLE_ROTATE, SP_ANCHOR_NE, GDK_EXCHANGE, 7, 0, 0}, + {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5}, }; /* -- cgit v1.2.3 From 0917cc6ed7207c0535360dd757705bda30410a47 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Feb 2014 21:28:00 +0100 Subject: Fix infinite loop (?) by disabling saving the order of filters when they are reordered by drag&drop in the filter editor dialog. (bug 1239296) Fixed bugs: - https://launchpad.net/bugs/1239296 (bzr r13055) --- src/ui/dialog/filter-effects-dialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 6a3a4c3f1..e8b09db8b 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1515,11 +1515,16 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa } void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& /*path*/) { +/* The code below is bugged. Use of "object->getRepr()->setPosition(0)" is dangerous! + Writing back the reordered list to XML (reordering XML nodes) should be implemented differently. + Note that the dialog does also not update its list of filters when the order is manually changed + using the XML dialog for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) { SPObject* object = (*i)[_columns.filter]; - if(object && object->getRepr()) + if(object && object->getRepr()) ; object->getRepr()->setPosition(0); } +*/ } void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustring& path) -- cgit v1.2.3 From b777ba99030a6ae4b44bb0a78ce6282f2d99cbe8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 24 Feb 2014 20:09:35 -0500 Subject: Move filter reordering closer to the layers.cpp patern of reordering xml (bzr r13056) --- src/ui/dialog/filter-effects-dialog.cpp | 11 ++++++----- src/ui/dialog/filter-effects-dialog.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index e8b09db8b..b763776c6 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1363,11 +1363,9 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) sw->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _list.get_column(1)->set_resizable(true); _list.set_reorderable(true); + _list.enable_model_drag_dest (Gdk::ACTION_MOVE); - // We can track the drag/drop reordering from the row_delete (occurs after - // row_inserted and may occur many times when adding a new item) - _model->signal_row_deleted().connect( - sigc::mem_fun(*this, &FilterModifier::on_filter_reorder)); + _list.signal_drag_drop().connect( sigc::mem_fun(*this, &FilterModifier::on_filter_move), false ); sw->set_shadow_type(Gtk::SHADOW_IN); show_all_children(); @@ -1514,7 +1512,9 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa } } -void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& /*path*/) { +bool FilterEffectsDialog::FilterModifier::on_filter_move(const Glib::RefPtr& /*context*/, int x, int y, guint /*time*/) { + +//const Gtk::TreeModel::Path& /*path*/) { /* The code below is bugged. Use of "object->getRepr()->setPosition(0)" is dangerous! Writing back the reordered list to XML (reordering XML nodes) should be implemented differently. Note that the dialog does also not update its list of filters when the order is manually changed @@ -1525,6 +1525,7 @@ void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel object->getRepr()->setPosition(0); } */ + return false; } void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustring& path) diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index ccf79e60d..3fc19e7de 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -86,7 +86,7 @@ private: void on_filter_selection_changed(); void on_name_edited(const Glib::ustring&, const Glib::ustring&); - void on_filter_reorder(const Gtk::TreeModel::Path& path); + bool on_filter_move(const Glib::RefPtr& /*context*/, int x, int y, guint /*time*/); void on_selection_toggled(const Glib::ustring&); void update_filters(); -- cgit v1.2.3