SFML community forums

General => General discussions => Topic started by: john_locke on June 30, 2021, 06:06:42 pm

Title: GUI Issue
Post by: john_locke on June 30, 2021, 06:06:42 pm
Hello, I am having a bit of a mid-project crisis. I am trying to make a simple GUI library that I can use for future projects. I recklessly hurtled along implementing the first ideas that came to mind. For the most part it worked out. Buttons work, Labels work, Panels, well Panels exist...

Currently I have panels implemented as a nine slice. Longer panel? Just add another middle sprite and watch as those corners don't become stretched and blurry! In my hurried hubris I failed to consider a common use case, what If the user (me really) wants custom sized panels. Uh oh, they're restricted to sizes that are multiples of each texture size (assuming you want the details of the texture to be a certain size).

I can't seem to come up with a satisfactory solution, and I was hoping someone here could give me some inspiration / point me to a relevant tutorial or something.

ps, as far as I can tell, this is an appropriate place to post this, but my sincere apologies if not...
Title: Re: GUI Issue
Post by: Nexus on June 30, 2021, 08:35:41 pm
It seems to me that you're designing the GUI library ahead of any project that uses it. While this can be nice to experiment with different scenarios, it is often more efficient to do Dogfooding (https://en.wikipedia.org/wiki/Dogfooding), as it will make the use cases more clearer and also tell you how the API should look.

What I can also recommend is to look at one of the many existing UI libraries (https://github.com/SFML/SFML/wiki/Projects#ui-user-interface) for SFML. Chances are that you might not need to reinvent the wheel, or at least draw inspiration from existing projects. There are of course also many UI libraries completely outside SFML; if you're not developing a game, that might be a better choice.

Btw, what is up with your font size? :D