this will allow for scaling by dragging the four borders.
and won't block the main loop.
and you can grab one of the corners to scale as well.
case sf::Event::MouseMoved:
if (ImGui::IsAnyItemActive() || ImGui::IsAnyWindowFocused())
break;
if (isMouseDragging) {
window.setPosition(window.getPosition() + sf::Vector2<int>(event.mouseMove.x - lastDownX, event.mouseMove.y - lastDownY));
}
//
if (isScalingLeft) {
window.setPosition(window.getPosition() + sf::Vector2<int>(event.mouseMove.x - lastDownX, 0));
window.setSize(window.getSize() - sf::Vector2u{ (unsigned int)(event.mouseMove.x - lastDownX ), 0 });
}
if (isScalingRight) {
//window.setSize(windowOldSize + sf::Vector2u{ (unsigned int)(event.mouseMove.x - lastDownX ), 0 });
window.setSize(window.getSize() + sf::Vector2u{ (unsigned int)(event.mouseMove.x - lastDownX), 0 });
lastDownX = event.mouseMove.x;
}
if (isScalingTop) {
window.setPosition(window.getPosition() + sf::Vector2<int>(0,event.mouseMove.y - lastDownY));
window.setSize(window.getSize() - sf::Vector2u{0, (unsigned int)(event.mouseMove.y - lastDownY)});
}
if (isScalingBottom) {
//window.setSize(windowOldSize + sf::Vector2u{ 0,(unsigned int)(event.mouseMove.y - lastDownY)});
window.setSize(window.getSize() + sf::Vector2u{ 0, (unsigned int)(event.mouseMove.y - lastDownY) });
lastDownY = event.mouseMove.y;
}
break;
case sf::Event::MouseButtonPressed:
std::cout <<"MouseButtonPressed"<< std::endl;
lastDownX = event.mouseButton.x;
lastDownY = event.mouseButton.y;
//
if (lastDownX <= borderWidth) {
isScalingLeft = true;
}
if (lastDownX >= window.getSize().x - borderWidth) {
isScalingRight = true;
}
if (lastDownY <= borderWidth) {
isScalingTop = true;
}
if (lastDownY >= window.getSize().y - borderWidth) {
isScalingBottom = true;
}
if(isScalingLeft || isScalingRight || isScalingTop || isScalingBottom)break;
isMouseDragging = true;
break;
case sf::Event::MouseButtonReleased:
isMouseDragging =
isScalingBottom=
isScalingTop=
isScalingRight=
isScalingLeft = false;
break;
The remaining problem however,
,is that can i change the mouse cursor when hovering on the borders?
well,I can,but only for the latest build.