@@ -147,6 +147,9 @@ namespace ImmVision
147147 bool PanWithMouse = true ;
148148 bool ZoomWithMouseWheel = true ;
149149
150+ // Can the image widget be resized by the user
151+ bool CanResize = true ;
152+
150153 // Color Order: RGB or RGBA versus BGR or BGRA (Note: by default OpenCV uses BGR and BGRA)
151154 bool IsColorOrderBGR = true ;
152155
@@ -9363,6 +9366,7 @@ namespace ImmVision
93639366 std::vector<char > FilenameEditBuffer = std::vector<char >(1000 , ' \0 ' );
93649367 bool IsMouseDragging = false ;
93659368 bool WasZoomJustUpdatedByLink = false ;
9369+ bool IsResizing = false ;
93669370 cv::Size PreviousImageSize;
93679371 struct ImageParams PreviousParams;
93689372 };
@@ -9811,6 +9815,8 @@ namespace ImmVision
98119815 // Mouse dragging
98129816 auto fnHandleMouseDragging = [¶ms](CachedParams & cacheParams)
98139817 {
9818+ if (cacheParams.IsResizing )
9819+ return ;
98149820 ZoomPanTransform::MatrixType& zoomMatrix = params->ZoomPanMatrix ;
98159821
98169822 int mouseDragButton = 0 ;
@@ -9914,6 +9920,50 @@ namespace ImmVision
99149920 return mouseInfo;
99159921 };
99169922
9923+ //
9924+ // Lambda / Show resize widget in the bottom right corner
9925+ //
9926+ auto fnShowResizeWidget = [¶ms](CachedParams & cacheParams)
9927+ {
9928+ if (!params->CanResize )
9929+ return ;
9930+ ImVec2 imageBottomRight = ImGui::GetItemRectMax ();
9931+ float em = ImGui::GetFontSize ();
9932+ float size = em * 1 .0f ;
9933+ ImVec2 br (imageBottomRight.x , imageBottomRight.y );
9934+ ImVec2 bl (br.x - size, br.y );
9935+ ImVec2 tr (br.x , br.y - size);
9936+ ImVec2 tl (br.x - size, br.y - size);
9937+
9938+ ImRect zone (tl, br);
9939+ ImGui::GetWindowDrawList ()->AddTriangleFilled (br, bl, tr, ImGui::GetColorU32 (ImGuiCol_ButtonHovered));
9940+
9941+ if (!cacheParams.IsResizing )
9942+ {
9943+ if (ImGui::IsMouseHoveringRect (zone.Min , zone.Max ) && ImGui::IsMouseDown (0 ))
9944+ {
9945+ ImGui::SetMouseCursor (ImGuiMouseCursor_ResizeNWSE);
9946+ cacheParams.IsResizing = true ;
9947+ }
9948+ }
9949+ if (cacheParams.IsResizing )
9950+ {
9951+ if (ImGui::IsMouseDown (0 ))
9952+ {
9953+ if (ImGui::GetIO ().MouseDelta .x != 0 . || ImGui::GetIO ().MouseDelta .y != 0 .)
9954+ {
9955+ params->ImageDisplaySize .width += ImGui::GetIO ().MouseDelta .x ;
9956+ params->ImageDisplaySize .height += ImGui::GetIO ().MouseDelta .y ;
9957+ }
9958+ }
9959+ else
9960+ {
9961+ ImGui::SetMouseCursor (ImGuiMouseCursor_Arrow);
9962+ cacheParams.IsResizing = false ;
9963+ }
9964+ }
9965+ };
9966+
99179967
99189968 //
99199969 // Lambda / Show pixel info
@@ -9942,6 +9992,7 @@ namespace ImmVision
99429992 ImGui::BeginGroup ();
99439993 // Show image
99449994 auto mouseInfo = fnShowImage (*cacheImages.GlTexture );
9995+ fnShowResizeWidget (cacheParams);
99459996 // Add Watched Pixel on double click
99469997 if ( params->AddWatchedPixelOnDoubleClick
99479998 && ImGui::IsMouseDoubleClicked (ImGuiMouseButton_Left)
@@ -10066,6 +10117,7 @@ namespace ImmVision
1006610117 imageParams.ShowOptionsPanel = false ;
1006710118 imageParams.ZoomWithMouseWheel = false ;
1006810119 imageParams.PanWithMouse = false ;
10120+ imageParams.CanResize = false ;
1006910121 imageParams.ShowPixelInfo = false ;
1007010122 imageParams.ShowImageInfo = false ;
1007110123 imageParams.ShowGrid = false ;
0 commit comments