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

Author Topic: Multi Platform GUI  (Read 1716 times)

0 Members and 1 Guest are viewing this topic.

WilliamR

  • Guest
Multi Platform GUI
« on: March 27, 2016, 06:42:22 pm »
Hi,

I am thinking about writing a GUI (Widget) Framework based on SFML. Since the GUI would be used in plugins (dynamic libaries), I can't diretly access the main thread but have to relly on calls from outside. Because of this, I am not sure if what I have in mind works both on Win and on Mac so I wanted to ask for your opinion about it.

The main issue seems to be that events should be polled in the same thread as the window creation (Win) and in case of Mac they have to be polled on the main thread. However, I thought that the whole painting and mouse / keyboard interaction should be handled in one thread so that events / painting can't collide.  What I had in mind  was this:

- create a Window in the main thread on Win and Mac
- create some kind of platform dependent timer that polls events in the main thread
- push these events in event queues which are evaluated in ...
- ... a main loop thread which handles painting directly and events with the queue

What do you think, is that a reasonable thing to do or is there a better approach? My solution might be really naive since I never wrote something similar.

Cheers!

ratzlaff

  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: Multi Platform GUI
« Reply #1 on: March 28, 2016, 10:38:02 pm »
Before you start thinking about how to thread your own GUI concept/implementation, I would be more interested to know what you find lacking from the already existing libraries.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: Multi Platform GUI
« Reply #2 on: March 29, 2016, 02:04:02 pm »
If you introduce threads, your whole code base will get a lot more complicated and harder to reason about.

First you should just implement the GUI system, which by itself is not a trivial task, only after that is fully working, you can think about how the library would look like.

Don't forget to take a look at SFGUI or TGUI, maybe they already fit your need.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything