| 8 | #include <sstream> |
| 9 | |
| 10 | int main() { |
| 11 | // Create the main SFML window |
| 12 | sf::RenderWindow app_window( sf::VideoMode( { 800, 600 } ), "SFGUI Range Example", sf::Style::Titlebar | sf::Style::Close ); |
| 13 | |
| 14 | // Create an SFGUI. This is required before doing anything with SFGUI. |
| 15 | sfg::SFGUI sfgui; |
| 16 | |
| 17 | // We have to do this because we don't use SFML to draw. |
| 18 | app_window.resetGLStates(); |
| 19 | |
| 20 | // Create our main SFGUI window |
| 21 | auto window = sfg::Window::Create(); |
| 22 | window->SetTitle( "Title" ); |
| 23 | |
| 24 | // Create our box. |
| 25 | auto box = sfg::Box::Create( sfg::Box::Orientation::HORIZONTAL ); |
| 26 | |
| 27 | // Create a label. |
| 28 | auto label = sfg::Label::Create(); |
| 29 | label->SetText( "20" ); |
| 30 | |
| 31 | // Scale and Scrollbar widgets are subclasses of the Range class. |
| 32 | // They have a common data representation object known as an |
| 33 | // Adjustment. The Adjustment that each range widget is bound to |
| 34 | // determines it's current state (where the slider is, what max |
| 35 | // and min values are, how much to scroll per step etc.). Because |
| 36 | // range widgets share this common data object they can also be |
| 37 | // linked together by a common Adjustment instance. An Adjustment |
| 38 | // is created automatically for you when you create a range widget. |
| 39 | |
| 40 | // Create the scale. |
| 41 | // We want a horizontal scale. |
| 42 | auto scale = sfg::Scale::Create( sfg::Scale::Orientation::HORIZONTAL ); |
| 43 | |
| 44 | // Create the scrollbar. |
| 45 | // We want a vertical scrollbar. |
| 46 | auto scrollbar = sfg::Scrollbar::Create( sfg::Scrollbar::Orientation::VERTICAL ); |
| 47 | |
| 48 | // We can link both widgets together by their adjustments. |
| 49 | auto adjustment = scrollbar->GetAdjustment(); |
| 50 | scale->SetAdjustment( adjustment ); |
| 51 | |
| 52 | // Tune the adjustment parameters. |
| 53 | adjustment->SetLower( 20.f ); |
| 54 | adjustment->SetUpper( 100.f ); |
| 55 | |
| 56 | // How much it should change when clicked on the stepper. |
| 57 | adjustment->SetMinorStep( 3.f ); |
| 58 | |
| 59 | // How much it should change when clicked on the trough. |
| 60 | adjustment->SetMajorStep( 12.f ); |
| 61 | |
| 62 | // CAUTION: |
| 63 | // Normally you would only set the page size for scrollbar adjustments. |
| 64 | // For demonstration purposes we do this for our scale widget too. |
| 65 | // If page size isn't 0 a scale widget won't be able to be set to it's |
| 66 | // maximum value. This is in fact also true for scrollbars, however |
| 67 | // because they are used to scroll the page size must be subtracted from |
nothing calls this directly
no test coverage detected