Skip to content

create_window

Daniel edited this page May 6, 2021 · 7 revisions

The create_window function creates and returns the window as type FUI_Window*

create_window takes 4 arguments

create_window(
              const std::string& identifier,
              const std::string& title,
              olc::vi2d position,
              olc::vi2d size
             );
// create the UI handler
olc::FrostUI ui;

// this will create the window but not store the window pointer
ui.create_window("window1", "TITLE HERE", { 10, 10 }, { 300, 200 });

// this will create the window and at the same time store the window pointer
auto window = ui.create_window("window1", "TITLE HERE", { 10, 10 }, { 300, 200 });

If you don't want to store the window pointer when creating the window you can always use
find_window(const std::string& identifier) whenever you're in need of accessing the member functions of the FUI_Window class

auto window = ui.find_window("window1");
window->set_top_border_thickness(20); // changes the thickness of the window header

Following member functions are available for the FUI_Window class

// gets the position of the window
olc::vi2d get_position() const;

// gets the size of the window
olc::vi2d get_size() const;

// gets the space within the window borders
olc::vi2d get_window_space() const;

// gets the window identifier
std::string get_id() const;

// gets the thickness of the window header (top border)
int get_top_border_thickness() const;

// gets the thickness of the surrounding window border (all borders except for the top border)
int get_border_thickness() const;

// set the thickness of the window header (top border)
void set_top_border_thickness(int thickness);

// set the thickness of the surrounding window border
void set_border_thickness(int thickness);

// close the window
void close_window(bool close);

// get the closed state of the window
bool get_closed_state() const;

// change the window position
void change_position(olc::vi2d pos);

// change the window size
void change_size(olc::vi2d s);

// set the current window to the focused window (will be drawn ontop of other existing windows)
void set_focused(bool state);

// get the focused state of the current window
bool is_focused() const;

Clone this wiki locally