diff options
| author | MenTaLguY <mental@rydia.net> | 2007-03-11 21:23:04 +0000 |
|---|---|---|
| committer | mental <mental@users.sourceforge.net> | 2007-03-11 21:23:04 +0000 |
| commit | 4e432e5960cb8bc9feb6648087b54788c774d773 (patch) | |
| tree | f83b7730dfb4ff96d45fb96e83367ab3dc28e56f /src/ui | |
| parent | Switch selection bounds and center to use NR::Maybe, addressing most of the (diff) | |
| download | inkscape-4e432e5960cb8bc9feb6648087b54788c774d773.tar.gz inkscape-4e432e5960cb8bc9feb6648087b54788c774d773.zip | |
Eliminate remaining sources of empty NR::Rects
(bzr r2605)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/align-and-distribute.cpp | 18 | ||||
| -rw-r--r-- | src/ui/dialog/align-and-distribute.h | 4 |
2 files changed, 9 insertions, 13 deletions
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 7c5908e58..34fa910cc 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -602,9 +602,8 @@ private : // This bbox is cached between calls to randomize, so that there's no growth nor shrink // nor drift on sequential randomizations. Discard cache on global (or better active // desktop's) selection_change signal. - if (!_dialog.randomize_bbox_set) { + if (!_dialog.randomize_bbox) { _dialog.randomize_bbox = *sel_bbox; - _dialog.randomize_bbox_set = true; } // see comment in ActionAlign above @@ -619,10 +618,10 @@ private : NR::Maybe<NR::Rect> item_box = sp_item_bbox_desktop (*it); if (item_box) { // find new center, staying within bbox - double x = _dialog.randomize_bbox.min()[NR::X] + item_box->extent(NR::X)/2 + - g_random_double_range (0, _dialog.randomize_bbox.extent(NR::X) - item_box->extent(NR::X)); - double y = _dialog.randomize_bbox.min()[NR::Y] + item_box->extent(NR::Y)/2 + - g_random_double_range (0, _dialog.randomize_bbox.extent(NR::Y) - item_box->extent(NR::Y)); + double x = _dialog.randomize_bbox->min()[NR::X] + item_box->extent(NR::X)/2 + + g_random_double_range (0, _dialog.randomize_bbox->extent(NR::X) - item_box->extent(NR::X)); + double y = _dialog.randomize_bbox->min()[NR::Y] + item_box->extent(NR::Y)/2 + + g_random_double_range (0, _dialog.randomize_bbox->extent(NR::Y) - item_box->extent(NR::Y)); // displacement is the new center minus old: NR::Point t = NR::Point (x, y) - 0.5*(item_box->max() + item_box->min()); sp_item_move_rel(*it, NR::translate(t)); @@ -767,7 +766,7 @@ void on_tool_changed(Inkscape::Application *inkscape, SPEventContext *context, A void on_selection_changed(Inkscape::Application *inkscape, Inkscape::Selection *selection, AlignAndDistribute *daad) { - daad->randomize_bbox_set = false; + daad->randomize_bbox = NR::Nothing(); } ///////////////////////////////////////////////////////// @@ -777,7 +776,7 @@ void on_selection_changed(Inkscape::Application *inkscape, Inkscape::Selection * AlignAndDistribute::AlignAndDistribute() : Dialog ("dialogs.align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE), - randomize_bbox (NR::Point (0, 0), NR::Point (0, 0)), + randomize_bbox(NR::Nothing()), _alignFrame(_("Align")), _distributeFrame(_("Distribute")), _removeOverlapFrame(_("Remove overlaps")), @@ -941,8 +940,7 @@ AlignAndDistribute::AlignAndDistribute() // Connect to the global selection change, to invalidate cached randomize_bbox g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this); - randomize_bbox = NR::Rect (NR::Point (0, 0), NR::Point (0, 0)); - randomize_bbox_set = false; + randomize_bbox = NR::Nothing(); show_all_children(); diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index 69fc17673..6d22071f3 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -65,9 +65,7 @@ public: std::list<SPItem *>::iterator find_master(std::list <SPItem *> &list, bool horizontal); void setMode(bool nodeEdit); - NR::Rect randomize_bbox; - bool randomize_bbox_set; - + NR::Maybe<NR::Rect> randomize_bbox; protected: |
