mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Horizontal mouse wheel: renamed io.MouseHorizWheel to io.MouseWheelH. Reorganized the code in NewFrame(). Examples: Updated GLFW+GL and SDL+GL accordingly. (#1463)
This commit is contained in:
		| @@ -24,8 +24,7 @@ | ||||
| // Data | ||||
| static double       g_Time = 0.0f; | ||||
| static bool         g_MousePressed[3] = { false, false, false }; | ||||
| static float        g_MouseHorizWheel = 0.0f; | ||||
| static float        g_MouseWheel = 0.0f; | ||||
| static ImVec2       g_MouseWheel = ImVec2(0.0f, 0.0f); | ||||
| static GLuint       g_FontTexture = 0; | ||||
|  | ||||
| // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) | ||||
| @@ -133,14 +132,10 @@ bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event) | ||||
|     { | ||||
|     case SDL_MOUSEWHEEL: | ||||
|         { | ||||
|             if (event->wheel.x > 0) | ||||
|                 g_MouseHorizWheel = 1; | ||||
|             if (event->wheel.x < 0) | ||||
|                 g_MouseHorizWheel = -1; | ||||
|             if (event->wheel.y > 0) | ||||
|                 g_MouseWheel = 1; | ||||
|             if (event->wheel.y < 0) | ||||
|                 g_MouseWheel = -1; | ||||
|             if (event->wheel.x > 0) g_MouseWheel.x = +1; | ||||
|             if (event->wheel.x < 0) g_MouseWheel.x = -1; | ||||
|             if (event->wheel.y > 0) g_MouseWheel.y = +1; | ||||
|             if (event->wheel.y < 0) g_MouseWheel.y = -1; | ||||
|             return true; | ||||
|         } | ||||
|     case SDL_MOUSEBUTTONDOWN: | ||||
| @@ -279,13 +274,13 @@ void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window) | ||||
|     int mx, my; | ||||
|     Uint32 mouse_buttons = SDL_GetMouseState(&mx, &my); | ||||
|     io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); | ||||
|     io.MouseWheel = g_MouseWheel; | ||||
|     io.MouseHorizWheel = g_MouseHorizWheel; | ||||
|     io.MouseWheel = g_MouseWheel.y; | ||||
|     io.MouseWheelH = g_MouseWheel.x; | ||||
|     io.MouseDown[0] = g_MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;  // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. | ||||
|     io.MouseDown[1] = g_MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0; | ||||
|     io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0; | ||||
|     g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false; | ||||
|     g_MouseWheel = g_MouseHorizWheel = 0.0f; | ||||
|     g_MouseWheel.x = g_MouseWheel.x = 0.0f; | ||||
|  | ||||
|     // We need to use SDL_CaptureMouse() to easily retrieve mouse coordinates outside of the client area. This is only supported from SDL 2.0.4 (released Jan 2016) | ||||
| #if (SDL_MAJOR_VERSION >= 2) && (SDL_MINOR_VERSION >= 0) && (SDL_PATCHLEVEL >= 4)    | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 omar
					omar