コード例 #1
0
ファイル: StGLWidget.cpp プロジェクト: KindDragon/sview
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();
}
コード例 #2
0
ファイル: StGLScrollArea.cpp プロジェクト: angelstudio/sview
void StGLScrollArea::stglUpdate(const StPointD_t& theCursorZo) {
    if(!isVisible()) {
        StGLWidget::stglUpdate(theCursorZo);
        return;
    }

    if(myIsLeftClick
    && isScrollable()) {
        StPointD_t aDelta = myRoot->getCursorZo() - myClickPntZo;
        double aDeltaY = aDelta.y() * myRoot->getRectPx().height();
        myClickPntZo = myRoot->getCursorZo();

        double aTime = myDragTimer.getElapsedTime();
        if(myDragTimer.isOn()) {
            if(aTime > 0.1) {
                myFlingYSpeed = 0.0;
                myDragYDelta  = 0.0;
                myDragTimer.restart();
            }
            else if(aTime > 0.0000001
                 && std::abs(aDeltaY) >= double(myRoot->scale(2))) {
                if(std::abs(myDragYDelta) < 0.001
                || haveSameSign(myDragYDelta, aDeltaY)) {
                    myFlingYSpeed = (myDragYDelta + aDeltaY) / aTime;
                }
                myDragYDelta = 0.0;
                myDragTimer.restart();
            } else {
                myDragYDelta += aDeltaY;
            }
        } else {
            myFlingYSpeed = 0.0;
            myDragYDelta  = 0.0;
            myDragTimer.restart();
        }
        doScroll((int )aDeltaY);
    } else if(myFlingTimer.isOn()) {
        double aTime = myFlingTimer.getElapsedTime();
        double anA   = (myFlingYSpeed > 0.0 ? -1.0 : 1.0) * myFlingAccel;
        int aFullDeltaY = int(myFlingYSpeed * aTime + anA * aTime * aTime);
        int aDeltaY     = aFullDeltaY - myFlingYDone;
        if(aDeltaY == 0) {
            // ignore zero update
        } else if(!haveSameSign(myFlingYSpeed, aDeltaY)) {
            myFlingTimer.stop();
        } else  {
            myFlingYDone += aDeltaY;
            doScroll(aDeltaY, true);
        }
    }

    StGLWidget::stglUpdate(theCursorZo);
}
コード例 #3
0
ファイル: StWindowImplAnd.cpp プロジェクト: gkv311/sview
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();
}
コード例 #4
0
ファイル: StGLWidget.cpp プロジェクト: KindDragon/sview
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()));
}
コード例 #5
0
ファイル: StGLWidget.cpp プロジェクト: KindDragon/sview
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);
}