mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 07:40:22 +01:00
Internals: Merge of harmless stuff from Navigation stuff. Added GetHoveredID() internal helper.
This commit is contained in:
parent
16285603f2
commit
1493de4f81
11
imgui.cpp
11
imgui.cpp
@ -1952,6 +1952,12 @@ void ImGui::SetHoveredID(ImGuiID id)
|
||||
g.HoveredIdTimer = (id != 0 && g.HoveredIdPreviousFrame == id) ? (g.HoveredIdTimer + g.IO.DeltaTime) : 0.0f;
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetHoveredID()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame;
|
||||
}
|
||||
|
||||
void ImGui::KeepAliveID(ImGuiID id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -4773,6 +4779,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
const float window_rounding = window->WindowRounding;
|
||||
const float window_border_size = window->WindowBorderSize;
|
||||
ImRect title_bar_rect = window->TitleBarRect();
|
||||
const bool window_is_focused = want_focus || (g.NavWindow && window->RootNonPopupWindow == g.NavWindow->RootNonPopupWindow);
|
||||
if (window->Collapsed)
|
||||
{
|
||||
// Title bar only
|
||||
@ -4788,7 +4795,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
||||
|
||||
// Title bar
|
||||
const bool window_is_focused = want_focus || (g.NavWindow && window->RootNonPopupWindow == g.NavWindow->RootNonPopupWindow);
|
||||
if (!(flags & ImGuiWindowFlags_NoTitleBar))
|
||||
window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg), window_rounding, ImDrawCornerFlags_Top);
|
||||
|
||||
@ -6358,7 +6364,8 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
|
||||
if (!ItemAdd(bb, id))
|
||||
return false;
|
||||
|
||||
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat) flags |= ImGuiButtonFlags_Repeat;
|
||||
if (window->DC.ItemFlags & ImGuiItemFlags_ButtonRepeat)
|
||||
flags |= ImGuiButtonFlags_Repeat;
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags);
|
||||
|
||||
|
@ -1552,7 +1552,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
ImGui::OpenPopup("Stacked 2");
|
||||
if (ImGui::BeginPopupModal("Stacked 2"))
|
||||
{
|
||||
ImGui::Text("Hello from Stacked The Second");
|
||||
ImGui::Text("Hello from Stacked The Second!");
|
||||
if (ImGui::Button("Close"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::EndPopup();
|
||||
@ -1857,6 +1857,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf));
|
||||
if (ImGui::IsItemActive()) has_focus = 3;
|
||||
ImGui::PopAllowKeyboardFocus();
|
||||
|
||||
if (has_focus)
|
||||
ImGui::Text("Item with focus: %d", has_focus);
|
||||
else
|
||||
|
@ -880,6 +880,7 @@ namespace ImGui
|
||||
IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window);
|
||||
IMGUI_API void ClearActiveID();
|
||||
IMGUI_API void SetHoveredID(ImGuiID id);
|
||||
IMGUI_API ImGuiID GetHoveredID();
|
||||
IMGUI_API void KeepAliveID(ImGuiID id);
|
||||
|
||||
IMGUI_API void ItemSize(const ImVec2& size, float text_offset_y = 0.0f);
|
||||
|
Loading…
Reference in New Issue
Block a user