| 56 | } |
| 57 | |
| 58 | void ScrollAreaCustom::mouseMoveEvent(QMouseEvent *event){ |
| 59 | setCursor(Qt::ArrowCursor); |
| 60 | if(pressed){ |
| 61 | //start scroll |
| 62 | if(!getCord->isActive() && event->pos().y() - lastY != 0){ |
| 63 | //start 30ms timer |
| 64 | getCord->start(30); |
| 65 | strtY = event->pos().y(); |
| 66 | } |
| 67 | if(container->y() <= 0 && container->y() + container->height() >= this->height()) |
| 68 | container->move(container->x(), container->y() + event->pos().y() - lastY); |
| 69 | else{ |
| 70 | if(!outOfEdge){ |
| 71 | bfEdgeY = event->pos().y(); |
| 72 | container->move(container->x(), container->y() + event->pos().y() - lastY); |
| 73 | outOfEdge = true; |
| 74 | } |
| 75 | else{ |
| 76 | int pos = container->y() >= 0 ? 1 : -1; |
| 77 | int dp = event->pos().y() - bfEdgeY; |
| 78 | if(dp == 0){ |
| 79 | outOfEdge = false; |
| 80 | nextMove = 1; |
| 81 | moveStored = 0; |
| 82 | if(container->y() >= 0) |
| 83 | container->move(container->x(), 0); |
| 84 | else |
| 85 | container->move(container->x(), this->height() - container->height()); |
| 86 | } |
| 87 | else if(dp / abs(dp) != pos){ |
| 88 | outOfEdge = false; |
| 89 | container->move(container->x(), this->y() + event->pos().y() - bfEdgeY); |
| 90 | nextMove = 1; |
| 91 | moveStored = 0; |
| 92 | } |
| 93 | else{ |
| 94 | while(abs(moveStored) + nextMove <= abs(event->pos().y() - bfEdgeY)){ |
| 95 | moveStored += nextMove * pos; |
| 96 | container->move(container->x(), container->y() + pos); |
| 97 | nextMove++; |
| 98 | } |
| 99 | while(nextMove > 1 && abs(moveStored) > abs(event->pos().y() - bfEdgeY)){ |
| 100 | nextMove--; |
| 101 | moveStored -= nextMove * pos; |
| 102 | container->move(container->x(), container->y() - pos); |
| 103 | } |
| 104 | if(moveStored == 0){ |
| 105 | outOfEdge = false; |
| 106 | if(container->y() >= 0) |
| 107 | container->move(container->x(), 0); |
| 108 | else |
| 109 | container->move(container->x(), this->height() - container->height()); |
| 110 | nextMove = 1; |
| 111 | moveStored = 0; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | } |