diff options
author | Ken Moore <ken@ixsystems.com> | 2017-08-31 11:42:33 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-08-31 11:42:33 -0400 |
commit | 2ed1ee7459868dca7228d61202a38c7c9c3e23f8 (patch) | |
tree | 60d44c92e91f63662ceef064b9f9736f0ffca6ce /src-qt5/core/libLumina/RootSubWindow.cpp | |
parent | A but more work on Lumina2: (diff) | |
download | lumina-2ed1ee7459868dca7228d61202a38c7c9c3e23f8.tar.gz lumina-2ed1ee7459868dca7228d61202a38c7c9c3e23f8.tar.bz2 lumina-2ed1ee7459868dca7228d61202a38c7c9c3e23f8.zip |
Get all the single-window interactions finished up.
Now the multiple types of animations will not conflict/overwrite each other, and the window itself will be properly "paused" for animations.
Also fix up some window resize calculation errors, so the offset to the mouse position is properly handled now
Diffstat (limited to 'src-qt5/core/libLumina/RootSubWindow.cpp')
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow.cpp | 93 |
1 files changed, 50 insertions, 43 deletions
diff --git a/src-qt5/core/libLumina/RootSubWindow.cpp b/src-qt5/core/libLumina/RootSubWindow.cpp index 36da43c2..9eb62ff5 100644 --- a/src-qt5/core/libLumina/RootSubWindow.cpp +++ b/src-qt5/core/libLumina/RootSubWindow.cpp @@ -57,7 +57,7 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()); } //difference from top-left corner return ResizeTopLeft; }else if(pt.x() > (this->width()*4.0/5.0)){ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(pt.y()); } //difference from top-right corner + if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()); } //difference from top-right corner return ResizeTopRight; }else{ if(setoffset){ offset.setX(0); offset.setY(pt.y()); } //difference from top edge (X does not matter) @@ -66,13 +66,13 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset }else if(pt.y() > (this->height()-WIN_BORDER) ){ //One of the bottom options if(pt.x() < this->width()/5){ - if(setoffset){ offset.setX(pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-left corner + if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()-this->height()); } //difference from bottom-left corner return ResizeBottomLeft; }else if(pt.x() > (this->width()*4.0/5.0)){ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-right corner + if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()-this->height()); } //difference from bottom-right corner return ResizeBottomRight; }else{ - if(setoffset){ offset.setX(0); offset.setY(this->height() - pt.y()); } //difference from bottom edge (X does not matter) + if(setoffset){ offset.setX(0); offset.setY(pt.y()-this->height()); } //difference from bottom edge (X does not matter) return ResizeBottom; } }else if(pt.x() < WIN_BORDER){ @@ -81,7 +81,7 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()); } //difference from top-left corner return ResizeTopLeft; }else if(pt.y() > (this->height()*4.0/5.0)){ - if(setoffset){ offset.setX(pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-left corner + if(setoffset){ offset.setX(pt.x()); offset.setY(pt.y()-this->height()); } //difference from bottom-left corner return ResizeBottomLeft; }else{ if(setoffset){ offset.setX(pt.x()); offset.setY(0); } //difference from left edge (Y does not matter) @@ -90,13 +90,13 @@ RootSubWindow::ModState RootSubWindow::getStateAtPoint(QPoint pt, bool setoffset }else if(pt.x() > (this->width()-WIN_BORDER) ){ //Right side options if(pt.y() < this->height()/5){ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(pt.y()); } //difference from top-right corner + if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()); } //difference from top-right corner return ResizeTopRight; }else if(pt.y() > (this->height()*4.0/5.0)){ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(this->height()-pt.y()); } //difference from bottom-right corner + if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(pt.y()-this->height()); } //difference from bottom-right corner return ResizeBottomRight; }else{ - if(setoffset){ offset.setX(this->width()-pt.x()); offset.setY(0); } //difference from right edge (Y does not matter) + if(setoffset){ offset.setX(pt.x()-this->width()); offset.setY(0); } //difference from right edge (Y does not matter) return ResizeRight; } }else{ @@ -187,11 +187,12 @@ void RootSubWindow::initWindowFrame(){ titleBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); mainLayout->addWidget(titleBar); mainLayout->addWidget(WinWidget); + mainLayout->setAlignment(titleBar, Qt::AlignTop); //Setup the cursors for the buttons closeB->setCursor(Qt::ArrowCursor); minB->setCursor(Qt::ArrowCursor); maxB->setCursor(Qt::ArrowCursor); - otherM->setCursor(Qt::ArrowCursor); + otherB->setCursor(Qt::ArrowCursor); titleLabel->setCursor(Qt::ArrowCursor); WinWidget->setCursor(Qt::ArrowCursor); //Now all the stylesheet options @@ -351,12 +352,14 @@ void RootSubWindow::startMoving(){ offset = this->mapFromGlobal(curpt); setMouseCursor(activeState, true); //this one is an override cursor //WinWidget->pause(); - //Also need to capture the mouse this->grabMouse(); } void RootSubWindow::startResizing(){ - + activeState = getStateAtPoint( this->mapFromGlobal(QCursor::pos()), true); //also have it set the offset variable + setMouseCursor(activeState, true); //this one is an override cursor + //WinWidget->pause(); + this->grabMouse(); } // === PRIVATE SLOTS === @@ -366,9 +369,11 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList //qDebug() << "RootSubWindow: Property Changed:" << props[i] << vals[i]; switch(props[i]){ case NativeWindow::Visible: - //qDebug() << "Got Visibility Change:" << vals[i] << this->geometry() << WIN->geometry(); - if(vals[i].toBool()){ loadAnimation( DesktopSettings::instance()->value(DesktopSettings::Animation, "window/appear", "random").toString(), NativeWindow::Visible, vals[i]); } - else{ loadAnimation( DesktopSettings::instance()->value(DesktopSettings::Animation, "window/disappear", "random").toString(), NativeWindow::Visible, vals[i]); } + if(!WinWidget->isPaused() && (this->isVisible()!=vals[i].toBool()) && activeState==Normal ){ + qDebug() << "Got Visibility Change:" << vals[i] << this->geometry() << WIN->geometry(); + if(vals[i].toBool()){ loadAnimation( DesktopSettings::instance()->value(DesktopSettings::Animation, "window/appear", "random").toString(), NativeWindow::Visible, vals[i]); } + else{ loadAnimation( DesktopSettings::instance()->value(DesktopSettings::Animation, "window/disappear", "random").toString(), NativeWindow::Visible, vals[i]); } + } break; case NativeWindow::Title: titleLabel->setText(vals[i].toString()); @@ -386,9 +391,9 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList props << props.takeAt(i); vals << vals.takeAt(i); i--; - }else if(anim->state() != QPropertyAnimation::Running && !WinWidget->isPaused()){ - if(WIN->property(NativeWindow::Size).toSize() != WinWidget->size() && activeState==Normal ){ - //qDebug() << "Got Direct Geometry Change:" << WIN->geometry(); + }else if(!WinWidget->isPaused() && !this->isVisible() && activeState==Normal){ + if(WIN->property(NativeWindow::Size).toSize() != WinWidget->size()){ + qDebug() << "Got Direct Geometry Change:" << WIN->geometry(); this->setGeometry(WIN->geometry()); } } @@ -437,28 +442,24 @@ void RootSubWindow::propertiesChanged(QList<NativeWindow::Property> props, QList void RootSubWindow::mousePressEvent(QMouseEvent *ev){ activate(); this->raise(); - //WinWidget->raiseWindow(); + QFrame::mousePressEvent(ev); //qDebug() << "Frame Mouse Press Event"; - offset.setX(0); offset.setY(0); if(activeState != Normal){ return; } // do nothing - already in a state of grabbed mouse - //this->activate(); - if(this->childAt(ev->pos())!=0){ - //Check for any non-left-click event and skip it - if(ev->button()!=Qt::LeftButton){ return; } - activeState = Move; - offset.setX(ev->pos().x()); offset.setY(ev->pos().y()); - }else{ - //Clicked on the frame somewhere - activeState = getStateAtPoint(ev->pos(), true); //also have it set the offset variable + offset.setX(0); offset.setY(0); + if(ev->button()==Qt::LeftButton){ + if(this->childAt(ev->pos())!=0){ + //Clicked on the titlebar + startMoving(); + }else{ + //Clicked on the frame somewhere + startResizing(); + } } - setMouseCursor(activeState, true); //this one is an override cursor - //if(activeState!=Normal){WinWidget->pause(); } - if(activeState!=Normal && activeState!=Move){WinWidget->pause(); } - QFrame::mousePressEvent(ev); + } void RootSubWindow::mouseMoveEvent(QMouseEvent *ev){ - //activate(); //make sure this window is "Active" on mouse over + QFrame::mouseMoveEvent(ev); if(activeState == Normal){ setMouseCursor( getStateAtPoint(ev->pos()) ); //just update the mouse cursor }else{ @@ -533,10 +534,15 @@ void RootSubWindow::mouseMoveEvent(QMouseEvent *ev){ break; } //if( (geom.width()%2==0 && geom.height()%2==0) || activeState==Move){ - this->setGeometry(geom); + //qDebug() << " Change Window:" << this->geometry() << geom; + if(activeState==Move){ this->setGeometry(geom); } + else{ + //qDebug() << " Change Window Dimensions:" << this->geometry() << geom; + //qDebug() << " - Mouse Pos:" << ev->globalPos() << ev->pos() << "Offset" << offset; + this->setGeometry(geom); + } //} } - QFrame::mouseMoveEvent(ev); } void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){ @@ -544,18 +550,19 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){ //qDebug() << "Frame Mouse Release Event"; QFrame::mouseReleaseEvent(ev); if( (activeState==Normal) && (titleBar->geometry().contains(ev->pos())) && (ev->button()==Qt::RightButton) ){ - WinWidget->raiseWindow();//need to ensure the native window is always on top of this frame but under the menu + //WinWidget->raiseWindow();//need to ensure the native window is always on top of this frame but under the menu otherM->popup(ev->globalPos()); return; } - if(activeState!=Normal){ WinWidget->resume(); } - if(activeState!=Normal && activeState!=Move){WinWidget->resume(); } - activeState = Normal; - QApplication::restoreOverrideCursor(); - setMouseCursor( getStateAtPoint(ev->pos()) ); + if(activeState!=Normal){ + if(WinWidget->isPaused()){ WinWidget->resume(); } + activeState = Normal; + QApplication::restoreOverrideCursor(); + setMouseCursor( getStateAtPoint(ev->pos()) ); + } if(QFrame::mouseGrabber() == this){ this->releaseMouse(); } activate(); - QTimer::singleShot(0, WinWidget, SLOT(raiseWindow()) ); + //QTimer::singleShot(0, WinWidget, SLOT(raiseWindow()) ); } /*void RootSubWindow::enterEvent(QEvent *ev){ @@ -573,7 +580,7 @@ void RootSubWindow::mouseReleaseEvent(QMouseEvent *ev){ void RootSubWindow::moveEvent(QMoveEvent *ev){ //qDebug() << "Got Move Event:" << ev->pos() << WinWidget->geometry(); QFrame::moveEvent(ev); - if(!closing && anim->state()!=QAbstractAnimation::Running){ + if(!closing && !WinWidget->isPaused()){ moveTimer->start(); } } |