Commit 415b84f2 authored by Piotr Henryk Dąbrowski's avatar Piotr Henryk Dąbrowski Committed by Bartosz Brachaczek

screenshot: #2286 fixed: intelligent toolbox positioning

parent 1a8a5f4c
......@@ -2,6 +2,7 @@
* plugins: #2272 fixed: added possibility to tell Kadu to try to load plugin failing to load on next Kadu run (beevvy)
* gadu: fixed compatibility with advanced message formatting including text mixed with multiple images (beevvy)
* screenshot: #2285 fixed: update the pixmap only if the crop rect changed (ultr)
* screenshot: #2286 fixed: intelligent toolbox positioning (ultr)
+++ version 0.10.1
* gadu: clearer contact list synchronization message when updating from <0.10.0 (beevvy)
......
......@@ -35,6 +35,7 @@
#define HANDLER_SIZE 10
#define HANDLER_HALF_SIZE (HANDLER_SIZE/2)
#define TOOLBOX_PADDING 10
CropImageWidget::CropImageWidget(QWidget *parent) :
QGraphicsView(parent), IsMouseButtonPressed(false)
......@@ -132,21 +133,31 @@ void CropImageWidget::updateCropRectDisplay()
QRect normalized = CropRect.normalized();
SelectionFrame->setSelection(normalized);
int xMiddle = (normalized.left() + normalized.right()) / 2;
int yMiddle = (normalized.top() + normalized.bottom()) / 2;
// workaround for wrong cursor on negative coordinates
TopLeftHandler->setPos(CropRect.left() - HANDLER_HALF_SIZE, CropRect.top() - HANDLER_HALF_SIZE);
TopHandler->setPos(xMiddle - HANDLER_HALF_SIZE, CropRect.top() - HANDLER_HALF_SIZE);
TopHandler->setPos(normalized.center().x() - HANDLER_HALF_SIZE, CropRect.top() - HANDLER_HALF_SIZE);
TopRightHandler->setPos(CropRect.right() - HANDLER_HALF_SIZE, CropRect.top() - HANDLER_HALF_SIZE);
LeftHandler->setPos(CropRect.left() - HANDLER_HALF_SIZE, yMiddle - HANDLER_HALF_SIZE);
RightHandler->setPos(CropRect.right() - HANDLER_HALF_SIZE, yMiddle - HANDLER_HALF_SIZE);
LeftHandler->setPos(CropRect.left() - HANDLER_HALF_SIZE, normalized.center().y() - HANDLER_HALF_SIZE);
RightHandler->setPos(CropRect.right() - HANDLER_HALF_SIZE, normalized.center().y() - HANDLER_HALF_SIZE);
BottomLeftHandler->setPos(CropRect.left() - HANDLER_HALF_SIZE, CropRect.bottom() - HANDLER_HALF_SIZE);
BottomHandler->setPos(xMiddle - HANDLER_HALF_SIZE, CropRect.bottom() - HANDLER_HALF_SIZE);
BottomHandler->setPos(normalized.center().x() - HANDLER_HALF_SIZE, CropRect.bottom() - HANDLER_HALF_SIZE);
BottomRightHandler->setPos(CropRect.right() - HANDLER_HALF_SIZE, CropRect.bottom() - HANDLER_HALF_SIZE);
ToolBox->setGeometry(QString("%1x%2").arg(normalized.width()).arg(normalized.height()));
ToolBoxProxy->setPos(xMiddle - ToolBox->width() / 2, yMiddle - ToolBox->height() / 2);
int left = normalized.right() + TOOLBOX_PADDING;
if (left + ToolBox->width() > width())
left = normalized.left() - TOOLBOX_PADDING - ToolBox->width();
if (left < 0)
left = normalized.center().x() - ToolBox->width() / 2;
int top = normalized.bottom() + TOOLBOX_PADDING;
if (top + ToolBox->height() > height())
top = normalized.top() - TOOLBOX_PADDING - ToolBox->height();
if (top < 0)
top = normalized.center().y() - ToolBox->height() / 2;
ToolBoxProxy->setPos(left, top);
scene()->update(scene()->sceneRect());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment