mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 07:36:35 +00:00
SetItemDefaultFocus() use ScrollToRectEx(), don't tab when Alt is held either, TabItemEx() uses ItemAdd's extra_flags, misc comments.
This commit is contained in:
parent
ec6ca06898
commit
44f801186f
@ -326,6 +326,7 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line?)
|
||||
- nav: configuration flag to disable global shortcuts (currently only CTRL-Tab) ?
|
||||
! nav: never clear NavId on some setup (e.g. gamepad centric)
|
||||
- nav: scroll up/down if possible when move request fails
|
||||
- nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable.
|
||||
- nav: code to focus child-window on restoring NavId appears to have issue: e.g. when focus change is implicit because of window closure.
|
||||
- nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view?
|
||||
@ -353,8 +354,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
|
||||
- nav/windowing: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering.
|
||||
- nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied
|
||||
- focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
|
||||
- focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
|
||||
- focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787, #343)
|
||||
|
||||
- inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
|
||||
- inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
|
||||
|
27
imgui.cpp
27
imgui.cpp
@ -3829,7 +3829,10 @@ void ImGui::UpdateTabFocus()
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
||||
// Pressing TAB activate widget focus
|
||||
g.TabFocusPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && !IsActiveIdUsingKey(ImGuiKey_Tab));
|
||||
g.TabFocusPressed = false;
|
||||
if (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
|
||||
if (!g.IO.KeyCtrl && !g.IO.KeyAlt && IsKeyPressedMap(ImGuiKey_Tab) && !IsActiveIdUsingKey(ImGuiKey_Tab))
|
||||
g.TabFocusPressed = true;
|
||||
if (g.ActiveId == 0 && g.TabFocusPressed)
|
||||
{
|
||||
// - This path is only taken when no widget are active/tabbed-into yet.
|
||||
@ -7091,15 +7094,17 @@ void ImGui::SetItemDefaultFocus()
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (!window->Appearing)
|
||||
return;
|
||||
if (g.NavWindow == window->RootWindowForNav && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == window->DC.NavLayerCurrent)
|
||||
{
|
||||
g.NavInitRequest = false;
|
||||
g.NavInitResultId = g.LastItemData.ID;
|
||||
g.NavInitResultRectRel = ImRect(g.LastItemData.Rect.Min - window->Pos, g.LastItemData.Rect.Max - window->Pos);
|
||||
NavUpdateAnyRequestFlag();
|
||||
if (!IsItemVisible())
|
||||
SetScrollHereY();
|
||||
}
|
||||
if (g.NavWindow != window->RootWindowForNav || (!g.NavInitRequest && g.NavInitResultId == 0) || g.NavLayer != window->DC.NavLayerCurrent)
|
||||
return;
|
||||
|
||||
g.NavInitRequest = false;
|
||||
g.NavInitResultId = g.LastItemData.ID;
|
||||
g.NavInitResultRectRel = ImRect(g.LastItemData.Rect.Min - window->Pos, g.LastItemData.Rect.Max - window->Pos);
|
||||
NavUpdateAnyRequestFlag();
|
||||
|
||||
// Scroll could be done in NavInitRequestApplyResult() via a opt-in flag (we however don't want regular init requests to scroll)
|
||||
if (!IsItemVisible())
|
||||
ScrollToRectEx(window, g.LastItemData.Rect, ImGuiScrollFlags_None);
|
||||
}
|
||||
|
||||
void ImGui::SetStateStorage(ImGuiStorage* tree)
|
||||
@ -9323,7 +9328,7 @@ static void ImGui::NavUpdate()
|
||||
}
|
||||
g.NavIdIsAlive = false;
|
||||
g.NavJustTabbedId = 0;
|
||||
IM_ASSERT(g.NavLayer == 0 || g.NavLayer == 1);
|
||||
IM_ASSERT(g.NavLayer == ImGuiNavLayer_Main || g.NavLayer == ImGuiNavLayer_Menu);
|
||||
|
||||
// Store our return window (for returning from Menu Layer to Main Layer) and clear it as soon as we step back in our own Layer 0
|
||||
if (g.NavWindow)
|
||||
|
@ -744,7 +744,7 @@ enum ImGuiItemFlags_
|
||||
ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window
|
||||
ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets)
|
||||
ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed.
|
||||
ImGuiItemFlags_Inputable = 1 << 8 // false // [WIP] Auto-activate item when focused. Currently only used and supported by a few items before it becomes a generic feature.
|
||||
ImGuiItemFlags_Inputable = 1 << 8 // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature.
|
||||
};
|
||||
|
||||
// Storage for LastItem data
|
||||
|
@ -7879,9 +7879,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags);
|
||||
if (p_open && !*p_open)
|
||||
{
|
||||
PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true);
|
||||
ItemAdd(ImRect(), id);
|
||||
PopItemFlag();
|
||||
ItemAdd(ImRect(), id, NULL, ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7948,9 +7946,7 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
||||
// and then gets submitted again, the tabs will have 'tab_appearing=true' but 'tab_is_new=false'.
|
||||
if (tab_appearing && (!tab_bar_appearing || tab_is_new))
|
||||
{
|
||||
PushItemFlag(ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus, true);
|
||||
ItemAdd(ImRect(), id);
|
||||
PopItemFlag();
|
||||
ItemAdd(ImRect(), id, NULL, ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus);
|
||||
if (is_tab_button)
|
||||
return false;
|
||||
return tab_contents_visible;
|
||||
|
Loading…
Reference in New Issue
Block a user