mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-01 02:37:24 +01:00
Nav: Added code to render thin highlight type. (#787)
This commit is contained in:
parent
6ea90af6b7
commit
a56b71e866
31
imgui.cpp
31
imgui.cpp
@ -2148,24 +2148,33 @@ 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);
|
||||||
const float THICKNESS = 2.0f;
|
if (flags & ImGuiNavHighlightFlags_TypeDefault)
|
||||||
const float DISTANCE = 3.0f + THICKNESS * 0.5f;
|
{
|
||||||
display_rect.Expand(ImVec2(DISTANCE,DISTANCE));
|
const float THICKNESS = 2.0f;
|
||||||
bool fully_visible = window->ClipRect.Contains(display_rect);
|
const float DISTANCE = 3.0f + THICKNESS * 0.5f;
|
||||||
if (!fully_visible)
|
display_rect.Expand(ImVec2(DISTANCE,DISTANCE));
|
||||||
window->DrawList->PushClipRect(display_rect.Min, display_rect.Max);
|
bool fully_visible = window->ClipRect.Contains(display_rect);
|
||||||
window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), display_rect.Max - ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), GetColorU32(ImGuiCol_NavHighlight), g.Style.FrameRounding, 0x0F, THICKNESS);
|
if (!fully_visible)
|
||||||
if (!fully_visible)
|
window->DrawList->PushClipRect(display_rect.Min, display_rect.Max);
|
||||||
window->DrawList->PopClipRect();
|
window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), display_rect.Max - ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), GetColorU32(ImGuiCol_NavHighlight), g.Style.FrameRounding, 0x0F, THICKNESS);
|
||||||
|
if (!fully_visible)
|
||||||
|
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.
|
||||||
|
@ -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…
Reference in New Issue
Block a user