Skip to content

Commit

Permalink
Use member initialization for constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Sep 21, 2024
1 parent eb46afe commit c9f1d91
Show file tree
Hide file tree
Showing 80 changed files with 356 additions and 723 deletions.
6 changes: 3 additions & 3 deletions include/guisan/cliprectangle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace gcn
/**
* Constructor.
*/
ClipRectangle();
ClipRectangle() = default;

/**
* Constructor.
Expand Down Expand Up @@ -105,12 +105,12 @@ namespace gcn
/**
* Holds the x offset of the x coordinate.
*/
int xOffset;
int xOffset = 0;

/**
* Holds the y offset of the y coordinate.
*/
int yOffset;
int yOffset = 0;
};
}

Expand Down
10 changes: 5 additions & 5 deletions include/guisan/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace gcn
/**
* Constructor. Initializes the color to black.
*/
Color();
Color() = default;

/**
* Constructor. Constructs a color from the bytes in an integer.
Expand Down Expand Up @@ -162,23 +162,23 @@ namespace gcn
/**
* Holds the red color component (range 0-255).
*/
int r;
int r = 0;

/**
* Holds the green color component (range 0-255).
*/
int g;
int g = 0;

/**
* Holds the blue color component (range 0-255).
*/
int b;
int b = 0;

/**
* Holds the alpha color component. A value of 0 means totally
* transparent while a value of 255 is considered opaque.
*/
int a;
int a = 255;
};
}

Expand Down
2 changes: 1 addition & 1 deletion include/guisan/containerevent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace gcn
/**
* Holds the container the event concerns.
*/
Container* mContainer;
Container* mContainer = nullptr;
};
} // namespace gcn

Expand Down
2 changes: 1 addition & 1 deletion include/guisan/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace gcn
/**
* Holds the source widget of the event.
*/
Widget* mSource;
Widget* mSource = nullptr;
};
}

Expand Down
8 changes: 4 additions & 4 deletions include/guisan/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace gcn
/**
* Constructor.
*/
Exception();
Exception() = default;

/**
* Constructor.
Expand Down Expand Up @@ -161,7 +161,7 @@ namespace gcn
* Holds the name of the function name where the
* exception occured.
*/
std::string mFunction;
std::string mFunction = "?";

/**
* Holds the error message of the exception.
Expand All @@ -171,12 +171,12 @@ namespace gcn
/**
* Holds the filename where the exception occured.
*/
std::string mFilename;
std::string mFilename = "?";

/**
* Holds the line number where the exception occured.
*/
unsigned int mLine;
unsigned int mLine = 0;
};
}

Expand Down
18 changes: 9 additions & 9 deletions include/guisan/focushandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace gcn
/**
* Constructor.
*/
FocusHandler();
FocusHandler() = default;

/**
* Destructor.
Expand Down Expand Up @@ -358,45 +358,45 @@ namespace gcn
/**
* Holds the focused widget. NULL if no widget has focus.
*/
Widget* mFocusedWidget;
Widget* mFocusedWidget = nullptr;

/**
* Holds the modal focused widget. NULL if no widget has
* modal focused.
*/
Widget* mModalFocusedWidget;
Widget* mModalFocusedWidget = nullptr;

/**
* Holds the modal mouse input focused widget. NULL if no widget
* is being dragged.
*/
Widget* mModalMouseInputFocusedWidget;
Widget* mModalMouseInputFocusedWidget = nullptr;

/**
* Holds the dragged widget. NULL if no widget is
* being dragged.
*/
Widget* mDraggedWidget;
Widget* mDraggedWidget = nullptr;

/**
* Holds the last widget with the mouse.
*/
Widget* mLastWidgetWithMouse;
Widget* mLastWidgetWithMouse = nullptr;

/**
* Holds the last widget with modal focus.
*/
Widget* mLastWidgetWithModalFocus;
Widget* mLastWidgetWithModalFocus = nullptr;

/**
* Holds the last widget with modal mouse input focus.
*/
Widget* mLastWidgetWithModalMouseInputFocus;
Widget* mLastWidgetWithModalMouseInputFocus = nullptr;

/**
* Holds the last widget pressed.
*/
Widget* mLastWidgetPressed;
Widget* mLastWidgetPressed = nullptr;
};
}

Expand Down
4 changes: 2 additions & 2 deletions include/guisan/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace gcn
/**
* Constructor.
*/
Graphics();
Graphics() = default;

/**
* Destructor.
Expand Down Expand Up @@ -290,7 +290,7 @@ namespace gcn
/**
* Holds the current font.
*/
Font* mFont;
Font* mFont = nullptr;
};
}

Expand Down
30 changes: 15 additions & 15 deletions include/guisan/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,27 +420,27 @@ namespace gcn
/**
* Holds the top widget.
*/
Widget* mTop;
Widget* mTop = nullptr;

/**
* Holds the graphics implementation used.
*/
Graphics* mGraphics;
Graphics* mGraphics = nullptr;

/**
* Holds the input implementation used.
*/
Input* mInput;
Input* mInput = nullptr;

/**
* Holds the focus handler for the Gui.
*/
FocusHandler* mFocusHandler;
FocusHandler* mFocusHandler = nullptr;

/**
* True if tabbing is enabled, false otherwise.
*/
bool mTabbing;
bool mTabbing = true;

typedef std::list<KeyListener*> KeyListenerList;
typedef KeyListenerList::iterator KeyListenerListIterator;
Expand All @@ -453,55 +453,55 @@ namespace gcn
/**
* True if shift is pressed, false otherwise.
*/
bool mShiftPressed;
bool mShiftPressed = false;

/**
* True if meta is pressed, false otherwise.
*/
bool mMetaPressed;
bool mMetaPressed = false;

/**
* True if control is pressed, false otherwise.
*/
bool mControlPressed;
bool mControlPressed = false;

/**
* True if alt is pressed, false otherwise.
*/
bool mAltPressed;
bool mAltPressed = false;

/**
* Holds the last mouse button pressed.
*/
unsigned int mLastMousePressButton;
unsigned int mLastMousePressButton = 0;

/**
* Holds the last mouse press time stamp.
*/
int mLastMousePressTimeStamp;
int mLastMousePressTimeStamp = 0;

/**
* Holds the last mouse x coordinate.
*/
int mLastMouseX;
int mLastMouseX = 0;

/**
* Holds the last mouse y coordinate.
*/
int mLastMouseY;
int mLastMouseY = 0;

/**
* Holds the current click count. Used to keep track
* of clicks for a the last pressed button.
*/
int mClickCount;
int mClickCount = 1;

/**
* Holds the last button used when a drag of a widget
* was initiated. Used to be able to release a drag
* when the same button is released.
*/
int mLastMouseDragButton;
int mLastMouseDragButton = 0;
};
}

Expand Down
8 changes: 4 additions & 4 deletions include/guisan/imagefont.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,22 @@ pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); @endcode
/**
* Holds the height of the image font.
*/
int mHeight;
int mHeight = 0;

/**
* Holds the glyph spacing of the image font.
*/
int mGlyphSpacing;
int mGlyphSpacing = 0;

/**
* Holds the row spacing of the image font.
*/
int mRowSpacing;
int mRowSpacing = 0;

/**
* Holds the image with the font data.
*/
Image* mImage;
Image* mImage = nullptr;

/**
* Holds the filename of the image with the font data.
Expand Down
4 changes: 2 additions & 2 deletions include/guisan/inputevent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ namespace gcn
* True if the input event is consumed,
* false otherwise.
*/
bool mIsConsumed;
bool mIsConsumed = false;

/**
* Holds the distributor of the event.
*/
Widget* mDistributor;
Widget* mDistributor = nullptr;

/**
* Gui is a friend of this class in order to be able to manipulate
Expand Down
14 changes: 7 additions & 7 deletions include/guisan/keyinput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace gcn
/**
* Constructor.
*/
KeyInput() { };
KeyInput() = default;

/**
* Constructor.
Expand Down Expand Up @@ -239,37 +239,37 @@ namespace gcn
/**
* Holds the type of the key input.
*/
unsigned int mType;
unsigned int mType = 0;

/**
* True if shift was pressed at the same time as the key,
* false otherwise.
*/
bool mShiftPressed;
bool mShiftPressed = false;

/**
* True if control was pressed at the same time as the key,
* false otherwise.
*/
bool mControlPressed;
bool mControlPressed = false;

/**
* True if alt was pressed at the same time as the key,
* false otherwise.
*/
bool mAltPressed;
bool mAltPressed = false;

/**
* True if meta was pressed at the same time as the key,
* false otherwise.
*/
bool mMetaPressed;
bool mMetaPressed = false;

/**
* True if the numeric pad was used when the key was pressed,
* false otherwise.
*/
bool mNumericPad;
bool mNumericPad = false;
};
}

Expand Down
Loading

0 comments on commit c9f1d91

Please sign in to comment.