Nav: Exposed RenderNavHighlight() in imgui_internal.h to increase discoverability and reordered arguments to be more consistent (#323)
This commit is contained in:
parent
6c19d7b13c
commit
cf16ba6572
24
imgui.cpp
24
imgui.cpp
@ -2074,7 +2074,7 @@ static bool NavScoreItem(ImRect cand)
|
||||
return new_best;
|
||||
}
|
||||
|
||||
static void RenderNavHighlight(ImU32 id, const ImRect& bb)
|
||||
void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (id != g.NavId || g.NavDisableHighlight)
|
||||
@ -4358,7 +4358,7 @@ void ImGui::EndChild()
|
||||
if (/*!(window->Flags & ImGuiWindowFlags_NavFlattened) &&*/ (window->DC.NavLayerActiveFlags != 0 || window->DC.NavHasScroll))
|
||||
{
|
||||
ItemAdd(bb, &id);
|
||||
RenderNavHighlight(id, bb);
|
||||
RenderNavHighlight(bb, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5093,7 +5093,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us
|
||||
ItemAdd(bb, &id); // To allow navigation
|
||||
if (ButtonBehavior(bb, id, NULL, NULL))
|
||||
window->CollapseToggleWanted = true; // Defer collapsing to next frame as we are too far in the Begin() function
|
||||
RenderNavHighlight(id, bb);
|
||||
RenderNavHighlight(bb, id);
|
||||
RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f, true);
|
||||
}
|
||||
|
||||
@ -6435,7 +6435,7 @@ bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags
|
||||
|
||||
// Render
|
||||
const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||
RenderNavHighlight(id, bb);
|
||||
RenderNavHighlight(bb, id);
|
||||
RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding);
|
||||
RenderTextClipped(bb.Min, bb.Max, label, NULL, &label_size, ImGuiAlign_Center | ImGuiAlign_VCenter);
|
||||
|
||||
@ -6565,7 +6565,7 @@ bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const I
|
||||
|
||||
// Render
|
||||
const ImU32 col = GetColorU32((hovered && held) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
|
||||
RenderNavHighlight(id, bb);
|
||||
RenderNavHighlight(bb, id);
|
||||
RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, style.FrameRounding));
|
||||
if (bg_col.w > 0.0f)
|
||||
window->DrawList->AddRectFilled(image_bb.Min, image_bb.Max, GetColorU32(bg_col));
|
||||
@ -7282,7 +7282,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
|
||||
|
||||
// Draw frame
|
||||
const ImU32 frame_col = GetColorU32((g.ActiveId == id && g.ActiveIdSource == ImGuiInputSource_Nav) ? ImGuiCol_FrameBgActive : ImGuiCol_FrameBg);
|
||||
RenderNavHighlight(id, frame_bb);
|
||||
RenderNavHighlight(frame_bb, id);
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding);
|
||||
|
||||
const bool is_non_linear = (power < 1.0f-0.00001f) && (power > 1.0f-0.00001f);
|
||||
@ -7647,7 +7647,7 @@ bool ImGui::DragBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_s
|
||||
|
||||
// Draw frame
|
||||
const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg);
|
||||
RenderNavHighlight(id, frame_bb);
|
||||
RenderNavHighlight(frame_bb, id);
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding);
|
||||
|
||||
bool value_changed = false;
|
||||
@ -8143,7 +8143,7 @@ bool ImGui::Checkbox(const char* label, bool* v)
|
||||
if (pressed)
|
||||
*v = !(*v);
|
||||
|
||||
RenderNavHighlight(id, total_bb);
|
||||
RenderNavHighlight(total_bb, id);
|
||||
RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
if (*v)
|
||||
{
|
||||
@ -8210,7 +8210,7 @@ bool ImGui::RadioButton(const char* label, bool active)
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
|
||||
|
||||
RenderNavHighlight(id, total_bb);
|
||||
RenderNavHighlight(total_bb, id);
|
||||
window->DrawList->AddCircleFilled(center, radius, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16);
|
||||
if (active)
|
||||
{
|
||||
@ -8906,7 +8906,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
// Select which buffer we are going to display. When ImGuiInputTextFlags_NoLiveEdit is set 'buf' might still be the old value. We set buf to NULL to prevent accidental usage from now on.
|
||||
const char* buf_display = (g.ActiveId == id && is_editable) ? edit_state.TempTextBuffer.Data : buf; buf = NULL;
|
||||
|
||||
RenderNavHighlight(id, frame_bb);
|
||||
RenderNavHighlight(frame_bb, id);
|
||||
if (!is_multiline)
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
|
||||
@ -9330,7 +9330,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi
|
||||
bool popup_open = IsPopupOpen(id);
|
||||
|
||||
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
||||
RenderNavHighlight(id, frame_bb);
|
||||
RenderNavHighlight(frame_bb, id);
|
||||
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
||||
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_open || hovered || navigated ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
||||
RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);
|
||||
@ -9861,7 +9861,7 @@ bool ImGui::ColorButton(const ImVec4& col, bool small_height, bool outline_borde
|
||||
|
||||
bool hovered, held;
|
||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
||||
RenderNavHighlight(id, bb);
|
||||
RenderNavHighlight(bb, id);
|
||||
RenderFrame(bb.Min, bb.Max, GetColorU32(col), outline_border, style.FrameRounding);
|
||||
|
||||
if (g.HoveredId == id)
|
||||
|
@ -804,6 +804,7 @@ namespace ImGui
|
||||
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f, bool shadow = false);
|
||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
||||
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id); // Navigation highlight
|
||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||
|
||||
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
|
||||
|
Loading…
Reference in New Issue
Block a user