Exemplo n.º 1
0
bool StGLWidget::isPointIn(const StPointD_t& thePointZo) const {
    const StRectD_t aRectGl = getRectGl();
    StPointD_t aPointGl = getPointGl(thePointZo);
    return aPointGl.x() > aRectGl.left()
        && aPointGl.x() < aRectGl.right()
        && aPointGl.y() > aRectGl.bottom()
        && aPointGl.y() < aRectGl.top();
}
Exemplo n.º 2
0
void StWindowImpl::processEvents() {
    if(myParentWin == NULL
    || myToResetDevice) {
        // window is closed!
        return;
    }

    // check if we are exiting
    if(myParentWin->ToDestroy()) {
        myStEvent.Type       = stEvent_Close;
        myStEvent.Close.Time = getEventTime();
        signals.onClose->emit(myStEvent.Close);
        return;
    }

    // check onNewIntent event
    StString aDndFile;
    myParentWin->setHardwareStereoOn(myToEnableStereoHW);
    myParentWin->setTrackOrientation(myToTrackOrient);
    myParentWin->setHideSystemBars(myToHideStatusBar, myToHideNavBar);
    myParentWin->fetchState(aDndFile, myQuaternion, myToSwapEyesHW, myKeysState);
    if(!aDndFile.isEmpty()) {
        std::vector<const char*> aDndList;
        aDndList.push_back(aDndFile.toCString());
        myStEvent.Type = stEvent_FileDrop;
        myStEvent.DNDrop.Time = getEventTime();
        myStEvent.DNDrop.NbFiles = aDndList.size();
        myStEvent.DNDrop.Files   = &aDndList[0];
        myEventsBuffer.append(myStEvent);
    }

    updateActiveState();

    StPointD_t anOldMousePt = myMousePt;
    int aPollRes  = 0;
    int aNbEvents = 0;
    StAndroidPollSource* aSource = NULL;
    bool toWaitEvents = false;
    while((aPollRes = ALooper_pollAll(toWaitEvents ? -1 : 0, NULL, &aNbEvents, (void** )&aSource)) >= 0) {
        if(aSource != NULL) {
            aSource->process(myParentWin, aSource);
        }
        if(myToResetDevice) {
            break;
        }

        // check if we are exiting
        if(myParentWin->ToDestroy()) {
            break;
        }
    }

    // check if we are exiting
    if(myParentWin->ToDestroy()) {
        myStEvent.Type       = stEvent_Close;
        myStEvent.Close.Time = getEventTime();
        signals.onClose->emit(myStEvent.Close);
        return;
    }

    myIsMouseMoved = false;
    if(myMousePt.x() >= 0.0 && myMousePt.x() <= 1.0 && myMousePt.y() >= 0.0 && myMousePt.y() <= 1.0) {
        StPointD_t aDspl = myMousePt - anOldMousePt;
        if(std::abs(aDspl.x()) >= 0.0008 || std::abs(aDspl.y()) >= 0.0008) {
            myIsMouseMoved = true;
        }
    }

    // update position only when all messages are parsed
    updateWindowPos();
    myIsUpdated = false;

    // StWindow XLib implementation process events in the same thread
    // thus this double buffer is not in use
    // however user events may be posted to it
    swapEventsBuffers();
}
Exemplo n.º 3
0
StPointD_t StGLWidget::getPointIn(const StPointD_t& thePointZo) const {
    const StRectD_t aRectGl = getRectGl();
    StPointD_t aPointGl = getPointGl(thePointZo);
    return StPointD_t((aPointGl.x() - aRectGl.left()) / (aRectGl.right() - aRectGl.left()),
                      (aRectGl.top() - aPointGl.y())  / (aRectGl.top() - aRectGl.bottom()));
}
Exemplo n.º 4
0
StPointD_t StGLWidget::getPointGl(const StPointD_t& thePointZo) const {
    double oglWidth  = myRoot->getRootRectGl().right() - myRoot->getRootRectGl().left();
    double oglHeight = myRoot->getRootRectGl().top() - myRoot->getRootRectGl().bottom();
    return StPointD_t((thePointZo.x() - 0.5) * oglWidth,
                      (0.5 - thePointZo.y()) * oglHeight);
}