#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "CustomBorders", sf::Style::None);
sf::RectangleShape bar(sf::Vector2f(800,20));
sf::Vector2i m_moveOldPos = {0, 0};
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (sf::Mouse::isButtonPressed(sf::Mouse::Left) && bar.getGlobalBounds().contains(static_cast<sf::Vector2f>(sf::Mouse::getPosition(window))))
{
if (m_moveOldPos != sf::Vector2i(0, 0))
{
sf::Vector2i newPos(window.getPosition() + sf::Mouse::getPosition(window) - m_moveOldPos);
window.setPosition(newPos);
std::cout << newPos.x << ", " << newPos.y << " | " << window.getPosition().x << ", " << window.getPosition().y << "\n";
}
m_moveOldPos = sf::Mouse::getPosition(window);
}
else m_moveOldPos = {0, 0};
window.clear();
window.draw(bar);
window.display();
}
}