@@ -3241,13 +3241,27 @@ void Graph::graphButtons()
32413241
32423242 // Create two windows using splitter
32433243 float paneWidth = (leftPaneWidth - 2 .0f );
3244- ImGui::BeginChild (" Selection" , ImVec2 (paneWidth, 0 ));
3244+
3245+ float aspectRatio = _renderer->getPixelRatio ();
3246+ ImVec2 screenSize = ImVec2 (paneWidth, paneWidth / aspectRatio);
3247+
3248+ ImVec2 mousePos = ImGui::GetMousePos ();
3249+ ImVec2 tempWindowPos = ImGui::GetCursorPos ();
3250+ bool cursorInRenderView = mousePos.x > tempWindowPos.x && mousePos.x < (tempWindowPos.x + screenSize.x ) &&
3251+ mousePos.y > tempWindowPos.y && mousePos.y < (tempWindowPos.y + screenSize.y );
3252+
3253+ ImGuiWindowFlags windowFlags = 0 ;
3254+
3255+ if (cursorInRenderView)
3256+ {
3257+ windowFlags |= ImGuiWindowFlags_NoScrollWithMouse;
3258+ }
3259+
3260+ ImGui::BeginChild (" Selection" , ImVec2 (paneWidth, 0 ), false , windowFlags);
32453261 ImVec2 windowPos = ImGui::GetWindowPos ();
32463262
32473263 // RenderView window
32483264 ImVec2 wsize = ImVec2 ((float ) _renderer->getViewWidth (), (float ) _renderer->getViewHeight ());
3249- float aspectRatio = _renderer->getPixelRatio ();
3250- ImVec2 screenSize = ImVec2 (paneWidth, paneWidth / aspectRatio);
32513265 _renderer->setViewWidth ((int ) screenSize[0 ]);
32523266 _renderer->setViewHeight ((int ) screenSize[1 ]);
32533267
@@ -3267,7 +3281,10 @@ void Graph::graphButtons()
32673281 ImGui::EndChild ();
32683282 ImGui::SameLine (0 .0f , 12 .0f );
32693283
3270- handleRenderViewInputs (windowPos, screenSize[0 ], screenSize[1 ]);
3284+ if (cursorInRenderView)
3285+ {
3286+ handleRenderViewInputs ();
3287+ }
32713288}
32723289
32733290void Graph::propertyEditor ()
@@ -3830,56 +3847,54 @@ void Graph::shaderPopup()
38303847 }
38313848}
38323849
3833- void Graph::handleRenderViewInputs (ImVec2 minValue, float width, float height )
3850+ void Graph::handleRenderViewInputs ()
38343851{
38353852 ImVec2 mousePos = ImGui::GetMousePos ();
3836- if (mousePos.x > minValue.x && mousePos.x < (minValue.x + width) && mousePos.y > minValue.y && mousePos.y < (minValue.y + height))
3853+ mx::Vector2 mxMousePos = mx::Vector2 (mousePos.x , mousePos.y );
3854+ float scrollAmt = ImGui::GetIO ().MouseWheel ;
3855+ int button = -1 ;
3856+ bool down = false ;
3857+ if (ImGui::IsMouseDragging (0 ) || ImGui::IsMouseDragging (1 ))
38373858 {
3838- mx::Vector2 mxMousePos = mx::Vector2 (mousePos.x , mousePos.y );
3839- float scrollAmt = ImGui::GetIO ().MouseWheel ;
3840- int button = -1 ;
3841- bool down = false ;
3842- if (ImGui::IsMouseDragging (0 ) || ImGui::IsMouseDragging (1 ))
3843- {
3844- _renderer->setMouseMotionEvent (mxMousePos);
3845- }
3846- if (ImGui::IsMouseClicked (0 ))
3847- {
3848- button = 0 ;
3849- down = true ;
3850- _renderer->setMouseButtonEvent (button, down, mxMousePos);
3851- }
3852- else if (ImGui::IsMouseClicked (1 ))
3853- {
3854- button = 1 ;
3855- down = true ;
3856- _renderer->setMouseButtonEvent (button, down, mxMousePos);
3857- }
3858- else if (ImGui::IsMouseReleased (0 ))
3859- {
3860- button = 0 ;
3861- _renderer->setMouseButtonEvent (button, down, mxMousePos);
3862- }
3863- else if (ImGui::IsMouseReleased (1 ))
3864- {
3865- button = 1 ;
3866- _renderer->setMouseButtonEvent (button, down, mxMousePos);
3867- }
3868- else if (ImGui::IsKeyPressed (ImGuiKey_KeypadAdd))
3869- {
3870- _renderer->setKeyEvent (ImGuiKey_KeypadAdd);
3871- }
3872- else if (ImGui::IsKeyPressed (ImGuiKey_KeypadSubtract))
3873- {
3874- _renderer->setKeyEvent (ImGuiKey_KeypadSubtract);
3875- }
3859+ _renderer->setMouseMotionEvent (mxMousePos);
3860+ }
3861+ if (ImGui::IsMouseClicked (0 ))
3862+ {
3863+ button = 0 ;
3864+ down = true ;
3865+ _renderer->setMouseButtonEvent (button, down, mxMousePos);
3866+ }
3867+ else if (ImGui::IsMouseClicked (1 ))
3868+ {
3869+ button = 1 ;
3870+ down = true ;
3871+ _renderer->setMouseButtonEvent (button, down, mxMousePos);
3872+ }
3873+ else if (ImGui::IsMouseReleased (0 ))
3874+ {
3875+ button = 0 ;
3876+ _renderer->setMouseButtonEvent (button, down, mxMousePos);
3877+ }
3878+ else if (ImGui::IsMouseReleased (1 ))
3879+ {
3880+ button = 1 ;
3881+ _renderer->setMouseButtonEvent (button, down, mxMousePos);
3882+ }
3883+ else if (ImGui::IsKeyPressed (ImGuiKey_KeypadAdd))
3884+ {
3885+ _renderer->setKeyEvent (ImGuiKey_KeypadAdd);
3886+ }
3887+ else if (ImGui::IsKeyPressed (ImGuiKey_KeypadSubtract))
3888+ {
3889+ _renderer->setKeyEvent (ImGuiKey_KeypadSubtract);
3890+ }
38763891
3877- // Scrolling not possible if open or save file dialog is open
3878- if (scrollAmt != 0 && !_fileDialogSave.isOpened () && !_fileDialog.isOpened () && !_fileDialogGeom.isOpened ())
3879- {
3880- _renderer->setScrollEvent (scrollAmt);
3881- }
3892+ // Scrolling not possible if open or save file dialog is open
3893+ if (scrollAmt != 0 && !_fileDialogSave.isOpened () && !_fileDialog.isOpened () && !_fileDialogGeom.isOpened ())
3894+ {
3895+ _renderer->setScrollEvent (scrollAmt);
38823896 }
3897+
38833898}
38843899
38853900void Graph::drawGraph (ImVec2 mousePos)
0 commit comments