r17615 by craig - #10767: Apply patch to allow add itemResizeToMargin action for right click on items handlers
scribus-commit
scribus-commit at lists.scribus.net
Sat Jun 23 17:17:31 UTC 2012
Author: craig
Date: Sat Jun 23 17:17:31 2012
New Revision: 17615
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17615
Log:
#10767: Apply patch to allow add itemResizeToMargin action for right click on items handlers
Modified:
trunk/Scribus/scribus/canvasgesture_resize.cpp
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/scribusdoc.h
Modified: trunk/Scribus/scribus/canvasgesture_resize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17615&path=/trunk/Scribus/scribus/canvasgesture_resize.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_resize.cpp (original)
+++ trunk/Scribus/scribus/canvasgesture_resize.cpp Sat Jun 23 17:17:31 2012
@@ -182,6 +182,13 @@
m_doc->setRedrawBounding(currItem);
if (currItem->asImageFrame())
currItem->AdjustPictScale();
+ }
+ //add action itemResizeToMargin for right click on item`s handlers
+ else if (m->button() == Qt::RightButton)
+ {
+ const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
+ Canvas::FrameHandle fh = m_canvas->frameHitTest(QPointF(mousePointDoc.x(),mousePointDoc.y()), currItem);
+ m_doc->itemResizeToMargin(currItem, fh);
}
m_view->resetMousePressed();
// necessary since mousebutton is still recorded pressed, and otherwise checkchanges() will do nothing
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17615&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Jun 23 17:17:31 2012
@@ -15333,3 +15333,47 @@
FrameItems.insert(fIndex, item);
return fIndex;
}
+
+void ScribusDoc::itemResizeToMargin(PageItem* item, int direction)
+{
+ //FIX ME: for now avoid for rotated items
+ if (item->rotation() != 0)
+ return;
+ Canvas::FrameHandle fh = (Canvas::FrameHandle) direction;
+ ScPage *currPage = Pages->at(item->OwnPage);
+ QMatrix ma;
+ ma.translate(item->xPos(), item->yPos());
+ double inX = ma.dx() - currentPage()->xOffset();
+ double inY = ma.dy() - currentPage()->yOffset();
+ if (fh == Canvas::NORTH || fh == Canvas::NORTHWEST || fh == Canvas::NORTHEAST)
+ {
+ double top = currPage->topMargin();
+ double dY = inY - top;
+ item->moveBy(0, -dY);
+ item->setHeight(item->height() + dY);
+ }
+ if (fh == Canvas::SOUTH || fh == Canvas::SOUTHWEST || fh == Canvas::SOUTHEAST)
+ {
+ double bottom = currPage->height() - currPage->bottomMargin();
+ double dY = bottom - (inY + item->height());
+ item->setHeight(item->height() + dY);
+ }
+ if (fh == Canvas::EAST || fh == Canvas::NORTHEAST || fh == Canvas::SOUTHEAST)
+ {
+ double right = currPage->width() - currPage->rightMargin();
+ double dX = right - (inX + item->width());
+ item->setWidth(item->width() + dX);
+ }
+ if (fh == Canvas::WEST || fh == Canvas::NORTHWEST || fh == Canvas::SOUTHWEST)
+ {
+ double left = currPage->leftMargin();
+ double dX = inX - left;
+ item->moveBy(-dX, 0);
+ item->setWidth(item->width() + dX);
+ }
+
+ item->updateClip();
+ item->invalid = true;
+ changed();
+ regionsChanged()->update(QRect());
+}
Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17615&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Sat Jun 23 17:17:31 2012
@@ -1328,6 +1328,8 @@
FPointArray symNewFrame;
Hyphenator * docHyphenator;
+ void itemResizeToMargin(PageItem* item, int direction); //direction reflect enum numbers from Canvas::FrameHandle
+
private:
UndoTransaction* m_itemCreationTransaction;
UndoTransaction* m_alignTransaction;
More information about the scribus-commit
mailing list