mirror of https://github.com/ocornut/imgui
Misc: Made it accepted to call SetMouseCursor() with any out-of-bound value, as a way to allow hacking in custom cursors if desirable.
This commit is contained in:
parent
4d00bf8add
commit
dab63231d8
|
@ -70,6 +70,8 @@ Other changes:
|
|||
(e.g. in our testing, handling of a 1 MB text buffer is now 3 times faster in VS2022 Debug build).
|
||||
This is the first step toward more refactorig. (#7925) [@alektron, @ocornut]
|
||||
- InputText: added CJK double-width punctuation to list of separators considered for CTRL+Arrow.
|
||||
- Misc: Made it accepted to call SetMouseCursor() with any out-of-bound value, as a way to allow
|
||||
hacking in custom cursors if desirable.
|
||||
- Fonts: fixed ellipsis "..." rendering width miscalculation bug introduced in 1.91.0. (#7976) [@DDeimos]
|
||||
- TextLinkOpenURL(): modified tooltip to display a verb "Open 'xxxx'". (#7885, #7660)
|
||||
- Backends: SDL2: use SDL_Vulkan_GetDrawableSize() when available. (#7967, #3190) [@scribam]
|
||||
|
|
10
imgui.cpp
10
imgui.cpp
|
@ -3702,7 +3702,8 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl
|
|||
void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
|
||||
if (mouse_cursor <= ImGuiMouseCursor_None || mouse_cursor >= ImGuiMouseCursor_COUNT) // We intentionally accept out of bound values.
|
||||
mouse_cursor = ImGuiMouseCursor_Arrow;
|
||||
ImFontAtlas* font_atlas = g.DrawListSharedData.Font->ContainerAtlas;
|
||||
for (ImGuiViewportP* viewport : g.Viewports)
|
||||
{
|
||||
|
@ -6198,7 +6199,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
|||
ButtonBehavior(resize_rect, resize_grip_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
|
||||
//GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
|
||||
if (hovered || held)
|
||||
g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE;
|
||||
SetMouseCursor((resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE);
|
||||
|
||||
if (held && g.IO.MouseDoubleClicked[0])
|
||||
{
|
||||
|
@ -6244,7 +6245,7 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
|||
if (hovered && g.HoveredIdTimer <= WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER)
|
||||
hovered = false;
|
||||
if (hovered || held)
|
||||
g.MouseCursor = (axis == ImGuiAxis_X) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS;
|
||||
SetMouseCursor((axis == ImGuiAxis_X) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS);
|
||||
if (held && g.IO.MouseDoubleClicked[0])
|
||||
{
|
||||
// Double-clicking bottom or right border auto-fit on this axis
|
||||
|
@ -9296,6 +9297,9 @@ ImGuiMouseCursor ImGui::GetMouseCursor()
|
|||
return g.MouseCursor;
|
||||
}
|
||||
|
||||
// We intentionally accept values of ImGuiMouseCursor that are outside our bounds, in case users needs to hack-in a custom cursor value.
|
||||
// Custom cursors may be handled by custom backends. If you are using a standard backend and want to hack in a custom cursor, you may
|
||||
// handle it before the backend _NewFrame() call and temporarily set ImGuiConfigFlags_NoMouseCursorChange during the backend _NewFrame() call.
|
||||
void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
|
@ -7490,7 +7490,8 @@ static void ShowDemoWindowInputs()
|
|||
IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT);
|
||||
|
||||
ImGuiMouseCursor current = ImGui::GetMouseCursor();
|
||||
ImGui::Text("Current mouse cursor = %d: %s", current, mouse_cursors_names[current]);
|
||||
const char* cursor_name = (current >= ImGuiMouseCursor_Arrow) && (current < ImGuiMouseCursor_COUNT) ? mouse_cursors_names[current] : "N/A";
|
||||
ImGui::Text("Current mouse cursor = %d: %s", current, cursor_name);
|
||||
ImGui::BeginDisabled(true);
|
||||
ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &io.BackendFlags, ImGuiBackendFlags_HasMouseCursors);
|
||||
ImGui::EndDisabled();
|
||||
|
|
|
@ -4409,7 +4409,7 @@ void ImGui::EndColumns()
|
|||
{
|
||||
ButtonBehavior(column_hit_rect, column_id, &hovered, &held);
|
||||
if (hovered || held)
|
||||
g.MouseCursor = ImGuiMouseCursor_ResizeEW;
|
||||
SetMouseCursor(ImGuiMouseCursor_ResizeEW);
|
||||
if (held && !(column->Flags & ImGuiOldColumnFlags_NoResize))
|
||||
dragging_column = n;
|
||||
}
|
||||
|
|
|
@ -4438,7 +4438,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||
}
|
||||
const bool hovered = ItemHoverable(frame_bb, id, g.LastItemData.InFlags);
|
||||
if (hovered)
|
||||
g.MouseCursor = ImGuiMouseCursor_TextInput;
|
||||
SetMouseCursor(ImGuiMouseCursor_TextInput);
|
||||
|
||||
// We are only allowed to access the state if we are already the active widget.
|
||||
ImGuiInputTextState* state = GetInputTextState(id);
|
||||
|
|
Loading…
Reference in New Issue