mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-17 13:20:45 +00:00
Add support to drag the selection in other editor when the active one is in MovingPixels state
This commit is contained in:
parent
ab9d2da762
commit
9966b48139
@ -70,7 +70,8 @@ protected:
|
||||
void onExecute(Context* context) override {
|
||||
Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
|
||||
|
||||
std::vector<DocumentView*> docViews;
|
||||
// Collect all document views
|
||||
DocumentViews docViews;
|
||||
for (auto view : *workspace) {
|
||||
DocumentView* docView = dynamic_cast<DocumentView*>(view);
|
||||
if (docView)
|
||||
|
@ -267,7 +267,7 @@ void DocumentView::onClonedFrom(WorkspaceView* from)
|
||||
bool DocumentView::onCloseView(Workspace* workspace)
|
||||
{
|
||||
if (m_editor->isMovingPixels())
|
||||
m_editor->cancelMovingPixels();
|
||||
m_editor->dropMovingPixels();
|
||||
|
||||
// If there is another view for this document, just close the view.
|
||||
for (auto view : *workspace) {
|
||||
|
@ -1604,7 +1604,7 @@ bool Editor::isMovingPixels() const
|
||||
return (dynamic_cast<MovingPixelsState*>(m_state.get()) != nullptr);
|
||||
}
|
||||
|
||||
void Editor::cancelMovingPixels()
|
||||
void Editor::dropMovingPixels()
|
||||
{
|
||||
ASSERT(isMovingPixels());
|
||||
backToPreviousState();
|
||||
|
@ -91,7 +91,7 @@ namespace app {
|
||||
EditorStatePtr getState() { return m_state; }
|
||||
|
||||
bool isMovingPixels() const;
|
||||
void cancelMovingPixels();
|
||||
void dropMovingPixels();
|
||||
|
||||
// Changes the state of the editor.
|
||||
void setState(const EditorStatePtr& newState);
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "app/tools/ink.h"
|
||||
#include "app/tools/pick_ink.h"
|
||||
#include "app/tools/tool.h"
|
||||
#include "app/ui/document_view.h"
|
||||
#include "app/ui/editor/drawing_state.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/editor/editor_customization_delegate.h"
|
||||
@ -423,13 +424,21 @@ void StandbyState::startSelectionTransformation(Editor* editor,
|
||||
|
||||
void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleType handle)
|
||||
{
|
||||
Document* document = editor->document();
|
||||
|
||||
for (auto docView : UIContext::instance()->getAllDocumentViews(document)) {
|
||||
if (docView->getEditor()->isMovingPixels()) {
|
||||
// TODO Transfer moving pixels state to this editor
|
||||
docView->getEditor()->dropMovingPixels();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// Clear brush preview, as the extra cel will be replaced with the
|
||||
// transformed image.
|
||||
editor->brushPreview().hide();
|
||||
|
||||
EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
|
||||
Document* document = editor->document();
|
||||
base::UniquePtr<Image> tmpImage(new_image_from_mask(editor->getSite()));
|
||||
|
||||
PixelsMovementPtr pixelsMovement(
|
||||
|
@ -134,7 +134,7 @@ void UIContext::setActiveDocument(Document* document)
|
||||
notifyActiveSiteChanged();
|
||||
}
|
||||
|
||||
DocumentView* UIContext::getFirstDocumentView(Document* document) const
|
||||
DocumentView* UIContext::getFirstDocumentView(doc::Document* document) const
|
||||
{
|
||||
MainWindow* mainWindow = App::instance()->getMainWindow();
|
||||
if (!mainWindow) // Main window can be null if we are in --batch mode
|
||||
@ -153,6 +153,22 @@ DocumentView* UIContext::getFirstDocumentView(Document* document) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DocumentViews UIContext::getAllDocumentViews(doc::Document* document) const
|
||||
{
|
||||
Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
|
||||
DocumentViews docViews;
|
||||
|
||||
for (WorkspaceView* view : *workspace) {
|
||||
if (DocumentView* docView = dynamic_cast<DocumentView*>(view)) {
|
||||
if (docView->getDocument() == document) {
|
||||
docViews.push_back(docView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return docViews;
|
||||
}
|
||||
|
||||
Editor* UIContext::activeEditor()
|
||||
{
|
||||
DocumentView* view = activeView();
|
||||
@ -188,18 +204,8 @@ void UIContext::onRemoveDocument(doc::Document* doc)
|
||||
// We don't destroy views in batch mode.
|
||||
if (isUIAvailable()) {
|
||||
Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
|
||||
DocumentViews docViews;
|
||||
|
||||
// Collect all views related to the document.
|
||||
for (WorkspaceView* view : *workspace) {
|
||||
if (DocumentView* docView = dynamic_cast<DocumentView*>(view)) {
|
||||
if (docView->getDocument() == doc) {
|
||||
docViews.push_back(docView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (DocumentView* docView : docViews) {
|
||||
for (DocumentView* docView : getAllDocumentViews(doc)) {
|
||||
workspace->removeView(docView);
|
||||
delete docView;
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ namespace app {
|
||||
void setActiveView(DocumentView* documentView);
|
||||
void setActiveDocument(Document* document);
|
||||
|
||||
DocumentView* getFirstDocumentView(Document* document) const;
|
||||
DocumentView* getFirstDocumentView(doc::Document* document) const;
|
||||
DocumentViews getAllDocumentViews(doc::Document* document) const;
|
||||
|
||||
// Returns the current editor. It can be null.
|
||||
Editor* activeEditor();
|
||||
|
Loading…
x
Reference in New Issue
Block a user