Пример #1
0
void wxhdDragTrackerTool::mouseDrag(wxhdMouseEvent& event)
{
	wxhdAbstractTool::mouseDrag(event);

	if(event.LeftIsDown())
	{
		int x=event.GetPosition().x, y=event.GetPosition().y;	

		//Hack to avoid a weird bug that ocurrs when use double click very fast over figure and drag a same time, lastX 
		//and lastY values becomes big negatives numbers, if this happens, then reset it to click point
		if(lastX<0)
			lastX=x;
		if(lastY<0) 
			lastY=y;

		hasMovedValue = (abs (x - anchorX) > 4 || abs (y - anchorX) > 4);

        if (hasMoved())
        {
            wxhdIFigure *tmp=NULL;
            wxhdIteratorBase *iterator=view->selectionFigures();
            while(iterator->HasNext())
            {
                tmp=(wxhdIFigure *)iterator->Next();
                tmp->moveBy(x - lastX, y - lastY);
            }
            delete iterator;
        }
        setLastCoords (x, y);
	}
}
Пример #2
0
/**jsdoc
 * @typedef {object} OverlayWindow.Properties
 * @property {string} title
 * @property {string} source
 * @property {number} width
 * @property {number} height
 * @property {boolean} visible
 */
void QmlWindowClass::initQml(QVariantMap properties) {
#ifndef DISABLE_QML
    auto offscreenUi = DependencyManager::get<OffscreenUi>();
    _source = properties[SOURCE_PROPERTY].toString();

    auto objectInitLambda = [&](QQmlContext* context, QObject* object) {
        _qmlWindow = object;
        context->setContextProperty(EVENT_BRIDGE_PROPERTY, this);
        context->engine()->setObjectOwnership(this, QQmlEngine::CppOwnership);
        context->engine()->setObjectOwnership(object, QQmlEngine::CppOwnership);
        if (properties.contains(TITLE_PROPERTY)) {
            object->setProperty(TITLE_PROPERTY, properties[TITLE_PROPERTY].toString());
        }
        if (properties.contains(HEIGHT_PROPERTY) && properties.contains(WIDTH_PROPERTY)) {
            uvec2 requestedSize { properties[WIDTH_PROPERTY].toUInt(), properties[HEIGHT_PROPERTY].toUInt() };
            requestedSize = glm::clamp(requestedSize, MIN_QML_WINDOW_SIZE, MAX_QML_WINDOW_SIZE);
            asQuickItem()->setSize(QSize(requestedSize.x, requestedSize.y));
        }

        bool visible = !properties.contains(VISIBILE_PROPERTY) || properties[VISIBILE_PROPERTY].toBool();
        object->setProperty(OFFSCREEN_VISIBILITY_PROPERTY, visible);
        object->setProperty(SOURCE_PROPERTY, _source);

        const QMetaObject *metaObject = _qmlWindow->metaObject();
        // Forward messages received from QML on to the script
        connect(_qmlWindow, SIGNAL(sendToScript(QVariant)), this, SLOT(qmlToScript(const QVariant&)), Qt::QueuedConnection);
        connect(_qmlWindow, SIGNAL(visibleChanged()), this, SIGNAL(visibleChanged()), Qt::QueuedConnection);

        if (metaObject->indexOfSignal("resized") >= 0)
            connect(_qmlWindow, SIGNAL(resized(QSizeF)), this, SIGNAL(resized(QSizeF)), Qt::QueuedConnection);
        if (metaObject->indexOfSignal("moved") >= 0)
            connect(_qmlWindow, SIGNAL(moved(QVector2D)), this, SLOT(hasMoved(QVector2D)), Qt::QueuedConnection);
        connect(_qmlWindow, SIGNAL(windowClosed()), this, SLOT(hasClosed()), Qt::QueuedConnection);
    };
void CCControlSwitch::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent)
{
    CCPoint location   = this->locationFromTouch(pTouch);

    m_pSwitchSprite->getThumbSprite()->setColor(ccWHITE);

    if (hasMoved())
    {
        setOn(!(location.x < m_pSwitchSprite->getContentSize().width / 2), true);
    } else
    {
        setOn(!m_bOn, true);
    }
}
Пример #4
0
void ControlSwitch::onTouchCancelled(Touch *pTouch, Event *pEvent)
{
    Point location   = this->locationFromTouch(pTouch);
    
    _switchSprite->getThumbSprite()->setColor(Color3B::WHITE);
    
    if (hasMoved())
    {
        setOn(!(location.x < _switchSprite->getContentSize().width / 2), true);
    } else
    {
        setOn(!_on, true);
    }
}
Пример #5
0
//------------------------------------------------------------------------------
//!
void
ValueEditor::onPointerRelease( const Event& ev )
{
   // Get into editing mode.
   Pointer& ptr = ev.pointer();
   if( !_inEdit && !hasMoved( ptr ) && pressed() )
   {
      Core::grabFocus( this );
      _inEdit = true;
      _editText.format( _format.cstr(), _value );
      _cursor = uint(_editText.size());
   }
   Widget::onPointerRelease( ev );
}
Пример #6
0
//------------------------------------------------------------------------------
//!
void
ValueEditor::onPointerMove( const Event& ev )
{
   // Update value?
   Pointer& ptr = ev.pointer();
   if( !_inEdit && pressed() && hasMoved( ptr ) )
   {
      float dx  = ptr.deltaPosition().x;
      float f   = CGM::round( CGM::sign(dx) * CGM::pow( CGM::abs(dx), 1.5f ) );
      float val = _value + _step * f;
      value( val );
   }

   Widget::onPointerMove( ev );
}
Пример #7
0
/**
  * Camera Listener - callback
  */
void CButCobDisplay::CNotifyCameraListener::cameraPreRenderScene(Ogre::Camera *cam)
{

    Ogre::Vector3 position( cam->getPosition() );
    Ogre::Quaternion orientation ( cam->getOrientation() );

    if( hasMoved( position, orientation ) )
    {
        //cam->getCullingFrustum();

        // callback
        changedCB( position, orientation );

        // Update stored position
        m_position = position;
        m_orientation = orientation;
    }
}
Пример #8
0
/* normal use funtions. These are the ones you should be using */
signed char getNextDirection()
{//returns relative Path

   signed char temp=0;
   signed char counter=0 ;
   if(pathStorage[0]!=0)
   {
        temp = pathStorage[1];
        pathStorage[0]--;

        /*
        if((temp==2)&&(directionOffset==1))
        {
        	temp=1;
        }else{
            temp = shiftBits(temp,directionOffset);
        }*/
        /*
        display_clear(1);
        display_goto_xy(0,0);
        display_int(directionOffset,1);
        display_goto_xy(3,0);
        display_int(pathStorage[1],1);
        display_goto_xy(1,6);
        display_int(temp,1);*/
        temp = shiftBitsForDriving(temp,directionOffset);
        /*
        display_goto_xy(3,7);
        display_int(temp,1);
        */
        switch(pathStorage[1])
        {
            case 1: hasMoved(top);directionOffset  = 0;break;
            case 2: hasMoved(right);directionOffset= 1;break;
            case 4: hasMoved(down);directionOffset = 2;break;
            case 8: hasMoved(left);directionOffset = 3;break;
            case 0: break;
            default: break;
        }
        /*
        display_goto_xy(1,1);
        display_int(directionOffset,1);
        display_update();*/
        //systick_wait_ms(1200);
        directionOffset = directionOffset % 4;
        //ecrobot_sound_tone(100,100, 100);
		//*/

        for(counter = 1; counter <=23;counter++){pathStorage[counter]=pathStorage[counter+1];}pathStorage[24]=0;
        return temp;
   }else{

        getNextUnvisited();
    	//ecrobot_sound_tone(900,80, 100);
        /*
        display_goto_xy(13,0);
        display_int(pathStorage[0],1);
        display_update();*/
        //systick_wait_ms(500);
        return getNextDirection();
   }
   return 0;
}
Пример #9
0
void
NwReqTracker::onReplyFinished()
{
    replyTimer.stop ();

    bool rv = false, done = false;
    QByteArray response;
    QNetworkReply *origReply = reply;

    do { // Begin cleanup block (not a loop)
        if (aborted) {
            Q_WARN("Reply was aborted");
            break;
        }

        if (QNetworkReply::NoError != origReply->error ()) {
            Q_WARN("Response error: ") << origReply->errorString ();
            break;
        }

        response = origReply->readAll ();
        rv = true;
    } while (0); // End cleanup block (not a loop)

    do { // Begin cleanup block (not a loop)
        done = true;

        if (!rv) {
            break;
        }

        if (!autoRedirect) {
            break;
        }

        QUrl urlMoved = hasMoved (origReply);
        if (urlMoved.isEmpty ()) {
            break;
        }

        QNetworkRequest req(urlMoved);
        req.setRawHeader("User-Agent", uaString);

        NwReqTracker::setCookies (jar, req);
        QNetworkReply *nextReply = nwMgr.get(req);
        if (!nextReply) {
            break;
        }

        disconnectReply ();
        init (nextReply, ctx, emitLog, autoDelete);
        autoRedirect = true;

        done = false;
    } while (0); // End cleanup block (not a loop)

    if (done) {
        if (!autoRedirect && response.contains ("Moved Temporarily")) {
            QString msg = "Auto-redirect not requested, but page content "
                          "probably indicates that this page has been "
                          "temporarily moved. Original request = %1";

            msg = msg.arg (origReply->request().url().toString ());

            QString strResp = response;
            int pos = strResp.indexOf ("a href=", 0, Qt::CaseInsensitive);
            if (-1 != pos) {
                int endpos = strResp.indexOf ("</a>", pos, Qt::CaseInsensitive);
                if (-1 != endpos) {
                    msg += "\nRedirect URL = " + strResp.mid(pos+8, endpos-pos);
                }
            }

            Q_WARN(msg);
        }

        emit sigDone (rv, response, origReply, ctx);
    }

    origReply->deleteLater ();
    if (done && autoDelete) {
        this->deleteLater ();
    }
}//NwReqTracker::onReplyFinished