Added va_list variations of all functions taking ... parameters (from Andrea Pessino)
This commit is contained in:
parent
8eafb373f7
commit
746951691a
76
imgui.cpp
76
imgui.cpp
@ -1844,13 +1844,18 @@ ImVec2 GetItemBoxMax()
|
|||||||
return window->DC.LastItemAabb.Max;
|
return window->DC.LastItemAabb.Max;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tooltip is sorted and turned into a BeginTooltip()/EndTooltip() sequence at the end of the frame. Each call override previous value.
|
// Tooltip is stored and turned into a BeginTooltip()/EndTooltip() sequence at the end of the frame. Each call override previous value.
|
||||||
void SetTooltip(const char* fmt, ...)
|
void SetTooltipV(const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
ImGuiState& g = GImGui;
|
ImGuiState& g = GImGui;
|
||||||
|
ImFormatStringV(g.Tooltip, IM_ARRAYSIZE(g.Tooltip), fmt, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetTooltip(const char* fmt, ...)
|
||||||
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
ImFormatStringV(g.Tooltip, IM_ARRAYSIZE(g.Tooltip), fmt, args);
|
SetTooltipV(fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2636,14 +2641,19 @@ void Text(const char* fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextColored(const ImVec4& col, const char* fmt, ...)
|
void TextColoredV(const ImVec4& col, const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, col);
|
ImGui::PushStyleColor(ImGuiCol_Text, col);
|
||||||
|
TextV(fmt, args);
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextColored(const ImVec4& col, const char* fmt, ...)
|
||||||
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
TextV(fmt, args);
|
TextColoredV(col, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
ImGui::PopStyleColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextUnformatted(const char* text, const char* text_end)
|
void TextUnformatted(const char* text, const char* text_end)
|
||||||
@ -2758,7 +2768,7 @@ void AlignFirstTextHeightToWidgets()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a label+text combo aligned to other label+value widgets
|
// Add a label+text combo aligned to other label+value widgets
|
||||||
void LabelText(const char* label, const char* fmt, ...)
|
void LabelTextV(const char* label, const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
ImGuiState& g = GImGui;
|
ImGuiState& g = GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
@ -2768,11 +2778,8 @@ void LabelText(const char* label, const char* fmt, ...)
|
|||||||
const float w = window->DC.ItemWidth.back();
|
const float w = window->DC.ItemWidth.back();
|
||||||
|
|
||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
const char* text_begin = &buf[0];
|
const char* text_begin = &buf[0];
|
||||||
const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
const ImVec2 text_size = CalcTextSize(label);
|
const ImVec2 text_size = CalcTextSize(label);
|
||||||
const ImGuiAabb value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + style.FramePadding.x*2, text_size.y));
|
const ImGuiAabb value_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w + style.FramePadding.x*2, text_size.y));
|
||||||
@ -2787,6 +2794,14 @@ void LabelText(const char* label, const char* fmt, ...)
|
|||||||
RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y), label);
|
RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y), label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LabelText(const char* label, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
LabelTextV(label, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
static bool ButtonBehaviour(const ImGuiAabb& bb, const ImGuiID& id, bool* out_hovered, bool* out_held, bool allow_key_modifiers, bool repeat)
|
static bool ButtonBehaviour(const ImGuiAabb& bb, const ImGuiID& id, bool* out_hovered, bool* out_held, bool allow_key_modifiers, bool repeat)
|
||||||
{
|
{
|
||||||
ImGuiState& g = GImGui;
|
ImGuiState& g = GImGui;
|
||||||
@ -3080,7 +3095,7 @@ bool CollapsingHeader(const char* label, const char* str_id, const bool display_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Text with a little bullet aligned to the typical tree node.
|
// Text with a little bullet aligned to the typical tree node.
|
||||||
void BulletText(const char* fmt, ...)
|
void BulletTextV(const char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
ImGuiState& g = GImGui;
|
ImGuiState& g = GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
@ -3088,11 +3103,8 @@ void BulletText(const char* fmt, ...)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
static char buf[1024];
|
static char buf[1024];
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
const char* text_begin = buf;
|
const char* text_begin = buf;
|
||||||
const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
const float line_height = window->FontSize();
|
const float line_height = window->FontSize();
|
||||||
const ImVec2 text_size = CalcTextSize(text_begin, text_end);
|
const ImVec2 text_size = CalcTextSize(text_begin, text_end);
|
||||||
@ -3108,14 +3120,19 @@ void BulletText(const char* fmt, ...)
|
|||||||
RenderText(bb.Min+ImVec2(window->FontSize()+g.Style.FramePadding.x*2,0), text_begin, text_end);
|
RenderText(bb.Min+ImVec2(window->FontSize()+g.Style.FramePadding.x*2,0), text_begin, text_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If returning 'true' the node is open and the user is responsible for calling TreePop
|
void BulletText(const char* fmt, ...)
|
||||||
bool TreeNode(const char* str_id, const char* fmt, ...)
|
|
||||||
{
|
{
|
||||||
static char buf[1024];
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
BulletTextV(fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If returning 'true' the node is open and the user is responsible for calling TreePop
|
||||||
|
bool TreeNodeV(const char* str_id, const char* fmt, va_list args)
|
||||||
|
{
|
||||||
|
static char buf[1024];
|
||||||
|
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||||
|
|
||||||
if (!str_id || !str_id[0])
|
if (!str_id || !str_id[0])
|
||||||
str_id = fmt;
|
str_id = fmt;
|
||||||
@ -3130,14 +3147,20 @@ bool TreeNode(const char* str_id, const char* fmt, ...)
|
|||||||
return opened;
|
return opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If returning 'true' the node is open and the user is responsible for calling TreePop
|
bool TreeNode(const char* str_id, const char* fmt, ...)
|
||||||
bool TreeNode(const void* ptr_id, const char* fmt, ...)
|
|
||||||
{
|
{
|
||||||
static char buf[1024];
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
bool s = TreeNodeV(str_id, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If returning 'true' the node is open and the user is responsible for calling TreePop
|
||||||
|
bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args)
|
||||||
|
{
|
||||||
|
static char buf[1024];
|
||||||
|
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||||
|
|
||||||
if (!ptr_id)
|
if (!ptr_id)
|
||||||
ptr_id = fmt;
|
ptr_id = fmt;
|
||||||
@ -3152,6 +3175,15 @@ bool TreeNode(const void* ptr_id, const char* fmt, ...)
|
|||||||
return opened;
|
return opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TreeNode(const void* ptr_id, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
bool s = TreeNodeV(ptr_id, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
bool TreeNode(const char* str_label_id)
|
bool TreeNode(const char* str_label_id)
|
||||||
{
|
{
|
||||||
return TreeNode(str_label_id, "%s", str_label_id);
|
return TreeNode(str_label_id, "%s", str_label_id);
|
||||||
|
6
imgui.h
6
imgui.h
@ -163,6 +163,7 @@ namespace ImGui
|
|||||||
|
|
||||||
// Tooltip
|
// Tooltip
|
||||||
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
|
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins.
|
||||||
|
void SetTooltipV(const char* fmt, va_list args);
|
||||||
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
|
void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text.
|
||||||
void EndTooltip();
|
void EndTooltip();
|
||||||
|
|
||||||
@ -194,9 +195,12 @@ namespace ImGui
|
|||||||
void Text(const char* fmt, ...);
|
void Text(const char* fmt, ...);
|
||||||
void TextV(const char* fmt, va_list args);
|
void TextV(const char* fmt, va_list args);
|
||||||
void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut to doing PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
void TextColored(const ImVec4& col, const char* fmt, ...); // shortcut to doing PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();
|
||||||
|
void TextColoredV(const ImVec4& col, const char* fmt, va_list args);
|
||||||
void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, better for long chunks of text.
|
void TextUnformatted(const char* text, const char* text_end = NULL); // doesn't require null terminated string if 'text_end' is specified. no copy done to any bounded stack buffer, better for long chunks of text.
|
||||||
void LabelText(const char* label, const char* fmt, ...);
|
void LabelText(const char* label, const char* fmt, ...);
|
||||||
|
void LabelTextV(const char* label, const char* fmt, va_list args);
|
||||||
void BulletText(const char* fmt, ...);
|
void BulletText(const char* fmt, ...);
|
||||||
|
void BulletTextV(const char* fmt, va_list args);
|
||||||
bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false);
|
bool Button(const char* label, ImVec2 size = ImVec2(0,0), bool repeat_when_held = false);
|
||||||
bool SmallButton(const char* label);
|
bool SmallButton(const char* label);
|
||||||
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
|
bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
|
||||||
@ -228,6 +232,8 @@ namespace ImGui
|
|||||||
bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
|
bool TreeNode(const char* str_label_id); // if returning 'true' the node is open and the user is responsible for calling TreePop
|
||||||
bool TreeNode(const char* str_id, const char* fmt, ...); // "
|
bool TreeNode(const char* str_id, const char* fmt, ...); // "
|
||||||
bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
|
bool TreeNode(const void* ptr_id, const char* fmt, ...); // "
|
||||||
|
bool TreeNodeV(const char* str_id, const char* fmt, va_list args); // "
|
||||||
|
bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args); // "
|
||||||
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
|
void TreePush(const char* str_id = NULL); // already called by TreeNode(), but you can call Push/Pop yourself for layouting purpose
|
||||||
void TreePush(const void* ptr_id = NULL); // "
|
void TreePush(const void* ptr_id = NULL); // "
|
||||||
void TreePop();
|
void TreePop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user