mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 19:29:58 +01:00
ImGuiToolkit to render a Disabled Button
This commit is contained in:
@@ -72,6 +72,33 @@ bool ImGuiToolkit::ButtonToggle( const char* label, bool* toggle, const char *to
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGuiToolkit::ButtonDisabled(const char* label, const ImVec2 &size_arg)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
|
if (window->SkipItems)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
const ImGuiStyle& style = g.Style;
|
||||||
|
const ImGuiID id = window->GetID(label);
|
||||||
|
const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);
|
||||||
|
|
||||||
|
ImVec2 pos = window->DC.CursorPos;
|
||||||
|
ImVec2 size = ImGui::CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f);
|
||||||
|
|
||||||
|
const ImRect bb(pos, pos + size);
|
||||||
|
ImGui::ItemSize(size, style.FramePadding.y);
|
||||||
|
if (!ImGui::ItemAdd(bb, id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Render
|
||||||
|
const ImU32 col = ImGui::GetColorU32(ImGuiCol_FrameBg);
|
||||||
|
ImGui::RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
||||||
|
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetColorU32(ImGuiCol_TextDisabled));
|
||||||
|
ImGui::RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb);
|
||||||
|
ImGui::PopStyleColor(1);
|
||||||
|
}
|
||||||
|
|
||||||
bool ImGuiToolkit::ButtonSwitch(const char* label, bool* toggle, const char* shortcut)
|
bool ImGuiToolkit::ButtonSwitch(const char* label, bool* toggle, const char* shortcut)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace ImGuiToolkit
|
|||||||
bool ButtonToggle (const char* label, bool* toggle, const char *tooltip = nullptr);
|
bool ButtonToggle (const char* label, bool* toggle, const char *tooltip = nullptr);
|
||||||
bool ButtonSwitch (const char* label, bool* toggle, const char *shortcut = nullptr);
|
bool ButtonSwitch (const char* label, bool* toggle, const char *shortcut = nullptr);
|
||||||
void ButtonOpenUrl (const char* label, const char* url, const ImVec2& size_arg = ImVec2(0,0));
|
void ButtonOpenUrl (const char* label, const char* url, const ImVec2& size_arg = ImVec2(0,0));
|
||||||
|
void ButtonDisabled(const char* label, const ImVec2& size_arg = ImVec2(0,0));
|
||||||
|
|
||||||
// tooltip and mouse over help
|
// tooltip and mouse over help
|
||||||
void setToolTipsEnabled (bool on);
|
void setToolTipsEnabled (bool on);
|
||||||
|
|||||||
Reference in New Issue
Block a user