Beispiel #1
0
    float FalagardSlider::getValueFromThumb(void) const
    {
        // get area the thumb is supposed to use as it's area.
        const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName);
        Rect area(wlf.getNamedArea("ThumbTrackArea").getArea().getPixelRect(*this));
        // get accesss to the thumb
        Thumb* theThumb = static_cast<Thumb*>(WindowManager::getSingleton().getWindow(getName() + "__auto_thumb__"));

        // slider is vertical
        if (d_vertical)
        {
            // pixel extent of total available area the thumb moves in
            float slideExtent = area.getHeight() - theThumb->getAbsoluteHeight();
            // calculate value represented by current thumb position
            float thumbValue = (theThumb->getAbsoluteYPosition() - area.d_top) / (slideExtent / d_maxValue);
            // return final thumb value according to slider settings
            return d_reversed ? thumbValue : d_maxValue - thumbValue;
        }
        // slider is horizontal
        else
        {
            // pixel extent of total available area the thumb moves in
            float slideExtent = area.getWidth() - theThumb->getAbsoluteWidth();
            // calculate value represented by current thumb position
            float thumbValue = (theThumb->getAbsoluteXPosition() - area.d_left) / (slideExtent / d_maxValue);
            // return final thumb value according to slider settings
            return d_reversed ? d_maxValue - thumbValue : thumbValue;
        }
    }
Beispiel #2
0
	float FalagardScrollbar::getValueFromThumb(void) const
	{
		const WidgetLookFeel& wlf = WidgetLookManager::getSingleton().getWidgetLook(d_lookName);
		Rect area(wlf.getNamedArea("ThumbTrackArea").getArea().getPixelRect(*this));

		Thumb* theThumb = static_cast<Thumb*>(WindowManager::getSingleton().getWindow(getName() + "__auto_thumb__"));
		float posExtent = d_documentSize - d_pageSize;

		if (d_vertical)
		{
			float slideExtent = area.getHeight() - theThumb->getAbsoluteHeight();
			return (theThumb->getAbsoluteYPosition() - area.d_top) / (slideExtent / posExtent);
		}
		else
		{
			float slideExtent = area.getWidth() - theThumb->getAbsoluteWidth();
			return (theThumb->getAbsoluteXPosition() - area.d_left) / (slideExtent / posExtent);
		}
	}