mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Added TextColored() helper. Changed some parameters to const references (still allows implicit casting)
This commit is contained in:
parent
9169b2911c
commit
2bc6346b48
30
imgui.cpp
30
imgui.cpp
@ -1697,7 +1697,7 @@ void SetTooltip(const char* fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void SetNewWindowDefaultPos(ImVec2 pos)
|
||||
void SetNewWindowDefaultPos(const ImVec2& pos)
|
||||
{
|
||||
ImGuiState& g = GImGui;
|
||||
g.NewWindowDefaultPos = pos;
|
||||
@ -2196,7 +2196,7 @@ void PopAllowKeyboardFocus()
|
||||
window->DC.AllowKeyboardFocus.pop_back();
|
||||
}
|
||||
|
||||
void PushStyleColor(ImGuiCol idx, ImVec4 col)
|
||||
void PushStyleColor(ImGuiCol idx, const ImVec4& col)
|
||||
{
|
||||
ImGuiState& g = GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
@ -2284,7 +2284,7 @@ ImVec2 GetWindowPos()
|
||||
return window->Pos;
|
||||
}
|
||||
|
||||
void SetWindowPos(ImVec2 pos)
|
||||
void SetWindowPos(const ImVec2& pos)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
window->Pos = pos;
|
||||
@ -2342,10 +2342,10 @@ ImVec2 GetCursorPos()
|
||||
return window->DC.CursorPos - window->Pos;
|
||||
}
|
||||
|
||||
void SetCursorPos(ImVec2 p)
|
||||
void SetCursorPos(const ImVec2& pos)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
window->DC.CursorPos = window->Pos + p;
|
||||
window->DC.CursorPos = window->Pos + pos;
|
||||
}
|
||||
|
||||
void SetScrollPosHere()
|
||||
@ -2385,6 +2385,16 @@ void Text(const char* fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void TextColored(const ImVec4& col, const char* fmt, ...)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, col);
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
TextV(fmt, args);
|
||||
va_end(args);
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
void TextUnformatted(const char* text, const char* text_end)
|
||||
{
|
||||
ImGuiState& g = GImGui;
|
||||
@ -4409,7 +4419,7 @@ bool IsClipped(const ImGuiAabb& bb)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsClipped(ImVec2 item_size)
|
||||
bool IsClipped(const ImVec2& item_size)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
return IsClipped(ImGuiAabb(window->DC.CursorPos, window->DC.CursorPos + item_size));
|
||||
@ -5441,6 +5451,14 @@ void ShowTestWindow(bool* open)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Colored Text"))
|
||||
{
|
||||
// This is a merely a shortcut, you can use PushStyleColor()/PopStyleColor() for more flexibility.
|
||||
ImGui::TextColored(ImVec4(1.0f,0.0f,1.0f,1.0f), "Pink");
|
||||
ImGui::TextColored(ImVec4(1.0f,1.0f,0.0f,1.0f), "Yellow");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
static int e = 0;
|
||||
ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine();
|
||||
ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine();
|
||||
|
13
imgui.h
13
imgui.h
@ -135,7 +135,7 @@ namespace ImGui
|
||||
bool GetWindowIsFocused();
|
||||
float GetWindowWidth();
|
||||
ImVec2 GetWindowPos(); // you should rarely need/care about the window position, but it can be useful if you want to use your own drawing
|
||||
void SetWindowPos(ImVec2 pos); // unchecked
|
||||
void SetWindowPos(const ImVec2& pos); // unchecked
|
||||
ImVec2 GetWindowSize();
|
||||
ImVec2 GetWindowContentRegionMin();
|
||||
ImVec2 GetWindowContentRegionMax();
|
||||
@ -149,7 +149,7 @@ namespace ImGui
|
||||
float GetItemWidth();
|
||||
void PushAllowKeyboardFocus(bool v);
|
||||
void PopAllowKeyboardFocus();
|
||||
void PushStyleColor(ImGuiCol idx, ImVec4 col);
|
||||
void PushStyleColor(ImGuiCol idx, const ImVec4& col);
|
||||
void PopStyleColor();
|
||||
|
||||
// Layout
|
||||
@ -161,8 +161,8 @@ namespace ImGui
|
||||
float GetColumnOffset(int column_index = -1);
|
||||
void SetColumnOffset(int column_index, float offset);
|
||||
float GetColumnWidth(int column_index = -1);
|
||||
ImVec2 GetCursorPos(); // cursor position relative to window position
|
||||
void SetCursorPos(ImVec2 p);
|
||||
ImVec2 GetCursorPos(); // cursor position is relative to window position
|
||||
void SetCursorPos(const ImVec2& pos); // "
|
||||
void AlignFirstTextHeightToWidgets(); // call once if the first item on the line is a Text() item and you want to vertically lower it to match higher widgets.
|
||||
float GetTextLineSpacing();
|
||||
float GetTextLineHeight();
|
||||
@ -176,6 +176,7 @@ namespace ImGui
|
||||
// Widgets
|
||||
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 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 BulletText(const char* fmt, ...);
|
||||
@ -230,11 +231,11 @@ namespace ImGui
|
||||
|
||||
// Utilities
|
||||
void SetTooltip(const char* fmt, ...); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). (currently no contention handling, last call win)
|
||||
void SetNewWindowDefaultPos(ImVec2 pos); // set position of window that do
|
||||
void SetNewWindowDefaultPos(const ImVec2& pos); // set position of window that do
|
||||
bool IsHovered(); // was the last item active area hovered by mouse?
|
||||
ImVec2 GetItemBoxMin(); // get bounding box of last item
|
||||
ImVec2 GetItemBoxMax(); // get bounding box of last item
|
||||
bool IsClipped(ImVec2 item_size); // to perform coarse clipping on user's side (as an optimisation)
|
||||
bool IsClipped(const ImVec2& item_size); // to perform coarse clipping on user's side (as an optimisation)
|
||||
bool IsKeyPressed(int key_index, bool repeat = true); // key_index into the keys_down[512] array, imgui doesn't know the semantic of each entry
|
||||
bool IsMouseClicked(int button, bool repeat = false);
|
||||
bool IsMouseDoubleClicked(int button);
|
||||
|
Loading…
Reference in New Issue
Block a user