ImGui

Functions

TNT_API void tnt_imgui_init (tnt::Window const &win) noexcept

Initialize all needed stuff to use ImGui on win.

Parameters
  • win: The target game window.

template<>
struct enable_bit_mask<ImGui::WindowFlags> : public true_type
namespace tnt
template<> WindowFlags > : public true_type
namespace ImGui

Enums

enum WindowFlags

An enum representing the flags that an ImGui window (not a game window) can have.

See

tnt::ImGui::Begin()

Note

This enum is not fully functional yet. This means that you should leave the default (last) argument of tnt::ImGui::Begin() as is.

Values:

enumerator Collapsible

with a collapse button

enumerator Closable

with a close button

enumerator Resizable

with a resize button

enumerator Movable

can be moved

enumerator WithTitleBar

has a title bar

enumerator OpaqueBackground

draw text and widgets, and the background

enumerator WidgetThenText

draw the widget on the left and it’s text on the right

enumerator Default

has all the enum’s values OR-ed

Functions

TNT_API void make_context () noexcept

Creates a new context and makes ImGui ready to be used.

Note

This is automatically called by tnt_imgui_begin().

TNT_API bool Begin (Window const &win, std::string_view name, int x, int y, WindowFlags flags=WindowFlags::Default) noexcept

Draw a new ImGui window on win at (x,y) and handle events related to it. Widgets that don’t require position parameters are drawn on this window.

Return

bool

See

tnt::ImGui::WindowFlags

Note

tnt::ImGui::End() should be called for each tnt::ImGui::Begin().

Note

For the moment, you CANNOT call tnt::ImGui::Begin() inside another tnt::ImGui::Begin() / tnt::ImGui::End() pair. That’s the only case when this function returns false, but this is subject to change.

Parameters
  • win: The window where the drawing should happen.

  • name: The desired title for the window.

  • x: The desired x position.

  • y: The desired y position.

  • flags: The flags the window should have.

TNT_API void End () noexcept

Stop drawing widgets on the last window where tnt::ImGui::Begin() is called. Also update some context-related data.

See

tnt::ImGui::Begin()

TNT_API bool BeginSection (Window const &win, std::string_view text) noexcept

Draw a “section” on the current ImGui window, which contains widgets and can be collapsed.

Return

bool

See

tnt::ImGui::EndSection()

Parameters
  • win: The game window where the drawing should happen.

  • text: The text to be displayed on the section.

TNT_API void EndSection () noexcept

Stop drawing widgets on the current “section”.

See

tnt::ImGui::BeginSection()

TNT_API void BeginList (bool indexed) noexcept

Prepare the current ImGui window for drawing a list on it. Calling BeginList() inside another BeginList() / EndList() pair indents the second list. This is useful for making sublists.

See

tnt::ImGui::EndList()

See

tnt::ImGui::list_item()

Note

tnt::ImGui::EndList() should be called for each tnt::ImGui::BeginList().

TNT_API void EndList () noexcept

End the current list of items. If this is a sublist (list inside another list) indentation is decreased.

See

tnt::ImGui::BeginList()

See

tnt::ImGui::list_item()

TNT_API void BeginMenuBar () noexcept

Prepare the last ImGui window to draw the menu bar on it.

See

tnt::ImGui::EndMenuBar()

See

tnt::ImGui::menu_button()

See

tnt::ImGui::menu_item()

TNT_API void EndMenuBar () noexcept

Do the cleanup of the menu bar stuff on the last ImGui window.

See

tnt::ImGui::BeginMenuBar()

See

tnt::ImGui::menu_button()

See

tnt::ImGui::menu_item()

TNT_API bool button (Window const &win, std::string_view text) noexcept

Draw a button on the current ImGui window, with text on it. Returns true if the button is pressed.

Return

bool

Parameters
  • win: The game window where the button should be drawed.

  • text: The text that should be drawn on the button.

TNT_API bool slider_int (Window const &win, int min_, int max_, int *value) noexcept

Draw a vertical slider that modifies an int value on the current ImGui window. The widget returns true if the value has been modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the slider should be drawed.

  • min_: The minimun value the widget can set.

  • max_: The maximum value the widget can set.

  • value: The value that the widget can modify.

TNT_API bool slider_float (Window const &win, float min_, float max_, float *value) noexcept

Draw a vertical slider that modifies an float value on the current ImGui window. The widget returns true if the value has been modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the slider should be drawed.

  • min_: The minimun value the widget can set.

  • max_: The maximum value the widget can set.

  • value: The value that the widget can modify.

TNT_API bool hslider_int (Window const &win, std::string_view text, int min_, int max_, int *value) noexcept

Draw a horizontal slider that modifies an int value on the current ImGui window. The widget returns true if the value has been modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the slider should be drawed.

  • text: The text that should be drawn next to the slider.

  • min_: The minimun value the widget can set.

  • max_: The maximum value the widget can set.

  • value: The value that the widget can modify.

TNT_API bool hslider_float (Window const &win, std::string_view text, float min_, float max_, float *value) noexcept

Draw a horizontal slider that modifies an float value on the current ImGui window. The widget returns true if the value has been modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the slider should be drawed.

  • text: The text that should be drawn next to the slider.

  • min_: The minimun value the widget can set.

  • max_: The maximum value the widget can set.

  • value: The value that the widget can modify.

TNT_API bool hslider_int2 (Window const &win, std::string_view text, int min_, int max_, int *value1, int *value2) noexcept

Draw two aligned horizontal sliders that modify 2 int values on the current ImGui window. The widget returns true if any of the values have been modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the slider should be drawed.

  • text: The text that should be drawn next to the sliders.

  • min_: The minimun value the widget can set for the first int.

  • max_: The maximum value the widget can set for the first int.

  • value1: The first value that the widget can modify.

  • value2: The second value that the widget can modify.

TNT_API bool hslider_float2 (Window const &win, std::string_view text, float min_, float max_, float *value1, float *value2) noexcept

Draw two aligned horizontal sliders that modify 2 float values on the current ImGui window. The widget returns true if any of the values have been modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the slider should be drawed.

  • text: The text that should be drawn next to the sliders.

  • min_: The minimun value the widget can set for the first float.

  • max_: The maximum value the widget can set for the first float.

  • value1: The first value that the widget can modify.

  • value2: The second value that the widget can modify.

TNT_API bool hslider_vec (Window const &win, std::string_view text, float min1, float max1, float min2, float max2, tnt::Vector *value) noexcept

Draw two aligned horizontal sliders that modify a tnt::Vector's value on the current ImGui window. The widget returns true if any of the values have been modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the slider should be drawed.

  • text: The text that should be drawn next to the sliders.

  • min1: The minimun value the widget can set for the first float of the tnt::Vector.

  • max1: The maximum value the widget can set for the first float of the tnt::Vector.

  • min2: The minimun value the widget can set for the second float of the tnt::Vector.

  • max2: The maximum value the widget can set for the second float of the tnt::Vector.

  • value: The tnt::Vector that the widget can modify.

TNT_API bool checkbox (Window const &win, std::string_view text, bool *value) noexcept

Draw a checkbox with text on the side of it. Returns true if modified, false otherwise.

Return

bool

Parameters
  • win: The game window where the checkbox should be drawed.

  • text: The text that should be displayed next to the checkbox.

  • value: The value representing the state of the checkbox.

TNT_API bool menu_button (Window const &win, std::string_view text) noexcept

Draw a menu button on the current window.

Return

bool

See

tnt::ImGui::BeginMenuBar()

See

tnt::ImGui::EndMenuBar()

See

tnt::ImGui::menu_item()

Parameters
  • win: The game window where the menu button will be drawed.

  • text: The name of the menu button.

TNT_API bool menu_item (Window const &win, std::string_view text) noexcept

Draw a menu bar with options from the options array. Returns the index of the pressed menu button (if any), or -1 otherwise.

Return

bool

See

tnt::ImGui::BeginMenuBar()

See

tnt::ImGui::EndMenuBar()

See

tnt::ImGui::menu_button()

Parameters
  • win: The game window where the menu should be drawed.

  • text: The text to be shown on the item’s button.

TNT_API void progress_bar (Window const &win, std::string_view text, int min_, int max_, int *value) noexcept

Draw a progress bar with text on the side of it.

Todo:

(maybe) return 1 if *value == max_

Parameters
  • win: The game window where the progress bar should be drawed.

  • text: The text that should be displayed next to the progress bar.

  • min_: The minimum value of the progress bar.

  • max_: The maximum value of the progress bar.

  • value: The value that shows the current progress bar index.

TNT_API void newline () noexcept

Add an empty line on the current window.

TNT_API void text (Window const &win, std::string_view text) noexcept

Draw text on the current window.

Parameters
  • win: The game window where the text should be drawed.

  • text: The text that should be drawed.

TNT_API void colored_text (Window const &win, std::string_view text, unsigned char r, unsigned char g, unsigned char b, unsigned char a) noexcept

Draw text with the specified color.

Parameters
  • win: The game window where the text should be drawed.

  • text: The text that should be drawed.

  • r: The red “component” of the text color.

  • g: The green “component” of the text color.

  • b: The blue “component” of the text color.

  • a: The transparent “component” of the text color.

TNT_API void list_item (Window const &win, std::string_view text) noexcept

Add a new item to the current list.

See

tnt::ImGui::BeginList()

See

tnt::ImGui::EndList()

Parameters
  • win: The game window where the list item should be drawed.

  • text: The text of the list item.