예제 #1
0
void KPrTimeLineView::paintLine(QPainter *painter, int row, const QRect &rect, bool selected)
{
    QColor m_color = m_mainView->barColor(row);
    const int lineHeight = qMin(LINE_HEIGHT , rect.height());
    const int vPadding = (rect.height() - lineHeight) / 2;
    qreal stepSize  = m_mainView->widthOfColumn(KPrShapeAnimations::StartTime) / m_mainView->numberOfSteps();
    qreal startOffSet = m_mainView->calculateStartOffset(row) / 1000.0;
    qreal duration = m_mainView->model()->data(m_mainView->model()->index(row, KPrShapeAnimations::Duration)).toInt() / 1000.0;
    qreal start = m_mainView->model()->data(m_mainView->model()->index(row, KPrShapeAnimations::StartTime)).toInt() / 1000.0
            + startOffSet;
    QRectF lineRect(rect.x() + stepSize * start, rect.y() + vPadding, stepSize * duration, lineHeight);

    QRectF fillRect (lineRect.x(),lineRect.y() + BAR_MARGIN, lineRect.width(), lineRect.height() - BAR_MARGIN * 2);
    QLinearGradient s_grad(lineRect.center().x(), lineRect.top(),
                           lineRect.center().x(), lineRect.bottom());
    if (selected) {
        s_grad.setColorAt(0, m_color.darker(150));
        s_grad.setColorAt(0.5, m_color.lighter(150));
        s_grad.setColorAt(1, m_color.darker(150));
        s_grad.setSpread(QGradient::ReflectSpread);
        painter->fillRect(fillRect, s_grad);
    }
    else {
        s_grad.setColorAt(0, m_color.darker(200));
        s_grad.setColorAt(0.5, m_color.lighter(125));
        s_grad.setColorAt(1, m_color.darker(200));
        s_grad.setSpread(QGradient::ReflectSpread);
        painter->fillRect(fillRect, s_grad);
    }
    QRect startRect(lineRect.x(), lineRect.y(), 3, lineRect.height());
    painter->fillRect(startRect, Qt::black);
    QRect endRect(lineRect.x() + lineRect.width(), lineRect.y(), 3, lineRect.height());
    painter->fillRect(endRect, Qt::black);
}
예제 #2
0
void CCPageScaleAnimation::zoomTo(const IntSize& finalScroll, float finalPageScale, double duration)
{
    if (m_pageScaleStart != finalPageScale) {
        // For uniform-looking zooming, infer the anchor (point that remains in
        // place throughout the zoom) from the start and end rects.
        FloatRect startRect(IntPoint(m_scrollStart), m_windowSize);
        FloatRect endRect(IntPoint(finalScroll), m_windowSize);
        endRect.scale(m_pageScaleStart / finalPageScale);

        // The anchor is the point which is at the same ratio of the sides of
        // both startRect and endRect. For example, a zoom-in double-tap to a
        // perfectly centered rect will have anchor ratios (0.5, 0.5), while one
        // to a rect touching the bottom-right of the screen will have anchor
        // ratios (1.0, 1.0). In other words, it obeys the equations:
        // anchorX = start_width * ratioX + start_x
        // anchorX = end_width * ratioX + end_x
        // anchorY = start_height * ratioY + start_y
        // anchorY = end_height * ratioY + end_y
        // where both anchor{x,y} and ratio{x,y} begin as unknowns. Solving
        // for the ratios, we get the following formulas:
        float ratioX = (startRect.x() - endRect.x()) / (endRect.width() - startRect.width());
        float ratioY = (startRect.y() - endRect.y()) / (endRect.height() - startRect.height());

        IntSize anchor(m_windowSize.width() * ratioX, m_windowSize.height() * ratioY);
        zoomWithAnchor(anchor, finalPageScale, duration);
    } else {
        // If this is a pure translation, then there exists no anchor. Linearly
        // interpolate the scroll offset instead.
        m_scrollEnd = finalScroll;
        m_pageScaleEnd = finalPageScale;
        m_duration = duration;
        m_anchorMode = false;
    }
}
void ossimQtVceCanvasWidget::contentsMouseReleaseEvent(QMouseEvent * e )
{
   theMouseButtonState = e->button();
   
   switch(e->button())
   {
   case Qt::LeftButton:
   {
      if(theSelectionRect)
      {
         QCanvasItemList collisionList = theSelectionRect->collisions(true);
         selectItems(collisionList);
         deleteSelectionRect();
      }
      else if(theLineObject)
      {
        ossimQtVceShapeRect  startRect(QRect(theLineObject->startPoint().x(),
                                             theLineObject->startPoint().y(),
                                             1,
                                             1),
                                       canvas());
        ossimQtVceShapeRect  endRect(QRect(theLineObject->endPoint().x(),
                                           theLineObject->endPoint().y(),
                                           1,
                                           1),
                                     canvas());
        
         // make sure that the selection rect is in front of everything
         //
         startRect.setZ(1);
         endRect.setZ(1);
         
         QCanvasItemList startList = startRect.collisions(true);
         QCanvasItemList endList   = endRect.collisions(true);
         QPoint startPt            = theLineObject->startPoint();
         QPoint endPt              = theLineObject->endPoint();
         
         ossimQtVceConnectableObject* startObj = getObjectWhereConnectableSlotIntersectsPoint(startList,
                                                                                              startPt);
         ossimQtVceConnectableObject* endObj   = getObjectWhereConnectableSlotIntersectsPoint(endList,
                                                                                              endPt);
         if(startObj&&endObj)
         {
            makeConnection(startObj, startPt, endObj, endPt);
         }
         delete theLineObject;
         theLineObject = NULL;
      }
      break;
   }
   default:
     {
       break;
     }
   }
   theMouseButtonState = Qt::NoButton;      
   emit canvasWidgetMouseReleaseEvent(e);
}
void workSpace::on_chattbox_clicked()
{
  w=new MainWindow(this,nameofLoggedUser);
    w->show();

    QPropertyAnimation *animation = new QPropertyAnimation(w, "geometry");
    animation->setDuration(1);
    QRect startRect(this->pos().x()+1034,this->pos().y()+50,w->width(),w->height());
    QRect endRect(this->pos().x()+1034,this->pos().y()+50,w->width(),w->height());
    animation->setStartValue(startRect);//QPoint(btnRight,btnBottom));//QPoint(0,0));
    animation->setEndValue(endRect);//QPoint(100,100));
    animation->start();

}