Skip to content

GUI Coding Guidelines

Tobias Hermanns edited this page Nov 16, 2020 · 6 revisions

Scoping

All GUI classes, functions and global variables should be located in the hal namespace. Thus, all GUI variables, class definitions and code implementations are to be made within the hal namespace scope.

namespace hal
{
    ...
    ...
    ...
}

Class / Struct Names

Classes and Structs are to be named following the guidelines of pascalCase. Class and Struct names have to start with their first letter in uppercase.

class PythonCodeEditor
{
    ...
    ...
    ...
};

struct HLine
{
    qreal mSmallX;
    qreal mBigX;
    qreal y;
};

Variable Names

Variables are to be named following the guidelines of camelCase. Depending on the scope of the variable a prefix has to be used.

Global Variables

Global variable names have to start with the character g and their second letter capitalized.

extern NetlistRelay* gNetlistRelay;

Static Variables

Static variable names have to start with the character s and their second letter capitalized.

static qreal sColorBarHeight;

Member Variables

Member variable names have to start with the character m and their second letter capitalized.

QString mCurrentInput;

Local Variables

Local variable names have to start with their first letter in lowercase. The variable name should be kept short and if necessary further explained in a comment.

//x position of the gate on the internal layouter grid
int xPos;

Enumerations

Enumeration type and enumeration value names have to be capitalized. Good practice for enumeration declarations is to place them into a class definitions if possible.

class Node
{
public:
    enum NodeType {None, Module, Gate};
}

Preprocessor constants

Preprocessor constants should only be used if absolutely necessary. Its name hast to be completely capitalized and the parts of the name have to be seperated by an underscore.

#define GUI_DEBUG_GRID
Clone this wiki locally