mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 08:49:02 +08:00
Nav: Added ImGuiCol_NavWindowingHighlight into style (#323)
This commit is contained in:
parent
6aa8019763
commit
a68132948b
11
imgui.cpp
11
imgui.cpp
@ -833,6 +833,7 @@ ImGuiStyle::ImGuiStyle()
|
|||||||
Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
||||||
Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
||||||
Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
|
Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
|
||||||
|
Colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.12f);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiIO::ImGuiIO()
|
ImGuiIO::ImGuiIO()
|
||||||
@ -1961,8 +1962,7 @@ static float NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scoring function for directional navigation. Based on https://gist.github.com/rygorous/6981057
|
// Scoring function for directional navigation. Based on https://gist.github.com/rygorous/6981057
|
||||||
// FIXME-NAVIGATION: Pretty rough.
|
// FIXME-NAVIGATION: Pretty rough. Also may want to handle the degenerate case that we have commented out.
|
||||||
// FIXME-NAVIGATION: May want to handle the degenerate case that we have commented out.
|
|
||||||
static bool NavScoreItem(ImRect cand)
|
static bool NavScoreItem(ImRect cand)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
@ -2540,7 +2540,6 @@ static void NavUpdate()
|
|||||||
g.NavWindowingToggleLayer &= (g.NavWindowingDisplayAlpha < 1.0f); // Once button is held long enough we don't consider it a tag-to-toggle-layer press anymore.
|
g.NavWindowingToggleLayer &= (g.NavWindowingDisplayAlpha < 1.0f); // Once button is held long enough we don't consider it a tag-to-toggle-layer press anymore.
|
||||||
|
|
||||||
// Select window to focus
|
// Select window to focus
|
||||||
// FIXME-NAVIGATION: Need to clarify input semantic, naming is misleading/incorrect here.
|
|
||||||
const int focus_change_dir = (int)IsNavInputPressed(ImGuiNavInput_PadFocusPrev, ImGuiNavReadMode_RepeatSlow) - (int)IsNavInputPressed(ImGuiNavInput_PadFocusNext, ImGuiNavReadMode_RepeatSlow);
|
const int focus_change_dir = (int)IsNavInputPressed(ImGuiNavInput_PadFocusPrev, ImGuiNavReadMode_RepeatSlow) - (int)IsNavInputPressed(ImGuiNavInput_PadFocusNext, ImGuiNavReadMode_RepeatSlow);
|
||||||
if (focus_change_dir != 0 && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal))
|
if (focus_change_dir != 0 && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal))
|
||||||
{
|
{
|
||||||
@ -4868,13 +4867,12 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
|||||||
window->DrawList->AddRectFilled(fullscreen_rect.Min, fullscreen_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio));
|
window->DrawList->AddRectFilled(fullscreen_rect.Min, fullscreen_rect.Max, GetColorU32(ImGuiCol_ModalWindowDarkening, g.ModalWindowDarkeningRatio));
|
||||||
|
|
||||||
// Navigation windowing (via ImGuiKey_NavWindowing key) shows whole window selected
|
// Navigation windowing (via ImGuiKey_NavWindowing key) shows whole window selected
|
||||||
// FIXME-NAVIGATION: Styling
|
|
||||||
if (g.NavWindowingTarget == window)
|
if (g.NavWindowingTarget == window)
|
||||||
{
|
{
|
||||||
ImRect bb = window->Rect();
|
ImRect bb = window->Rect();
|
||||||
bb.Expand(g.FontSize);
|
bb.Expand(g.FontSize);
|
||||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, IM_COL32(255,255,255,(int)(30 * g.NavWindowingDisplayAlpha))/*ImGui::GetColorU32(ImGuiCol_HeaderHovered, 0.15f)*/, g.Style.WindowRounding);
|
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingDisplayAlpha), g.Style.WindowRounding);
|
||||||
window->DrawList->AddRect(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_HeaderHovered, g.NavWindowingDisplayAlpha), g.Style.WindowRounding);
|
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_HeaderHovered, g.NavWindowingDisplayAlpha), g.Style.WindowRounding);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw window + handle manual resize
|
// Draw window + handle manual resize
|
||||||
@ -5586,6 +5584,7 @@ const char* ImGui::GetStyleColName(ImGuiCol idx)
|
|||||||
case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
|
case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
|
||||||
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
|
||||||
case ImGuiCol_ModalWindowDarkening: return "ModalWindowDarkening";
|
case ImGuiCol_ModalWindowDarkening: return "ModalWindowDarkening";
|
||||||
|
case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
|
||||||
}
|
}
|
||||||
IM_ASSERT(0);
|
IM_ASSERT(0);
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
|
1
imgui.h
1
imgui.h
@ -665,6 +665,7 @@ enum ImGuiCol_
|
|||||||
ImGuiCol_PlotHistogramHovered,
|
ImGuiCol_PlotHistogramHovered,
|
||||||
ImGuiCol_TextSelectedBg,
|
ImGuiCol_TextSelectedBg,
|
||||||
ImGuiCol_ModalWindowDarkening, // darken entire screen when a modal window is active
|
ImGuiCol_ModalWindowDarkening, // darken entire screen when a modal window is active
|
||||||
|
ImGuiCol_NavWindowingHighlight, // when holding NavMenu to focus/move/resize windows
|
||||||
ImGuiCol_COUNT
|
ImGuiCol_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user