From c3a160589a9cb41c70a56e5e7b66a65857a0d10e Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 1 Jul 2013 21:04:32 +0100 Subject: Factored layer model out into new Inkscape::LayerModel class. This allows Inkscape::Selection to use a LayerModel that is not associated with a UI. Changed the interface of verbs (SPAction) to use a new ActionContext rather than UI::View::View, again so that verbs may be used in a console mode. Modified boolean operation verbs to work in console-only mode. Fixed up DESKTOP_IS_ACTIVE macro to work in the case of no desktops. Modified main.cpp to process selections and verbs in no-GUI mode. Other changes are all consequences of the SPDesktop, Selection and LayerModel interface changes. (bzr r12387.1.1) --- src/selection.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/selection.h') diff --git a/src/selection.h b/src/selection.h index 10775dcb5..65a6c5140 100644 --- a/src/selection.h +++ b/src/selection.h @@ -33,6 +33,7 @@ class SPBox3D; struct Persp3D; namespace Inkscape { +class LayerModel; namespace XML { class Node; } @@ -41,10 +42,10 @@ class Node; namespace Inkscape { /** - * The set of selected SPObjects for a given desktop. + * The set of selected SPObjects for a given document and layer model. * * This class represents the set of selected SPItems for a given - * SPDesktop. + * document (referenced in LayerModel). * * An SPObject and its parent cannot be simultaneously selected; * selecting an SPObjects has the side-effect of unselecting any of @@ -64,17 +65,26 @@ class Selection : public Inkscape::GC::Managed<>, public: /** * Constructs an selection object, bound to a particular - * SPDesktop + * layer model * - * @param desktop the desktop in question + * @param layer_model the layer model (for the SPDesktop, if GUI) + * @param desktop the desktop associated with the layer model, or NULL if in console mode */ - Selection(SPDesktop *desktop); + Selection(LayerModel *layer_model, SPDesktop *desktop); ~Selection(); + /** + * Returns the layer model the selection is bound to (works in console or GUI mode) + * + * @return the layer model the selection is bound to, which is the same as the desktop + * layer model for GUI mode + */ + LayerModel *layerModel() { return _layer_model; } + /** * Returns the desktop the selection is bound to * - * @return the desktop the selection is bound to + * @return the desktop the selection is bound to, or NULL if in console mode */ SPDesktop *desktop() { return _desktop; } @@ -342,6 +352,7 @@ private: std::list _3dboxes; + LayerModel *_layer_model; GC::soft_ptr _desktop; SPObject* _selection_context; guint _flags; -- cgit v1.2.3 From 104efe4e3ecadc975ab76748c66f041abf8ee7b1 Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Thu, 4 Jul 2013 15:01:44 +0100 Subject: Code readability improvements and licence changes for action-context.* based on merge request code review and feedback (bzr r12387.1.7) --- src/selection.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/selection.h') diff --git a/src/selection.h b/src/selection.h index 65a6c5140..f076cf7aa 100644 --- a/src/selection.h +++ b/src/selection.h @@ -67,10 +67,10 @@ public: * Constructs an selection object, bound to a particular * layer model * - * @param layer_model the layer model (for the SPDesktop, if GUI) + * @param layers the layer model (for the SPDesktop, if GUI) * @param desktop the desktop associated with the layer model, or NULL if in console mode */ - Selection(LayerModel *layer_model, SPDesktop *desktop); + Selection(LayerModel *layers, SPDesktop *desktop); ~Selection(); /** @@ -79,7 +79,7 @@ public: * @return the layer model the selection is bound to, which is the same as the desktop * layer model for GUI mode */ - LayerModel *layerModel() { return _layer_model; } + LayerModel *layers() { return _layers; } /** * Returns the desktop the selection is bound to @@ -352,7 +352,7 @@ private: std::list _3dboxes; - LayerModel *_layer_model; + LayerModel *_layers; GC::soft_ptr _desktop; SPObject* _selection_context; guint _flags; -- cgit v1.2.3 From 80a911db81b651f38205c1eb926af4986bc033e8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 10 Jul 2013 22:24:38 -0400 Subject: Step 2 refactoring the align functions, added some functionality to selection. (bzr r12413) --- src/selection.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/selection.h') diff --git a/src/selection.h b/src/selection.h index f076cf7aa..25c018f7b 100644 --- a/src/selection.h +++ b/src/selection.h @@ -27,6 +27,7 @@ #include "sp-item.h" #include "snapped-point.h" + class SPDesktop; class SPItem; class SPBox3D; @@ -63,6 +64,7 @@ class Selection : public Inkscape::GC::Managed<>, public Inkscape::GC::Anchored { public: + enum CompareSize { HORIZONTAL, VERTICAL, AREA }; /** * Constructs an selection object, bound to a particular * layer model @@ -219,6 +221,16 @@ public: */ SPItem *singleItem(); + /** + * Returns the smallest item from this selection. + */ + SPItem *smallestItem(CompareSize compare); + + /** + * Returns the largest item from this selection. + */ + SPItem *largestItem(CompareSize compare); + /** * Returns a single selected object's xml node. * @@ -308,6 +320,11 @@ public: return _modified_signal.connect(slot); } + /** + * Selection wants to be aligned to this point, not bbox + */ + Geom::Point *align_point; + private: /** no copy. */ Selection(Selection const &); @@ -349,6 +366,7 @@ private: void add_3D_boxes_recursively(SPObject *obj); void remove_box_perspective(SPBox3D *box); void remove_3D_boxes_recursively(SPObject *obj); + SPItem *_sizeistItem(bool small, CompareSize compare); std::list _3dboxes; -- cgit v1.2.3 From c3074d380bbdbd8ec8f17b9cfb3059119005a30b Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 10 Jul 2013 23:08:15 -0400 Subject: Remove align point, not required any more (bzr r12414) --- src/selection.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/selection.h') diff --git a/src/selection.h b/src/selection.h index 25c018f7b..75351a4ff 100644 --- a/src/selection.h +++ b/src/selection.h @@ -320,11 +320,6 @@ public: return _modified_signal.connect(slot); } - /** - * Selection wants to be aligned to this point, not bbox - */ - Geom::Point *align_point; - private: /** no copy. */ Selection(Selection const &); -- cgit v1.2.3 From df87c3c1c14f2483a9dbfc8bf2ac69e9834a42bf Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 11 Jul 2013 06:41:25 -0400 Subject: Change small to sml to fix windows compile problem (bzr r12415) --- src/selection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/selection.h') diff --git a/src/selection.h b/src/selection.h index 75351a4ff..32eade21f 100644 --- a/src/selection.h +++ b/src/selection.h @@ -361,7 +361,7 @@ private: void add_3D_boxes_recursively(SPObject *obj); void remove_box_perspective(SPBox3D *box); void remove_3D_boxes_recursively(SPObject *obj); - SPItem *_sizeistItem(bool small, CompareSize compare); + SPItem *_sizeistItem(bool sml, CompareSize compare); std::list _3dboxes; -- cgit v1.2.3