Repository navigation
add_checkbox
Daniel edited this page Oct 1, 2021
·
3 revisions
The add_checkbox function will add a checkbox to the ui handler, add_checkbox does not return the FUI_Element* related to the checkbox.
add_checkbox has two different implementations
add_checkbox(
const std::string& identifier,
const std::string& text,
olc::vi2d position,
olc::vi2d size,
);
add_checkbox(
const std::string& parent_id,
const std::string& identifier,
const std::string& text,
olc::vi2d position,
olc::vi2d size,
);Example usage for checkbox with a parent
// create the UI handler
olc::FrostUI ui;
// create a window
ui.create_window("window1", "TITLE HERE", { 10, 10 }, { 300, 200 });
// create checkbox while specifying the parent_id manually
ui.add_checkbox("window1", "checkbox1", "Example Checkbox", { 10, 10 }, { 100, 20 });Example usage for standalone checkbox
// create checkbox that does not have a parent
ui.add_checkbox("checkbox1", "Example Checkbox", { 10, 10 }, { 100, 20 });We can also access the member functions by making use of find_element(const std::string& id)
// store the FUI_Element* connected with the checkbox
auto checkbox = ui.find_element("checkbox1");
// Set the text color of our checkbox to white
checkbox->set_text_color(olc::WHITE);Available member functions for checkboxes
// set the size of the checkbox
void set_size(olc::vi2d s);
// set the position of the checkbox
void set_position(olc::vi2d p);
// set the checkboxtext
void set_text(const std::string& txt);
// set the text color of the checkbox
void set_text_color(olc::Pixel color);
// get the group the checkbox 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 checkbox
const olc::vi2d get_position();
// will return the text size of the checkbox
olc::vi2d get_text_size(olc::PixelGameEngine* pge);