mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
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;
|
||||
}
|
||||
|
||||
// Tooltip is sorted and turned into a BeginTooltip()/EndTooltip() sequence at the end of the frame. Each call override previous value.
|
||||
void SetTooltip(const char* fmt, ...)
|
||||
// Tooltip is stored and turned into a BeginTooltip()/EndTooltip() sequence at the end of the frame. Each call override previous value.
|
||||
void SetTooltipV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiState& g = GImGui;
|
||||
ImFormatStringV(g.Tooltip, IM_ARRAYSIZE(g.Tooltip), fmt, args);
|
||||
}
|
||||
|
||||
void SetTooltip(const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ImFormatStringV(g.Tooltip, IM_ARRAYSIZE(g.Tooltip), fmt, args);
|
||||
SetTooltipV(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@ -2636,14 +2641,19 @@ void Text(const char* fmt, ...)
|
||||
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);
|
||||
TextV(fmt, args);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void TextColored(const ImVec4& col, const char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
TextV(fmt, args);
|
||||
TextColoredV(col, fmt, args);
|
||||
va_end(args);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
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
|
||||
void LabelText(const char* label, const char* fmt, ...)
|
||||
void LabelTextV(const char* label, const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiState& g = GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -2768,11 +2778,8 @@ void LabelText(const char* label, const char* fmt, ...)
|
||||
const float w = window->DC.ItemWidth.back();
|
||||
|
||||
static char buf[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
const char* text_begin = &buf[0];
|
||||
const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
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));
|
||||
@ -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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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.
|
||||
void BulletText(const char* fmt, ...)
|
||||
void BulletTextV(const char* fmt, va_list args)
|
||||
{
|
||||
ImGuiState& g = GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -3088,11 +3103,8 @@ void BulletText(const char* fmt, ...)
|
||||
return;
|
||||
|
||||
static char buf[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
const char* text_begin = buf;
|
||||
const char* text_end = text_begin + ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
const float line_height = window->FontSize();
|
||||
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);
|
||||
}
|
||||
|
||||
// If returning 'true' the node is open and the user is responsible for calling TreePop
|
||||
bool TreeNode(const char* str_id, const char* fmt, ...)
|
||||
void BulletText(const char* fmt, ...)
|
||||
{
|
||||
static char buf[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||
BulletTextV(fmt, 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])
|
||||
str_id = fmt;
|
||||
@ -3130,14 +3147,20 @@ bool TreeNode(const char* str_id, const char* fmt, ...)
|
||||
return opened;
|
||||
}
|
||||
|
||||
// If returning 'true' the node is open and the user is responsible for calling TreePop
|
||||
bool TreeNode(const void* ptr_id, const char* fmt, ...)
|
||||
bool TreeNode(const char* str_id, const char* fmt, ...)
|
||||
{
|
||||
static char buf[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||
bool s = TreeNodeV(str_id, fmt, 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)
|
||||
ptr_id = fmt;
|
||||
@ -3152,6 +3175,15 @@ bool TreeNode(const void* ptr_id, const char* fmt, ...)
|
||||
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)
|
||||
{
|
||||
return TreeNode(str_label_id, "%s", str_label_id);
|
||||
|
6
imgui.h
6
imgui.h
@ -163,6 +163,7 @@ namespace ImGui
|
||||
|
||||
// Tooltip
|
||||
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 EndTooltip();
|
||||
|
||||
@ -194,9 +195,12 @@ namespace ImGui
|
||||
void Text(const char* fmt, ...);
|
||||
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 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 LabelText(const char* label, const char* fmt, ...);
|
||||
void LabelTextV(const char* label, const char* fmt, va_list args);
|
||||
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 SmallButton(const char* label);
|
||||
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_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 void* ptr_id = NULL); // "
|
||||
void TreePop();
|
||||
|
Loading…
Reference in New Issue
Block a user