Added InvisibleButton()

This commit is contained in:
ocornut 2015-01-21 23:03:25 +01:00
parent dbffbacaf6
commit 26174cba85
2 changed files with 24 additions and 0 deletions

View File

@ -3599,6 +3599,29 @@ bool ImGui::SmallButton(const char* label)
return pressed;
}
// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack.
// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id)
bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size)
{
ImGuiState& g = GImGui;
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return false;
const ImGuiAabb bb(window->DC.CursorPos, window->DC.CursorPos + size);
ItemSize(bb);
if (ClipAdvance(bb))
return false;
const ImGuiID id = window->GetID(str_id);
bool hovered, held;
bool pressed = ButtonBehaviour(bb, id, &hovered, &held, true);
return pressed;
}
// Upper-right button to close a window.
static bool CloseWindowButton(bool* p_opened)
{

View File

@ -243,6 +243,7 @@ namespace ImGui
IMGUI_API void BulletTextV(const char* fmt, va_list args);
IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0,0), bool repeat_when_held = false);
IMGUI_API bool SmallButton(const char* label);
IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size);
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0,0), const ImVec2& uv1 = ImVec2(1,1), ImU32 tint_col = 0xFFFFFFFF, ImU32 border_col = 0x00000000);
IMGUI_API bool CollapsingHeader(const char* label, const char* str_id = NULL, const bool display_frame = true, const bool default_open = false);
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders.