MCPcopy Create free account
hub / github.com/TankOs/SFGUI / GetSliderRect

Method GetSliderRect

src/SFGUI/Scale.cpp:31–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31const 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
52std::unique_ptr<RenderQueue> Scale::InvalidateImpl() const {

Callers 2

CreateScaleDrawableMethod · 0.45

Calls 4

GetUpperMethod · 0.80
GetLowerMethod · 0.80
GetPageSizeMethod · 0.80
GetValueMethod · 0.45

Tested by

no test coverage detected