diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-07-17 05:13:49 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-07-17 05:13:49 +0000 |
| commit | dd59aa3bb2cab030296a4622e5166f0e3f8d5445 (patch) | |
| tree | a86612c94d3ddce3edf696ea17fefb58b0accccf /src/ui | |
| parent | Temporary fixes/kludges. (diff) | |
| parent | Shape calculations. re-introduce grid of a smaller size. (http://article.gman... (diff) | |
| download | inkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.tar.gz inkscape-dd59aa3bb2cab030296a4622e5166f0e3f8d5445.zip | |
Merge from trunk.
(bzr r12380.1.17)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/align-and-distribute.cpp | 190 | ||||
| -rw-r--r-- | src/ui/dialog/align-and-distribute.h | 10 | ||||
| -rw-r--r-- | src/ui/dialog/layers.cpp | 7 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 3 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 5 | ||||
| -rw-r--r-- | src/ui/tool/transform-handle-set.cpp | 12 | ||||
| -rw-r--r-- | src/ui/widget/dock.cpp | 20 | ||||
| -rw-r--r-- | src/ui/widget/dock.h | 10 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 3 | ||||
| -rw-r--r-- | src/ui/widget/style-swatch.cpp | 3 |
10 files changed, 80 insertions, 183 deletions
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 7f88824f7..8845b60e5 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -88,119 +88,73 @@ Action::Action(const Glib::ustring &id, } -void ActionAlign::do_action(SPDesktop *desktop, int index) { - +void ActionAlign::do_action(SPDesktop *desktop, int index) +{ Inkscape::Selection *selection = sp_desktop_selection(desktop); if (!selection) return; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); - int prefs_bbox = prefs->getBool("/tools/bounding_box"); using Inkscape::Util::GSListConstIterator; std::list<SPItem *> selected; selected.insert<GSListConstIterator<SPItem *> >(selected.end(), selection->itemList(), NULL); if (selected.empty()) return; - Geom::Point mp; //Anchor point - AlignAndDistribute::AlignTarget target = AlignAndDistribute::getAlignTarget(); - const Coeffs &a= _allCoeffs[index]; - switch (target) - { - case AlignAndDistribute::LAST: - case AlignAndDistribute::FIRST: - case AlignAndDistribute::BIGGEST: - case AlignAndDistribute::SMALLEST: + const Coeffs &a = _allCoeffs[index]; + SPItem *focus = NULL; + Geom::OptRect b = Geom::OptRect(); + Selection::CompareSize horiz = (a.mx0 != 0.0) || (a.mx1 != 0.0) + ? Selection::HORIZONTAL : Selection::VERTICAL; + + switch (AlignTarget(prefs->getInt("/dialogs/align/align-to", 6))) { - //Check 2 or more selected objects - std::list<SPItem *>::iterator second(selected.begin()); - ++second; - if (second == selected.end()) - return; - //Find the master (anchor on which the other objects are aligned) - std::list<SPItem *>::iterator master( - AlignAndDistribute::find_master ( - selected, - (a.mx0 != 0.0) || - (a.mx1 != 0.0) ) - ); - //remove the master from the selection - SPItem * thing = *master; - // TODO: either uncomment or remove the following commented lines, depending on which - // behaviour of moving objects makes most sense; also cf. discussion at - // https://bugs.launchpad.net/inkscape/+bug/255933 - /*if (!sel_as_group) { */ - selected.erase(master); - /*}*/ - //Compute the anchor point - Geom::OptRect b = !prefs_bbox ? thing->desktopVisualBounds() : thing->desktopGeometricBounds(); - if (b) { - mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], - a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); - } else { - return; - } + case LAST: + focus = SP_ITEM(*selected.begin()); break; - } - - case AlignAndDistribute::PAGE: - mp = Geom::Point(a.mx1 * sp_desktop_document(desktop)->getWidth(), - a.my1 * sp_desktop_document(desktop)->getHeight()); + case FIRST: + focus = SP_ITEM(*--(selected.end())); break; - - case AlignAndDistribute::DRAWING: - { - Geom::OptRect b = !prefs_bbox ? sp_desktop_document(desktop)->getRoot()->desktopVisualBounds() - : sp_desktop_document(desktop)->getRoot()->desktopGeometricBounds(); - if (b) { - mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], - a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); - } else { - return; - } + case BIGGEST: + focus = selection->largestItem(horiz); break; - } - - case AlignAndDistribute::SELECTION: - { - Geom::OptRect b = !prefs_bbox ? selection->visualBounds() : selection->geometricBounds(); - if (b) { - mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], - a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); - } else { - return; - } + case SMALLEST: + focus = selection->smallestItem(horiz); + break; + case PAGE: + b = sp_desktop_document(desktop)->preferredBounds(); + break; + case DRAWING: + b = sp_desktop_document(desktop)->getRoot()->desktopPreferredBounds(); + break; + case SELECTION: + b = selection->preferredBounds(); break; - } - default: g_assert_not_reached (); break; - }; // end of switch + }; + + if(focus) + b = focus->desktopPreferredBounds(); + g_return_if_fail(b); - // Top hack: temporarily set clone compensation to unmoved, so that we can align/distribute - // clones with their original (and the move of the original does not disturb the - // clones). The only problem with this is that if there are outside-of-selection clones of - // a selected original, they will be unmoved too, possibly contrary to user's - // expecation. However this is a minor point compared to making align/distribute always - // work as expected, and "unmoved" is the default option anyway. - int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); + // Generate the move point from the selected bounding box + Geom::Point mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], + a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); bool changed = false; - Geom::OptRect b; if (sel_as_group) - b = !prefs_bbox ? selection->visualBounds() : selection->geometricBounds(); + b = selection->preferredBounds(); //Move each item in the selected list separately for (std::list<SPItem *>::iterator it(selected.begin()); - it != selected.end(); - ++it) + it != selected.end(); ++it) { sp_desktop_document (desktop)->ensureUpToDate(); if (!sel_as_group) - b = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); - if (b) { + b = (*it)->desktopPreferredBounds(); + if (b && (!focus || (*it) != focus)) { Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); Geom::Point const mp_rel( mp - sp ); @@ -211,15 +165,10 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) { } } - // restore compensation setting - prefs->setInt("/options/clonecompensation/value", saved_compensation); - if (changed) { DocumentUndo::done( sp_desktop_document(desktop) , SP_VERB_DIALOG_ALIGN_DISTRIBUTE, _("Align")); } - - } @@ -1265,69 +1214,6 @@ void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib:: *this, table, orientation, distribute)); } - - - -std::list<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem *> &list, bool horizontal){ - std::list<SPItem *>::iterator master = list.end(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int prefs_bbox = prefs->getBool("/tools/bounding_box"); - switch (getAlignTarget()) { - case LAST: - return list.begin(); - break; - - case FIRST: - return --(list.end()); - break; - - case BIGGEST: - { - gdouble max = -1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { - Geom::OptRect b = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); - if (b) { - gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); - if (dim > max) { - max = dim; - master = it; - } - } - } - return master; - } - - case SMALLEST: - { - gdouble max = 1e18; - for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); ++it) { - Geom::OptRect b = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); - if (b) { - gdouble dim = (*b)[horizontal ? Geom::X : Geom::Y].extent(); - if (dim < max) { - max = dim; - master = it; - } - } - } - return master; - } - - default: - g_assert_not_reached (); - break; - - } // end of switch statement - return master; -} - -AlignAndDistribute::AlignTarget AlignAndDistribute::getAlignTarget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - return AlignTarget(prefs->getInt("/dialogs/align/align-to", 6)); -} - - - } // namespace Dialog } // namespace UI } // namespace Inkscape diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index c9165a83e..dfd84535b 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -47,12 +47,6 @@ public: static AlignAndDistribute &getInstance() { return *new AlignAndDistribute(); } - enum AlignTarget { LAST=0, FIRST, BIGGEST, SMALLEST, PAGE, DRAWING, SELECTION }; - - - - static AlignTarget getAlignTarget(); - #if WITH_GTKMM_3_0 Gtk::Grid &align_table(){return _alignTable;} Gtk::Grid &distribute_table(){return _distributeTable;} @@ -67,7 +61,6 @@ public: Gtk::Table &nodes_table(){return _nodesTable;} #endif - static std::list<SPItem *>::iterator find_master(std::list <SPItem *> &list, bool horizontal); void setMode(bool nodeEdit); Geom::OptRect randomize_bbox; @@ -189,6 +182,7 @@ public : double sx0, sx1, sy0, sy1; int verb_id; }; + enum AlignTarget { LAST=0, FIRST, BIGGEST, SMALLEST, PAGE, DRAWING, SELECTION }; ActionAlign(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, @@ -204,6 +198,7 @@ public : * Static function called to align from a keyboard shortcut */ static void do_verb_action(SPDesktop *desktop, int verb); + static int verb_to_coeff(int verb); private : @@ -217,7 +212,6 @@ private : } static void do_action(SPDesktop *desktop, int index); - static int verb_to_coeff(int verb); guint _index; AlignAndDistribute &_dialog; diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index ce923f6b4..c41046123 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -27,6 +27,7 @@ #include "document.h" #include "document-undo.h" #include "helper/action.h" +#include "helper/action-context.h" #include "inkscape.h" #include "layer-fns.h" #include "layer-manager.h" @@ -99,7 +100,7 @@ void LayersPanel::_styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned i if ( desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !set && action && action->image ) { GtkWidget *child = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, action->image ); gtk_widget_show( child ); @@ -131,7 +132,7 @@ Gtk::MenuItem& LayersPanel::_addPopupItem( SPDesktop *desktop, unsigned int code if ( desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(desktop)); if ( !iconWidget && action && action->image ) { iconWidget = sp_icon_new( Inkscape::ICON_SIZE_MENU, action->image ); } @@ -172,7 +173,7 @@ void LayersPanel::_fireAction( unsigned int code ) if ( _desktop ) { Verb *verb = Verb::get( code ); if ( verb ) { - SPAction *action = verb->get_action(_desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext(_desktop)); if ( action ) { sp_action_perform( action, NULL ); // } else { diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 90cb1cdc9..094a6fa6a 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -57,6 +57,7 @@ #include "verbs.h" #include "gradient-chemistry.h" #include "helper/action.h" +#include "helper/action-context.h" namespace Inkscape { namespace UI { @@ -154,7 +155,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) // Invoke the gradient tool Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_CONTEXT_GRADIENT ); if ( verb ) { - SPAction *action = verb->get_action( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP); + SPAction *action = verb->get_action( Inkscape::ActionContext( ( Inkscape::UI::View::View * ) SP_ACTIVE_DESKTOP ) ); if ( action ) { sp_action_perform( action, NULL ); } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index b71686a17..26bc52947 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -67,6 +67,7 @@ #include "verbs.h" #include "helper/action.h" +#include "helper/action-context.h" #include "xml/repr.h" namespace Inkscape { @@ -329,13 +330,13 @@ void SymbolsDialog::rebuild() { void SymbolsDialog::insertSymbol() { Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_SYMBOL ); - SPAction *action = verb->get_action((Inkscape::UI::View::View *) this->currentDesktop); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop) ); sp_action_perform (action, NULL); } void SymbolsDialog::revertSymbol() { Inkscape::Verb *verb = Inkscape::Verb::get( SP_VERB_EDIT_UNSYMBOL ); - SPAction *action = verb->get_action((Inkscape::UI::View::View *) this->currentDesktop); + SPAction *action = verb->get_action(Inkscape::ActionContext( (Inkscape::UI::View::View *) this->currentDesktop ) ); sp_action_perform (action, NULL); } diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index f0bf149f4..30963cabd 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -458,9 +458,9 @@ private: static Glib::RefPtr<Gdk::Pixbuf> _corner_to_pixbuf(unsigned c) { sp_select_context_get_type(); switch (c % 4) { - case 0: return Glib::wrap(handles[10], true); - case 1: return Glib::wrap(handles[8], true); - case 2: return Glib::wrap(handles[6], true); + case 0: return Glib::wrap(handles[7], true); + case 1: return Glib::wrap(handles[6], true); + case 2: return Glib::wrap(handles[5], true); default: return Glib::wrap(handles[4], true); } } @@ -605,9 +605,9 @@ private: static Glib::RefPtr<Gdk::Pixbuf> _side_to_pixbuf(unsigned s) { sp_select_context_get_type(); switch (s % 4) { - case 0: return Glib::wrap(handles[9], true); - case 1: return Glib::wrap(handles[7], true); - case 2: return Glib::wrap(handles[5], true); + case 0: return Glib::wrap(handles[10], true); + case 1: return Glib::wrap(handles[9], true); + case 2: return Glib::wrap(handles[8], true); default: return Glib::wrap(handles[11], true); } } diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 2bfc7e0df..52e9ea605 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -48,11 +48,21 @@ const int Dock::_default_dock_bar_width = 36; Dock::Dock(Gtk::Orientation orientation) - : _gdl_dock (GDL_DOCK (gdl_dock_new())), - _gdl_dock_bar (GDL_DOCK_BAR (gdl_dock_bar_new(GDL_DOCK(_gdl_dock)))), + : _gdl_dock(gdl_dock_new()), +#if WITH_GDL_3_6 + _gdl_dock_bar(GDL_DOCK_BAR(gdl_dock_bar_new(G_OBJECT(_gdl_dock)))), +#else + _gdl_dock_bar(GDL_DOCK_BAR(gdl_dock_bar_new(GDL_DOCK(_gdl_dock)))), +#endif _scrolled_window (Gtk::manage(new Gtk::ScrolledWindow)) { - gdl_dock_bar_set_orientation(_gdl_dock_bar, static_cast<GtkOrientation>(orientation)); +#if WITH_GDL_3_6 + gtk_orientable_set_orientation(GTK_ORIENTABLE(_gdl_dock_bar), + static_cast<GtkOrientation>(orientation)); +#else + gdl_dock_bar_set_orientation(_gdl_dock_bar, + static_cast<GtkOrientation>(orientation)); +#endif #if WITH_GTKMM_3_0 switch(orientation) { @@ -127,7 +137,9 @@ Dock::~Dock() void Dock::addItem(DockItem& item, DockItem::Placement placement) { _dock_items.push_back(&item); - gdl_dock_add_item(_gdl_dock, GDL_DOCK_ITEM(item.gobj()), (GdlDockPlacement)placement); + gdl_dock_add_item(GDL_DOCK(_gdl_dock), + GDL_DOCK_ITEM(item.gobj()), + (GdlDockPlacement)placement); // FIXME: This is a hack to prevent the dock from expanding the main window, this can't be done // initially as the paned doesn't exist. diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h index 611c10f46..33e60b836 100644 --- a/src/ui/widget/dock.h +++ b/src/ui/widget/dock.h @@ -74,11 +74,11 @@ protected: /** Interface widgets, will be packed like * _scrolled_window -> (_dock_box -> (_paned -> (_dock -> _filler) | _dock_bar)) */ - Gtk::Box *_dock_box; - Gtk::Paned* _paned; - GdlDock *_gdl_dock; - GdlDockBar *_gdl_dock_bar; - Gtk::VBox _filler; + Gtk::Box *_dock_box; + Gtk::Paned *_paned; + GtkWidget *_gdl_dock; + GdlDockBar *_gdl_dock_bar; + Gtk::VBox _filler; Gtk::ScrolledWindow *_scrolled_window; /** Internal signal handlers */ diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 14e280f6d..73b75090b 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -36,6 +36,7 @@ #include "document.h" #include "desktop.h" #include "helper/action.h" +#include "helper/action-context.h" #include "util/units.h" #include "inkscape.h" #include "sp-namedview.h" @@ -616,7 +617,7 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing() Verb *verb = Verb::get( SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING ); if (verb) { - SPAction *action = verb->get_action(dt); + SPAction *action = verb->get_action(Inkscape::ActionContext(dt)); if (action) { sp_action_perform(action, NULL); } diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index a89f42575..aedab3fa5 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -28,6 +28,7 @@ #include "widgets/widget-sizes.h" #include "helper/units.h" #include "helper/action.h" +#include "helper/action-context.h" #include "preferences.h" #include "inkscape.h" #include "verbs.h" @@ -200,7 +201,7 @@ StyleSwatch::on_click(GdkEventButton */*event*/) { if (this->_desktop && this->_verb_t != SP_VERB_NONE) { Inkscape::Verb *verb = Inkscape::Verb::get(this->_verb_t); - SPAction *action = verb->get_action((Inkscape::UI::View::View *) this->_desktop); + SPAction *action = verb->get_action(Inkscape::ActionContext((Inkscape::UI::View::View *) this->_desktop)); sp_action_perform (action, NULL); return true; } |
