diff options
| author | Eric Greveson <eric@greveson.co.uk> | 2013-07-01 20:09:53 +0000 |
|---|---|---|
| committer | Eric Greveson <eric@greveson.co.uk> | 2013-07-01 20:09:53 +0000 |
| commit | 6fe6a37589cbd6e53bf763879503ace16260e7a2 (patch) | |
| tree | ab3d7fa48e6ca4af582a54cf4c042de0fac2bef2 /src/helper/action-context.cpp | |
| parent | Factored layer model out into new Inkscape::LayerModel class. This allows (diff) | |
| download | inkscape-6fe6a37589cbd6e53bf763879503ace16260e7a2.tar.gz inkscape-6fe6a37589cbd6e53bf763879503ace16260e7a2.zip | |
Added new files referenced in previous commit message (forgot to add!)
(bzr r12387.1.2)
Diffstat (limited to 'src/helper/action-context.cpp')
| -rw-r--r-- | src/helper/action-context.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/helper/action-context.cpp b/src/helper/action-context.cpp new file mode 100644 index 000000000..c88086f7f --- /dev/null +++ b/src/helper/action-context.cpp @@ -0,0 +1,74 @@ +/* + * ActionContext implementation. + * + * Author: + * Eric Greveson <eric@greveson.co.uk> + * + * Copyright (C) 2013 Eric Greveson + * + * This code is in public domain + */ + +#include "desktop.h" +#include "document.h" +#include "layer-model.h" +#include "selection.h" +#include "helper/action-context.h" +#include "ui/view/view.h" + +namespace Inkscape { + +ActionContext::ActionContext() + : _selection(NULL) + , _view(NULL) +{ +} + +ActionContext::ActionContext(Selection *selection) + : _selection(selection) + , _view(NULL) +{ +} + +ActionContext::ActionContext(UI::View::View *view) + : _selection(NULL) + , _view(view) +{ + SPDesktop *desktop = static_cast<SPDesktop *>(view); + if (desktop) { + _selection = desktop->selection; + } +} + +SPDocument *ActionContext::getDocument() const +{ + if (_selection == NULL) { + return NULL; + } + + // Should be the same as the view's document, if view is non-NULL + return _selection->layerModel()->getDocument(); +} + +Selection *ActionContext::getSelection() const +{ + return _selection; +} + +UI::View::View *ActionContext::getView() const +{ + return _view; +} + +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |
