Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: problems with view  (Read 1437 times)

0 Members and 1 Guest are viewing this topic.

Tima32

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
problems with view
« on: July 23, 2018, 12:26:21 pm »
I make a window that can be moved with the mouse, but when it is at the right or bottom side of the window it disappears. What am I doing wrong?
View save_view = parent_window->getView();

        RectangleShape background;
        background.setPosition(0, 0);
        background.setSize(Vector2f(width, height));
        background.setFillColor(fon_color);
        background.setOutlineThickness(outlain_size);
        background.setOutlineColor(border_color);

        RectangleShape handl;
        handl.setPosition(-outlain_size, -header_height);
        handl.setSize(Vector2f(width + outlain_size*2, header_height));
        handl.setFillColor(border_color);
       
        View view = parent_window->getView();
        view.setCenter(parent_window->getSize().x / 2 - x, parent_window->getSize().y / 2 - y);
        parent_window->setView(view);
        parent_window->draw(background);
        parent_window->draw(handl);
        parent_window->setView(save_view);

Hapax

  • Hero Member
  • *****
  • Posts: 3353
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: problems with view
« Reply #1 on: July 24, 2018, 12:23:18 am »
Are you modifying the window's view outside of this code?

Does the same occur if you instead set view to equal save_view instead of getting the window's current view?

What are x and y?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Tima32

  • Newbie
  • *
  • Posts: 21
    • View Profile
    • Email
Re: problems with view
« Reply #2 on: July 24, 2018, 06:03:34 pm »
There was an error in converting data types in the string:
view.setCenter(parent_window->getSize().x / 2 - x, parent_window->getSize().y / 2 - y);
the data turned into a unsigned int.

Hapax

  • Hero Member
  • *****
  • Posts: 3353
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: problems with view
« Reply #3 on: July 25, 2018, 12:46:23 pm »
So it's fixed now?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*