| 29 | } |
| 30 | |
| 31 | const sf::FloatRect Scale::GetSliderRect() const { |
| 32 | auto slider_length = Context::Get().GetEngine().GetProperty<float>( "SliderLength", shared_from_this() ); |
| 33 | auto slider_width = (GetOrientation() == Orientation::HORIZONTAL) ? GetAllocation().size.y : GetAllocation().size.x; |
| 34 | auto adjustment = GetAdjustment(); |
| 35 | auto current_value = adjustment->GetValue(); |
| 36 | auto value_range = adjustment->GetUpper() - adjustment->GetLower() - adjustment->GetPageSize(); |
| 37 | |
| 38 | if( GetOrientation() == Orientation::HORIZONTAL ) { |
| 39 | auto slider_x = (GetAllocation().size.x - slider_length) * (current_value - adjustment->GetLower()) / value_range; |
| 40 | auto slider_y = (GetAllocation().size.y - slider_width) / 2.f; |
| 41 | |
| 42 | return sf::FloatRect( { slider_x, slider_y }, { slider_length, slider_width } ); |
| 43 | } |
| 44 | |
| 45 | auto slider_x = (GetAllocation().size.x - slider_width) / 2.f; |
| 46 | auto slider_y = (GetAllocation().size.y - slider_length) * (1 - ((current_value - adjustment->GetLower()) / value_range)); |
| 47 | |
| 48 | return sf::FloatRect( { slider_x, slider_y }, { slider_width, slider_length } ); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | std::unique_ptr<RenderQueue> Scale::InvalidateImpl() const { |
no test coverage detected