SFML community forums

General => SFML projects => Topic started by: Sergi on August 08, 2014, 03:59:46 pm

Title: SFML_Layout - An expansion of SFML functionality in C++.
Post by: Sergi on August 08, 2014, 03:59:46 pm
Hi!

I've been working lately on an expansion of SFML in C++ intended to make the process of creating and managing UI layouts easier. It's not a full GUI, but a set of classes and methods aimed towards helping you make your own according to the needs of your game/application.

While I was starting the development of a game a few months ago, I realised that some of the functionality I needed to implement was general enough so it could be useful for reuse in future projects, so I decided to create a stand-alone library expanding SFML in the ways I needed for my own layouts (and other ways that I could potentially need in future projects). Because it's usual when developing a game to create our own objects (as opposed to limiting ourselves to those offered by SFML and other libraries), I deemed it best to make the library heavy on polymorphism at its core, so it could be further expanded with minimal extra code.

The default classes in SFML_Layout implement:


In addition to the library itself (layout.hpp, layout.cpp, SFMLLayout.hpp, SFMLLayout.cpp), the repository also contains:


I've done my best with the in-code documentation, but even with that and the example it may still be a bit tricky to take full advantage of the library without thoroughly understanding it. At the moment I'm working on a detailed guide on how to use and expand SFML_Layout, but until then (and also afterwards, I guess) you can contact me for any doubt/bug report/request/quarrel you have about it here in the comments, or through e-mail at sergi (at) protonmail (dot) ch.

Link to repository: https://github.com/SergiSalvadorLozano/SFML_Layout (https://github.com/SergiSalvadorLozano/SFML_Layout).
Latest release: https://github.com/SergiSalvadorLozano/SFML_Layout/releases/tag/v1.0.1 (https://github.com/SergiSalvadorLozano/SFML_Layout/releases) (2014/08/10).
Title: Re: SFML_Layout - An expansion of SFML functionality in C++.
Post by: Raincode on August 09, 2014, 10:06:07 am
Hi there,

I am not that experienced with programming yet, but it seems to me that "LAYOUT" is a rather long and large namespace.

In case you didn't know, substituting "foo\\bar" with "foo/bar" will also work on windows, at least I can guarantee it does on my windows pc e.g. loadFromFile("Assets/quit.png").

As I said, I am not an expert, but I believe you could use enums instead of declaring a bunch of ints for your different modes for example in DRAW or ALIGNMENT.

Overall, I think this is an interesting project, because I have already struggled with making a nice ui, fitting the game's theme.

Kind Regards,
Raincode

Title: Re: SFML_Layout - An expansion of SFML functionality in C++.
Post by: Jesper Juhl on August 09, 2014, 10:38:09 am
but it seems to me that "LAYOUT" is a rather long and large namespace.

You can always use a namespace alias (http://en.cppreference.com/w/cpp/language/namespace_alias) to shorten it in your own code  :)
Title: Re: SFML_Layout - An expansion of SFML functionality in C++.
Post by: Raincode on August 09, 2014, 10:53:20 am
but it seems to me that "LAYOUT" is a rather long and large namespace.

You can always use a namespace alias (http://en.cppreference.com/w/cpp/language/namespace_alias) to shorten it in your own code  :)

Ah thanks, I didn't know about that ;)
Title: Re: SFML_Layout - An expansion of SFML functionality in C++.
Post by: Sergi on August 09, 2014, 12:24:00 pm
Yeah, I think that my attempts to make my code "self-explaining" often lead to me using names for namespaces, classes, and methods which may seem too long. I will try to address that on future work, but for now, if this is a common opinion, I can shorten the namespace name to something like "LA" or "LT".

I didn't know about Unix path names working on Windows SFML, so thank you! I will try it out and if it works I will change it for the next version.

I will study the use of "enums", too. As there is no arithmetic for those int the change will probably not break anything. That will require some testing, though.
Title: Re: SFML_Layout - An expansion of SFML functionality in C++.
Post by: Jesper Juhl on August 09, 2014, 01:42:05 pm
Yeah, I think that my attempts to make my code "self-explaining" often lead to me using names for namespaces, classes, and methods which may seem too long.

I don't think that's a problem. Descriptive names are good. And, as I pointed out above, users can just declare shorter aliases themselves.

I didn't know about Unix path names working on Windows SFML, so thank you! I will try it out and if it works I will change it for the next version.

That's not SFML specific. "/" works for include paths in any C++ program and "/" works for path names in any C++ program and also in your Windows cmd "shell" - just try it ;)

I will study the use of "enums", too. As there is no arithmetic for those int the change will probably not break anything.

I'd advice to use the new strongly typed C++11 "enum class" - read here: http://en.cppreference.com/w/cpp/language/enum and here: http://www.cprogramming.com/c++11/c++11-nullptr-strongly-typed-enum-class.html
Title: Re: SFML_Layout - An expansion of SFML functionality in C++.
Post by: Sergi on August 09, 2014, 02:01:48 pm
Just tried to change the path names and it works just fine  :). I will inform myself about the enum class so I can change that for the next version.

Thanks for the feedback!

EDIT: Done. Released a new version with those changes.