diff --git a/TODO b/TODO index 871d9f1..144729f 100644 --- a/TODO +++ b/TODO @@ -32,7 +32,6 @@ Sync / inputs: * Support for overrides * Fix the various remaining issues * Zooming issues on the right side - * Mouse wheel * Add curve display Misc: diff --git a/ui-imgui-sdl.cc b/ui-imgui-sdl.cc index 44bb00e..8e67fce 100644 --- a/ui-imgui-sdl.cc +++ b/ui-imgui-sdl.cc @@ -12,9 +12,13 @@ // 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 GLuint g_FontTexture = 0; +#warning fix this if/when ocornut integrates the patch +/*static*/ float ImGuiIO_MouseHorizWheel = 0.0f; + // This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure) // If text or lines are blurry when integrating ImGui in your engine: // - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f) @@ -115,6 +119,10 @@ bool ImGui_ImplSdl_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) @@ -273,8 +281,9 @@ void ImGui_ImplSdl_NewFrame(SDL_Window *window , io.MouseDown[2] = g_MousePressed[2] || (mouseMask & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0; g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false; + ImGuiIO_MouseHorizWheel = g_MouseHorizWheel; io.MouseWheel = g_MouseWheel; - g_MouseWheel = 0.0f; + g_MouseHorizWheel = g_MouseWheel = 0.0f; // Hide OS mouse cursor if ImGui is drawing it SDL_ShowCursor(io.MouseDrawCursor ? 0 : 1); diff --git a/ui-imgui-sdl.hh b/ui-imgui-sdl.hh index 952f3ce..4f63231 100644 --- a/ui-imgui-sdl.hh +++ b/ui-imgui-sdl.hh @@ -20,3 +20,7 @@ IMGUI_API bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event); // Use if you want to reset your rendering device without losing ImGui state. IMGUI_API void ImGui_ImplSdl_InvalidateDeviceObjects(); IMGUI_API bool ImGui_ImplSdl_CreateDeviceObjects(); + + +#warning fix this if/when ocornut integrates the patch +extern float ImGuiIO_MouseHorizWheel; diff --git a/ui-sequencer.cc b/ui-sequencer.cc index c045eb6..14f1b86 100644 --- a/ui-sequencer.cc +++ b/ui-sequencer.cc @@ -9,6 +9,8 @@ #include "ui-sequencer.hh" #include "ui-utilities.hh" +#include "ui-imgui-sdl.hh" + #define IMGUI_DEFINE_MATH_OPERATORS #include @@ -634,14 +636,22 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept if ( io.KeyShift ) { zoomLevel = ImSaturate( zoomLevel + .025 * io.MouseWheel ); } else { - vScroll = ImMax( 0.f , - ImMin( vScroll - 3.f * io.MouseWheel , - totalHeight - bbDisplay.GetHeight( ) ) ); + vScroll = ImClamp( vScroll - 3.f * io.MouseWheel , + 0.f , + ImMax( 0.f , totalHeight - bbDisplay.GetHeight( ) ) ); } } if ( bbDisplay.Contains( io.MousePos ) ) { displayTooltips( mTime ); } + if ( ImGuiIO_MouseHorizWheel != 0 ) { + startPos = ImClamp( + sync.durationUnits( ) + * ( startPixel - 20.f * ImGuiIO_MouseHorizWheel ) + / totalPixels , + 0.f , sync.durationUnits( ) ); + checkLockMode = true; + } return; } @@ -662,6 +672,9 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept zoomLevel = ( ppu - BarWidth ) / ( BarWidth - width / u ) + 1; } } + } else if ( zoomInProgress && io.MouseDown[ 1 ] ) { + curZoomPixel = mPixels; + return; } if ( selPointDnD && handlePointDrag( mPixels , io.MouseDown[ 0 ] ) ) { @@ -679,10 +692,8 @@ void T_SyncViewImpl_::sequencerWidget( ) noexcept sync.setTime( mTime ); } if ( io.MouseDown[ 1 ] ) { - if ( !zoomInProgress ) { - firstZoomPixel = mPixels; - zoomInProgress = true; - } + firstZoomPixel = mPixels; + zoomInProgress = true; curZoomPixel = mPixels; }