mirror of
https://github.com/Drezil/imgui.git
synced 2025-04-01 17:02:45 +00:00
Nav: Added code to render thin highlight type. (#787)
This commit is contained in:
parent
6ea90af6b7
commit
a56b71e866
13
imgui.cpp
13
imgui.cpp
@ -2148,15 +2148,19 @@ static bool NavScoreItem(ImRect cand)
|
|||||||
return new_best;
|
return new_best;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id)
|
void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (id != g.NavId || g.NavDisableHighlight)
|
if (id != g.NavId)
|
||||||
|
return;
|
||||||
|
if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysRender))
|
||||||
return;
|
return;
|
||||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
|
|
||||||
ImRect display_rect = bb;
|
ImRect display_rect = bb;
|
||||||
display_rect.ClipWith(window->ClipRect);
|
display_rect.ClipWith(window->ClipRect);
|
||||||
|
if (flags & ImGuiNavHighlightFlags_TypeDefault)
|
||||||
|
{
|
||||||
const float THICKNESS = 2.0f;
|
const float THICKNESS = 2.0f;
|
||||||
const float DISTANCE = 3.0f + THICKNESS * 0.5f;
|
const float DISTANCE = 3.0f + THICKNESS * 0.5f;
|
||||||
display_rect.Expand(ImVec2(DISTANCE,DISTANCE));
|
display_rect.Expand(ImVec2(DISTANCE,DISTANCE));
|
||||||
@ -2167,6 +2171,11 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id)
|
|||||||
if (!fully_visible)
|
if (!fully_visible)
|
||||||
window->DrawList->PopClipRect();
|
window->DrawList->PopClipRect();
|
||||||
}
|
}
|
||||||
|
if (flags & ImGuiNavHighlightFlags_TypeThin)
|
||||||
|
{
|
||||||
|
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), g.Style.FrameRounding, ~0, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Declare item bounding box for clipping and interaction.
|
// Declare item bounding box for clipping and interaction.
|
||||||
// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
|
// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
|
||||||
|
@ -51,6 +51,7 @@ typedef int ImGuiTreeNodeFlags; // enum ImGuiTreeNodeFlags_
|
|||||||
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
typedef int ImGuiSliderFlags; // enum ImGuiSliderFlags_
|
||||||
typedef int ImGuiSeparatorFlags; // enum ImGuiSeparatorFlags_
|
typedef int ImGuiSeparatorFlags; // enum ImGuiSeparatorFlags_
|
||||||
typedef int ImGuiItemFlags; // enum ImGuiItemFlags_
|
typedef int ImGuiItemFlags; // enum ImGuiItemFlags_
|
||||||
|
typedef int ImGuiNavHighlightFlags;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// STB libraries
|
// STB libraries
|
||||||
@ -250,6 +251,13 @@ enum ImGuiDir
|
|||||||
ImGuiDir_Down = 3
|
ImGuiDir_Down = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ImGuiNavHighlightFlags_
|
||||||
|
{
|
||||||
|
ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
|
||||||
|
ImGuiNavHighlightFlags_TypeThin = 1 << 1,
|
||||||
|
ImGuiNavHighlightFlags_AlwaysRender = 1 << 2
|
||||||
|
};
|
||||||
|
|
||||||
enum ImGuiCorner
|
enum ImGuiCorner
|
||||||
{
|
{
|
||||||
ImGuiCorner_TopLeft = 1 << 0, // 1
|
ImGuiCorner_TopLeft = 1 << 0, // 1
|
||||||
@ -895,7 +903,7 @@ namespace ImGui
|
|||||||
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
|
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
|
||||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
||||||
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id); // Navigation highlight
|
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
|
||||||
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
||||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user