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

Author Topic: Getting/setting title of sf::Window?  (Read 13354 times)

0 Members and 1 Guest are viewing this topic.

RetroX

  • Newbie
  • *
  • Posts: 13
    • View Profile
Getting/setting title of sf::Window?
« on: March 07, 2010, 03:44:28 am »
Probably been asked for before, but it seems like one of the very few features in SFML that is really needed.  And while it can be done, the only solutions are not cross-platform.

Basically would be something like:
void sf::Window::SetTitle(std::string Title)
std::string sf::Window::GetTitle()

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Getting/setting title of sf::Window?
« Reply #1 on: March 07, 2010, 09:46:58 am »
Yes, I'm going to add it.

Is GetTitle() really necessary?
Laurent Gomila - SFML developer

Thiziri

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Getting/setting title of sf::Window?
« Reply #2 on: March 07, 2010, 05:30:22 pm »
Yes It is. I need this method for my future GUI, beucause actually I must save the title string for using it after and It is not very stylish.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Getting/setting title of sf::Window?
« Reply #3 on: March 07, 2010, 05:31:50 pm »
Why do you need to get a window's title? I can't imagine a good use case, at the moment...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Thiziri

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
Getting/setting title of sf::Window?
« Reply #4 on: March 07, 2010, 05:35:36 pm »
All "Mac Os like menues" in my GUI need to know the SFML window's title, because the first entry inside is this title precisely.

RetroX

  • Newbie
  • *
  • Posts: 13
    • View Profile
Getting/setting title of sf::Window?
« Reply #5 on: March 07, 2010, 06:55:46 pm »
GetTitle() is just something that may be useful in a few situations and if you're going to add SetTitle(), it might as well be added, as well.

I find it odd that you would be able to set the title but not know what title that you had just set.

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Getting/setting title of sf::Window?
« Reply #6 on: September 27, 2012, 01:24:34 pm »
*necropost*

Is GetTitle() really necessary?

It'd be useful in cases where the title was changed outside of the program, i.e. by third-party window managers, sandboxes, or macros/scripts.

Plus, as others have said, it would just make sense as a convenience function.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Getting/setting title of sf::Window?
« Reply #7 on: September 27, 2012, 03:41:44 pm »
Quote
It'd be useful in cases where the title was changed outside of the program, i.e. by third-party window managers, sandboxes, or macros/scripts.
Sounds like an extreme use case. And what would you do with the title anyway? To me it's something that you set, but never need to get back.

Quote
Plus, as others have said, it would just make sense as a convenience function.
If I added a getter for every setter that SFML provides, the API would have a lot more functions. And you know that I don't like that ;)
Laurent Gomila - SFML developer

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Getting/setting title of sf::Window?
« Reply #8 on: September 27, 2012, 04:13:10 pm »
Quote
It'd be useful in cases where the title was changed outside of the program, i.e. by third-party window managers, sandboxes, or macros/scripts.
Sounds like an extreme use case. And what would you do with the title anyway? To me it's something that you set, but never need to get back.

Not really. I run multiple versions of my code in sandboxes all the time for memory profiling and such, and need to log/output the title name for debugging issues. It'd be a nice thing to have.

Quote
Plus, as others have said, it would just make sense as a convenience function.
If I added a getter for every setter that SFML provides, the API would have a lot more functions. And you know that I don't like that ;)

Oh jeez, one method won't hurt Laurent ;) You're leaving the API open-ended anyway by leaving it out.
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Getting/setting title of sf::Window?
« Reply #9 on: September 27, 2012, 04:18:09 pm »
Quote
I run multiple versions of my code in sandboxes all the time for memory profiling and such, and need to log/output the title name for debugging issues
But since you set the title of the window, you obviously already know it, so why do you need to read it from the window?

Quote
Oh jeez, one method won't hurt Laurent
It's not one method, it's a lot. If I add this one, which usefulness is not obvious to me, then why wouldn't I add all the other missing getters too?
Laurent Gomila - SFML developer

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Getting/setting title of sf::Window?
« Reply #10 on: September 27, 2012, 04:39:52 pm »
Quote
I run multiple versions of my code in sandboxes all the time for memory profiling and such, and need to log/output the title name for debugging issues
But since you set the title of the window, you obviously already know it, so why do you need to read it from the window?

But you don't know it, that's the thing. I'm saying that third party applications can change the title. Yes I can store a string with the title I last applied to the window, but if if something like a sandbox appends "SomeTitle <sandboxie>" to the end, then I need a way to get that new title, which I have no control over.

Quote
Oh jeez, one method won't hurt Laurent
It's not one method, it's a lot. If I add this one, which usefulness is not obvious to me, then why wouldn't I add all the other missing getters too?

Because most other getters are defined as it is ;)
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Getting/setting title of sf::Window?
« Reply #11 on: September 27, 2012, 04:46:34 pm »
Rewrite tiny part of sfml yourself? This is extremely niche feature.
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Getting/setting title of sf::Window?
« Reply #12 on: September 27, 2012, 04:48:54 pm »
Quote
But you don't know it, that's the thing. I'm saying that third party applications can change the title. Yes I can store a string with the title I last applied to the window, but if if something like a sandbox appends "SomeTitle <sandboxie>" to the end, then I need a way to get that new title, which I have no control over.
Ok I get it. But:
- this is unreliable, what happens to your log if one of the sandboxes doesn't add its name to the window title? to me you should handle this yourself, to get consistent results
- it still doesn't convinces me (this is a very very very specific use case...)
:)

Quote
Rewrite tiny part of sfml yourself? This is extremely niche feature.
Or write an external function that uses window.getSystemHandle(), with one implementation per target OS.
Laurent Gomila - SFML developer

Qix

  • Full Member
  • ***
  • Posts: 139
  • I am Qix!
    • View Profile
    • Natoga Technologies
Re: Getting/setting title of sf::Window?
« Reply #13 on: September 27, 2012, 04:57:31 pm »
Quote
But you don't know it, that's the thing. I'm saying that third party applications can change the title. Yes I can store a string with the title I last applied to the window, but if if something like a sandbox appends "SomeTitle <sandboxie>" to the end, then I need a way to get that new title, which I have no control over.
Ok I get it. But:
- this is unreliable, what happens to your log if one of the sandboxes doesn't add its name to the window title? to me you should handle this yourself, to get consistent results
- it still doesn't convinces me (this is a very very very specific use case...)
:)

Not really, it can be used in almost any logging/debugging use case. If I am working with pure SFML windows and want to know the title name for a quick log, I'm SOL. I'd have to wrap the window and hold a string, which is cluttered and goes against many designing rules/theories anyway (i.e. don't store data that can be easily obtained somewhere else). I think this applies.

Further, this is just such a small, simple thing that really should be in there. It just doesn't seem like a complete class without a getter such as this.

Quote
Rewrite tiny part of sfml yourself? This is extremely niche feature.
Or write an external function that uses window.getSystemHandle(), with one implementation per target OS.

But then that requires the extra time for each project to write/implement/create a wrapper for something that should already be implemented in a native window class!!
~ Qix
Creator of Rippl Studio
Code: [Select]
<danharibo> iostream: I don't do enough drugs to think that's a good idea.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Getting/setting title of sf::Window?
« Reply #14 on: September 27, 2012, 05:21:27 pm »
Quote
But then that requires the extra time for each project to write/implement/create a wrapper for something that should already be implemented in a native window class!!
Just edit source and header and cmake normally, possibly doing some conditional compilation that will end up printing to cout "Warning: Non-standard SFML extension function called for object at adress (this) of type (typeid(*this).name())." in debug each time you get title.
« Last Edit: September 27, 2012, 05:23:06 pm by FRex »
Back to C++ gamedev with SFML in May 2023