Exemplo n.º 1
0
void CWindowMover::toZero()
{
    CCoeControl* control =(viewer->winId());
    RDrawableWindow* rWindow=(control->DrawableWindow());
    control->SetPosition(TPoint(0,0));
    prevY=0;
}
Exemplo n.º 2
0
void CWindowMover::yAnimChanged(const QVariant &value)
{
    bool ok;
    int val=value.toInt(&ok);
     CCoeControl* control =(viewer->winId());
     control->SetPosition(TPoint(0,val));
     int loop=yAnim->currentLoop();
     TSize s=TSize(control->Size().iWidth,abs(yAnim->keyValueAt(loop).toInt()-val));
     control->DrawBackground(TRect(TPoint(0,val),s));
     //if ((abs(val)==control->Size().iHeight)&&iCallBack) iCallBack->Hide();
     //qDebug()<<"y anim"<<val;
}
Exemplo n.º 3
0
void CWindowMover::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    {
    CCoeControl* control =(viewer->winId());
    if (aPointerEvent.iType == TPointerEvent::EButton1Down)
        {
        iPointerPoint1=aPointerEvent.iPosition;
        iPointerPoint2=aPointerEvent.iPosition;
        MovingChanged(true);

        QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
        pressEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX, iPointerPoint1.iY-control->Position().iY));
        qDebug()<<pressEvent.scenePos().x()<<pressEvent.scenePos().y();
        pressEvent.setButton(Qt::LeftButton);
        pressEvent.setButtons(Qt::LeftButton);
        QApplication::sendEvent(viewer->scene(), &pressEvent);
        }
    else if (aPointerEvent.iType == TPointerEvent::EDrag)
        {
        iDragged=ETrue;
        TInt dx=aPointerEvent.iPosition.iX-iPointerPoint1.iX;
        TInt dy=aPointerEvent.iPosition.iY-iPointerPoint1.iY;
        if (!axisSet)
        {
            if (abs(dy)>abs(dx)) {axisX=0; axisY=1;}
            else {axisX=1;axisY=0;}
            axisSet=true;
        }
        RWindow rWindow=(control->Window());
        control->SetPosition(TPoint(dx*axisX,dy*axisY));
        control->DrawBackground(TRect(control->Position(),control->Size()));
        }
    else if (aPointerEvent.iType==TPointerEvent::EButton1Up)
        {
        iPointerPoint2=aPointerEvent.iPosition;
        //MakeVisible(EFalse);
        int gest=settings->value("settings/gesture").toInt();
        if (gest==0) axisSet=false;

        float horSense=settings->value("settings/horsense",0.5).toFloat();
        float verSense=settings->value("settings/versense",0.5).toFloat();
        int width=control->Size().iWidth;
        int height=control->Size().iHeight;
        int x=control->Position().iX;
        int y=control->Position().iY;
        qDebug()<<"("<<x<<","<<y<<")"<<horSense<<verSense;
        if (x>(horSense)*width)
           {startAnim(EXAxis,width);}
        else if (x<(-horSense)*width)
           {startAnim(EXAxis,-width);}
        else if (x!=0)
           {startAnim(EXAxis,0);}
        if (y>(verSense)*height)
           {startAnim(EYAxis,height);}
        else if (y<(-verSense)*height)
           {startAnim(EYAxis,-height);}
        else if (y!=0)
           {startAnim(EYAxis,0);}
        if (abs(iPointerPoint1.iX-iPointerPoint2.iX)<20&&abs(iPointerPoint1.iY-iPointerPoint2.iY)<20)
        {
            QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
            releaseEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX, iPointerPoint1.iY-control->Position().iY));
            releaseEvent.setButton(Qt::LeftButton);
            releaseEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &releaseEvent);
        }
        else
        {
            QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove);
            moveEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX-10,iPointerPoint1.iY-control->Position().iY-10));
            moveEvent.setButton(Qt::LeftButton);
            moveEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &moveEvent);
            QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
            releaseEvent.setScenePos(QPointF(0,0));
            releaseEvent.setButton(Qt::LeftButton);
            releaseEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &releaseEvent);

        }
        MovingChanged(false);
        }
    CCoeControl::HandlePointerEventL(aPointerEvent);
    }