public ref CursorShape this[ImGuiMouseCursor cursor] { get { switch (cursor) { case ImGuiMouseCursor.Arrow: return(ref Arrow); case ImGuiMouseCursor.TextInput: return(ref TextInput); case ImGuiMouseCursor.ResizeAll: return(ref ResizeAll); case ImGuiMouseCursor.ResizeEW: return(ref ResizeEW); case ImGuiMouseCursor.ResizeNS: return(ref ResizeNS); case ImGuiMouseCursor.ResizeNESW: return(ref ResizeNESW); case ImGuiMouseCursor.ResizeNWSE: return(ref ResizeNWSE); case ImGuiMouseCursor.Hand: return(ref Hand); case ImGuiMouseCursor.NotAllowed: return(ref NotAllowed); default: return(ref Arrow); } } }
private void GlfwShutdown() { for (ImGuiMouseCursor cursorN = 0; cursorN < ImGuiMouseCursor.COUNT; cursorN++) { glfwDestroyCursor(_mouseCursors[(int)cursorN]); _mouseCursors[(int)cursorN] = IntPtr.Zero; } }
public void Update() { UpdateKeyModifiers(); UpdateMousePosition(); var mouseCursor = ImGui.GetIO().MouseDrawCursor ? ImGuiMouseCursor.None : ImGui.GetMouseCursor(); if (mouseCursor != lastCursor) { lastCursor = mouseCursor; UpdateMouseCursor(); } }
static public void ImGui_ImplGlfw_Shutdown() { if (installedCallbacks) { Glfw.SetMouseButtonCallback(windowHandle, prevUserCallbackMousebutton); Glfw.SetScrollCallback(windowHandle, prevUserCallbackScroll); Glfw.SetKeyCallback(windowHandle, prevUserCallbackKey); Glfw.SetCharCallback(windowHandle, prevUserCallbackChar); installedCallbacks = false; } for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor.COUNT; cursor_n++) { Glfw.DestroyCursor(mouseCursors[(int)cursor_n]); mouseCursors[(int)cursor_n] = new Cursor(); // idk if this clearing is nessesary } }
public bool GetMouseCursorTexData(ImGuiMouseCursor cursor, out Vector2 out_offset, out Vector2 out_size, out Vector2 out_uv_border, out Vector2 out_uv_fill) { fixed(Vector2 *native_out_offset = &out_offset) { fixed(Vector2 *native_out_size = &out_size) { fixed(Vector2 *native_out_uv_border = &out_uv_border) { fixed(Vector2 *native_out_uv_fill = &out_uv_fill) { byte ret = ImGuiNative.ImFontAtlas_GetMouseCursorTexData(NativePtr, cursor, native_out_offset, native_out_size, native_out_uv_border, native_out_uv_fill); return(ret != 0); } } } } }
private static void UpdateMouseCursor(Window window) { var io = ImGui.GetIO(); if ((io.ConfigFlags & ImGuiConfigFlags.NoMouseCursorChange) == 0) { ImGuiMouseCursor cursor = ImGui.GetMouseCursor(); if (io.MouseDrawCursor || cursor == ImGuiMouseCursor.None) { window.SetMouseCursorVisible(false); } else { window.SetMouseCursorVisible(true); //Cursor c = s_mouseCursorLoaded[(int)cursor] ? s_mouseCursors[(int)cursor] : s_mouseCursors[(int)ImGuiMouseCursor.Arrow]; //window.SetMouseCursor(c); } } }
void UpdateMouseCursor() { ImGuiIOPtr io = ImGui.GetIO(); if ((io.ConfigFlags & ImGuiConfigFlags.NoMouseCursorChange) == 0 || Raylib.IsCursorHidden()) { return; } ImGuiMouseCursor imgui_cursor = ImGui.GetMouseCursor(); if (imgui_cursor == ImGuiMouseCursor.None || io.MouseDrawCursor) { Raylib.HideCursor(); } else { Raylib.ShowCursor(); } }
public static SDL_SystemCursor?Cursor(ImGuiMouseCursor cursor) { switch (cursor) { case ImGuiMouseCursor.Arrow: return(SDL_SystemCursor.Arrow); case ImGuiMouseCursor.Hand: return(SDL_SystemCursor.Hand); case ImGuiMouseCursor.ResizeAll: return(SDL_SystemCursor.SizeAll); case ImGuiMouseCursor.ResizeNESW: return(SDL_SystemCursor.SizeNESW); case ImGuiMouseCursor.ResizeNS: return(SDL_SystemCursor.SizeNS); case ImGuiMouseCursor.ResizeNWSE: return(SDL_SystemCursor.SizeNWSE); case ImGuiMouseCursor.ResizeEW: return(SDL_SystemCursor.SizeWE); default: return(null); } }
void UpdateCursor(ImGuiIOPtr io, ImGuiMouseCursor cursor) { if (io.MouseDrawCursor) { cursor = ImGuiMouseCursor.None; } if (_lastCursor == cursor) { return; } if ((io.ConfigFlags & ImGuiConfigFlags.NoMouseCursorChange) != 0) { return; } _lastCursor = cursor; Cursor.visible = cursor != ImGuiMouseCursor.None; // hide cursor if ImGui is drawing it or if it wants no cursor if (_cursorShapes != null) { Cursor.SetCursor(_cursorShapes[cursor].texture, _cursorShapes[cursor].hotspot, CursorMode.Auto); } }
static void ImGui_ImplGlfw_UpdateMouseCursor() { ImGuiIOPtr io = ImGui.GetIO(); if ((io.ConfigFlags & ImGuiConfigFlags.NoMouseCursorChange) > 0 || Glfw.GetInputMode(windowHandle, InputMode.Cursor) == (int)CursorMode.Disabled) { return; } ImGuiMouseCursor imgui_cursor = ImGui.GetMouseCursor(); if (imgui_cursor == ImGuiMouseCursor.None || io.MouseDrawCursor) { // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor Glfw.SetInputMode(windowHandle, InputMode.Cursor, (int)CursorMode.Hidden); } else { // Show OS mouse cursor // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here. Glfw.SetCursor(windowHandle, mouseCursors[(int)imgui_cursor] != Cursor.None ? mouseCursors[(int)imgui_cursor] : mouseCursors[(int)ImGuiMouseCursor.Arrow]); Glfw.SetInputMode(windowHandle, InputMode.Cursor, (int)CursorMode.Normal); } }
private static void LoadMouseCursor(ImGuiMouseCursor imguiCursorType, ImGuiMouseCursor sfmlCursorType) { s_mouseCursorLoaded[(int)imguiCursorType] = true; }
private static void LoadMouseCursor(ImGuiMouseCursor imguiCursorType, Cursor.CursorType sfmlCursorType) { s_mouseCursors[(int)imguiCursorType] = new Cursor(sfmlCursorType); s_mouseCursorLoaded[(int)imguiCursorType] = true; }
public void SetCursor(Cursor cursor) { captureCursor = cursor != Cursor.BrowserHostNoCapture; this.cursor = DecodeCursor(cursor); }
public abstract void igSetMouseCursor(ImGuiMouseCursor type);
public abstract byte ImFontAtlas_GetMouseCursorTexData(ImFontAtlas *self, ImGuiMouseCursor cursor, Vector2 *out_offset, Vector2 *out_size, Vector2 *out_uv_border, Vector2 *out_uv_fill);
void LateUpdate() { last_start = stopwatch.Elapsed.TotalSeconds; if (drawDebugWindow) { DrawDebugWindow(); } ImGui.EndFrame(); if (queue_font_rebuild) { RebuildFonts(); queue_font_rebuild = false; } // custom cursors if (enableCustomCursors) { ImGuiMouseCursor cursor = ImGui.GetMouseCursor(); Texture2D cursorTex = null; Vector2 hotspot = cursorHotspot; switch (cursor) { case ImGuiMouseCursor.Arrow: cursorTex = customCursorArrow; break; case ImGuiMouseCursor.TextInput: cursorTex = customCursorTextInput; break; case ImGuiMouseCursor.ResizeEW: cursorTex = customCursorResizeEW; break; case ImGuiMouseCursor.ResizeNESW: cursorTex = customCursorResizeNESW; hotspot.x += 5; hotspot.y += 5; break; case ImGuiMouseCursor.ResizeNS: cursorTex = customCursorResizeNS; break; case ImGuiMouseCursor.ResizeNWSE: cursorTex = customCursorResizeNWSE; hotspot.x += 5; hotspot.y += 5; break; default: break; } // Don't set cursor if it has not actually changed if (currentCursorTex != cursorTex) { if (cursorTex != null) { Cursor.SetCursor(cursorTex, hotspot, CursorMode.Auto); } else { Cursor.SetCursor(null, cursorHotspot, CursorMode.Auto); } currentCursorTex = cursorTex; } } ImGui.Render(); // render ImGui ImDrawDataPtr data = ImGui.GetDrawData(); if (commandBuffer != null) { // Clear buffer regardless of whether we have something to render or not commandBuffer.Clear(); } // Don't update meshes and Command Buffers if there is nothing to render if (data.CmdListsCount > 0) { // resize meshes array int numDrawCommands = 0; for (int i = 0; i < data.CmdListsCount; i++) { ImDrawListPtr cmdList = data.getDrawListPtr(i); var cmdBuffer = cmdList.CmdBuffer; numDrawCommands += cmdBuffer.Size; } if (meshes == null) { meshes = new List <ImGuiMesh>(); } if (meshes.Count != numDrawCommands) { // add new meshes to list if needed for (int i = meshes.Count; i < numDrawCommands; i++) { ImGuiMesh mesh = new ImGuiMesh(); meshes.Add(mesh); } // delete extra meshes if needed for (int i = meshes.Count - 1; i >= numDrawCommands; i--) { Destroy(meshes[i].mesh); meshes.RemoveAt(i); } } if (commandBuffer == null) { commandBuffer = new CommandBuffer(); commandBuffer.name = "ImGui Renderer"; commandBuffer.SetRenderTarget(BuiltinRenderTextureType.CameraTarget); guiCamera.AddCommandBuffer(CameraEvent.AfterEverything, commandBuffer); } commandBuffer.SetRenderTarget(BuiltinRenderTextureType.CameraTarget); // orthogonal projection of GUI mesh to camera space Matrix4x4 matrix = Matrix4x4.Ortho(0, Screen.width, 0, Screen.height, 0, 0.1f); // negate world to camera transform and projection which Unity applies itself matrix = guiCamera.cameraToWorldMatrix * guiCamera.projectionMatrix.inverse * matrix; // update Command Buffers int count = 0; for (int i = 0; i < data.CmdListsCount; i++) { ImDrawListPtr cmdList = data.getDrawListPtr(i); var cmdBuffer = cmdList.CmdBuffer; uint startElement = 0; for (int j = 0; j < cmdBuffer.Size; j++) { ImDrawCmd cmd = cmdBuffer[j]; Rect rect = new Rect { min = new Vector2(cmd.ClipRect.x, Screen.height - cmd.ClipRect.y), max = new Vector2(cmd.ClipRect.z, Screen.height - cmd.ClipRect.w) }; commandBuffer.EnableScissorRect(rect); meshes[count].UpdateMesh(cmd, cmdList.IdxBuffer, cmdList.VtxBuffer, (int)startElement); if (cmd.TextureId == fontTexturePtr) { mpb.SetTexture(main_tex_id, fontTexture); commandBuffer.DrawMesh(meshes[count].mesh, matrix, material, 0, 0, mpb); } else if (textures.ContainsKey(cmd.TextureId)) { mpb.SetTexture(main_tex_id, textures[cmd.TextureId]); commandBuffer.DrawMesh(meshes[count].mesh, matrix, material, 0, 0, mpb); } else { Debug.LogWarning("Image texture missing!"); } startElement += cmd.ElemCount; count++; } } } else if (commandBuffer != null) { // Remove Command Buffer if there is nothing to render guiCamera.RemoveCommandBuffer(CameraEvent.AfterEverything, commandBuffer); commandBuffer = null; } textures.Clear(); last_end = stopwatch.Elapsed.TotalSeconds; }
internal char[] TempBuffer = new char[1024 * 3 + 1]; // temporary text buffer internal ImGuiState() { IO = new ImGuiIO(); Style = new ImGuiStyle(); Windows = new ImVector <ImGuiWindow>(); WindowsSortBuffer = new ImVector <ImGuiWindow>(); CurrentWindowStack = new ImVector <ImGuiWindow>(); Settings = new ImVector <ImGuiIniData>(); ColorModifiers = new ImVector <ImGuiColMod>(); StyleModifiers = new ImVector <ImGuiStyleMod>(); FontStack = new ImVector <ImFont>(); OpenedPopupStack = new ImVector <ImGuiPopupRef>(); CurrentPopupStack = new ImVector <ImGuiPopupRef>(); RenderDrawData = new ImDrawData(); for (var i = 0; i < RenderDrawLists.Length; i++) { RenderDrawLists[i] = new ImVector <ImDrawList>(); } OverlayDrawList = new ImDrawList(); ColorEditModeStorage = new ImGuiStorage(); for (var i = 0; i < MouseCursorData.Length; i++) { MouseCursorData[i] = new ImGuiMouseCursorData(); } InputTextState = new ImGuiTextEditState(); Initialized = false; Font = null; FontSize = FontBaseSize = 0.0f; FontTexUvWhitePixel = new ImVec2(0.0f, 0.0f); Time = 0.0f; FrameCount = 0; FrameCountEnded = FrameCountRendered = -1; CurrentWindow = null; FocusedWindow = null; HoveredWindow = null; HoveredRootWindow = null; HoveredId = 0; HoveredIdAllowOverlap = false; HoveredIdPreviousFrame = 0; ActiveId = 0; ActiveIdPreviousFrame = 0; ActiveIdIsAlive = false; ActiveIdIsJustActivated = false; ActiveIdAllowOverlap = false; ActiveIdWindow = null; MovedWindow = null; SettingsDirtyTimer = 0.0f; SetNextWindowPosVal = new ImVec2(0.0f, 0.0f); SetNextWindowSizeVal = new ImVec2(0.0f, 0.0f); SetNextWindowCollapsedVal = false; SetNextWindowPosCond = 0; SetNextWindowSizeCond = 0; SetNextWindowContentSizeCond = 0; SetNextWindowCollapsedCond = 0; SetNextWindowFocus = false; SetNextTreeNodeOpenedVal = false; SetNextTreeNodeOpenedCond = 0; ScalarAsInputTextId = 0; ActiveClickDeltaToCenter = new ImVec2(0.0f, 0.0f); DragCurrentValue = 0.0f; DragLastMouseDelta = new ImVec2(0.0f, 0.0f); DragSpeedDefaultRatio = 0.01f; DragSpeedScaleSlow = 0.01f; DragSpeedScaleFast = 10.0f; ScrollbarClickDeltaToGrabCenter = new ImVec2(0.0f, 0.0f); //memset(Tooltip, 0, sizeof(Tooltip)); PrivateClipboard = null; OsImePosRequest = OsImePosSet = new ImVec2(-1.0f, -1.0f); ModalWindowDarkeningRatio = 0.0f; OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging MouseCursor = ImGuiMouseCursor.ImGuiMouseCursor_Arrow; //memset(MouseCursorData, 0, sizeof(MouseCursorData)); LogEnabled = false; //LogFile = null; //TODO: LogClipboard = null; LogStartDepth = 0; LogAutoExpandMaxDepth = 2; //memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); FramerateSecPerFrameIdx = 0; FramerateSecPerFrameAccum = 0.0f; CaptureMouseNextFrame = CaptureKeyboardNextFrame = -1; //memset(TempBuffer, 0, sizeof(TempBuffer)); }