1
Window / Re: Forcing RenderWindow position (linux-ubuntu)
« on: December 21, 2017, 07:46:57 pm »
Okay, I think I got a way around the issue.
First of all, I needed to make my window borderless (for my project, nothing to do with yours) but this helped me to position the window with extra accuracy (idk why but with borders I got weird and non-accurate positions)
Next, I had to make the window big enough to move it where I wanted in order to have a portion of the window in and the other one out:
Then, I had to move the window to the bottom (now that i can, cuz magic) and resize it.
The problem after this is that my square gets all shrinked, this may or may not be because of the resizing event that triggers the call of "setSize()" on my window.
(The white part is just empty space)
So I added a event handler to my event handling function
And thats it
Hope I helped somebody. If not feel free to delete this post
Happy Holydays
First of all, I needed to make my window borderless (for my project, nothing to do with yours) but this helped me to position the window with extra accuracy (idk why but with borders I got weird and non-accurate positions)
Next, I had to make the window big enough to move it where I wanted in order to have a portion of the window in and the other one out:
// Going full savage with this starting video mode:
sf::VideoMode vm(sf::VideoMode::getDesktopMode().width, sf::VideoMode::getDesktopMode().height);
sf::RenderWindow* window = new sf::RenderWindow(vm, "Effects", sf::Style::None);
window->setFramerateLimit(60);
...
sf::VideoMode vm(sf::VideoMode::getDesktopMode().width, sf::VideoMode::getDesktopMode().height);
sf::RenderWindow* window = new sf::RenderWindow(vm, "Effects", sf::Style::None);
window->setFramerateLimit(60);
...
Then, I had to move the window to the bottom (now that i can, cuz magic) and resize it.
sf::VideoMode vm(sf::VideoMode::getDesktopMode().width, sf::VideoMode::getDesktopMode().height);
sf::RenderWindow* window = new sf::RenderWindow(vm, "Effects", sf::Style::None);
window->setFramerateLimit(60);
// Here, I move it to where i want and resizing to the needed dimensions
window->setPosition(sf::Vector2i( 0, sf::VideoMode::getDesktopMode().height - 54)); // 54 its just my ubuntu navbar height
window->setSize(sf::Vector2u(window->getSize().x, 54));
sf::RenderWindow* window = new sf::RenderWindow(vm, "Effects", sf::Style::None);
window->setFramerateLimit(60);
// Here, I move it to where i want and resizing to the needed dimensions
window->setPosition(sf::Vector2i( 0, sf::VideoMode::getDesktopMode().height - 54)); // 54 its just my ubuntu navbar height
window->setSize(sf::Vector2u(window->getSize().x, 54));
The problem after this is that my square gets all shrinked, this may or may not be because of the resizing event that triggers the call of "setSize()" on my window.
(The white part is just empty space)
So I added a event handler to my event handling function
if (e.type == sf::Event::Resized){
w->setView(sf::View(sf::FloatRect(0.f, 0.f,
static_cast<float>(w->getSize().x),
static_cast<float>(w->getSize().y))
)
);
}
w->setView(sf::View(sf::FloatRect(0.f, 0.f,
static_cast<float>(w->getSize().x),
static_cast<float>(w->getSize().y))
)
);
}
And thats it
Hope I helped somebody. If not feel free to delete this post
Happy Holydays