Skip to content

Commit

Permalink
enhancement: guisan: clang tidy, use const when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Sep 12, 2024
1 parent f9a99da commit ff8c6b3
Show file tree
Hide file tree
Showing 55 changed files with 300 additions and 303 deletions.
2 changes: 1 addition & 1 deletion external/libguisan/include/guisan/sdl/sdlinput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace gcn
* @return A Guisan key value.
* @see Key
*/
Key convertSDLEventToGuichanKeyValue(SDL_Event event);
Key convertSDLEventToGuichanKeyValue(const SDL_Event& event);

std::queue<KeyInput> mKeyInputQueue;
std::queue<MouseInput> mMouseInputQueue;
Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/include/guisan/widgets/dropdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace gcn
* @return the ListModel used.
* @see setListModel
*/
ListModel *getListModel();
ListModel *getListModel() const;

/**
* Adjusts the height of the drop down to fit the height of the
Expand Down
6 changes: 3 additions & 3 deletions external/libguisan/include/guisan/widgets/imagetextbutton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ namespace gcn
* @param filename The filename of the image to display.
* @param caption The text to display.
*/
ImageTextButton(const std::string& filename, std::string& caption);
ImageTextButton(const std::string& filename, const std::string& caption);

/**
* Constructor.
*
* @param image The image to display.
* @param caption The text to display.
*/
ImageTextButton(Image* image, std::string& caption);
ImageTextButton(const Image* image, const std::string& caption);

/**
* Destructor.
Expand All @@ -110,7 +110,7 @@ namespace gcn
*
* @return The image of the image button.
*/
Image* getImage();
Image* getImage() const;


// Inherited from Widget
Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/include/guisan/widgets/listbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ namespace gcn
* @return the list model used.
* @see setListModel
*/
ListModel *getListModel();
ListModel *getListModel() const;

/**
* Adjusts the size of the list box to fit its list model.
Expand Down
4 changes: 2 additions & 2 deletions external/libguisan/include/guisan/widgets/messagebox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ namespace gcn
*
* @return the title bar height.
*/
unsigned int getTitleBarHeight();
unsigned int getTitleBarHeight() const;

/**
* Check if the window is movable.
Expand All @@ -184,7 +184,7 @@ namespace gcn
*
* @return true or false.
*/
bool isOpaque();
bool isOpaque() const;

/**
* Add this MessageBox to a parent container, centered both horizontally and vertically
Expand Down
14 changes: 7 additions & 7 deletions external/libguisan/include/guisan/widgets/scrollarea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace gcn
*
* @return the content of the ScrollArea.
*/
Widget* getContent();
Widget* getContent() const;

/**
* Sets the horizontal scrollbar policy.
Expand Down Expand Up @@ -416,42 +416,42 @@ namespace gcn
*
* @return the dimension of the up button.
*/
Rectangle getUpButtonDimension();
Rectangle getUpButtonDimension() const;

/**
* Gets the down button dimension.
*
* @return the dimension of the down button.
*/
Rectangle getDownButtonDimension();
Rectangle getDownButtonDimension() const;

/**
* Gets the left button dimension.
*
* @return the dimension of the left button.
*/
Rectangle getLeftButtonDimension();
Rectangle getLeftButtonDimension() const;

/**
* Gets the right button dimension.
*
* @return the dimension of the right button.
*/
Rectangle getRightButtonDimension();
Rectangle getRightButtonDimension() const;

/**
* Gets the vertical scrollbar dimension.
*
* @return the dimension of the vertical scrollbar.
*/
Rectangle getVerticalBarDimension();
Rectangle getVerticalBarDimension() const;

/**
* Gets the horizontal scrollbar dimension.
*
* @return the dimension of the horizontal scrollbar.
*/
Rectangle getHorizontalBarDimension();
Rectangle getHorizontalBarDimension() const;

/**
* Gets the vertical marker dimension.
Expand Down
6 changes: 3 additions & 3 deletions external/libguisan/include/guisan/widgets/tabbedarea.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ namespace gcn
* @return The selected tab.
* @see isTabSelected, setSelectedTab
*/
Tab* getSelectedTab();
Tab* getSelectedTab() const;


// Inherited from Widget
Expand Down Expand Up @@ -247,12 +247,12 @@ namespace gcn
/**
* Adjusts the size of the tab container and the widget container.
*/
void adjustSize();
void adjustSize() const;

/**
* Adjusts the positions of the tabs.
*/
void adjustTabPositions();
void adjustTabPositions() const;

/**
* Holds the selected tab.
Expand Down
10 changes: 5 additions & 5 deletions external/libguisan/include/guisan/widgets/textbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace gcn
* @param position the positon of the caret.
* @see getCaretPosition
*/
void setCaretPosition(unsigned int position);
void setCaretPosition(unsigned int position) const;

/**
* Gets the row number where the caret is currently located.
Expand All @@ -162,7 +162,7 @@ namespace gcn
* @param The row where the caret should be currently located.
* @see getCaretRow
*/
void setCaretRow(int row);
void setCaretRow(int row) const;

/**
* Gets the column where the caret is currently located.
Expand All @@ -178,7 +178,7 @@ namespace gcn
* @param The column where the caret should be currently located.
* @see getCaretColumn
*/
void setCaretColumn(int column);
void setCaretColumn(int column) const;

/**
* Sets the row and the column where the caret should be currently
Expand All @@ -188,7 +188,7 @@ namespace gcn
* @param column The column where the caret should be currently located.
* @see getCaretRow, getCaretColumn
*/
void setCaretRowColumn(int row, int column);
void setCaretRowColumn(int row, int column) const;

/**
* Scrolls the text to the caret if the text box is in a scroll area.
Expand Down Expand Up @@ -227,7 +227,7 @@ namespace gcn
* @return True if the text box is opaque, false otherwise.
* @see setOpaque
*/
bool isOpaque();
bool isOpaque() const;

/**
* Sets the text box to be opaque or not. An opaque text box will draw
Expand Down
4 changes: 2 additions & 2 deletions external/libguisan/include/guisan/widgets/textfield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace gcn
* @param text The text of the text field.
* @see getText
*/
void setText(const std::string& text);
void setText(const std::string& text) const;

/**
* Gets the text of the text field.
Expand Down Expand Up @@ -140,7 +140,7 @@ namespace gcn
* @param position The caret position.
* @see getCaretPosition
*/
void setCaretPosition(unsigned int position);
void setCaretPosition(unsigned int position) const;

/**
* Gets the caret position. As there is only one line of text
Expand Down
4 changes: 2 additions & 2 deletions external/libguisan/include/guisan/widgets/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace gcn
* @return The title bar height.
* @see setTitleBarHeight
*/
unsigned int getTitleBarHeight();
unsigned int getTitleBarHeight() const;

/**
* Sets the window to be moveble or not.
Expand Down Expand Up @@ -187,7 +187,7 @@ namespace gcn
* @return True if the window is opaque, false otherwise.
* @see setOpaque
*/
bool isOpaque();
bool isOpaque() const;

/**
* Resizes the window to fit the content.
Expand Down
32 changes: 16 additions & 16 deletions external/libguisan/src/basiccontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace gcn
{
WidgetListIterator it;

for (it = mWidgets.begin(); it != mWidgets.end(); it++)
for (it = mWidgets.begin(); it != mWidgets.end(); ++it)
{
if ((*it)->isFocused())
{
Expand All @@ -146,9 +146,9 @@ namespace gcn
it = mWidgets.begin();
}

it++;
++it;

for ( ; it != end; it++)
for ( ; it != end; ++it)
{
if (it == mWidgets.end())
{
Expand All @@ -167,7 +167,7 @@ namespace gcn
{
WidgetListReverseIterator it;

for (it = mWidgets.rbegin(); it != mWidgets.rend(); it++)
for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++it)
{
if ((*it)->isFocused())
{
Expand All @@ -177,14 +177,14 @@ namespace gcn

WidgetListReverseIterator end = it;

it++;
++it;

if (it == mWidgets.rend())
{
it = mWidgets.rbegin();
}

for ( ; it != end; it++)
for ( ; it != end; ++it)
{
if (it == mWidgets.rend())
{
Expand Down Expand Up @@ -212,7 +212,7 @@ namespace gcn
y -= r.y;

WidgetListReverseIterator it;
for (it = mWidgets.rbegin(); it != mWidgets.rend(); it++)
for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++it)
{
if ((*it)->isVisible() && (*it)->getDimension().isContaining(x, y))
{
Expand Down Expand Up @@ -254,7 +254,7 @@ namespace gcn
}

WidgetListIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
(*iter)->_setFocusHandler(focusHandler);
}
Expand All @@ -280,7 +280,7 @@ namespace gcn
void BasicContainer::remove(Widget* widget)
{
WidgetListIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
if (*iter == widget)
{
Expand All @@ -299,7 +299,7 @@ namespace gcn
{
WidgetListIterator iter;

for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
(*iter)->_setFocusHandler(NULL);
(*iter)->_setParent(NULL);
Expand All @@ -314,7 +314,7 @@ namespace gcn
graphics->pushClipArea(getChildrenArea());

WidgetListIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
if ((*iter)->isVisible())
{
Expand Down Expand Up @@ -344,7 +344,7 @@ namespace gcn
void BasicContainer::logicChildren()
{
WidgetListIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
(*iter)->logic();
}
Expand Down Expand Up @@ -383,7 +383,7 @@ namespace gcn
Widget::setInternalFocusHandler(focusHandler);

WidgetListIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
if (mInternalFocusHandler == NULL)
{
Expand All @@ -399,7 +399,7 @@ namespace gcn
Widget* BasicContainer::findWidgetById(const std::string& id)
{
WidgetListIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
if ((*iter)->getId() == id)
{
Expand Down Expand Up @@ -438,7 +438,7 @@ namespace gcn
{
int w = 0, h = 0;

for (WidgetListIterator it = mWidgets.begin(); it != mWidgets.end(); it++)
for (WidgetListIterator it = mWidgets.begin(); it != mWidgets.end(); ++it)
{
if ((*it)->getX() + (*it)->getWidth() > w)
{
Expand All @@ -458,7 +458,7 @@ namespace gcn
{
std::list<Widget*> result;

for (std::list<Widget*>::const_iterator iter = mWidgets.begin(); iter != mWidgets.end(); iter++)
for (std::list<Widget*>::const_iterator iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
Widget* widget = (*iter);
if (ignore != widget && widget->getDimension().isIntersecting(area))
Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/src/cliprectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace gcn
x = y = width = height = xOffset = yOffset = 0;
}

ClipRectangle::ClipRectangle(int x, int y, int width, int height, int xOffset, int yOffset)
ClipRectangle::ClipRectangle(const int x, const int y, const int width, const int height, const int xOffset, const int yOffset)
{
this->x = x;
this->y = y;
Expand Down
Loading

0 comments on commit ff8c6b3

Please sign in to comment.