void QtnPropertyDelegateQStringInvalidBase::drawValueImpl(QStylePainter& painter, const QRect& rect, const QStyle::State& state, bool* needTooltip) const
{
    if ((m_invalidColor.alpha() != 0) && !isPropertyValid())
    {
        QPen oldPen = painter.pen();
        painter.setPen(m_invalidColor);
        QtnPropertyDelegateQString::drawValueImpl(painter, rect, state, needTooltip);
        painter.setPen(oldPen);
    }
    else
    {
        QtnPropertyDelegateQString::drawValueImpl(painter, rect, state, needTooltip);
    }
}
예제 #2
0
void CSGestureScroll::ProcessScroll(int x1, int y1, int x2, int y2) {
    if (isPropertyValid(x1) &&
        isPropertyValid(y1) &&
        isPropertyValid(x2) &&
        isPropertyValid(y2)){
        
        int delta_x1 = x1 - lastx1;
        int delta_y1 = y1 - lasty1;
        
        int delta_x2 = x2 - lastx2;
        int delta_y2 = y2 - lasty2;
        
        bool ignoreScroll = false;
        
        if (lastx1 == 0 || lasty1 == 0 || lastx2 == 0 || lasty2 == 0)
            ignoreScroll = true;
            
        lastx1 = x1;
        lasty1 = y1;
        lastx2 = x2;
        lasty2 = y2;
        
        if (ignoreScroll)
            return;
        
        int avgy = (delta_y1 + delta_y2) / 2;
        int avgx = (delta_x1 + delta_x2) / 2;
        
        if (abs(avgx) > 100)
            avgx = 0;
        if (abs(avgy) > 100)
            avgx = 0;
        
        if (avgx == 0 && avgy == 0) {
            noScrollCounter++;
            if (noScrollCounter < 3)
                return;
        }
        else {
            noScrollCounter = 0;
        }
        
        avgy = -avgy;
        avgx = -avgx;
        
        if (abs(avgy) > abs(avgx)) {
            _pointingWrapper->updateScroll(avgy, 0, 0);
            
            if (!isSameSign(momentumscrollcurrenty, avgy)) {
                momentumscrollcurrenty = 0;
                momentumscrollrest1y = 0;
                momentumscrollrest2y = 0;
                dy_history.reset();
            }
            
            dy_history.filter(avgy);
            dx_history.reset();
        } else {
            _pointingWrapper->updateScroll(0, avgx, 0);
            
            if (!isSameSign(momentumscrollcurrentx, avgx)) {
                momentumscrollcurrentx = 0;
                momentumscrollrest1x = 0;
                momentumscrollrest2x = 0;
                dx_history.reset();
            }
            
            dx_history.filter(avgx);
            dy_history.reset();
        }
        ;
        isTouchActive = true;
    } else {
        if (isTouchActive){
            if (dx_history.count() > momentumscrollsamplesmin) {
                int scrollx = dx_history.sum() * 10;
                if (isSameSign(momentumscrollcurrentx, scrollx))
                    momentumscrollcurrentx += scrollx;
                else
                    momentumscrollcurrentx = scrollx;
                momentumscrollrest1x = 0;
                momentumscrollrest2x = 0;
            }
            
            if (dy_history.count() > momentumscrollsamplesmin) {
                int scrolly = dy_history.sum() * 10;
                if (isSameSign(momentumscrollcurrenty, scrolly))
                    momentumscrollcurrenty += scrolly;
                else
                    momentumscrollcurrenty = scrolly;
                momentumscrollrest1y = 0;
                momentumscrollrest2y = 0;
            }
            
            dx_history.reset();
            dy_history.reset();
            isTouchActive = false;
        }
        
        lastx1 = 0;
        lasty1 = 0;
        lastx2 = 0;
        lasty2 = 0;
    }
}