63inline void Window(
const char* name,
bool* p_open, ImGuiWindowFlags flags, std::invocable<>
auto next)
65 if (ImGui::Begin(name, p_open, flags)) {
70inline void Window(
const char* name,
bool* p_open, std::invocable<>
auto next)
72 Window(name, p_open, 0, next);
74inline void Window(
const char* name, std::invocable<>
auto next)
76 Window(name,
nullptr, 0, next);
85inline void Window(
const char* name,
WindowStatus& status, ImGuiWindowFlags flags, std::invocable<>
auto next)
87 if (ImGui::Begin(name, &status.
open, flags)) {
90 if (!ImGui::IsWindowAppearing()) {
92 if (
auto* swf = ImGui::GetPlatformIO().Platform_SetWindowFocus) {
93 swf(ImGui::GetWindowViewport());
97 ImGui::SetWindowFocus();
106 Window(name, status, 0, next);
110inline void Child(
const char* str_id,
const ImVec2& size, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags, std::invocable<>
auto next)
112 if (ImGui::BeginChild(str_id, size, child_flags, window_flags)) {
117inline void Child(
const char* str_id,
const ImVec2& size, ImGuiChildFlags child_flags, std::invocable<>
auto next)
119 Child(str_id, size, child_flags, 0, next);
121inline void Child(
const char* str_id,
const ImVec2& size, std::invocable<>
auto next)
123 Child(str_id, size, 0, 0, next);
125inline void Child(
const char* str_id, std::invocable<>
auto next)
127 Child(str_id, {}, 0, 0, next);
131inline void Font(ImFont* font, std::invocable<>
auto next)
133 ImGui::PushFont(font);
160 if (active) ImGui::PopStyleColor(N);
162template<
int N,
typename... Args>
165 if (active) ImGui::PushStyleColor(idx, col);
166 StyleColor_impl<N>(active, std::forward<Args>(args)...);
168template<
int N,
typename... Args>
171 if (active) ImGui::PushStyleColor(idx, ImGui::ColorConvertU32ToFloat4(col));
172 StyleColor_impl<N>(active, std::forward<Args>(args)...);
174template<
typename... Args>
177 static constexpr auto N =
sizeof...(args);
178 static_assert(N >= 3);
179 static_assert((N & 1) == 1);
182template<
typename... Args>
185 StyleColor(
true, std::forward<Args>(args)...);
190inline void StyleVar(ImGuiStyleVar idx,
float val, std::invocable<>
auto next)
192 ImGui::PushStyleVar(idx, val);
194 ImGui::PopStyleVar(1);
196inline void StyleVar(ImGuiStyleVar idx,
const ImVec2& val, std::invocable<>
auto next)
198 ImGui::PushStyleVar(idx, val);
200 ImGui::PopStyleVar(1);
204inline void ItemWidth(
float item_width, std::invocable<>
auto next)
206 ImGui::PushItemWidth(item_width);
208 ImGui::PopItemWidth();
212inline void TextWrapPos(
float wrap_local_pos_x, std::invocable<>
auto next)
214 ImGui::PushTextWrapPos(wrap_local_pos_x);
216 ImGui::PopTextWrapPos();
224inline void Indent(
float indent_w, std::invocable<>
auto next)
226 ImGui::Indent(indent_w);
228 ImGui::Unindent(indent_w);
230inline void Indent(std::invocable<>
auto next)
236inline void Group(std::invocable<>
auto next)
244inline void ID(
const char* str_id, std::invocable<>
auto next)
246 ImGui::PushID(str_id);
250inline void ID(
const char* str_id_begin,
const char* str_id_end, std::invocable<>
auto next)
252 ImGui::PushID(str_id_begin, str_id_end);
256inline void ID(
const void* ptr_id, std::invocable<>
auto next)
258 ImGui::PushID(ptr_id);
262inline void ID(
int int_id, std::invocable<>
auto next)
264 ImGui::PushID(int_id);
268inline void ID(
const std::string& str, std::invocable<>
auto next)
270 auto begin = str.data();
274inline void ID(std::string_view str, std::invocable<>
auto next)
276 auto begin = str.data();
281inline void ID_for_range(std::integral
auto count, std::invocable<int>
auto next)
283 for (
auto i :
xrange(narrow<int>(count))) {
284 ID(i, [&]{ next(i); });
289inline void Combo(
const char* label,
const char* preview_value, ImGuiComboFlags flags, std::invocable<>
auto next)
291 if (ImGui::BeginCombo(label, preview_value, flags)) {
296inline void Combo(
const char* label,
const char* preview_value, std::invocable<>
auto next)
298 Combo(label, preview_value, 0, next);
302inline bool TreeNode(
const char* label, ImGuiTreeNodeFlags flags, std::invocable<>
auto next)
304 bool open = ImGui::TreeNodeEx(label, flags);
311inline bool TreeNode(
const char* label, std::invocable<>
auto next)
315inline void TreeNode(
const char* label,
bool* p_open, std::invocable<>
auto next)
318 ImGui::SetNextItemOpen(*p_open);
320 *p_open = ImGui::TreeNodeEx(label, flags);
328inline void ListBox(
const char* label,
const ImVec2& size, std::invocable<>
auto next)
330 if (ImGui::BeginListBox(label, size)) {
335inline void ListBox(
const char* label, std::invocable<>
auto next)
341inline void MenuBar(std::invocable<>
auto next)
343 if (ImGui::BeginMenuBar()) {
352 if (ImGui::BeginMainMenuBar()) {
354 ImGui::EndMainMenuBar();
359inline bool Menu(
const char* label,
bool enabled, std::invocable<>
auto next)
361 bool open = ImGui::BeginMenu(label, enabled);
368inline bool Menu(
const char* label, std::invocable<>
auto next)
370 return Menu(label,
true, next);
374inline void Tooltip(std::invocable<>
auto next)
376 if (ImGui::BeginTooltip()) {
384 if (ImGui::BeginItemTooltip()) {
391inline void Popup(
const char* str_id, ImGuiWindowFlags flags, std::invocable<>
auto next)
393 if (ImGui::BeginPopup(str_id, flags)) {
398inline void Popup(
const char* str_id, std::invocable<>
auto next)
400 Popup(str_id, 0, next);
404inline void PopupModal(
const char* name,
bool* p_open, ImGuiWindowFlags flags, std::invocable<>
auto next)
406 if (ImGui::BeginPopupModal(name, p_open, flags)) {
411inline void PopupModal(
const char* name,
bool* p_open, std::invocable<>
auto next)
415inline void PopupModal(
const char* name, std::invocable<>
auto next)
421inline void PopupContextItem(
const char* str_id, ImGuiPopupFlags popup_flags, std::invocable<>
auto next)
423 if (ImGui::BeginPopupContextItem(str_id, popup_flags)) {
438inline void PopupContextWindow(
const char* str_id, ImGuiPopupFlags popup_flags, std::invocable<>
auto next)
440 if (ImGui::BeginPopupContextWindow(str_id, popup_flags)) {
455inline void Table(
const char* str_id,
int column, ImGuiTableFlags flags,
const ImVec2& outer_size,
float inner_width, std::invocable<>
auto next)
457 if (ImGui::BeginTable(str_id, column, flags, outer_size, inner_width)) {
462inline void Table(
const char* str_id,
int column, ImGuiTableFlags flags,
const ImVec2& outer_size, std::invocable<>
auto next)
464 Table(str_id, column, flags, outer_size, 0.0f, next);
466inline void Table(
const char* str_id,
int column, ImGuiTableFlags flags, std::invocable<>
auto next)
468 Table(str_id, column, flags, {}, 0.0f, next);
470inline void Table(
const char* str_id,
int column, std::invocable<>
auto next)
472 Table(str_id, column, 0, {}, 0.0f, next);
476inline void TabBar(
const char* str_id, ImGuiTabBarFlags flags, std::invocable<>
auto next)
478 if (ImGui::BeginTabBar(str_id, flags)) {
483inline void TabBar(
const char* str_id, std::invocable<>
auto next)
489inline void TabItem(
const char* label,
bool* p_open, ImGuiTabItemFlags flags, std::invocable<>
auto next)
491 if (ImGui::BeginTabItem(label, p_open, flags)) {
496inline void TabItem(
const char* label,
bool* p_open, std::invocable<>
auto next)
498 TabItem(label, p_open, 0, next);
500inline void TabItem(
const char* label, std::invocable<>
auto next)
502 TabItem(label,
nullptr, 0, next);
506inline void Disabled(
bool b, std::invocable<>
auto next)
508 ImGui::BeginDisabled(b);
510 ImGui::EndDisabled();
516 ImGui::BeginDisabled(b);
520 ImGui::EndDisabled();
527 const auto& style = ImGui::GetStyle();
528 ImGui::PushStyleVar(ImGuiStyleVar_Alpha, style.Alpha * style.DisabledAlpha);
532 ImGui::PopStyleVar(1);
538inline void ListClipper(
size_t count,
int forceIndex,
float lineHeight, std::invocable<int>
auto next)
540 ImGuiListClipper clipper;
541 clipper.Begin(narrow<int>(count), lineHeight);
542 if (forceIndex > 0) clipper.IncludeItemByIndex(narrow<int>(forceIndex));
543 while (clipper.Step()) {
544 for (
int i :
xrange(clipper.DisplayStart, clipper.DisplayEnd)) {
549inline void ListClipper(
size_t count,
int forceIndex, std::invocable<int>
auto next)
553inline void ListClipper(
size_t count, std::invocable<int>
auto next)
561 ImGuiListClipper clipper;
562 clipper.Begin(narrow<int>(count));
563 while (clipper.Step()) {
564 for (
int i :
xrange(clipper.DisplayStart, clipper.DisplayEnd)) {
void DisabledIndent(bool b, std::invocable<> auto next)
void Table(const char *str_id, int column, ImGuiTableFlags flags, const ImVec2 &outer_size, float inner_width, std::invocable<> auto next)
void MainMenuBar(std::invocable<> auto next)
void MenuBar(std::invocable<> auto next)
void Window(const char *name, bool *p_open, ImGuiWindowFlags flags, std::invocable<> auto next)
void VisuallyDisabled(bool b, std::invocable<> auto next)
void ID(const char *str_id, std::invocable<> auto next)
void PopupContextItem(const char *str_id, ImGuiPopupFlags popup_flags, std::invocable<> auto next)
void StyleColor_impl(bool active, std::invocable<> auto next)
void StyleVar(ImGuiStyleVar idx, float val, std::invocable<> auto next)
void TabBar(const char *str_id, ImGuiTabBarFlags flags, std::invocable<> auto next)
void PopupContextWindow(const char *str_id, ImGuiPopupFlags popup_flags, std::invocable<> auto next)
bool TreeNode(const char *label, ImGuiTreeNodeFlags flags, std::invocable<> auto next)
void Combo(const char *label, const char *preview_value, ImGuiComboFlags flags, std::invocable<> auto next)
void ItemWidth(float item_width, std::invocable<> auto next)
void ListBox(const char *label, const ImVec2 &size, std::invocable<> auto next)
void StyleColor(bool active, Args &&...args)
void Child(const char *str_id, const ImVec2 &size, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags, std::invocable<> auto next)
void PopupModal(const char *name, bool *p_open, ImGuiWindowFlags flags, std::invocable<> auto next)
void TextWrapPos(float wrap_local_pos_x, std::invocable<> auto next)
bool Menu(const char *label, bool enabled, std::invocable<> auto next)
void Disabled(bool b, std::invocable<> auto next)
void Group(std::invocable<> auto next)
void Font(ImFont *font, std::invocable<> auto next)
void TabItem(const char *label, bool *p_open, ImGuiTabItemFlags flags, std::invocable<> auto next)
void Tooltip(std::invocable<> auto next)
void Indent(float indent_w, std::invocable<> auto next)
void ListClipper(size_t count, int forceIndex, float lineHeight, std::invocable< int > auto next)
void ListClipperID(size_t count, std::invocable< int > auto next)
void Popup(const char *str_id, ImGuiWindowFlags flags, std::invocable<> auto next)
void ID_for_range(std::integral auto count, std::invocable< int > auto next)
void ItemTooltip(std::invocable<> auto next)
ScopedFont(const ScopedFont &)=delete
ScopedFont(ScopedFont &&)=delete
ScopedFont & operator=(ScopedFont &&)=delete
ScopedFont & operator=(const ScopedFont &)=delete
constexpr auto xrange(T e)
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)