~ubuntu-branches/ubuntu/lucid/inkscape/lucid

« back to all changes in this revision

Viewing changes to src/ui/dialog/align-and-distribute.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook, Ted Gould, Kees Cook
  • Date: 2009-06-24 14:00:43 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624140043-07stp20mry48hqup
Tags: 0.47~pre0-0ubuntu1
* New upstream release

[ Ted Gould ]
* debian/control: Adding libgsl0 and removing version specifics on boost

[ Kees Cook ]
* debian/watch: updated to run uupdate and mangle pre-release versions.
* Dropped patches that have been taken upstream:
  - 01_mips
  - 02-poppler-0.8.3
  - 03-chinese-inkscape
  - 05_fix_latex_patch
  - 06_gcc-4.4
  - 07_cdr2svg
  - 08_skip-bad-utf-on-pdf-import
  - 09_gtk-clist
  - 10_belarussian
  - 11_libpng
  - 12_desktop
  - 13_slider
  - 100_svg_import_improvements
  - 102_sp_pattern_painter_free
  - 103_bitmap_type_print

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * \brief Align and Distribute dialog
3
 
 *
4
 
 * Authors:
 
1
/** @file
 
2
 * @brief Align and Distribute dialog - implementation
 
3
 */
 
4
/* Authors:
5
5
 *   Bryce W. Harrington <bryce@bryceharrington.org>
6
6
 *   Aubanel MONNIER <aubi@libertysurf.fr>
7
7
 *   Frank Felfe <innerspace@iname.com>
18
18
# include <config.h>
19
19
#endif
20
20
 
21
 
#include "verbs.h"
 
21
#include <gtkmm/spinbutton.h>
22
22
 
23
 
#include "dialogs/unclump.h"
24
 
#include "removeoverlap/removeoverlap.h"
 
23
#include "desktop-handles.h"
 
24
#include "unclump.h"
 
25
#include "document.h"
 
26
#include "enums.h"
25
27
#include "graphlayout/graphlayout.h"
26
 
 
27
 
#include <gtkmm/spinbutton.h>
28
 
 
29
 
 
30
 
 
31
 
 
32
 
#include "util/glib-list-iterators.h"
33
 
 
34
 
#include "widgets/icon.h"
35
 
 
36
28
#include "inkscape.h"
37
 
#include "document.h"
 
29
#include "macros.h"
 
30
#include "node-context.h"  //For access to ShapeEditor
 
31
#include "preferences.h"
 
32
#include "removeoverlap/removeoverlap.h"
38
33
#include "selection.h"
39
 
#include "desktop-handles.h"
40
 
#include "macros.h"
 
34
#include "shape-editor.h" //For node align/distribute methods
 
35
#include "sp-flowtext.h"
41
36
#include "sp-item-transform.h"
42
 
#include "prefs-utils.h"
43
 
#include "enums.h"
44
 
 
45
37
#include "sp-text.h"
46
 
#include "sp-flowtext.h"
47
38
#include "text-editing.h"
48
 
 
49
 
#include "node-context.h"  //For access to ShapeEditor
50
 
#include "shape-editor.h" //For node align/distribute methods
51
 
 
52
39
#include "tools-switch.h"
 
40
#include "ui/icon-names.h"
 
41
#include "util/glib-list-iterators.h"
 
42
#include "verbs.h"
 
43
#include "widgets/icon.h"
53
44
 
54
45
#include "align-and-distribute.h"
55
46
 
99
90
public :
100
91
    struct Coeffs {
101
92
       double mx0, mx1, my0, my1;
102
 
        double sx0, sx1, sy0, sy1;
 
93
       double sx0, sx1, sy0, sy1;
103
94
    };
104
95
    ActionAlign(const Glib::ustring &id,
105
96
                const Glib::ustring &tiptext,
122
113
        Inkscape::Selection *selection = sp_desktop_selection(desktop);
123
114
        if (!selection) return;
124
115
 
 
116
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
117
        bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups");
 
118
 
125
119
        using Inkscape::Util::GSListConstIterator;
126
120
        std::list<SPItem *> selected;
127
121
        selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL);
128
122
        if (selected.empty()) return;
129
123
 
130
 
        NR::Point mp; //Anchor point
 
124
        Geom::Point mp; //Anchor point
131
125
        AlignAndDistribute::AlignTarget target = _dialog.getAlignTarget();
132
126
        const Coeffs &a= _allCoeffs[_index];
133
127
        switch (target)
151
145
                );
152
146
            //remove the master from the selection
153
147
            SPItem * thing = *master;
154
 
            selected.erase(master);
 
148
            // TODO: either uncomment or remove the following commented lines, depending on which
 
149
            //       behaviour of moving objects makes most sense; also cf. discussion at
 
150
            //       https://bugs.launchpad.net/inkscape/+bug/255933
 
151
            /*if (!sel_as_group) { */
 
152
                selected.erase(master);
 
153
            /*}*/
155
154
            //Compute the anchor point
156
 
            NR::Maybe<NR::Rect> b = sp_item_bbox_desktop (thing);
 
155
            Geom::OptRect b = sp_item_bbox_desktop (thing);
157
156
            if (b) {
158
 
                mp = NR::Point(a.mx0 * b->min()[NR::X] + a.mx1 * b->max()[NR::X],
159
 
                               a.my0 * b->min()[NR::Y] + a.my1 * b->max()[NR::Y]);
 
157
                mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
 
158
                               a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
160
159
            } else {
161
160
                return;
162
161
            }
164
163
        }
165
164
 
166
165
        case AlignAndDistribute::PAGE:
167
 
            mp = NR::Point(a.mx1 * sp_document_width(sp_desktop_document(desktop)),
 
166
            mp = Geom::Point(a.mx1 * sp_document_width(sp_desktop_document(desktop)),
168
167
                           a.my1 * sp_document_height(sp_desktop_document(desktop)));
169
168
            break;
170
169
 
171
170
        case AlignAndDistribute::DRAWING:
172
171
        {
173
 
            NR::Maybe<NR::Rect> b = sp_item_bbox_desktop
 
172
            Geom::OptRect b = sp_item_bbox_desktop
174
173
                ( (SPItem *) sp_document_root (sp_desktop_document (desktop)) );
175
174
            if (b) {
176
 
                mp = NR::Point(a.mx0 * b->min()[NR::X] + a.mx1 * b->max()[NR::X],
177
 
                               a.my0 * b->min()[NR::Y] + a.my1 * b->max()[NR::Y]);
 
175
                mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
 
176
                               a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
178
177
            } else {
179
178
                return;
180
179
            }
183
182
 
184
183
        case AlignAndDistribute::SELECTION:
185
184
        {
186
 
            NR::Maybe<NR::Rect> b =  selection->bounds();
 
185
            Geom::OptRect b =  selection->bounds();
187
186
            if (b) {
188
 
                mp = NR::Point(a.mx0 * b->min()[NR::X] + a.mx1 * b->max()[NR::X],
189
 
                               a.my0 * b->min()[NR::Y] + a.my1 * b->max()[NR::Y]);
 
187
                mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X],
 
188
                               a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]);
190
189
            } else {
191
190
                return;
192
191
            }
204
203
        // a selected original, they will be unmoved too, possibly contrary to user's
205
204
        // expecation. However this is a minor point compared to making align/distribute always
206
205
        // work as expected, and "unmoved" is the default option anyway.
207
 
        int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
208
 
        prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
 
206
        int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
 
207
        prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
209
208
 
210
209
        bool changed = false;
211
 
        //Move each item in the selected list
 
210
        Geom::OptRect b;
 
211
        if (sel_as_group)
 
212
            b = selection->bounds();
 
213
 
 
214
        //Move each item in the selected list separately
212
215
        for (std::list<SPItem *>::iterator it(selected.begin());
213
216
             it != selected.end();
214
217
             it++)
215
218
        {
216
219
            sp_document_ensure_up_to_date(sp_desktop_document (desktop));
217
 
            NR::Maybe<NR::Rect> b = sp_item_bbox_desktop (*it);
 
220
            if (!sel_as_group)
 
221
                b = sp_item_bbox_desktop (*it);
218
222
            if (b) {
219
 
                NR::Point const sp(a.sx0 * b->min()[NR::X] + a.sx1 * b->max()[NR::X],
220
 
                                   a.sy0 * b->min()[NR::Y] + a.sy1 * b->max()[NR::Y]);
221
 
                NR::Point const mp_rel( mp - sp );
 
223
                Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X],
 
224
                                     a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]);
 
225
                Geom::Point const mp_rel( mp - sp );
222
226
                if (LInfty(mp_rel) > 1e-9) {
223
 
                    sp_item_move_rel(*it, NR::translate(mp_rel));
 
227
                    sp_item_move_rel(*it, Geom::Translate(mp_rel));
224
228
                    changed = true;
225
229
                }
226
230
            }
227
231
        }
228
232
 
229
233
        // restore compensation setting
230
 
        prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
 
234
        prefs->setInt("/options/clonecompensation/value", saved_compensation);
231
235
 
232
236
        if (changed) {
233
237
            sp_document_done ( sp_desktop_document (desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
255
259
    {0., 0., 1., 0., 0., 0., 0., 1.}
256
260
};
257
261
 
258
 
struct BBoxSort
259
 
{
260
 
    SPItem *item;
261
 
    float anchor;
262
 
    NR::Rect bbox;
263
 
    BBoxSort(SPItem *pItem, NR::Rect bounds, NR::Dim2 orientation, double kBegin, double kEnd) :
 
262
BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd) :
264
263
        item(pItem),
265
264
        bbox (bounds)
266
 
    {
 
265
{
267
266
        anchor = kBegin * bbox.min()[orientation] + kEnd * bbox.max()[orientation];
268
 
    }
269
 
    BBoxSort(const BBoxSort &rhs):
 
267
}
 
268
BBoxSort::BBoxSort(const BBoxSort &rhs) :
270
269
        //NOTE :  this copy ctor is called O(sort) when sorting the vector
271
270
        //this is bad. The vector should be a vector of pointers.
272
271
        //But I'll wait the bohem GC before doing that
273
 
        item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) {
274
 
    }
275
 
};
 
272
        item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) 
 
273
{
 
274
}
 
275
 
276
276
bool operator< (const BBoxSort &a, const BBoxSort &b)
277
277
{
278
278
    return (a.anchor < b.anchor);
285
285
                     guint row, guint column,
286
286
                     AlignAndDistribute &dialog,
287
287
                     bool onInterSpace,
288
 
                     NR::Dim2 orientation,
 
288
                     Geom::Dim2 orientation,
289
289
                     double kBegin, double kEnd
290
290
        ):
291
291
        Action(id, tiptext, row, column,
322
322
            it != selected.end();
323
323
            ++it)
324
324
        {
325
 
            NR::Maybe<NR::Rect> bbox = sp_item_bbox_desktop(*it);
 
325
            Geom::OptRect bbox = sp_item_bbox_desktop(*it);
326
326
            if (bbox) {
327
327
                sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd));
328
328
            }
331
331
        std::sort(sorted.begin(), sorted.end());
332
332
 
333
333
        // see comment in ActionAlign above
334
 
        int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
335
 
        prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
 
334
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
335
        int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
 
336
        prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
336
337
 
337
338
        unsigned int len = sorted.size();
338
339
        bool changed = false;
345
346
            float span = 0;
346
347
            for (unsigned int i = 0; i < len; i++)
347
348
            {
348
 
                span += sorted[i].bbox.extent(_orientation);
 
349
                span += sorted[i].bbox[_orientation].extent();
349
350
            }
350
351
            //new distance between each bbox
351
352
            float step = (dist - span) / (len - 1);
355
356
                  it ++ )
356
357
            {
357
358
                if (!NR_DF_TEST_CLOSE (pos, it->bbox.min()[_orientation], 1e-6)) {
358
 
                    NR::Point t(0.0, 0.0);
 
359
                    Geom::Point t(0.0, 0.0);
359
360
                    t[_orientation] = pos - it->bbox.min()[_orientation];
360
 
                    sp_item_move_rel(it->item, NR::translate(t));
 
361
                    sp_item_move_rel(it->item, Geom::Translate(t));
361
362
                    changed = true;
362
363
                }
363
 
                pos += it->bbox.extent(_orientation);
 
364
                pos += it->bbox[_orientation].extent();
364
365
                pos += step;
365
366
            }
366
367
        }
379
380
                //Don't move if we are really close
380
381
                if (!NR_DF_TEST_CLOSE (pos, it.anchor, 1e-6)) {
381
382
                    //Compute translation
382
 
                    NR::Point t(0.0, 0.0);
 
383
                    Geom::Point t(0.0, 0.0);
383
384
                    t[_orientation] = pos - it.anchor;
384
385
                    //translate
385
 
                    sp_item_move_rel(it.item, NR::translate(t));
 
386
                    sp_item_move_rel(it.item, Geom::Translate(t));
386
387
                    changed = true;
387
388
                }
388
389
            }
389
390
        }
390
391
 
391
392
        // restore compensation setting
392
 
        prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
 
393
        prefs->setInt("/options/clonecompensation/value", saved_compensation);
393
394
 
394
395
        if (changed) {
395
 
            sp_document_done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 
 
396
            sp_document_done ( sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
396
397
                               _("Distribute"));
397
398
        }
398
399
    }
399
400
    guint _index;
400
401
    AlignAndDistribute &_dialog;
401
402
    bool _onInterSpace;
402
 
    NR::Dim2 _orientation;
 
403
    Geom::Dim2 _orientation;
403
404
 
404
405
    double _kBegin;
405
406
    double _kEnd;
413
414
               const Glib::ustring &tiptext,
414
415
               guint column,
415
416
               AlignAndDistribute &dialog,
416
 
               NR::Dim2 orientation, bool distribute):
 
417
               Geom::Dim2 orientation, bool distribute):
417
418
        Action(id, tiptext, 0, column,
418
419
               dialog.nodes_table(), dialog.tooltips(), dialog),
419
420
        _orientation(orientation),
421
422
    {}
422
423
 
423
424
private :
424
 
    NR::Dim2 _orientation;
 
425
    Geom::Dim2 _orientation;
425
426
    bool _distribute;
426
427
    virtual void on_button_click()
427
428
    {
428
429
 
429
430
        if (!_dialog.getDesktop()) return;
430
 
        SPEventContext *event_context = sp_desktop_event_context(_dialog.getDesktop());
431
 
        if (!SP_IS_NODE_CONTEXT (event_context)) return ;
 
431
        SPEventContext *event_context = sp_desktop_event_context(_dialog.getDesktop());
 
432
        if (!SP_IS_NODE_CONTEXT (event_context)) return ;
432
433
 
433
434
        if (_distribute)
434
 
            SP_NODE_CONTEXT (event_context)->shape_editor->distribute(_orientation);
 
435
            event_context->shape_editor->distribute((Geom::Dim2)_orientation);
435
436
        else
436
 
            SP_NODE_CONTEXT (event_context)->shape_editor->align(_orientation);
 
437
            event_context->shape_editor->align((Geom::Dim2)_orientation);
437
438
 
438
439
    }
439
440
};
455
456
               dialog.removeOverlap_table(), dialog.tooltips(), dialog)
456
457
    {
457
458
        dialog.removeOverlap_table().set_col_spacings(3);
458
 
    
 
459
 
459
460
        removeOverlapXGap.set_digits(1);
460
461
        removeOverlapXGap.set_size_request(60, -1);
461
 
        removeOverlapXGap.set_increments(1.0, 5.0);
 
462
        removeOverlapXGap.set_increments(1.0, 0);
462
463
        removeOverlapXGap.set_range(-1000.0, 1000.0);
463
464
        removeOverlapXGap.set_value(0);
464
465
        dialog.tooltips().set_tip(removeOverlapXGap,
465
466
                                  _("Minimum horizontal gap (in px units) between bounding boxes"));
466
 
        /* TRANSLATORS: Horizontal gap */
467
 
        removeOverlapXGapLabel.set_label(_("H:"));
 
467
        //TRANSLATORS: only translate "string" in "context|string".
 
468
        // For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
 
469
        // "H:" stands for horizontal gap
 
470
        removeOverlapXGapLabel.set_label(Q_("gap|H:"));
468
471
 
469
472
        removeOverlapYGap.set_digits(1);
470
473
        removeOverlapYGap.set_size_request(60, -1);
471
 
        removeOverlapYGap.set_increments(1.0, 5.0);
 
474
        removeOverlapYGap.set_increments(1.0, 0);
472
475
        removeOverlapYGap.set_range(-1000.0, 1000.0);
473
476
        removeOverlapYGap.set_value(0);
474
477
        dialog.tooltips().set_tip(removeOverlapYGap,
489
492
        if (!_dialog.getDesktop()) return;
490
493
 
491
494
        // see comment in ActionAlign above
492
 
        int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
493
 
        prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
 
495
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
496
        int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
 
497
        prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
494
498
 
495
499
        // xGap and yGap are the minimum space required between bounding rectangles.
496
500
        double const xGap = removeOverlapXGap.get_value();
499
503
                      xGap, yGap);
500
504
 
501
505
        // restore compensation setting
502
 
        prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
 
506
        prefs->setInt("/options/clonecompensation/value", saved_compensation);
503
507
 
504
 
        sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 
 
508
        sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
505
509
                         _("Remove overlaps"));
506
510
    }
507
511
};
523
527
        if (!_dialog.getDesktop()) return;
524
528
 
525
529
        // see comment in ActionAlign above
526
 
        int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
527
 
        prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
 
530
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
531
        int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
 
532
        prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
528
533
 
529
534
        graphlayout(sp_desktop_selection(_dialog.getDesktop())->itemList());
530
535
 
531
536
        // restore compensation setting
532
 
        prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
 
537
        prefs->setInt("/options/clonecompensation/value", saved_compensation);
533
538
 
534
 
        sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 
 
539
        sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
535
540
                         _("Arrange connector network"));
536
541
    }
537
542
};
553
558
        if (!_dialog.getDesktop()) return;
554
559
 
555
560
        // see comment in ActionAlign above
556
 
        int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
557
 
        prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
 
561
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
562
        int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
 
563
        prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
558
564
 
559
565
        unclump ((GSList *) sp_desktop_selection(_dialog.getDesktop())->itemList());
560
566
 
561
567
        // restore compensation setting
562
 
        prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
 
568
        prefs->setInt("/options/clonecompensation/value", saved_compensation);
563
569
 
564
 
        sp_document_done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 
 
570
        sp_document_done (sp_desktop_document (_dialog.getDesktop()), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
565
571
                          _("Unclump"));
566
572
    }
567
573
};
594
600
        //Check 2 or more selected objects
595
601
        if (selected.size() < 2) return;
596
602
 
597
 
        NR::Maybe<NR::Rect> sel_bbox = selection->bounds();
 
603
        Geom::OptRect sel_bbox = selection->bounds();
598
604
        if (!sel_bbox) {
599
605
            return;
600
606
        }
607
613
        }
608
614
 
609
615
        // see comment in ActionAlign above
610
 
        int saved_compensation = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
611
 
        prefs_set_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
 
616
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
617
        int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
 
618
        prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
612
619
 
613
620
        for (std::list<SPItem *>::iterator it(selected.begin());
614
621
            it != selected.end();
615
622
            ++it)
616
623
        {
617
624
            sp_document_ensure_up_to_date(sp_desktop_document (desktop));
618
 
            NR::Maybe<NR::Rect> item_box = sp_item_bbox_desktop (*it);
 
625
            Geom::OptRect item_box = sp_item_bbox_desktop (*it);
619
626
            if (item_box) {
620
 
                // find new center, staying within bbox 
621
 
                double x = _dialog.randomize_bbox->min()[NR::X] + item_box->extent(NR::X)/2 +
622
 
                    g_random_double_range (0, _dialog.randomize_bbox->extent(NR::X) - item_box->extent(NR::X));
623
 
                double y = _dialog.randomize_bbox->min()[NR::Y] + item_box->extent(NR::Y)/2 +
624
 
                    g_random_double_range (0, _dialog.randomize_bbox->extent(NR::Y) - item_box->extent(NR::Y));
 
627
                // find new center, staying within bbox
 
628
                double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 +
 
629
                    g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::X].extent() - (*item_box)[Geom::X].extent());
 
630
                double y = _dialog.randomize_bbox->min()[Geom::Y] + (*item_box)[Geom::Y].extent()/2 +
 
631
                    g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::Y].extent() - (*item_box)[Geom::Y].extent());
625
632
                // displacement is the new center minus old:
626
 
                NR::Point t = NR::Point (x, y) - 0.5*(item_box->max() + item_box->min());
627
 
                sp_item_move_rel(*it, NR::translate(t));
 
633
                Geom::Point t = Geom::Point (x, y) - 0.5*(item_box->max() + item_box->min());
 
634
                sp_item_move_rel(*it, Geom::Translate(t));
628
635
            }
629
636
        }
630
637
 
631
638
        // restore compensation setting
632
 
        prefs_set_int_attribute("options.clonecompensation", "value", saved_compensation);
 
639
        prefs->setInt("/options/clonecompensation/value", saved_compensation);
633
640
 
634
 
        sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 
 
641
        sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
635
642
                          _("Randomize positions"));
636
643
    }
637
644
};
639
646
struct Baselines
640
647
{
641
648
    SPItem *_item;
642
 
    NR::Point _base;
643
 
    NR::Dim2 _orientation;
644
 
    Baselines(SPItem *item, NR::Point base, NR::Dim2 orientation) :
 
649
    Geom::Point _base;
 
650
    Geom::Dim2 _orientation;
 
651
    Baselines(SPItem *item, Geom::Point base, Geom::Dim2 orientation) :
645
652
        _item (item),
646
653
        _base (base),
647
654
        _orientation (orientation)
661
668
               guint column,
662
669
               AlignAndDistribute &dialog,
663
670
               Gtk::Table &table,
664
 
               NR::Dim2 orientation, bool distribute):
 
671
               Geom::Dim2 orientation, bool distribute):
665
672
        Action(id, tiptext, row, column,
666
673
               table, dialog.tooltips(), dialog),
667
674
        _orientation(orientation),
669
676
    {}
670
677
 
671
678
private :
672
 
    NR::Dim2 _orientation;
 
679
    Geom::Dim2 _orientation;
673
680
    bool _distribute;
674
681
    virtual void on_button_click()
675
682
    {
687
694
        //Check 2 or more selected objects
688
695
        if (selected.size() < 2) return;
689
696
 
690
 
        NR::Point b_min = NR::Point (HUGE_VAL, HUGE_VAL);
691
 
        NR::Point b_max = NR::Point (-HUGE_VAL, -HUGE_VAL);
 
697
        Geom::Point b_min = Geom::Point (HUGE_VAL, HUGE_VAL);
 
698
        Geom::Point b_max = Geom::Point (-HUGE_VAL, -HUGE_VAL);
692
699
 
693
700
        std::vector<Baselines> sorted;
694
701
 
698
705
        {
699
706
            if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
700
707
                Inkscape::Text::Layout const *layout = te_get_layout(*it);
701
 
                NR::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
702
 
                if (base[NR::X] < b_min[NR::X]) b_min[NR::X] = base[NR::X];
703
 
                if (base[NR::Y] < b_min[NR::Y]) b_min[NR::Y] = base[NR::Y];
704
 
                if (base[NR::X] > b_max[NR::X]) b_max[NR::X] = base[NR::X];
705
 
                if (base[NR::Y] > b_max[NR::Y]) b_max[NR::Y] = base[NR::Y];
 
708
                Geom::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
 
709
                if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X];
 
710
                if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y];
 
711
                if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X];
 
712
                if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y];
706
713
 
707
714
                Baselines b (*it, base, _orientation);
708
715
                sorted.push_back(b);
720
727
            double step = (b_max[_orientation] - b_min[_orientation])/(sorted.size() - 1);
721
728
            for (unsigned int i = 0; i < sorted.size(); i++) {
722
729
                SPItem *item = sorted[i]._item;
723
 
                NR::Point base = sorted[i]._base;
724
 
                NR::Point t(0.0, 0.0);
 
730
                Geom::Point base = sorted[i]._base;
 
731
                Geom::Point t(0.0, 0.0);
725
732
                t[_orientation] = b_min[_orientation] + step * i - base[_orientation];
726
 
                sp_item_move_rel(item, NR::translate(t));
 
733
                sp_item_move_rel(item, Geom::Translate(t));
727
734
                changed = true;
728
735
            }
729
736
 
730
737
            if (changed) {
731
 
                sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 
 
738
                sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
732
739
                                  _("Distribute text baselines"));
733
740
            }
734
741
 
739
746
            {
740
747
                if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) {
741
748
                    Inkscape::Text::Layout const *layout = te_get_layout(*it);
742
 
                    NR::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
743
 
                    NR::Point t(0.0, 0.0);
 
749
                    Geom::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it);
 
750
                    Geom::Point t(0.0, 0.0);
744
751
                    t[_orientation] = b_min[_orientation] - base[_orientation];
745
 
                    sp_item_move_rel(*it, NR::translate(t));
 
752
                    sp_item_move_rel(*it, Geom::Translate(t));
746
753
                    changed = true;
747
754
                }
748
755
            }
749
756
 
750
757
            if (changed) {
751
 
                sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE, 
 
758
                sp_document_done (sp_desktop_document (desktop), SP_VERB_DIALOG_ALIGN_DISTRIBUTE,
752
759
                                  _("Align text baselines"));
753
760
            }
754
761
        }
757
764
 
758
765
 
759
766
 
760
 
void on_tool_changed(Inkscape::Application *inkscape, SPEventContext *context, AlignAndDistribute *daad)
 
767
void on_tool_changed(Inkscape::Application */*inkscape*/, SPEventContext */*context*/, AlignAndDistribute *daad)
761
768
{
762
769
    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
763
770
    if (desktop && sp_desktop_event_context(desktop))
764
771
        daad->setMode(tools_active(desktop) == TOOLS_NODES);
765
772
}
766
773
 
767
 
void on_selection_changed(Inkscape::Application *inkscape, Inkscape::Selection *selection, AlignAndDistribute *daad)
 
774
void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, AlignAndDistribute *daad)
768
775
{
769
 
    daad->randomize_bbox = NR::Nothing();
 
776
    daad->randomize_bbox = Geom::OptRect();
770
777
}
771
778
 
772
779
/////////////////////////////////////////////////////////
774
781
 
775
782
 
776
783
 
777
 
AlignAndDistribute::AlignAndDistribute() 
778
 
    : UI::Widget::Panel ("", "dialogs.align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE),
779
 
      randomize_bbox(NR::Nothing()),
 
784
AlignAndDistribute::AlignAndDistribute()
 
785
    : UI::Widget::Panel ("", "/dialogs/align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE),
 
786
      randomize_bbox(),
780
787
      _alignFrame(_("Align")),
781
788
      _distributeFrame(_("Distribute")),
782
789
      _removeOverlapFrame(_("Remove overlaps")),
787
794
      _removeOverlapTable(1, 5, false),
788
795
      _graphLayoutTable(1, 5, false),
789
796
      _nodesTable(1, 4, true),
790
 
      _anchorLabel(_("Relative to: "))
 
797
      _anchorLabel(_("Relative to: ")),
 
798
      _selgrpLabel(_("Treat selection as group: "))
791
799
{
 
800
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
792
801
 
793
802
    //Instanciate the align buttons
794
 
    addAlignButton("al_left_out",
795
 
                   _("Align right sides of objects to left side of anchor"),
 
803
    addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT_TO_ANCHOR,
 
804
                   _("Align right edges of objects to the left edge of the anchor"),
796
805
                   0, 0);
797
 
    addAlignButton("al_left_in",
798
 
                   _("Align left sides"),
 
806
    addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT,
 
807
                   _("Align left edges"),
799
808
                   0, 1);
800
 
    addAlignButton("al_center_hor",
801
 
                   _("Center on vertical axis"),
 
809
    addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_CENTER,
 
810
                   _("Center objects horizontally"),
802
811
                   0, 2);
803
 
    addAlignButton("al_right_in",
 
812
    addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_RIGHT,
804
813
                   _("Align right sides"),
805
814
                   0, 3);
806
 
    addAlignButton("al_right_out",
807
 
                   _("Align left sides of objects to right side of anchor"),
 
815
    addAlignButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_LEFT_TO_ANCHOR,
 
816
                   _("Align left edges of objects to the right edge of the anchor"),
808
817
                   0, 4);
809
 
    addAlignButton("al_top_out",
810
 
                   _("Align bottoms of objects to top of anchor"),
 
818
    addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM_TO_ANCHOR,
 
819
                   _("Align bottom edges of objects to the top edge of the anchor"),
811
820
                   1, 0);
812
 
    addAlignButton("al_top_in",
813
 
                   _("Align tops"),
 
821
    addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_TOP,
 
822
                   _("Align top edges"),
814
823
                   1, 1);
815
 
    addAlignButton("al_center_ver",
 
824
    addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_CENTER,
816
825
                   _("Center on horizontal axis"),
817
826
                   1, 2);
818
 
    addAlignButton("al_bottom_in",
819
 
                   _("Align bottoms"),
 
827
    addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_BOTTOM,
 
828
                   _("Align bottom edges"),
820
829
                   1, 3);
821
 
    addAlignButton("al_bottom_out",
822
 
                   _("Align tops of objects to bottom of anchor"),
 
830
    addAlignButton(INKSCAPE_ICON_ALIGN_VERTICAL_TOP_TO_ANCHOR,
 
831
                   _("Align top edges of objects to the bottom edge of the anchor"),
823
832
                   1, 4);
824
833
 
825
834
    //Baseline aligns
826
 
    addBaselineButton("al_baselines_vert",
827
 
                   _("Align baseline anchors of texts vertically"),
828
 
                      0, 5, this->align_table(), NR::X, false);
829
 
    addBaselineButton("al_baselines_hor",
 
835
    addBaselineButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_BASELINE,
830
836
                   _("Align baseline anchors of texts horizontally"),
831
 
                     1, 5, this->align_table(), NR::Y, false);
 
837
                      0, 5, this->align_table(), Geom::X, false);
 
838
    addBaselineButton(INKSCAPE_ICON_ALIGN_VERTICAL_BASELINE,
 
839
                   _("Align baselines of texts"),
 
840
                     1, 5, this->align_table(), Geom::Y, false);
832
841
 
833
842
    //The distribute buttons
834
 
    addDistributeButton("distribute_hdist",
 
843
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_GAPS,
835
844
                        _("Make horizontal gaps between objects equal"),
836
 
                        0, 4, true, NR::X, .5, .5);
 
845
                        0, 4, true, Geom::X, .5, .5);
837
846
 
838
 
    addDistributeButton("distribute_left",
839
 
                        _("Distribute left sides equidistantly"),
840
 
                        0, 1, false, NR::X, 1., 0.);
841
 
    addDistributeButton("distribute_hcentre",
 
847
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_LEFT,
 
848
                        _("Distribute left edges equidistantly"),
 
849
                        0, 1, false, Geom::X, 1., 0.);
 
850
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_CENTER,
842
851
                        _("Distribute centers equidistantly horizontally"),
843
 
                        0, 2, false, NR::X, .5, .5);
844
 
    addDistributeButton("distribute_right",
845
 
                        _("Distribute right sides equidistantly"),
846
 
                        0, 3, false, NR::X, 0., 1.);
 
852
                        0, 2, false, Geom::X, .5, .5);
 
853
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_RIGHT,
 
854
                        _("Distribute right edges equidistantly"),
 
855
                        0, 3, false, Geom::X, 0., 1.);
847
856
 
848
 
    addDistributeButton("distribute_vdist",
 
857
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_GAPS,
849
858
                        _("Make vertical gaps between objects equal"),
850
 
                        1, 4, true, NR::Y, .5, .5);
 
859
                        1, 4, true, Geom::Y, .5, .5);
851
860
 
852
 
    addDistributeButton("distribute_top",
853
 
                        _("Distribute tops equidistantly"),
854
 
                        1, 1, false, NR::Y, 0, 1);
855
 
    addDistributeButton("distribute_vcentre",
 
861
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_TOP,
 
862
                        _("Distribute top edges equidistantly"),
 
863
                        1, 1, false, Geom::Y, 0, 1);
 
864
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_CENTER,
856
865
                        _("Distribute centers equidistantly vertically"),
857
 
                        1, 2, false, NR::Y, .5, .5);
858
 
    addDistributeButton("distribute_bottom",
859
 
                        _("Distribute bottoms equidistantly"),
860
 
                        1, 3, false, NR::Y, 1., 0.);
 
866
                        1, 2, false, Geom::Y, .5, .5);
 
867
    addDistributeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BOTTOM,
 
868
                        _("Distribute bottom edges equidistantly"),
 
869
                        1, 3, false, Geom::Y, 1., 0.);
861
870
 
862
871
    //Baseline distribs
863
 
    addBaselineButton("distribute_baselines_hor",
 
872
    addBaselineButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_BASELINE,
864
873
                   _("Distribute baseline anchors of texts horizontally"),
865
 
                      0, 5, this->distribute_table(), NR::X, true);
866
 
    addBaselineButton("distribute_baselines_vert",
867
 
                   _("Distribute baseline anchors of texts vertically"),
868
 
                     1, 5, this->distribute_table(), NR::Y, true);
 
874
                      0, 5, this->distribute_table(), Geom::X, true);
 
875
    addBaselineButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_BASELINE,
 
876
                   _("Distribute baselines of texts vertically"),
 
877
                     1, 5, this->distribute_table(), Geom::Y, true);
869
878
 
870
879
    //Randomize & Unclump
871
 
    addRandomizeButton("distribute_randomize",
 
880
    addRandomizeButton(INKSCAPE_ICON_DISTRIBUTE_RANDOMIZE,
872
881
                        _("Randomize centers in both dimensions"),
873
882
                        2, 2);
874
 
    addUnclumpButton("unclump",
 
883
    addUnclumpButton(INKSCAPE_ICON_DISTRIBUTE_UNCLUMP,
875
884
                        _("Unclump objects: try to equalize edge-to-edge distances"),
876
885
                        2, 4);
877
886
 
878
887
    //Remove overlaps
879
 
    addRemoveOverlapsButton("remove_overlaps",
 
888
    addRemoveOverlapsButton(INKSCAPE_ICON_DISTRIBUTE_REMOVE_OVERLAPS,
880
889
                            _("Move objects as little as possible so that their bounding boxes do not overlap"),
881
890
                            0, 0);
882
891
    //Graph Layout
883
 
    addGraphLayoutButton("graph_layout",
 
892
    addGraphLayoutButton(INKSCAPE_ICON_DISTRIBUTE_GRAPH,
884
893
                            _("Nicely arrange selected connector network"),
885
894
                            0, 0);
886
895
 
887
896
    //Node Mode buttons
888
 
    addNodeButton("node_halign",
889
 
                  _("Align selected nodes horizontally"),
890
 
                  0, NR::X, false);
891
 
    addNodeButton("node_valign",
892
 
                  _("Align selected nodes vertically"),
893
 
                  1, NR::Y, false);
894
 
    addNodeButton("node_hdistribute",
 
897
    // NOTE: "align nodes vertically" means "move nodes vertically until they align on a common
 
898
    // _horizontal_ line". This is analogous to what the "align-vertical-center" icon means.
 
899
    // There is no doubt some ambiguity. For this reason the descriptions are different.
 
900
    addNodeButton(INKSCAPE_ICON_ALIGN_VERTICAL_NODES,
 
901
                  _("Align selected nodes to a common horizontal line"),
 
902
                  0, Geom::X, false);
 
903
    addNodeButton(INKSCAPE_ICON_ALIGN_HORIZONTAL_NODES,
 
904
                  _("Align selected nodes to a common vertical line"),
 
905
                  1, Geom::Y, false);
 
906
    addNodeButton(INKSCAPE_ICON_DISTRIBUTE_HORIZONTAL_NODE,
895
907
                  _("Distribute selected nodes horizontally"),
896
 
                  2, NR::X, true);
897
 
    addNodeButton("node_vdistribute",
 
908
                  2, Geom::X, true);
 
909
    addNodeButton(INKSCAPE_ICON_DISTRIBUTE_VERTICAL_NODE,
898
910
                  _("Distribute selected nodes vertically"),
899
 
                  3, NR::Y, true);
 
911
                  3, Geom::Y, true);
900
912
 
901
913
    //Rest of the widgetry
902
914
 
903
915
    _combo.append_text(_("Last selected"));
904
916
    _combo.append_text(_("First selected"));
905
 
    _combo.append_text(_("Biggest item"));
906
 
    _combo.append_text(_("Smallest item"));
 
917
    _combo.append_text(_("Biggest object"));
 
918
    _combo.append_text(_("Smallest object"));
907
919
    _combo.append_text(_("Page"));
908
920
    _combo.append_text(_("Drawing"));
909
921
    _combo.append_text(_("Selection"));
910
922
 
911
 
    _combo.set_active(prefs_get_int_attribute("dialogs.align", "align-to", 6));
 
923
    _combo.set_active(prefs->getInt("/dialogs/align/align-to", 6));
912
924
    _combo.signal_changed().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_ref_change));
913
925
 
914
926
    _anchorBox.pack_start(_anchorLabel);
915
927
    _anchorBox.pack_start(_combo);
916
928
 
 
929
    _selgrpBox.pack_start(_selgrpLabel);
 
930
    _selgrpBox.pack_start(_selgrp);
 
931
    _selgrp.set_active(prefs->getBool("/dialogs/align/sel-as-groups"));
 
932
    _selgrp.signal_toggled().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_selgrp_toggled));
 
933
 
917
934
    _alignBox.pack_start(_anchorBox);
 
935
    _alignBox.pack_start(_selgrpBox);
918
936
    _alignBox.pack_start(_alignTable);
919
937
 
920
938
    _alignFrame.add(_alignBox);
939
957
 
940
958
    // Connect to the global selection change, to invalidate cached randomize_bbox
941
959
    g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
942
 
    randomize_bbox = NR::Nothing();
 
960
    randomize_bbox = Geom::OptRect();
943
961
 
944
962
    show_all_children();
945
963
 
946
964
    on_tool_changed (NULL, NULL, this); // set current mode
947
965
}
948
966
 
949
 
AlignAndDistribute::~AlignAndDistribute() 
 
967
AlignAndDistribute::~AlignAndDistribute()
950
968
{
951
969
    sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this);
952
970
 
957
975
}
958
976
 
959
977
void AlignAndDistribute::on_ref_change(){
960
 
 
961
 
    prefs_set_int_attribute("dialogs.align", "align-to", _combo.get_active_row_number());
 
978
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
979
    prefs->setInt("/dialogs/align/align-to", _combo.get_active_row_number());
 
980
 
 
981
    //Make blink the master
 
982
}
 
983
 
 
984
void AlignAndDistribute::on_selgrp_toggled(){
 
985
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
 
986
    prefs->setInt("/dialogs/align/sel-as-groups", _selgrp.get_active());
962
987
 
963
988
    //Make blink the master
964
989
}
994
1019
}
995
1020
void AlignAndDistribute::addDistributeButton(const Glib::ustring &id, const Glib::ustring tiptext,
996
1021
                                      guint row, guint col, bool onInterSpace,
997
 
                                      NR::Dim2 orientation, float kBegin, float kEnd)
 
1022
                                      Geom::Dim2 orientation, float kBegin, float kEnd)
998
1023
{
999
1024
    _actionList.push_back(
1000
1025
        new ActionDistribute(
1006
1031
}
1007
1032
 
1008
1033
void AlignAndDistribute::addNodeButton(const Glib::ustring &id, const Glib::ustring tiptext,
1009
 
                   guint col, NR::Dim2 orientation, bool distribute)
 
1034
                   guint col, Geom::Dim2 orientation, bool distribute)
1010
1035
{
1011
1036
    _actionList.push_back(
1012
1037
        new ActionNode(
1051
1076
}
1052
1077
 
1053
1078
void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext,
1054
 
                                    guint row, guint col, Gtk::Table &table, NR::Dim2 orientation, bool distribute)
 
1079
                                    guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute)
1055
1080
{
1056
1081
    _actionList.push_back(
1057
1082
        new ActionBaseline(
1058
 
            id, tiptext, row, col, 
 
1083
            id, tiptext, row, col,
1059
1084
            *this, table, orientation, distribute));
1060
1085
}
1061
1086
 
1077
1102
    {
1078
1103
        gdouble max = -1e18;
1079
1104
        for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
1080
 
            NR::Maybe<NR::Rect> b = sp_item_bbox_desktop (*it);
 
1105
            Geom::OptRect b = sp_item_bbox_desktop (*it);
1081
1106
            if (b) {
1082
 
                gdouble dim = b->extent(horizontal ? NR::X : NR::Y);
 
1107
                gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent();
1083
1108
                if (dim > max) {
1084
1109
                    max = dim;
1085
1110
                    master = it;
1094
1119
    {
1095
1120
        gdouble max = 1e18;
1096
1121
        for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
1097
 
            NR::Maybe<NR::Rect> b = sp_item_bbox_desktop (*it);
 
1122
            Geom::OptRect b = sp_item_bbox_desktop (*it);
1098
1123
            if (b) {
1099
 
                gdouble dim = b->extent(horizontal ? NR::X : NR::Y);
 
1124
                gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent();
1100
1125
                if (dim < max) {
1101
1126
                    max = dim;
1102
1127
                    master = it;