Repository navigation
add_*type*_slider
Daniel edited this page Oct 1, 2021
·
7 revisions
The add_int_slider / add_float_slider function will add a slider to the ui handler, add_int_slider / add_float_slider does not return the FUI_Element* related to the slider.
add_int_slider / add_float_slider has four different implementations, two for each type of slider
add_int_slider(
const std::string& identifier,
const std::string& text,
olc::vi2d position,
olc::vi2d size,
olc::vi2d range,
);
add_int_slider(
const std::string& parent_id,
const std::string& identifier,
const std::string& text,
olc::vi2d position,
olc::vi2d size,
olc::vi2d range,
);
add_float_slider(
const std::string& identifier,
const std::string& text,
olc::vi2d position,
olc::vi2d size,
olc::vf2d range,
);
add_float_slider(
const std::string& parent_id,
const std::string& identifier,
const std::string& text,
olc::vi2d position,
olc::vi2d size,
olc::vf2d range,
);Example usage for sliders with a parent
// create the UI handler
olc::FrostUI ui;
// create a window
ui.create_window("window1", "TITLE HERE", { 10, 10 }, { 300, 200 });
// create int slider with range 0 - 100 while specifying the parent_id manually
ui.add_int_slider("window1", "int_slider1", "Example Slider", { 10, 10 }, { 100, 20 }, { 0, 100 });Example usage for standalone slider
// create float slider that does not have a parent
ui.add_float_slider("float_slider1", "Example Slider", { 10, 10 }, { 100, 20 }, { 0.f, 100.f });We can also access the member functions by making use of find_element(const std::string& id)
// store the FUI_Element* connected with the slider
auto slider = ui.find_element("float_slider1");
// Set the text color of our slider to white
slider->set_text_color(olc::WHITE);Available member functions for sliders
// set the size of the slider
void set_size(olc::vi2d s);
// set the position of the slider
void set_position(olc::vi2d p);
// set the slider text
void set_text(const std::string& txt);
// set the text color of the slider
void set_text_color(olc::Pixel color);
// get the group the slider is apart of
const std::string get_group();
// set the scaling of the text
void scale_text(olc::vf2d scale);
// will return the position of the slider
const olc::vi2d get_position();
// will return the text size of the slider
olc::vi2d get_text_size(olc::PixelGameEngine* pge);
// set the value of slider
template<typename T>
void set_slider_value(T value);
// get the value of the slider, (get_slider_value<int>() or get_slider_value<float>() depending on slider type)
template<typename T>
const T get_slider_value();