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

Author Topic: How to set proportional window border ?  (Read 3920 times)

0 Members and 3 Guests are viewing this topic.

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
How to set proportional window border ?
« on: May 18, 2015, 09:26:45 pm »
How to set proportional window border changing ?
Like in Dont Starve game.

Because when I click and hold to border of window - no event detected.
Maybe its set up in window settings, but how?

P.s. I achieved window changing - resize window from different resize.
But need to directly 1 time change without re-change.

Thanks in advance.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to set proportional window border ?
« Reply #1 on: May 18, 2015, 09:59:04 pm »
It's unclear to me what it is you are having trouble doing and what you aiming to achieve.
When you drag the window's borders manually, the window resizes. When you let go of the drag, the program gets a resized event.

You can resize the window programmatically too using the .create() function (similar to window's constructor).

If you want the final size to be a specific proportion after a resize, you can use the create function to alter one of the dimensions so that it's in proportion to the other dimension.

You can't, however, affect how the window acts or during the resizing.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: How to set proportional window border ?
« Reply #2 on: May 19, 2015, 10:29:00 am »
Just look to Dont Starve... proportional winApi border change.
After Event logic I already have.
« Last Edit: May 19, 2015, 10:47:13 am by Redee »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: How to set proportional window border ?
« Reply #3 on: May 19, 2015, 10:40:05 am »
SFML only handles the WM_SIZE event, which gets triggered after you've resized the window. So all you can do is catch the resize event and set the window size proportionally after the window was resized.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: How to set proportional window border ?
« Reply #4 on: May 19, 2015, 10:50:52 am »
SFML only handles the WM_SIZE event, which gets triggered after you've resized the window. So all you can do is catch the resize event and set the window size proportionally after the window was resized.
Its already have )).

People just start Dont Starve and look to border under mouse cursor when changing window size using mouse left click.
You will see about I say.
I think its must do from window handle with winApi functions to set proportional ratio.

Yeah, I found some...
Sounds exact what needed - WM_SIZING message
https://msdn.microsoft.com/en-us/library/windows/desktop/ms632647%28v=vs.85%29.aspx
Immediately second question how access to it...

Here need to add new event logic for read WM_SIZING, and return(set) proportional drag form to resize window...


Some troubles - because we know - events parsed from "one door".
And its in private scope..
void WindowImplWin32::registerWindowClass()
{
        WNDCLASSW windowClass;
        windowClass.style         = 0;
        windowClass.lpfnWndProc   = &WindowImplWin32::globalOnEvent;
 

Need to modify Sfml sources....
I wanted external add-on portable solution, but its impossible in this case.

Keys to success - add methods to get reference of MSG message.
To change lParam of checked before border type in wPparam.
Maybe MSG message will be better as field at private scope of class.
« Last Edit: May 19, 2015, 07:54:25 pm by Redee »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to set proportional window border ?
« Reply #5 on: May 19, 2015, 07:24:39 pm »
SFML doesn't process the 'currently resizing' events and you can't access the events that it doesn't process as it discards them.
You would have to create the window yourself using direct Windows code if you require this (although there may be some window creation library that can help) but your code would no longer be cross-platform and you lose the awesomeness that is SFML ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Redee

  • Jr. Member
  • **
  • Posts: 97
    • View Profile
Re: How to set proportional window border ?
« Reply #6 on: May 19, 2015, 08:05:45 pm »
Nope, I add some code only to Event.hpp (Event::Sizing) and WindowImplWin32.cpp
And if its non-windows OS I have after Event resizing logic too.

Creators of Sfml can add this for Unix / MacOS systems too.
Its no so hard and I try finalize own modification of Sfml tonight )).

..

Tonight 20 may 2015.
Modification code was added to this files >>
WindowImpl.hpp / WindowImpl.cpp / Window.hpp / Window.cpp
Remove some code from >>
WindowImplWin32.cpp

Its great I got reference to MSG and can do what I want )).
And its no change for sfml LINUX and MACOS because I used SFML_SYSTEM_WINDOWS constant for my mod.
« Last Edit: May 20, 2015, 08:45:16 pm by Redee »