예제 #1
0
 public void BuildRanges(out ImVector out_ranges)
 {
     fixed(ImVector *native_out_ranges = &out_ranges)
     {
         ImGuiNative.GlyphRangesBuilder_BuildRanges(NativePtr, native_out_ranges);
     }
 }
예제 #2
0
 public ImPtrVector(ImVector vector, int stride)
     : this(vector.Size, vector.Capacity, vector.Data, stride)
 {
 }
예제 #3
0
 public ImVector_ushort(ImVector vector)
 {
     Size     = vector.Size;
     Capacity = vector.Capacity;
     Data     = (ushort *)vector.Data;
 }
        private void UpdateImGuiInput(InputSnapshot snapshot)
        {
            ImGuiIOPtr io = ImGui.GetIO();

            // Determine if any of the mouse buttons were pressed during this snapshot period, even if they are no longer held.
            bool leftPressed   = false;
            bool middlePressed = false;
            bool rightPressed  = false;

            foreach (MouseEvent me in snapshot.MouseEvents)
            {
                if (me.Down)
                {
                    switch (me.MouseButton)
                    {
                    case MouseButton.Left:
                        leftPressed = true;
                        break;

                    case MouseButton.Middle:
                        middlePressed = true;
                        break;

                    case MouseButton.Right:
                        rightPressed = true;
                        break;
                    }
                }
            }

            io.MouseDown[0] = leftPressed || snapshot.IsMouseDown(MouseButton.Left);
            io.MouseDown[1] = middlePressed || snapshot.IsMouseDown(MouseButton.Right);
            io.MouseDown[2] = rightPressed || snapshot.IsMouseDown(MouseButton.Middle);

            if (p_sdl_GetGlobalMouseState == null)
            {
                p_sdl_GetGlobalMouseState = Sdl2Native.LoadFunction <SDL_GetGlobalMouseState_t>("SDL_GetGlobalMouseState");
            }

            if ((io.ConfigFlags & ImGuiConfigFlags.ViewportsEnable) != 0)
            {
                int x, y;
                unsafe
                {
                    uint buttons = p_sdl_GetGlobalMouseState(&x, &y);
                    io.MouseDown[0] = (buttons & 0b00001) != 0;
                    io.MouseDown[1] = (buttons & 0b00010) != 0;
                    io.MouseDown[2] = (buttons & 0b00100) != 0;
                    io.MouseDown[3] = (buttons & 0b01000) != 0;
                    io.MouseDown[4] = (buttons & 0b10000) != 0;
                }
                io.MousePos = new Vector2(x, y);
            }
            else
            {
                io.MousePos = snapshot.MousePosition;
            }

            io.MouseWheel = snapshot.WheelDelta;

            IReadOnlyList <char> keyCharPresses = snapshot.KeyCharPresses;

            for (int i = 0; i < keyCharPresses.Count; i++)
            {
                char c = keyCharPresses[i];
                io.AddInputCharacter(c);
            }

            IReadOnlyList <KeyEvent> keyEvents = snapshot.KeyEvents;

            for (int i = 0; i < keyEvents.Count; i++)
            {
                io.KeysDown[(int)keyEvents[i].Key] = keyEvents[i].Down;
            }

            io.KeyCtrl  = io.KeysDown[(int)Key.ControlLeft] || io.KeysDown[(int)Key.ControlRight];
            io.KeyAlt   = io.KeysDown[(int)Key.AltLeft] || io.KeysDown[(int)Key.AltRight];
            io.KeyShift = io.KeysDown[(int)Key.ShiftLeft] || io.KeysDown[(int)Key.ShiftRight];
            io.KeySuper = io.KeysDown[(int)Key.WinLeft] || io.KeysDown[(int)Key.WinRight];

            ImVector <ImGuiViewportPtr> viewports = ImGui.GetPlatformIO().Viewports;

            for (int i = 1; i < viewports.Size; i++)
            {
                ImGuiViewportPtr   v      = viewports[i];
                VeldridImGuiWindow window = ((VeldridImGuiWindow)GCHandle.FromIntPtr(v.PlatformUserData).Target);
                window.Update();
            }
        }
예제 #5
0
 public ImVector_ImDrawVert(ImVector vector)
 {
     Size     = vector.Size;
     Capacity = vector.Capacity;
     Data     = (ImDrawVert *)vector.Data;
 }