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

Author Topic: Support for dialog popups (MessageBoxes)  (Read 7014 times)

0 Members and 2 Guests are viewing this topic.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Support for dialog popups (MessageBoxes)
« on: February 14, 2012, 02:19:11 pm »
This is something brought up here already and I really think this is something that should be included, given the fact it's rather hard to do it in a cross platform way by hand (if you don't want to resort on writing your own GUI render code or use third party libs for this). After all it's something that can be very useful for any multimedia application or game (even if it's just to tell the user that something went wrong).

Essentially, I'd like to see some simple interface that works similar to Windows API's MessageBox().

The signature would be something like this (parameters could be bitmasks or some object, too):
Code: [Select]
sf::DialogResult sf::Window::ShowDialog(const sf::String &text, sf::String &caption, const sf::DialogIcon icon = IconNone, const sf::DialogButtons buttons = ButtonsOk) const;
Code: [Select]
sf::DialogResult sf::Window::ShowDialog(const sf::String &text, sf::String &caption, const unsigned int flags = 0) const;
Code: [Select]
sf::DialogResult sf::Window::ShowDialog(const sf::String &text, sf::String &caption, const sf::DialogStyle &style = sf::DialogStyle()) const;
It's a member function, so the window can act as its parent, but some static version with an optional window parameter might be interesting, too.

I could as well think of dialogs with more elaborate dialog choices (compareable to those found in Windows Vista, Windows 7 or (I think) Unity), but at least the basics would be very neat.

Right now I use defines to redirect my error messages to console or MessageBox(), but some ready to be used function or class (might be overkill) would definitely be better.

I could provide a barebone implementation ready to be used for Windows, but unfortunately I'm far too unexperienced in X Windows, etc., to do the same for the other platforms.

Elgan

  • Jr. Member
  • **
  • Posts: 77
    • AOL Instant Messenger - Flat+1,+17+st+Cl
    • View Profile
Support for dialog popups (MessageBoxes)
« Reply #1 on: February 14, 2012, 03:38:53 pm »
I noticed there is one here, BUT I can not read it msyelf?

https://github.com/SFML/SFML/wiki/Sources

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Support for dialog popups (MessageBoxes)
« Reply #2 on: February 14, 2012, 03:53:03 pm »
Quote
I noticed there is one here, BUT I can not read it msyelf?

The page doesn't exist. Which means that the page was created on the old wiki and nobody ported it to the new wiki. So you can find it there:
http://www.sfml-dev.org/wiki/en/sources/messagebox

But it's written in Ruby, and it's a very simple class that uses sf::RenderWindow and sf::Text. Nothing to do with native OS message box.

Quote
given the fact it's rather hard to do it in a cross platform way by hand (if you don't want to resort on writing your own GUI render code or use third party libs for this)

It's really easy to display some text and a button, without using a GUI library. The only thing that may block you is the lack of modal/stay-on-top feature for SFML windows.

Of course, if you really want native message boxes then it's a totally different story. Which is out of scope for SFML, in my opinion.
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Support for dialog popups (MessageBoxes)
« Reply #3 on: February 15, 2012, 02:29:54 am »
Yeah, I've read about using SFML to show a message box in the other thread, but I'd still try to avoid using a SFML/OpenGL context window for drawing, even if it's just for those cases where you (for whatever reason) fail to create such a window. Think I'll rethink about it and then try to create a standalone/native class, even if it's just Windows and X.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Support for dialog popups (MessageBoxes)
« Reply #4 on: February 15, 2012, 08:03:12 am »
Good luck for X :P
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Support for dialog popups (MessageBoxes)
« Reply #5 on: February 15, 2012, 01:22:04 pm »
Haha. :P Just in case, there's still the printf() fallback. :)

 

anything