bool RenderFrameSet::userResize(MouseEvent* evt) { if (flattenFrameSet()) return false; if (!m_isResizing) { if (needsLayout()) return false; if (evt->type() == eventNames().mousedownEvent && evt->button() == LeftButton) { FloatPoint localPos = absoluteToLocal(evt->absoluteLocation(), UseTransforms); startResizing(m_cols, localPos.x()); startResizing(m_rows, localPos.y()); if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResized != noSplit) { setIsResizing(true); return true; } } } else { if (evt->type() == eventNames().mousemoveEvent || (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton)) { FloatPoint localPos = absoluteToLocal(evt->absoluteLocation(), UseTransforms); continueResizing(m_cols, localPos.x()); continueResizing(m_rows, localPos.y()); if (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton) { setIsResizing(false); return true; } } } return false; }
bool RenderFrameSet::userResize(MouseEvent* evt) { if (!m_isResizing) { if (needsLayout()) return false; if (evt->type() == eventNames().mousedownEvent && evt->button() == LeftButton) { startResizing(m_cols, evt->pageX() - xPos()); startResizing(m_rows, evt->pageY() - yPos()); if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResized != noSplit) { setIsResizing(true); return true; } } } else { if (evt->type() == eventNames().mousemoveEvent || (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton)) { continueResizing(m_cols, evt->pageX() - xPos()); continueResizing(m_rows, evt->pageY() - yPos()); if (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton) { setIsResizing(false); return true; } } } return false; }
KMagSelWin::KMagSelWin ( QWidget * parent, Qt::WFlags ) : QWidget(parent) //Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop | Qt::WType_TopLevel | Qt::WX11BypassWM) { setWindowFlags( Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(QBitmap::fromData( QSize(8, 8), line_bits))); setPalette(p); titleBar = new KMagSelWinCorner (this); titleBar->setObjectName( QLatin1String("titlebar" )); setPaletteColor(titleBar, QPalette::Background, getTitleColor()); setPaletteColor(titleBar, QPalette::Foreground, getTextColor()); titleBar->setText(i18n("Selection Window")+QLatin1String( " - " )+i18n("KMagnifier")); connect (titleBar, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (titleBar, SIGNAL (resized(QPoint)), this, SLOT (titleMoved(QPoint))); topLeftCorner = new KMagSelWinCorner (this); topLeftCorner->setObjectName( QLatin1String("topleft" )); topLeftCorner->setCursor (Qt::SizeFDiagCursor); setPaletteColor(topLeftCorner, QPalette::Background, getTitleBtnColor()); connect (topLeftCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (topLeftCorner, SIGNAL (resized(QPoint)), this, SLOT (topLeftResized(QPoint))); topRightCorner = new KMagSelWinCorner (this); topRightCorner->setObjectName( QLatin1String("topright" )); topRightCorner->setCursor (Qt::SizeBDiagCursor); setPaletteColor(topRightCorner, QPalette::Background, getTitleBtnColor ()); connect (topRightCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (topRightCorner, SIGNAL (resized(QPoint)), this, SLOT (topRightResized(QPoint))); bottomLeftCorner = new KMagSelWinCorner (this); bottomLeftCorner->setObjectName( QLatin1String("bottomleft" )); bottomLeftCorner->setCursor (Qt::SizeBDiagCursor); setPaletteColor(bottomLeftCorner, QPalette::Background, getTitleBtnColor()); connect (bottomLeftCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (bottomLeftCorner, SIGNAL (resized(QPoint)), this, SLOT (bottomLeftResized(QPoint))); bottomRightCorner = new KMagSelWinCorner (this); bottomRightCorner->setObjectName( QLatin1String("bottomright" )); bottomRightCorner->setCursor (Qt::SizeFDiagCursor); setPaletteColor(bottomRightCorner, QPalette::Background, getTitleBtnColor ()); connect (bottomRightCorner, SIGNAL (startResizing()), this, SLOT (startResizing())); connect (bottomRightCorner, SIGNAL (resized(QPoint)), this, SLOT (bottomRightResized(QPoint))); }
void SelectTool::mousePress(const QPoint &pos) { // Last point is used for undrawing at the last position and calculating the distance the mouse has moved m_lastPoint = view()->canvasWidget()->mapFromScreen(pos); m_origPoint = m_lastPoint; // Check if we nailed a custom drag point on a selected stencil if( startCustomDragging(pos, true) ) { m_mode = stmCustomDragging; return; } // Check if we are resizing if( startResizing(pos) ) { m_mode = stmResizing; return; } // Check if we nailed a custom drag point on any other stencil if( startCustomDragging(pos, false) ) { m_mode = stmCustomDragging; return; } // Check if we can drag a stencil if( startDragging(pos, false) ) { m_mode = stmDragging; return; } // This should always be the last 'start' call since it always returns true if( startRubberBanding(pos) ) { m_mode = stmDrawRubber; return; } }
void KMagSelWinCorner::mousePressEvent ( QMouseEvent * e ) { oldPos = e->globalPos (); emit startResizing (); }
void AbstractSelection::mousePressEvent(QMouseEvent *event, ImageArea &imageArea) { mButton = event->button(); mIsMouseMoved = false; if (mIsSelectionExists) { imageArea.setImage(mImageCopy); paint(imageArea); if (mButton == Qt::RightButton) { mIsSelectionAdjusting = true; startAdjusting(imageArea); } if (event->pos().x() > mTopLeftPoint.x() && event->pos().x() < mBottomRightPoint.x() && event->pos().y() > mTopLeftPoint.y() && event->pos().y() < mBottomRightPoint.y()) { if (!mIsSelectionAdjusting) { makeUndoCommand(imageArea); } if (!mIsImageSelected) { startMoving(imageArea); if (!mIsSelectionAdjusting) { mIsImageSelected = true; } } else { drawBorder(imageArea); } mIsSelectionMoving = true; mMoveDiffPoint = mBottomRightPoint - event->pos(); return; } else if (event->pos().x() >= mBottomRightPoint.x() && event->pos().x() <= mBottomRightPoint.x() + 6 && event->pos().y() >= mBottomRightPoint.y() && event->pos().y() <= mBottomRightPoint.y() + 6) { if (!mIsSelectionAdjusting) { makeUndoCommand(imageArea); } startResizing(imageArea); mIsSelectionResizing = true; return; } else { clearSelection(imageArea); } } if (event->button() == Qt::LeftButton) { mBottomRightPoint = mTopLeftPoint = event->pos(); mHeight = mWidth = 0; mImageCopy = *imageArea.getImage(); startSelection(imageArea); mIsPaint = true; } }