| 3558 | } |
| 3559 | |
| 3560 | bool IGFD::KeyExplorerFeature::m_FlashableSelectable(const char* label, bool selected, ImGuiSelectableFlags flags, bool vFlashing, const ImVec2& size_arg) { |
| 3561 | using namespace ImGui; |
| 3562 | |
| 3563 | ImGuiWindow* window = GetCurrentWindow(); |
| 3564 | if (window->SkipItems) return false; |
| 3565 | |
| 3566 | ImGuiContext& g = *GImGui; |
| 3567 | const ImGuiStyle& style = g.Style; |
| 3568 | |
| 3569 | // Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle. |
| 3570 | ImGuiID id = window->GetID(label); |
| 3571 | ImVec2 label_size = CalcTextSize(label, NULL, true); |
| 3572 | ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); |
| 3573 | ImVec2 pos = window->DC.CursorPos; |
| 3574 | pos.y += window->DC.CurrLineTextBaseOffset; |
| 3575 | ItemSize(size, 0.0f); |
| 3576 | |
| 3577 | // Fill horizontal space |
| 3578 | // We don't support (size < 0.0f) in Selectable() because the ItemSpacing extension would make explicitly right-aligned sizes not visibly match other widgets. |
| 3579 | const bool span_all_columns = (flags & ImGuiSelectableFlags_SpanAllColumns) != 0; |
| 3580 | const float min_x = span_all_columns ? window->ParentWorkRect.Min.x : pos.x; |
| 3581 | const float max_x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x; |
| 3582 | if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth)) size.x = ImMax(label_size.x, max_x - min_x); |
| 3583 | |
| 3584 | // Text stays at the submission position, but bounding box may be extended on both sides |
| 3585 | const ImVec2 text_min = pos; |
| 3586 | const ImVec2 text_max(min_x + size.x, pos.y + size.y); |
| 3587 | |
| 3588 | // Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable. |
| 3589 | // FIXME: Not part of layout so not included in clipper calculation, but ItemSize currenty doesn't allow offsetting CursorPos. |
| 3590 | ImRect bb(min_x, pos.y, text_max.x, text_max.y); |
| 3591 | if ((flags & ImGuiSelectableFlags_NoPadWithHalfSpacing) == 0) { |
| 3592 | const float spacing_x = span_all_columns ? 0.0f : style.ItemSpacing.x; |
| 3593 | const float spacing_y = style.ItemSpacing.y; |
| 3594 | const float spacing_L = IM_TRUNC(spacing_x * 0.50f); |
| 3595 | const float spacing_U = IM_TRUNC(spacing_y * 0.50f); |
| 3596 | bb.Min.x -= spacing_L; |
| 3597 | bb.Min.y -= spacing_U; |
| 3598 | bb.Max.x += (spacing_x - spacing_L); |
| 3599 | bb.Max.y += (spacing_y - spacing_U); |
| 3600 | } |
| 3601 | // if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(0, 255, 0, 255)); } |
| 3602 | |
| 3603 | // Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackgroundChannel for every Selectable.. |
| 3604 | const float backup_clip_rect_min_x = window->ClipRect.Min.x; |
| 3605 | const float backup_clip_rect_max_x = window->ClipRect.Max.x; |
| 3606 | if (span_all_columns) { |
| 3607 | window->ClipRect.Min.x = window->ParentWorkRect.Min.x; |
| 3608 | window->ClipRect.Max.x = window->ParentWorkRect.Max.x; |
| 3609 | } |
| 3610 | |
| 3611 | const bool disabled_item = (flags & ImGuiSelectableFlags_Disabled) != 0; |
| 3612 | const bool is_visible = ItemAdd(bb, id, NULL, disabled_item ? (ImGuiItemFlags)ImGuiItemFlags_Disabled : ImGuiItemFlags_None); |
| 3613 | |
| 3614 | if (span_all_columns) { |
| 3615 | window->ClipRect.Min.x = backup_clip_rect_min_x; |
| 3616 | window->ClipRect.Max.x = backup_clip_rect_max_x; |
| 3617 | } |
nothing calls this directly
no outgoing calls
no test coverage detected