28#embed "../Conf/imgui.ini"
39 ImGuiIO& io = ImGui::GetIO();
40 const char* userIniPath =
"imgui.ini";
42 io.IniFilename = userIniPath;
44 if (!std::filesystem::exists(userIniPath)) {
47 std::ofstream outFile(userIniPath);
67 ImVec2 size = ImGui::CalcTextSize(label);
68 return size.x + (ImGui::GetStyle().FramePadding.x * 2.0f);
78 float avail = ImGui::GetContentRegionAvail().x;
80 ImGui::GetCursorPosX() + std::max(0.0f, avail - totalWidth);
81 ImGui::SetCursorPosX(startX);
91 return ImGui::IsKeyPressed(ImGuiKey_Enter,
false) ||
92 ImGui::IsKeyPressed(ImGuiKey_KeypadEnter,
false);
102 return ImGui::IsKeyPressed(ImGuiKey_Escape,
false);
114 const char* secondary,
const char* tertiary =
nullptr) {
115 float spacing = ImGui::GetStyle().ItemSpacing.x;
118 float tertiaryWidth = tertiary ?
ButtonWidth(tertiary) : 0.0f;
119 int count = tertiary ? 3 : 2;
120 float totalWidth = primaryWidth + secondaryWidth + tertiaryWidth +
121 (spacing * (count - 1));
126 if (ImGui::Button(tertiary))
130 if (ImGui::Button(secondary))
133 if (ImGui::Button(primary))
194 return ImGui::Button(label);
224 for (
int i = ImGuiKey_NamedKey_BEGIN; i < ImGuiKey_NamedKey_END; i++) {
225 auto key = (ImGuiKey)i;
226 if (key == ImGuiKey_LeftCtrl || key == ImGuiKey_RightCtrl ||
227 key == ImGuiKey_LeftShift || key == ImGuiKey_RightShift ||
228 key == ImGuiKey_LeftAlt || key == ImGuiKey_RightAlt ||
229 key == ImGuiKey_LeftSuper || key == ImGuiKey_RightSuper ||
230 key == ImGuiKey_MouseLeft || key == ImGuiKey_MouseRight)
232 if (ImGui::IsKeyReleased(key))
235 return ImGuiKey_None;
249 const char* username =
252 username = std::getenv(
"LOGNAME");
255 username = std::getenv(
"USERNAME");
258 username =
"unknown";
ImGui/OpenGL/GLFW integration utilities and file dialog wrapper.
ButtonRowResult YesNoButtons()
Renders a Yes/No button row.
Definition ImUtil.h:154
ButtonRowResult
Identifies which button was pressed in a button row.
Definition ImUtil.h:59
@ Tertiary
Definition ImUtil.h:59
@ Primary
Definition ImUtil.h:59
@ Secondary
Definition ImUtil.h:59
@ None
Definition ImUtil.h:59
bool EscPressed()
Returns true when Escape is pressed this frame.
Definition ImUtil.h:101
ImGuiKey GetAnyReleasedKey()
Returns the first non-modifier key released this frame.
Definition ImUtil.h:223
float ButtonWidth(const char *label)
Returns the width needed to render a button with the given label.
Definition ImUtil.h:66
void AlignButtonsRight(float totalWidth)
Right-aligns the next row of buttons within the current content region.
Definition ImUtil.h:77
const char * GetUsername()
Small util function for fetching the current users' username. Used for filling out the animation auth...
Definition ImUtil.h:248
constexpr char s_DefaultLayout[]
Definition ImUtil.h:27
ButtonRowResult OkCancelButtons()
Renders an OK/Cancel button row.
Definition ImUtil.h:144
ButtonRowResult ConfirmButtons(const char *primary, const char *secondary, const char *tertiary=nullptr)
Renders CONFIRM buttons for popups.
Definition ImUtil.h:113
ButtonRowResult CloseOkButtons()
Renders an OK/Close button row.
Definition ImUtil.h:174
ButtonRowResult ExportCloseButtons()
Renders an Export/Close button row.
Definition ImUtil.h:184
void SetupDefaultLayout()
Sets up the default ImGui layout in-case there's no user-defined one.
Definition ImUtil.h:38
bool CloseButton()
Renders a single Close button.
Definition ImUtil.h:213
bool OkButton()
Renders a single OK button.
Definition ImUtil.h:203
bool EnterPressed()
Returns true when Enter or keypad Enter is pressed this frame.
Definition ImUtil.h:90
ButtonRowResult YesNoCancelButtons()
Renders a Yes/No/Cancel button row.
Definition ImUtil.h:164
bool SingleButtonRow(const char *label)
Renders a single right-aligned button.
Definition ImUtil.h:192