예제 #1
0
    float FalagardScrollbar::getValueFromThumb(void) const
    {
        Scrollbar* w = (Scrollbar*)d_window;
        const WidgetLookFeel& wlf = getLookNFeel();
        const Rectf area(wlf.getNamedArea("ThumbTrackArea").getArea().getPixelRect(*w));

        Thumb* theThumb = w->getThumb();
        float posExtent = w->getDocumentSize() - w->getPageSize();

        if (d_vertical)
        {
            float slideExtent = area.getHeight() - theThumb->getPixelSize().d_height;
            return (CoordConverter::asAbsolute(theThumb->getYPosition(), w->getPixelSize().d_height) - area.top()) / (slideExtent / posExtent);
        }
        else
        {
            float slideExtent = area.getWidth() - theThumb->getPixelSize().d_width;
            return (CoordConverter::asAbsolute(theThumb->getXPosition(), w->getPixelSize().d_width) - area.left()) / (slideExtent / posExtent);
        }
    }
예제 #2
0
    float FalagardScrollbar::getAdjustDirectionFromPoint(const Vector2f& pt) const
    {
        Scrollbar* w = (Scrollbar*)d_window;
        const Rectf& absrect(w->getThumb()->getUnclippedOuterRect().get());

        if ((d_vertical && (pt.d_y > absrect.bottom())) ||
            (!d_vertical && (pt.d_x > absrect.right())))
        {
            return 1;
        }
        else if ((d_vertical && (pt.d_y < absrect.top())) ||
            (!d_vertical && (pt.d_x < absrect.left())))
        {
            return -1;
        }
        else
        {
            return 0;
        }
    }