102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
gui_widgets.c File Reference
#include "gui_internal.h"
#include <math.h>

Go to the source code of this file.

Data Structures

struct  config_path_picker_button
struct  config_theme_color

Typedefs

typedef void(* config_path_dialog_fn) (const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)

Functions

void same_path_button_row (const DTTR_ImGuiDialogContext *ctx)
void add_scaled_vertical_spacing (const DTTR_ImGuiDialogContext *ctx, float height)
static float config_path_control_width ()
float config_standard_input_width ()
static float config_standard_content_width ()
static float config_gamepad_content_width ()
int config_window_width ()
static int choice_index (const DTTR_ConfigChoice *choices, int choice_count, int value)
bool choice_combo (const char *label, int *value, DTTR_ConfigChoiceList choices, const char *const *tooltips)
static void draw_wrapped_tooltip_segment (const char *start, const char *end)
static void draw_inline_tooltip_segment (const char *start, const char *end)
static void draw_default_inline_text (const char *start, const char *end)
static void draw_default_tooltip_value (const char *default_value_start, const char *default_value_end)
void show_tooltip (const char *text)
bool themed_row_button (const DTTR_ImGuiDialogContext *ctx, const char *id, const char *label, float width)
void push_config_theme ()
void pop_config_theme ()
static bool format_status_text (const config_ui_state *state, char *buffer, size_t buffer_size)
static float status_text_height (const char *status_text)
float config_footer_height (const DTTR_ImGuiDialogContext *ctx, const config_ui_state *state)
bool begin_config_content_region (const DTTR_ImGuiDialogContext *ctx, const config_ui_state *state)
void end_config_content_region ()
void draw_footer_text (const DTTR_ImGuiDialogContext *ctx, const config_ui_state *state)
bool begin_padded_panel (const DTTR_ImGuiDialogContext *ctx)
void end_padded_panel ()
static ImVec2_c table_cell_padding (const DTTR_ImGuiDialogContext *ctx, float padding_x)
static bool begin_config_table (const DTTR_ImGuiDialogContext *ctx, const char *id, int column_count, float cell_padding_x, float table_width)
static void setup_scaled_table_column (const DTTR_ImGuiDialogContext *ctx, const char *id, ImGuiTableColumnFlags flags, float width)
static void append_table_header_text (const DTTR_ImGuiDialogContext *ctx, int column, const char *text)
static void begin_table_header_row ()
static bool begin_settings_table_with_cell_padding (const DTTR_ImGuiDialogContext *ctx, const char *id, float label_width, float input_width, float table_width, float cell_padding_x)
bool begin_settings_table_with_width (const DTTR_ImGuiDialogContext *ctx, const char *id, float label_width, float input_width, float table_width)
bool begin_settings_table (const DTTR_ImGuiDialogContext *ctx, const char *id, float label_width, float input_width)
void end_settings_table ()
bool begin_gamepad_button_table (const DTTR_ImGuiDialogContext *ctx)
void begin_config_table_row ()
void begin_setting_row ()
float table_input_width (const DTTR_ImGuiDialogContext *ctx, float input_width)
float path_text_input_width (const DTTR_ImGuiDialogContext *ctx, int button_count)
static ImVec4_c config_label_text_color (config_label_state label_state)
void draw_config_label (const char *label, const char *tooltip, config_label_state label_state)
static void begin_labeled_control (const DTTR_ImGuiDialogContext *ctx, const char *label, float input_width, const char *tooltip, config_label_state label_state)
static void draw_path_picker_button (const DTTR_ImGuiDialogContext *ctx, config_ui_state *state, const char *id, const char *label, const char *tooltip, config_path_dialog_fn open_dialog)
static void draw_path_picker_buttons (const DTTR_ImGuiDialogContext *ctx, config_ui_state *state, const config_path_picker_button *buttons, int button_count)
static bool labeled_path_picker_with_dialog (const DTTR_ImGuiDialogContext *ctx, config_ui_state *state, const char *label, const char *id, char *buf, size_t buf_size, const char *tooltip, config_label_state label_state, const config_path_picker_button *buttons, int button_count)
bool labeled_input_text (const DTTR_ImGuiDialogContext *ctx, const char *label, const char *id, char *buf, size_t buf_size, const char *tooltip, config_label_state label_state)
bool labeled_path_picker (const DTTR_ImGuiDialogContext *ctx, config_ui_state *state, const char *label, const char *id, char *buf, size_t buf_size, const char *tooltip, config_label_state label_state)
bool labeled_log_path_picker (const DTTR_ImGuiDialogContext *ctx, config_ui_state *state, const char *label, const char *id, char *buf, size_t buf_size, const char *tooltip, config_label_state label_state)
bool labeled_input_int (const DTTR_ImGuiDialogContext *ctx, const char *label, const char *id, int *value, int step, int step_fast, const char *tooltip, config_label_state label_state)
bool labeled_input_float (const DTTR_ImGuiDialogContext *ctx, const char *label, const char *id, float *value, const char *tooltip, config_label_state label_state)
bool labeled_checkbox (const DTTR_ImGuiDialogContext *ctx, const char *label, const char *id, bool *value, const char *tooltip, config_label_state label_state)
bool labeled_choice_combo (const DTTR_ImGuiDialogContext *ctx, const char *label, const char *id, int *value, DTTR_ConfigChoiceList choices, const char *const *tooltips, const char *tooltip, config_label_state label_state)

Variables

static const char *const FOOTER_HINT_TEXT = "Ctrl+S to save your changes."
static const config_theme_color CONFIG_THEME_COLORS []

Typedef Documentation

◆ config_path_dialog_fn

typedef void(* config_path_dialog_fn) (const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)

Definition at line 16 of file gui_widgets.c.

Function Documentation

◆ add_scaled_vertical_spacing()

void add_scaled_vertical_spacing ( const DTTR_ImGuiDialogContext * ctx,
float height )

◆ append_table_header_text()

void append_table_header_text ( const DTTR_ImGuiDialogContext * ctx,
int column,
const char * text )
static

◆ begin_config_content_region()

bool begin_config_content_region ( const DTTR_ImGuiDialogContext * ctx,
const config_ui_state * state )

Definition at line 333 of file gui_widgets.c.

References config_footer_height(), ctx, and state.

Referenced by draw_ui().

◆ begin_config_table()

bool begin_config_table ( const DTTR_ImGuiDialogContext * ctx,
const char * id,
int column_count,
float cell_padding_x,
float table_width )
static

◆ begin_config_table_row()

void begin_config_table_row ( )

Definition at line 575 of file gui_widgets.c.

Referenced by begin_setting_row(), draw_gamepad_button_row(), and draw_mod_toggle_row().

◆ begin_gamepad_button_table()

◆ begin_labeled_control()

void begin_labeled_control ( const DTTR_ImGuiDialogContext * ctx,
const char * label,
float input_width,
const char * tooltip,
config_label_state label_state )
static

◆ begin_padded_panel()

◆ begin_setting_row()

◆ begin_settings_table()

bool begin_settings_table ( const DTTR_ImGuiDialogContext * ctx,
const char * id,
float label_width,
float input_width )

Definition at line 510 of file gui_widgets.c.

References begin_settings_table_with_width(), and ctx.

Referenced by begin_tab_settings_table(), and draw_gamepad_axes().

◆ begin_settings_table_with_cell_padding()

bool begin_settings_table_with_cell_padding ( const DTTR_ImGuiDialogContext * ctx,
const char * id,
float label_width,
float input_width,
float table_width,
float cell_padding_x )
static

◆ begin_settings_table_with_width()

bool begin_settings_table_with_width ( const DTTR_ImGuiDialogContext * ctx,
const char * id,
float label_width,
float input_width,
float table_width )

◆ begin_table_header_row()

void begin_table_header_row ( )
static

◆ choice_combo()

bool choice_combo ( const char * label,
int * value,
DTTR_ConfigChoiceList choices,
const char *const * tooltips )

◆ choice_index()

int choice_index ( const DTTR_ConfigChoice * choices,
int choice_count,
int value )
static

Definition at line 58 of file gui_widgets.c.

Referenced by choice_combo().

◆ config_footer_height()

float config_footer_height ( const DTTR_ImGuiDialogContext * ctx,
const config_ui_state * state )

Definition at line 318 of file gui_widgets.c.

References ctx, format_status_text(), state, and status_text_height().

Referenced by begin_config_content_region().

◆ config_gamepad_content_width()

float config_gamepad_content_width ( )
static

◆ config_label_text_color()

◆ config_path_control_width()

float config_path_control_width ( )
static

◆ config_standard_content_width()

float config_standard_content_width ( )
static

Definition at line 40 of file gui_widgets.c.

References config_standard_input_width(), and DTTR_CONFIG_UI_LABEL_W.

Referenced by config_window_width().

◆ config_standard_input_width()

◆ config_window_width()

int config_window_width ( )

◆ draw_config_label()

void draw_config_label ( const char * label,
const char * tooltip,
config_label_state label_state )

◆ draw_default_inline_text()

void draw_default_inline_text ( const char * start,
const char * end )
static

Definition at line 130 of file gui_widgets.c.

References DTTR_CONFIG_UI_TOOLTIP_DEFAULT_TEXT_COLOR.

Referenced by draw_default_tooltip_value().

◆ draw_default_tooltip_value()

void draw_default_tooltip_value ( const char * default_value_start,
const char * default_value_end )
static

Definition at line 144 of file gui_widgets.c.

References draw_default_inline_text(), and draw_inline_tooltip_segment().

Referenced by show_tooltip().

◆ draw_footer_text()

void draw_footer_text ( const DTTR_ImGuiDialogContext * ctx,
const config_ui_state * state )

◆ draw_inline_tooltip_segment()

void draw_inline_tooltip_segment ( const char * start,
const char * end )
static

Definition at line 121 of file gui_widgets.c.

Referenced by draw_default_tooltip_value().

◆ draw_path_picker_button()

void draw_path_picker_button ( const DTTR_ImGuiDialogContext * ctx,
config_ui_state * state,
const char * id,
const char * label,
const char * tooltip,
config_path_dialog_fn open_dialog )
static

◆ draw_path_picker_buttons()

void draw_path_picker_buttons ( const DTTR_ImGuiDialogContext * ctx,
config_ui_state * state,
const config_path_picker_button * buttons,
int button_count )
static

Definition at line 656 of file gui_widgets.c.

References ctx, draw_path_picker_button(), and state.

Referenced by labeled_path_picker_with_dialog().

◆ draw_wrapped_tooltip_segment()

void draw_wrapped_tooltip_segment ( const char * start,
const char * end )
static

Definition at line 113 of file gui_widgets.c.

Referenced by show_tooltip().

◆ end_config_content_region()

void end_config_content_region ( )

Definition at line 348 of file gui_widgets.c.

Referenced by draw_ui().

◆ end_padded_panel()

void end_padded_panel ( )

Definition at line 386 of file gui_widgets.c.

Referenced by draw_ui().

◆ end_settings_table()

◆ format_status_text()

bool format_status_text ( const config_ui_state * state,
char * buffer,
size_t buffer_size )
static

Definition at line 273 of file gui_widgets.c.

References config_has_unsaved_changes(), and state.

Referenced by config_footer_height(), and draw_footer_text().

◆ labeled_checkbox()

bool labeled_checkbox ( const DTTR_ImGuiDialogContext * ctx,
const char * label,
const char * id,
bool * value,
const char * tooltip,
config_label_state label_state )

◆ labeled_choice_combo()

bool labeled_choice_combo ( const DTTR_ImGuiDialogContext * ctx,
const char * label,
const char * id,
int * value,
DTTR_ConfigChoiceList choices,
const char *const * tooltips,
const char * tooltip,
config_label_state label_state )

◆ labeled_input_float()

bool labeled_input_float ( const DTTR_ImGuiDialogContext * ctx,
const char * label,
const char * id,
float * value,
const char * tooltip,
config_label_state label_state )

◆ labeled_input_int()

bool labeled_input_int ( const DTTR_ImGuiDialogContext * ctx,
const char * label,
const char * id,
int * value,
int step,
int step_fast,
const char * tooltip,
config_label_state label_state )

◆ labeled_input_text()

bool labeled_input_text ( const DTTR_ImGuiDialogContext * ctx,
const char * label,
const char * id,
char * buf,
size_t buf_size,
const char * tooltip,
config_label_state label_state )

◆ labeled_log_path_picker()

bool labeled_log_path_picker ( const DTTR_ImGuiDialogContext * ctx,
config_ui_state * state,
const char * label,
const char * id,
char * buf,
size_t buf_size,
const char * tooltip,
config_label_state label_state )

Definition at line 768 of file gui_widgets.c.

References ctx, labeled_path_picker_with_dialog(), open_log_file_dialog(), and state.

Referenced by draw_general_tab().

◆ labeled_path_picker()

bool labeled_path_picker ( const DTTR_ImGuiDialogContext * ctx,
config_ui_state * state,
const char * label,
const char * id,
char * buf,
size_t buf_size,
const char * tooltip,
config_label_state label_state )

◆ labeled_path_picker_with_dialog()

bool labeled_path_picker_with_dialog ( const DTTR_ImGuiDialogContext * ctx,
config_ui_state * state,
const char * label,
const char * id,
char * buf,
size_t buf_size,
const char * tooltip,
config_label_state label_state,
const config_path_picker_button * buttons,
int button_count )
static

◆ path_text_input_width()

◆ pop_config_theme()

void pop_config_theme ( )

Definition at line 271 of file gui_widgets.c.

References CONFIG_THEME_COLORS.

Referenced by draw_ui().

◆ push_config_theme()

void push_config_theme ( )

Definition at line 265 of file gui_widgets.c.

References color, CONFIG_THEME_COLORS, and target.

Referenced by draw_ui().

◆ same_path_button_row()

void same_path_button_row ( const DTTR_ImGuiDialogContext * ctx)

◆ setup_scaled_table_column()

void setup_scaled_table_column ( const DTTR_ImGuiDialogContext * ctx,
const char * id,
ImGuiTableColumnFlags flags,
float width )
static

◆ show_tooltip()

◆ status_text_height()

float status_text_height ( const char * status_text)
static

Definition at line 301 of file gui_widgets.c.

References float.

Referenced by config_footer_height().

◆ table_cell_padding()

ImVec2_c table_cell_padding ( const DTTR_ImGuiDialogContext * ctx,
float padding_x )
static

◆ table_input_width()

float table_input_width ( const DTTR_ImGuiDialogContext * ctx,
float input_width )

Definition at line 582 of file gui_widgets.c.

References ctx, and DTTR_ImGuiDialog_ScaledFloat().

Referenced by begin_labeled_control(), and path_text_input_width().

◆ themed_row_button()

bool themed_row_button ( const DTTR_ImGuiDialogContext * ctx,
const char * id,
const char * label,
float width )

Variable Documentation

◆ CONFIG_THEME_COLORS

const config_theme_color CONFIG_THEME_COLORS[]
static
Initial value:
= {
{ImGuiCol_FrameBg, DTTR_IMGUI_COLOR_STACK_FRAME_BG},
{ImGuiCol_FrameBgHovered, DTTR_IMGUI_COLOR_BUTTON_BG_HOVERED},
{ImGuiCol_FrameBgActive, DTTR_IMGUI_COLOR_BUTTON_BG_ACTIVE},
{ImGuiCol_Button, DTTR_IMGUI_COLOR_BUTTON_BG},
{ImGuiCol_ButtonHovered, DTTR_IMGUI_COLOR_BUTTON_BG_HOVERED},
{ImGuiCol_ButtonActive, DTTR_IMGUI_COLOR_BUTTON_BG_ACTIVE},
{ImGuiCol_Header, DTTR_IMGUI_COLOR_BUTTON_BG},
{ImGuiCol_HeaderHovered, DTTR_IMGUI_COLOR_BUTTON_BG_HOVERED},
{ImGuiCol_HeaderActive, DTTR_IMGUI_COLOR_BUTTON_BG_ACTIVE},
{ImGuiCol_Tab, DTTR_IMGUI_COLOR_BUTTON_BG},
{ImGuiCol_TabHovered, DTTR_IMGUI_COLOR_BUTTON_BG_HOVERED},
{ImGuiCol_TabSelected, DTTR_CONFIG_UI_SELECTED_TAB_BG},
{ImGuiCol_TabDimmed, DTTR_IMGUI_COLOR_STACK_FRAME_BG},
{ImGuiCol_TabDimmedSelected, DTTR_CONFIG_UI_SELECTED_TAB_BG},
{ImGuiCol_MenuBarBg, DTTR_IMGUI_COLOR_STACK_FRAME_BG},
{ImGuiCol_PopupBg, DTTR_IMGUI_COLOR_STACK_FRAME_BG},
{ImGuiCol_Border, DTTR_CONFIG_UI_BORDER_COLOR},
{ImGuiCol_Separator, DTTR_CONFIG_UI_SEPARATOR_COLOR},
{ImGuiCol_SeparatorHovered, DTTR_CONFIG_UI_SEPARATOR_COLOR},
{ImGuiCol_SeparatorActive, DTTR_CONFIG_UI_SEPARATOR_COLOR},
{ImGuiCol_TableBorderStrong, DTTR_CONFIG_UI_TABLE_BORDER_COLOR},
{ImGuiCol_TableBorderLight, DTTR_CONFIG_UI_BORDER_COLOR},
}
#define DTTR_IMGUI_COLOR_BUTTON_BG
Definition dttr_imgui.h:12
#define DTTR_IMGUI_COLOR_BUTTON_BG_HOVERED
Definition dttr_imgui.h:13
#define DTTR_IMGUI_COLOR_STACK_FRAME_BG
Definition dttr_imgui.h:11
#define DTTR_IMGUI_COLOR_BUTTON_BG_ACTIVE
Definition dttr_imgui.h:14
#define DTTR_CONFIG_UI_SEPARATOR_COLOR
#define DTTR_CONFIG_UI_BORDER_COLOR
#define DTTR_CONFIG_UI_SELECTED_TAB_BG
#define DTTR_CONFIG_UI_TABLE_BORDER_COLOR

Definition at line 240 of file gui_widgets.c.

Referenced by pop_config_theme(), and push_config_theme().

◆ FOOTER_HINT_TEXT

const char* const FOOTER_HINT_TEXT = "Ctrl+S to save your changes."
static

Definition at line 28 of file gui_widgets.c.

Referenced by draw_footer_text().