Reset to original position instead of deleting when selection dropped off-page

presentation
JJones780 7 years ago
parent b3077a85df
commit bb834b9dee
  1. 28
      src/control/tools/EditSelection.cpp
  2. 16
      src/control/tools/EditSelectionContents.cpp
  3. 18
      src/control/tools/EditSelectionContents.h

@ -165,23 +165,25 @@ void EditSelection::finalizeSelection()
XojPageView* v = getBestMatchingPageView();
if (v == NULL)
{
this->view->getXournal()->deleteSelection(this);
{ // Not on any page - move back to original page and position
this->x = this->contents->getOriginalX();
this->y = this->contents->getOriginalY();
v = this->contents->getSourceView();
}
else
{
this->view = v;
PageRef page = this->view->getPage();
Layer* layer = page->getSelectedLayer();
this->contents->finalizeSelection(this->x, this->y, this->width, this->height,
this->aspectRatio, layer, page, this->view, this->undo);
this->view = v;
this->view->rerenderRect(this->x, this->y, this->width, this->height);
PageRef page = this->view->getPage();
Layer* layer = page->getSelectedLayer();
this->contents->finalizeSelection(this->x, this->y, this->width, this->height,
this->aspectRatio, layer, page, this->view, this->undo);
this->view->rerenderRect(this->x, this->y, this->width, this->height);
// This is needed if the selection not was 100% on a page
this->view->getXournal()->repaintSelection(true);
// This is needed if the selection not was 100% on a page
this->view->getXournal()->repaintSelection(true);
}
}
/**

@ -429,6 +429,22 @@ void EditSelectionContents::finalizeSelection(double x, double y, double width,
}
double EditSelectionContents::getOriginalX()
{
return this->originalX;
}
double EditSelectionContents::getOriginalY()
{
return this->originalY;
}
XojPageView* EditSelectionContents::getSourceView()
{
return this->sourceView;
}
void EditSelectionContents::updateContent(double x, double y, double rotation, double width, double height, bool aspectRatio,
Layer* layer, PageRef targetPage, XojPageView* targetView,
UndoRedoHandler* undo, CursorSelectionType type)

@ -108,6 +108,24 @@ private:
static bool repaintSelection(EditSelectionContents* selection);
public:
/**
* Gets the original view of the contents
*/
XojPageView * getSourceView();
/**
* Gets the original X of the contents
*/
double getOriginalX();
/**
* Gets the original Y of the contents
*/
double getOriginalY();
/**
* Gets the original width of the contents
*/

Loading…
Cancel
Save