| 34 | } |
| 35 | |
| 36 | const sf::FloatRect Scrollbar::GetSliderRect() const { |
| 37 | float mimimum_slider_length( Context::Get().GetEngine().GetProperty<float>( "SliderMinimumLength", shared_from_this() ) ); |
| 38 | |
| 39 | Adjustment::Ptr adjustment( GetAdjustment() ); |
| 40 | |
| 41 | auto value_range = std::max( adjustment->GetUpper() - adjustment->GetLower() - adjustment->GetPageSize(), .0f ); |
| 42 | auto pages = std::max( ( adjustment->GetPageSize() > .0f ) ? ( ( adjustment->GetUpper() - adjustment->GetLower() ) / adjustment->GetPageSize() ) : 1.f, 1.f ); |
| 43 | |
| 44 | if( GetOrientation() == Orientation::HORIZONTAL ) { |
| 45 | auto stepper_length = GetAllocation().size.y; |
| 46 | auto trough_length = GetAllocation().size.x - 2.f * stepper_length; |
| 47 | auto slider_length = std::max( mimimum_slider_length, trough_length / pages ); |
| 48 | |
| 49 | auto slider_x = stepper_length; |
| 50 | auto slider_y = 0.f; |
| 51 | |
| 52 | if( value_range > .0f ) { |
| 53 | slider_x = stepper_length + ( trough_length - slider_length ) * ( adjustment->GetValue() - adjustment->GetLower() ) / value_range; |
| 54 | } |
| 55 | |
| 56 | return sf::FloatRect( { slider_x, slider_y }, { slider_length, GetAllocation().size.y } ); |
| 57 | } |
| 58 | |
| 59 | auto stepper_length = GetAllocation().size.x; |
| 60 | auto trough_length = GetAllocation().size.y - 2.f * stepper_length; |
| 61 | auto slider_length = std::max( mimimum_slider_length, trough_length / pages ); |
| 62 | |
| 63 | auto slider_x = 0.f; |
| 64 | auto slider_y = stepper_length; |
| 65 | |
| 66 | if( value_range > .0f ) { |
| 67 | slider_y = stepper_length + ( trough_length - slider_length ) * ( adjustment->GetValue() - adjustment->GetLower() ) / value_range; |
| 68 | } |
| 69 | |
| 70 | return sf::FloatRect( { slider_x, slider_y }, { GetAllocation().size.x, slider_length } ); |
| 71 | } |
| 72 | |
| 73 | bool Scrollbar::IsDecreaseStepperPressed() const { |
| 74 | return m_decrease_pressed; |
nothing calls this directly
no test coverage detected