Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (72 sloc) 2.24 KB

SFGUI contribution guidelines


This file gives information about some code guidelines for the SFGUI project. The main reason is to keep the code style and behaviour of the whole library as consistent as possible.

Commits/contributions to the repository

The repository uses two special branches:

  • master: Includes commits that will definitely be in the next version.
  • dev: Includes commits that are most likely accepted to be merged to the master branch. Might be unstable/rewritten.

Send your patches through GitHub pull requests.

A real advantage for us is if you rebase your commits onto our latest commits of the dev branch. This minimizes the merge effort we might have to spend when applying your patch, and it makes sure that your changes work with our latest changes.

Code style

Check the sources of SFGUI to see how code is formatted. Formatting code is like a religion for programmers, but please stick to SFGUI's style if you're about to contribute source code.

General rules

  1. No definitions in class declarations: Do not define something within a class declaration, including methods: Even if they're short, do not auto-inline by defining it.


    class Foo {
      void Bar() { ... }


    class Foo {
      void Bar();
    void Foo::Bar() {
  2. Pay attention to const-correct method signatures: Getters mostly return const references — an exception are built-in C++ types like int, char etc.


    sf::String GetText();
    int GetNumber();


    const sf::String& GetText() const;
    int GetNumber() const;
  3. Use descriptive and verbose names, especially for methods.


    void SetPos();
    for( int i = 0; i < 10; ++i ) {...}


    void SetPosition();
    for( int widget_index = 0; widget_index < 10; ++widget_index ) {...}
  4. Always use new-style casts. Avoid reinterpret_cast and const_cast whenever possible.


    float foo = (float)4;


    float foo = static_cast<float>( 4 );