float FalagardSlider::getValueFromThumb(void) const { Slider* w = (Slider*)d_window; // get area the thumb is supposed to use as it's area. const WidgetLookFeel& wlf = getLookNFeel(); const Rectf area(wlf.getNamedArea("ThumbTrackArea").getArea().getPixelRect(*w)); // get accesss to the thumb Thumb* theThumb = w->getThumb(); // slider is vertical if (d_vertical) { // pixel extent of total available area the thumb moves in float slideExtent = area.getHeight() - theThumb->getPixelSize().d_height; // calculate value represented by current thumb position float thumbValue = (CoordConverter::asAbsolute( theThumb->getYPosition(), w->getPixelSize().d_height) - area.top()) / (slideExtent / w->getMaxValue()); // return final thumb value according to slider settings return d_reversed ? thumbValue : w->getMaxValue() - thumbValue; } // slider is horizontal else { // pixel extent of total available area the thumb moves in float slideExtent = area.getWidth() - theThumb->getPixelSize().d_width; // calculate value represented by current thumb position float thumbValue = (CoordConverter::asAbsolute( theThumb->getXPosition(), w->getPixelSize().d_width) - area.left()) / (slideExtent / w->getMaxValue()); // return final thumb value according to slider settings return d_reversed ? w->getMaxValue() - thumbValue : thumbValue; } }
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); } }