From 66e7f0fe3bf02277259b86249d6b81985e741e0c Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Tue, 30 Dec 2025 21:49:50 +0100 Subject: [PATCH 01/14] Don't use else after return Get rid of a bunch of 'else' statements after returns. Improves readability and shortens the source. --- include/TGUI/RendererDefines.hpp | 31 ++-- .../Renderer/SFML-Graphics/CanvasSFML.cpp | 3 +- src/Backend/Window/Backend.cpp | 3 +- src/Backend/Window/BackendGui.cpp | 26 ++-- src/Backend/Window/SFML/BackendGuiSFML.cpp | 3 +- src/Backend/Window/SFML/BackendSFML.cpp | 3 +- src/Components.cpp | 10 +- src/Container.cpp | 32 ++--- src/Font.cpp | 20 +-- src/Layout.cpp | 132 ++++++++--------- src/Loading/DataIO.cpp | 48 +++---- src/Loading/Deserializer.cpp | 68 ++++----- src/Loading/Serializer.cpp | 23 ++- src/Loading/Theme.cpp | 6 +- src/Loading/ThemeLoader.cpp | 3 +- src/Loading/WidgetFactory.cpp | 3 +- src/Renderers/BoxLayoutRenderer.cpp | 14 +- src/Renderers/ChildWindowRenderer.cpp | 13 +- src/Renderers/WidgetRenderer.cpp | 9 +- src/SignalManager.cpp | 6 +- src/String.cpp | 14 +- src/SvgImage.cpp | 3 +- src/Text.cpp | 22 ++- src/Texture.cpp | 6 +- src/Transform.cpp | 3 +- src/Widget.cpp | 26 ++-- src/Widgets/BitmapButton.cpp | 3 +- src/Widgets/BoxLayout.cpp | 3 +- src/Widgets/Button.cpp | 11 +- src/Widgets/ButtonBase.cpp | 3 +- src/Widgets/ChatBox.cpp | 19 ++- src/Widgets/CheckBox.cpp | 22 +-- src/Widgets/ChildWindow.cpp | 19 ++- src/Widgets/ClickableWidget.cpp | 16 +-- src/Widgets/ColorPicker.cpp | 8 +- src/Widgets/ComboBox.cpp | 6 +- src/Widgets/ContextMenu.cpp | 3 +- src/Widgets/EditBox.cpp | 17 +-- src/Widgets/EditBoxSlider.cpp | 6 +- src/Widgets/FileDialog.cpp | 48 +++---- src/Widgets/Grid.cpp | 15 +- src/Widgets/Group.cpp | 3 +- src/Widgets/GrowHorizontalLayout.cpp | 3 +- src/Widgets/GrowVerticalLayout.cpp | 3 +- src/Widgets/HorizontalLayout.cpp | 3 +- src/Widgets/HorizontalWrap.cpp | 3 +- src/Widgets/Knob.cpp | 11 +- src/Widgets/Label.cpp | 9 +- src/Widgets/ListBox.cpp | 19 ++- src/Widgets/ListView.cpp | 134 +++++++----------- src/Widgets/MenuBar.cpp | 6 +- src/Widgets/MenuWidgetBase.cpp | 48 +++---- src/Widgets/MessageBox.cpp | 6 +- src/Widgets/Panel.cpp | 18 ++- src/Widgets/Picture.cpp | 6 +- src/Widgets/ProgressBar.cpp | 8 +- src/Widgets/RadioButton.cpp | 110 ++++++-------- src/Widgets/RadioButtonGroup.cpp | 3 +- src/Widgets/RangeSlider.cpp | 12 +- src/Widgets/RichTextLabel.cpp | 9 +- src/Widgets/ScrollablePanel.cpp | 8 +- src/Widgets/Scrollbar.cpp | 22 ++- src/Widgets/SeparatorLine.cpp | 3 +- src/Widgets/Slider.cpp | 32 ++--- src/Widgets/SpinButton.cpp | 11 +- src/Widgets/SpinControl.cpp | 6 +- src/Widgets/SplitContainer.cpp | 30 ++-- src/Widgets/TabContainer.cpp | 8 +- src/Widgets/Tabs.cpp | 14 +- src/Widgets/TextArea.cpp | 34 ++--- src/Widgets/ToggleButton.cpp | 11 +- src/Widgets/TreeView.cpp | 78 +++++----- src/Widgets/VerticalLayout.cpp | 3 +- 73 files changed, 552 insertions(+), 851 deletions(-) diff --git a/include/TGUI/RendererDefines.hpp b/include/TGUI/RendererDefines.hpp index ec8c2afcd..84ef2983b 100644 --- a/include/TGUI/RendererDefines.hpp +++ b/include/TGUI/RendererDefines.hpp @@ -35,8 +35,7 @@ const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \ if (it != m_data->propertyValuePairs.end()) \ return it->second.getOutline(); \ - else \ - return {}; \ + return {}; \ } \ void CLASS::set##NAME(const tgui::Outline& outline) \ { \ @@ -51,8 +50,7 @@ const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \ if (it != m_data->propertyValuePairs.end()) \ return it->second.getColor(); \ - else \ - return DEFAULT; \ + return DEFAULT; \ } \ void CLASS::set##NAME(tgui::Color color) \ { \ @@ -67,8 +65,7 @@ const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \ if (it != m_data->propertyValuePairs.end()) \ return it->second.getTextStyle(); \ - else \ - return DEFAULT; \ + return DEFAULT; \ } \ void CLASS::set##NAME(tgui::TextStyles style) \ { \ @@ -83,8 +80,7 @@ const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \ if (it != m_data->propertyValuePairs.end()) \ return it->second.getNumber(); \ - else \ - return DEFAULT; \ + return DEFAULT; \ } #define TGUI_RENDERER_PROPERTY_NUMBER(CLASS, NAME, DEFAULT) \ @@ -102,8 +98,7 @@ const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \ if (it != m_data->propertyValuePairs.end()) \ return it->second.getBool(); \ - else \ - return DEFAULT; \ + return DEFAULT; \ } #define TGUI_RENDERER_PROPERTY_BOOL(CLASS, NAME, DEFAULT) \ @@ -121,11 +116,8 @@ const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \ if (it != m_data->propertyValuePairs.end()) \ return it->second.getTexture(); \ - else \ - { \ - m_data->propertyValuePairs[tgui::String(#NAME)] = {tgui::Texture{}}; \ - return m_data->propertyValuePairs[tgui::String(#NAME)].getTexture(); \ - } \ + m_data->propertyValuePairs[tgui::String(#NAME)] = {tgui::Texture{}}; \ + return m_data->propertyValuePairs[tgui::String(#NAME)].getTexture(); \ } \ void CLASS::set##NAME(const tgui::Texture& texture) \ { \ @@ -140,12 +132,9 @@ const auto it = m_data->propertyValuePairs.find(tgui::String(#NAME)); \ if (it != m_data->propertyValuePairs.end()) \ return it->second.getRenderer(); \ - else \ - { \ - const auto& renderer = tgui::Theme::getDefault()->getRendererNoThrow(RENDERER); \ - m_data->propertyValuePairs[tgui::String(#NAME)] = {renderer ? renderer : (DEFAULT)}; \ - return renderer; \ - } \ + const auto& renderer = tgui::Theme::getDefault()->getRendererNoThrow(RENDERER); \ + m_data->propertyValuePairs[tgui::String(#NAME)] = {renderer ? renderer : (DEFAULT)}; \ + return renderer; \ } \ void CLASS::set##NAME(std::shared_ptr renderer) \ { \ diff --git a/src/Backend/Renderer/SFML-Graphics/CanvasSFML.cpp b/src/Backend/Renderer/SFML-Graphics/CanvasSFML.cpp index 3d98eb8ee..786e15aa4 100644 --- a/src/Backend/Renderer/SFML-Graphics/CanvasSFML.cpp +++ b/src/Backend/Renderer/SFML-Graphics/CanvasSFML.cpp @@ -114,8 +114,7 @@ namespace tgui { if (canvas) return std::static_pointer_cast(canvas->clone()); - else - return nullptr; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Backend/Window/Backend.cpp b/src/Backend/Window/Backend.cpp index 368847d83..4abf15b6d 100644 --- a/src/Backend/Window/Backend.cpp +++ b/src/Backend/Window/Backend.cpp @@ -109,8 +109,7 @@ namespace tgui { if (m_fontBackend) return {static_cast(defaultFontBytes), sizeof(defaultFontBytes)}; - else - return {}; + return {}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Backend/Window/BackendGui.cpp b/src/Backend/Window/BackendGui.cpp index 6234f597f..a799791b6 100644 --- a/src/Backend/Window/BackendGui.cpp +++ b/src/Backend/Window/BackendGui.cpp @@ -147,7 +147,7 @@ namespace tgui if (event.type == Event::Type::MouseMoved) return m_container->processMouseMoveEvent(mouseCoords); - else if (event.type == Event::Type::MouseWheelScrolled) + if (event.type == Event::Type::MouseWheelScrolled) { if (m_container->processScrollEvent(event.mouseWheel.delta, mouseCoords, false)) return true; @@ -155,17 +155,15 @@ namespace tgui // Even if no scrollbar moved, we will still absorb the scroll event when the mouse is on top of a widget return m_container->getWidgetAtPos(mouseCoords, false) != nullptr; } - else if (event.type == Event::Type::MouseButtonPressed) + if (event.type == Event::Type::MouseButtonPressed) return m_container->processMousePressEvent(event.mouseButton.button, mouseCoords); - else // if (event.type == Event::Type::MouseButtonReleased) - { - const bool eventHandled = m_container->processMouseReleaseEvent(event.mouseButton.button, mouseCoords); - if (event.mouseButton.button == Event::MouseButton::Left) - m_container->leftMouseButtonNoLongerDown(); - else if (event.mouseButton.button == Event::MouseButton::Right) - m_container->rightMouseButtonNoLongerDown(); - return eventHandled; - } + // if (event.type == Event::Type::MouseButtonReleased) + const bool eventHandled = m_container->processMouseReleaseEvent(event.mouseButton.button, mouseCoords); + if (event.mouseButton.button == Event::MouseButton::Left) + m_container->leftMouseButtonNoLongerDown(); + else if (event.mouseButton.button == Event::MouseButton::Right) + m_container->rightMouseButtonNoLongerDown(); + return eventHandled; } case Event::Type::KeyPressed: { @@ -178,8 +176,7 @@ namespace tgui return true; } - else - return m_container->processKeyPressEvent(event.key); + return m_container->processKeyPressEvent(event.key); } case Event::Type::TextEntered: { @@ -271,8 +268,7 @@ namespace tgui { if (m_container->getInheritedFont()) return m_container->getInheritedFont(); - else - return Font::getGlobalFont(); + return Font::getGlobalFont(); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Backend/Window/SFML/BackendGuiSFML.cpp b/src/Backend/Window/SFML/BackendGuiSFML.cpp index b9ffbcd11..eb4a6fef7 100644 --- a/src/Backend/Window/SFML/BackendGuiSFML.cpp +++ b/src/Backend/Window/SFML/BackendGuiSFML.cpp @@ -258,8 +258,7 @@ namespace tgui Optional duration = Timer::getNextScheduledTime(); if (duration && (*duration < std::chrono::milliseconds(10))) return *duration; - else - return Duration{std::chrono::milliseconds(10)}; + return Duration{std::chrono::milliseconds(10)}; }; setDrawingUpdatesTime(false); diff --git a/src/Backend/Window/SFML/BackendSFML.cpp b/src/Backend/Window/SFML/BackendSFML.cpp index e8f3d7f70..1504fd0ef 100644 --- a/src/Backend/Window/SFML/BackendSFML.cpp +++ b/src/Backend/Window/SFML/BackendSFML.cpp @@ -314,8 +314,7 @@ namespace tgui auto cursor = sf::Cursor::createFromSystem(typeSFML); if (cursor) return std::make_unique(std::move(*cursor)); - else - return nullptr; + return nullptr; #else auto cursor = std::make_unique(); if (cursor->loadFromSystem(typeSFML)) diff --git a/src/Components.cpp b/src/Components.cpp index 17b88b8c7..02430590a 100644 --- a/src/Components.cpp +++ b/src/Components.cpp @@ -491,11 +491,10 @@ namespace dev { if ((pos.x < m_borders.getLeft()) || (pos.y < m_borders.getTop()) || (pos.x >= m_borders.getLeft() + m_clientSize.x) || (pos.y >= m_borders.getTop() + m_clientSize.y)) return false; - else - return m_sprite.isTransparentPixel(pos - m_borders.getOffset()); + return m_sprite.isTransparentPixel(pos - m_borders.getOffset()); } - else /// TODO: Perform check when using rounded corners - return false; + /// TODO: Perform check when using rounded corners + return false; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -849,8 +848,7 @@ namespace dev { if (transparentTexture && m_sprite.isSet()) /// TODO: transparentTexture should be option on Texture (similar to Smooth) instead of a parameter return m_sprite.isTransparentPixel(pos); - else - return false; + return false; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Container.cpp b/src/Container.cpp index 14cf59c8b..6de0decd2 100644 --- a/src/Container.cpp +++ b/src/Container.cpp @@ -1211,22 +1211,20 @@ namespace tgui return true; } - else // The mouse did not went down on a widget, so unfocus the focused child widget, but keep ourselves focused + // The mouse did not went down on a widget, so unfocus the focused child widget, but keep ourselves focused + if (button == Event::MouseButton::Left) { - if (button == Event::MouseButton::Left) - { - m_widgetWithLeftMouseDown = nullptr; - m_draggingWidget = false; - } - else if (button == Event::MouseButton::Right) - m_widgetWithRightMouseDown = nullptr; + m_widgetWithLeftMouseDown = nullptr; + m_draggingWidget = false; + } + else if (button == Event::MouseButton::Right) + m_widgetWithRightMouseDown = nullptr; - if (m_focusedWidget) - m_focusedWidget->setFocused(false); + if (m_focusedWidget) + m_focusedWidget->setFocused(false); - m_focusedWidget = nullptr; - setFocused(true); - } + m_focusedWidget = nullptr; + setFocused(true); return false; } @@ -1246,7 +1244,7 @@ namespace tgui m_draggingWidget = false; return true; } - else if ((button == Event::MouseButton::Right) && m_widgetWithRightMouseDown) + if ((button == Event::MouseButton::Right) && m_widgetWithRightMouseDown) { m_widgetWithRightMouseDown->rightMouseButtonNoLongerDown(); m_widgetWithRightMouseDown = nullptr; @@ -1290,17 +1288,17 @@ namespace tgui m_focusedWidget->getNavigationUp()->setFocused(true); return true; } - else if ((event.code == Event::KeyboardKey::Down) && m_focusedWidget->getNavigationDown()) + if ((event.code == Event::KeyboardKey::Down) && m_focusedWidget->getNavigationDown()) { m_focusedWidget->getNavigationDown()->setFocused(true); return true; } - else if ((event.code == Event::KeyboardKey::Left) && m_focusedWidget->getNavigationLeft()) + if ((event.code == Event::KeyboardKey::Left) && m_focusedWidget->getNavigationLeft()) { m_focusedWidget->getNavigationLeft()->setFocused(true); return true; } - else if ((event.code == Event::KeyboardKey::Right) && m_focusedWidget->getNavigationRight()) + if ((event.code == Event::KeyboardKey::Right) && m_focusedWidget->getNavigationRight()) { m_focusedWidget->getNavigationRight()->setFocused(true); return true; diff --git a/src/Font.cpp b/src/Font.cpp index 725fc8eae..0b68a5c62 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -137,11 +137,9 @@ namespace tgui { if (m_backendFont != nullptr) return m_backendFont->getGlyph(codePoint, characterSize, bold, outlineThickness); - else - { - TGUI_PRINT_WARNING("Font::getGlyph called on font that wasn't initialized"); - return {}; - } + + TGUI_PRINT_WARNING("Font::getGlyph called on font that wasn't initialized"); + return {}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -150,8 +148,7 @@ namespace tgui { if (m_backendFont) return m_backendFont->getKerning(first, second, characterSize, bold); - else - return 0; + return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -160,8 +157,7 @@ namespace tgui { if (m_backendFont) return m_backendFont->getLineSpacing(characterSize); - else - return 0; + return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -170,8 +166,7 @@ namespace tgui { if (m_backendFont) return m_backendFont->getFontHeight(characterSize); - else - return 0; + return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -188,8 +183,7 @@ namespace tgui { if (m_backendFont) return m_backendFont->isSmooth(); - else - return true; + return true; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Layout.cpp b/src/Layout.cpp index 6f3bff4e5..e68f73208 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -189,21 +189,20 @@ namespace tgui *this = Layout{expression.substr(1, expression.size()-2)}; return; } - else if ((searchPos == 3) && (bracketPos == expression.size()-1) && (expression.substr(0, 3) == U"min")) + if ((searchPos == 3) && (bracketPos == expression.size()-1) && (expression.substr(0, 3) == U"min")) { const auto& minSubExpressions = parseMinMaxExpresssion(expression.substr(4, expression.size() - 5)); *this = Layout{Operation::Minimum, std::make_unique(minSubExpressions.first), std::make_unique(minSubExpressions.second)}; return; } - else if ((searchPos == 3) && (bracketPos == expression.size()-1) && (expression.substr(0, 3) == U"max")) + if ((searchPos == 3) && (bracketPos == expression.size()-1) && (expression.substr(0, 3) == U"max")) { const auto& maxSubExpressions = parseMinMaxExpresssion(expression.substr(4, expression.size() - 5)); *this = Layout{Operation::Maximum, std::make_unique(maxSubExpressions.first), std::make_unique(maxSubExpressions.second)}; return; } - else // The brackets form a sub-expression - searchPos = bracketPos; - + // The brackets form a sub-expression + searchPos = bracketPos; break; } @@ -215,12 +214,10 @@ namespace tgui TGUI_PRINT_WARNING("bracket mismatch while parsing layout string '" << expression << "'."); return; } - else - { - // Search for the next operator, starting from the closing bracket, but keeping prevSearchPos before the opening bracket - searchPos = expression.find_first_of("+-/*()", searchPos + 1); - continue; - } + + // Search for the next operator, starting from the closing bracket, but keeping prevSearchPos before the opening bracket + searchPos = expression.find_first_of("+-/*()", searchPos + 1); + continue; } case ')': TGUI_PRINT_WARNING("bracket mismatch while parsing layout string '" << expression << "'."); @@ -471,15 +468,13 @@ namespace tgui { return String::fromNumber(m_value); } - else if (m_operation == Operation::Minimum) + if (m_operation == Operation::Minimum) { return U"min(" + m_leftOperand->toString() + U", " + m_rightOperand->toString() + U")"; } - else if (m_operation == Operation::Maximum) - { + if (m_operation == Operation::Maximum) return U"max(" + m_leftOperand->toString() + U", " + m_rightOperand->toString() + U")"; - } - else if ((m_operation == Operation::Plus) || (m_operation == Operation::Minus) || (m_operation == Operation::Multiplies) || (m_operation == Operation::Divides)) + if ((m_operation == Operation::Plus) || (m_operation == Operation::Minus) || (m_operation == Operation::Multiplies) || (m_operation == Operation::Divides)) { char operatorChar; if (m_operation == Operation::Plus) @@ -507,66 +502,54 @@ namespace tgui if (subExpressionNeedsBrackets(m_leftOperand) && subExpressionNeedsBrackets(m_rightOperand)) return U"(" + m_leftOperand->toString() + U") " + operatorChar + U" (" + m_rightOperand->toString() + U")"; - else if (subExpressionNeedsBrackets(m_leftOperand)) + if (subExpressionNeedsBrackets(m_leftOperand)) return U"(" + m_leftOperand->toString() + U") " + operatorChar + U" " + m_rightOperand->toString(); - else if (subExpressionNeedsBrackets(m_rightOperand)) + if (subExpressionNeedsBrackets(m_rightOperand)) return m_leftOperand->toString() + U" " + operatorChar + U" (" + m_rightOperand->toString() + U")"; - else - { - if ((m_operation == Operation::Multiplies) && (m_leftOperand->m_operation == Operation::Value) && (m_rightOperand->toString() == U"100%")) - return String::fromNumber(m_leftOperand->getValue() * 100) + '%'; - else - return m_leftOperand->toString() + U" " + operatorChar + U" " + m_rightOperand->toString(); - } + if ((m_operation == Operation::Multiplies) && (m_leftOperand->m_operation == Operation::Value) && (m_rightOperand->toString() == U"100%")) + return String::fromNumber(m_leftOperand->getValue() * 100) + '%'; + return m_leftOperand->toString() + U" " + operatorChar + U" " + m_rightOperand->toString(); } - else - { - if (m_boundString == U"&.innersize") - return U"100%"; + if (m_boundString == U"&.innersize") + return U"100%"; - // Hopefully the expression is stored in the bound string, otherwise (i.e. when bind functions were used) it is infeasible to turn it into a string - if (!m_boundString.empty()) - return m_boundString; - else + // Hopefully the expression is stored in the bound string, otherwise (i.e. when bind functions were used) it is infeasible to turn it into a string + if (!m_boundString.empty()) + return m_boundString; + if ((m_operation == Operation::BindingPosX) || (m_operation == Operation::BindingPosY) + || (m_operation == Operation::BindingLeft) || (m_operation == Operation::BindingTop) + || (m_operation == Operation::BindingWidth) || (m_operation == Operation::BindingHeight) + || (m_operation == Operation::BindingInnerWidth) || (m_operation == Operation::BindingInnerHeight)) + { + TGUI_ASSERT(m_boundWidget != nullptr, "There has to be a bound widget with this operation type"); + const String boundWidgetName = m_boundWidget->getWidgetName(); + if (boundWidgetName.empty()) { - if ((m_operation == Operation::BindingPosX) || (m_operation == Operation::BindingPosY) - || (m_operation == Operation::BindingLeft) || (m_operation == Operation::BindingTop) - || (m_operation == Operation::BindingWidth) || (m_operation == Operation::BindingHeight) - || (m_operation == Operation::BindingInnerWidth) || (m_operation == Operation::BindingInnerHeight)) - { - TGUI_ASSERT(m_boundWidget != nullptr, "There has to be a bound widget with this operation type"); - const String boundWidgetName = m_boundWidget->getWidgetName(); - if (boundWidgetName.empty()) - { - TGUI_PRINT_WARNING("layout can't be correctly converted to string because the bound widget has no name"); - } - - if (m_operation == Operation::BindingPosX) - return boundWidgetName + U".x"; - else if (m_operation == Operation::BindingPosY) - return boundWidgetName + U".y"; - else if (m_operation == Operation::BindingLeft) - return boundWidgetName + U".left"; - else if (m_operation == Operation::BindingTop) - return boundWidgetName + U".top"; - else if (m_operation == Operation::BindingWidth) - return boundWidgetName + U".width"; - else if (m_operation == Operation::BindingHeight) - return boundWidgetName + U".height"; - else if (m_operation == Operation::BindingInnerWidth) - return boundWidgetName + U".innerwidth"; - else - { - TGUI_ASSERT(m_operation == Operation::BindingInnerHeight, "Operation can't be anything other than BindingInnerHeight here"); - return boundWidgetName + U".innerheight"; - } - } - - // The layout contains an empty string - TGUI_ASSERT(m_operation == Operation::BindingString, "All operation types should have been covered already"); - return m_boundString; + TGUI_PRINT_WARNING("layout can't be correctly converted to string because the bound widget has no name"); } + + if (m_operation == Operation::BindingPosX) + return boundWidgetName + U".x"; + if (m_operation == Operation::BindingPosY) + return boundWidgetName + U".y"; + if (m_operation == Operation::BindingLeft) + return boundWidgetName + U".left"; + if (m_operation == Operation::BindingTop) + return boundWidgetName + U".top"; + if (m_operation == Operation::BindingWidth) + return boundWidgetName + U".width"; + if (m_operation == Operation::BindingHeight) + return boundWidgetName + U".height"; + if (m_operation == Operation::BindingInnerWidth) + return boundWidgetName + U".innerwidth"; + + TGUI_ASSERT(m_operation == Operation::BindingInnerHeight, "Operation can't be anything other than BindingInnerHeight here"); + return boundWidgetName + U".innerheight"; } + + // The layout contains an empty string + TGUI_ASSERT(m_operation == Operation::BindingString, "All operation types should have been covered already"); + return m_boundString; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -836,22 +819,19 @@ namespace tgui { if (xAxis) return parseBindingString(U"width", widget, xAxis); - else - return parseBindingString(U"height", widget, xAxis); + return parseBindingString(U"height", widget, xAxis); } else if (expression == U"innersize") { if (xAxis) return parseBindingString(U"innerwidth", widget, xAxis); - else - return parseBindingString(U"innerheight", widget, xAxis); + return parseBindingString(U"innerheight", widget, xAxis); } else if ((expression == U"pos") || (expression == U"position")) { if (xAxis) return parseBindingString(U"x", widget, xAxis); - else - return parseBindingString(U"y", widget, xAxis); + return parseBindingString(U"y", widget, xAxis); } else { @@ -867,7 +847,7 @@ namespace tgui // If there is no parent yet then patiently wait until the widget is added to its parent return; } - else if (!widgetName.empty()) + if (!widgetName.empty()) { // If the widget is a container, search in its children first Container* container = dynamic_cast(widget); diff --git a/src/Loading/DataIO.cpp b/src/Loading/DataIO.cpp index f2ae24899..c9ae4868d 100644 --- a/src/Loading/DataIO.cpp +++ b/src/Loading/DataIO.cpp @@ -80,8 +80,7 @@ { \ if (ReturnErrorOnEOF) \ return "Unexpected EOF while parsing."; \ - else \ - return ""; \ + return ""; \ } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -106,7 +105,7 @@ namespace tgui stream.read(&c, 1); return word; } - else if (!std::isspace(static_cast(c)) && (c != '=') && (c != ';') && (c != ':') && (c != '{') && (c != '}')) + if (!std::isspace(static_cast(c)) && (c != '=') && (c != ';') && (c != ':') && (c != '{') && (c != '}')) { stream.read(&c, 1); @@ -242,13 +241,13 @@ namespace tgui if ((c == '=') || (c == '{')) return ""; - else if ((c == ';') || (c == '}')) + if ((c == ';') || (c == '}')) { // Remove trailing whitespace before returning the line line.erase(line.find_last_not_of(" \n\r\t")+1); return line; } - else if (::isspace(c)) + if (::isspace(c)) { stream.read(&c, 1); if (!whitespaceFound) @@ -349,21 +348,16 @@ namespace tgui node->propertyValuePairs[key] = std::move(valueNode); return ""; } - else - { - if (stream.peek() == EOF) - return "Found EOF while trying to read a value."; - else - { - chr = static_cast(stream.peek()); - if (chr == '=') - return "Found '=' while trying to read a value."; - else if (chr == '{') - return "Found '{' while trying to read a value."; - else - return "Found empty value."; - } - } + + if (stream.peek() == EOF) + return "Found EOF while trying to read a value."; + + chr = static_cast(stream.peek()); + if (chr == '=') + return "Found '=' while trying to read a value."; + if (chr == '{') + return "Found '{' while trying to read a value."; + return "Found empty value."; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -450,7 +444,7 @@ namespace tgui { if (stream.peek() == EOF) return "Found EOF while trying to read property or nested section name."; - else if (stream.peek() == '}') + if (stream.peek() == '}') { node->children.push_back(std::move(sectionNode)); @@ -464,7 +458,7 @@ namespace tgui REMOVE_WHITESPACE_AND_COMMENTS(false) return ""; } - else if (stream.peek() != '{') + if (stream.peek() != '{') return "Expected property or nested section name, found '" + String(1, static_cast(stream.peek())) + "' instead."; } @@ -511,12 +505,11 @@ namespace tgui REMOVE_WHITESPACE_AND_COMMENTS(true) if (stream.peek() == '{') return parseSection(stream, root, word); - else if (stream.peek() == '=') + if (stream.peek() == '=') return parseKeyValue(stream, root, word); - else if (stream.peek() == ':') + if (stream.peek() == ':') return parseInheritance(stream, root, word); - else - return "Expected '{', '=' or ':', found '" + String(1, static_cast(stream.peek())) + "' instead."; + return "Expected '{', '=' or ':', found '" + String(1, static_cast(stream.peek())) + "' instead."; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -581,8 +574,7 @@ namespace tgui auto lineNumber = std::count(str.begin(), str.begin() + static_cast(position), U'\n') + 1; throw Exception{U"Error while parsing input at line " + String::fromNumber(lineNumber) + U". " + error}; } - else - throw Exception{U"Error while parsing input. " + error}; + throw Exception{U"Error while parsing input. " + error}; } } diff --git a/src/Loading/Deserializer.cpp b/src/Loading/Deserializer.cpp index 7404b2ca0..9cfe10851 100644 --- a/src/Loading/Deserializer.cpp +++ b/src/Loading/Deserializer.cpp @@ -41,18 +41,18 @@ namespace tgui if (c == U'a') return 10; - else if (c == U'b') + if (c == U'b') return 11; - else if (c == U'c') + if (c == U'c') return 12; - else if (c == U'd') + if (c == U'd') return 13; - else if (c == U'e') + if (c == U'e') return 14; - else if (c == U'f') + if (c == U'f') return 15; - else // if (c >= U'0' && c <= U'9') - return static_cast(c - U'0'); + // if (c >= U'0' && c <= U'9') + return static_cast(c - U'0'); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -82,12 +82,12 @@ namespace tgui rect = {tokens[0].toUInt(), tokens[1].toUInt(), tokens[2].toUInt(), tokens[3].toUInt()}; return true; } - else if (!rectRequiresFourValues && (tokens.size() == 2)) + if (!rectRequiresFourValues && (tokens.size() == 2)) { rect = {tokens[0].toUInt(), tokens[1].toUInt(), 0, 0}; return true; } - else if (!rectRequiresFourValues && (tokens.size() == 1)) + if (!rectRequiresFourValues && (tokens.size() == 1)) { rect = {tokens[0].toUInt(), tokens[0].toUInt(), 0, 0}; return true; @@ -103,10 +103,10 @@ namespace tgui { if (viewEqualIgnoreCase(str, U"true") || viewEqualIgnoreCase(str, U"yes") || viewEqualIgnoreCase(str, U"on") || viewEqualIgnoreCase(str, U"1")) return {true}; - else if (viewEqualIgnoreCase(str, U"false") || viewEqualIgnoreCase(str, U"no") || viewEqualIgnoreCase(str, U"off") || viewEqualIgnoreCase(str, U"0")) + if (viewEqualIgnoreCase(str, U"false") || viewEqualIgnoreCase(str, U"no") || viewEqualIgnoreCase(str, U"off") || viewEqualIgnoreCase(str, U"0")) return {false}; - else - throw Exception{U"Failed to deserialize boolean from '" + str + U"'"}; + + throw Exception{U"Failed to deserialize boolean from '" + str + U"'"}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -170,35 +170,31 @@ namespace tgui static_cast(hexToDec(str[2]) * 16 + hexToDec(str[2])), static_cast(hexToDec(str[3]) * 16 + hexToDec(str[3]))}; } - else if (str.length() == 5) + if (str.length() == 5) { return Color{static_cast(hexToDec(str[1]) * 16 + hexToDec(str[1])), static_cast(hexToDec(str[2]) * 16 + hexToDec(str[2])), static_cast(hexToDec(str[3]) * 16 + hexToDec(str[3])), static_cast(hexToDec(str[4]) * 16 + hexToDec(str[4]))}; } - else if (str.length() == 7) + if (str.length() == 7) { return Color{static_cast(hexToDec(str[1]) * 16 + hexToDec(str[2])), static_cast(hexToDec(str[3]) * 16 + hexToDec(str[4])), static_cast(hexToDec(str[5]) * 16 + hexToDec(str[6]))}; } - else // if (str.length() == 9) - { - return Color{static_cast(hexToDec(str[1]) * 16 + hexToDec(str[2])), - static_cast(hexToDec(str[3]) * 16 + hexToDec(str[4])), - static_cast(hexToDec(str[5]) * 16 + hexToDec(str[6])), - static_cast(hexToDec(str[7]) * 16 + hexToDec(str[8]))}; - } + // if (str.length() == 9) + return Color{static_cast(hexToDec(str[1]) * 16 + hexToDec(str[2])), + static_cast(hexToDec(str[3]) * 16 + hexToDec(str[4])), + static_cast(hexToDec(str[5]) * 16 + hexToDec(str[6])), + static_cast(hexToDec(str[7]) * 16 + hexToDec(str[8]))}; } - else // Color doesn't start with '#' + // Color doesn't start with '#' + // Check if the color is represented by a string with its name + for (const auto& pair : Color::colorNamesMap) { - // Check if the color is represented by a string with its name - for (const auto& pair : Color::colorNamesMap) - { - if (str == pair.first) - return pair.second; - } + if (str == pair.first) + return pair.second; } // The string can optionally start with "rgb" or "rgba", but this is ignored @@ -249,8 +245,7 @@ namespace tgui return {result}; } - else - return {value}; + return {value}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -279,12 +274,12 @@ namespace tgui const std::vector tokens = Deserializer::split(str, ','); if (tokens.size() == 1) return {Outline{tokens[0]}}; - else if (tokens.size() == 2) + if (tokens.size() == 2) return {Outline{tokens[0], tokens[1]}}; - else if (tokens.size() == 4) + if (tokens.size() == 4) return {Outline{tokens[0], tokens[1], tokens[2], tokens[3]}}; - else - throw Exception{U"Failed to deserialize outline '" + value + U"'. Expected numbers separated with a comma."}; + + throw Exception{U"Failed to deserialize outline '" + value + U"'. Expected numbers separated with a comma."}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -348,13 +343,12 @@ namespace tgui smooth = true; break; } - else if (viewEqualIgnoreCase(smoothParam, U"nosmooth")) + if (viewEqualIgnoreCase(smoothParam, U"nosmooth")) { smooth = false; break; } - else - throw Exception{U"Failed to deserialize texture '" + value + U"'. Invalid text found behind filename."}; + throw Exception{U"Failed to deserialize texture '" + value + U"'. Invalid text found behind filename."}; } if (word.empty()) diff --git a/src/Loading/Serializer.cpp b/src/Loading/Serializer.cpp index b89bae3da..5db798604 100644 --- a/src/Loading/Serializer.cpp +++ b/src/Loading/Serializer.cpp @@ -44,18 +44,17 @@ namespace tgui if (c == 10) return 'A'; - else if (c == 11) + if (c == 11) return 'B'; - else if (c == 12) + if (c == 12) return 'C'; - else if (c == 13) + if (c == 13) return 'D'; - else if (c == 14) + if (c == 14) return 'E'; - else if (c == 15) + if (c == 15) return 'F'; - else - return static_cast(c + '0'); + return static_cast(c + '0'); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -78,8 +77,7 @@ namespace tgui { if (value.getBool()) return "true"; - else - return "false"; + return "false"; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -88,8 +86,7 @@ namespace tgui { if (value.getFont() && !value.getFont().getId().empty()) return Serializer::serialize({value.getFont().getId()}); - else - return "null"; + return "null"; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -249,8 +246,8 @@ namespace tgui if (!encodedStyle.empty()) return encodedStyle.substr(3); - else // Something is wrong with the style parameter - return "Regular"; + // Something is wrong with the style parameter + return "Regular"; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Loading/Theme.cpp b/src/Loading/Theme.cpp index 9a275bcb3..a8ddc8408 100644 --- a/src/Loading/Theme.cpp +++ b/src/Loading/Theme.cpp @@ -808,8 +808,7 @@ namespace tgui auto propertyIt = m_globalProperties.find(property); if (propertyIt != m_globalProperties.end()) return propertyIt->second; - else - return {}; + return {}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -845,8 +844,7 @@ namespace tgui m_renderers.erase(it); return true; } - else - return false; + return false; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Loading/ThemeLoader.cpp b/src/Loading/ThemeLoader.cpp index 6de006b5b..6f141e582 100644 --- a/src/Loading/ThemeLoader.cpp +++ b/src/Loading/ThemeLoader.cpp @@ -240,8 +240,7 @@ namespace tgui { if (filename.empty()) return true; - else - return m_propertiesCache[filename].find(section) != m_propertiesCache[filename].end(); + return m_propertiesCache[filename].find(section) != m_propertiesCache[filename].end(); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Loading/WidgetFactory.cpp b/src/Loading/WidgetFactory.cpp index a0bb3afd1..33c6bec1a 100644 --- a/src/Loading/WidgetFactory.cpp +++ b/src/Loading/WidgetFactory.cpp @@ -93,8 +93,7 @@ namespace tgui auto it = m_constructFunctions.find(type); if (it != m_constructFunctions.end()) return it->second; - else - return nullptr; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Renderers/BoxLayoutRenderer.cpp b/src/Renderers/BoxLayoutRenderer.cpp index 332121865..8c378da17 100644 --- a/src/Renderers/BoxLayoutRenderer.cpp +++ b/src/Renderers/BoxLayoutRenderer.cpp @@ -43,17 +43,13 @@ namespace tgui auto it = m_data->propertyValuePairs.find("SpaceBetweenWidgets"); if (it != m_data->propertyValuePairs.end()) return it->second.getNumber(); - else + it = m_data->propertyValuePairs.find("Padding"); + if (it != m_data->propertyValuePairs.end()) { - it = m_data->propertyValuePairs.find("Padding"); - if (it != m_data->propertyValuePairs.end()) - { - const Padding padding = it->second.getOutline(); - return std::max(std::min(padding.getLeft(), padding.getRight()), std::min(padding.getTop(), padding.getBottom())); - } - else - return 0; + const Padding padding = it->second.getOutline(); + return std::max(std::min(padding.getLeft(), padding.getRight()), std::min(padding.getTop(), padding.getBottom())); } + return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Renderers/ChildWindowRenderer.cpp b/src/Renderers/ChildWindowRenderer.cpp index 18bed4535..c1e7cb5b0 100644 --- a/src/Renderers/ChildWindowRenderer.cpp +++ b/src/Renderers/ChildWindowRenderer.cpp @@ -59,14 +59,11 @@ namespace tgui auto it = m_data->propertyValuePairs.find("TitleBarHeight"); if (it != m_data->propertyValuePairs.end()) return it->second.getNumber(); - else - { - it = m_data->propertyValuePairs.find("TextureTitleBar"); - if (it != m_data->propertyValuePairs.end() && it->second.getTexture().getData()) - return static_cast(it->second.getTexture().getImageSize().y); - else - return 20; - } + + it = m_data->propertyValuePairs.find("TextureTitleBar"); + if (it != m_data->propertyValuePairs.end() && it->second.getTexture().getData()) + return static_cast(it->second.getTexture().getImageSize().y); + return 20; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Renderers/WidgetRenderer.cpp b/src/Renderers/WidgetRenderer.cpp index 60dbc18e1..671f72471 100644 --- a/src/Renderers/WidgetRenderer.cpp +++ b/src/Renderers/WidgetRenderer.cpp @@ -154,8 +154,7 @@ namespace tgui auto it = m_data->propertyValuePairs.find("Font"); if (it != m_data->propertyValuePairs.end()) return it->second.getFont(); - else - return {}; + return {}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -172,8 +171,7 @@ namespace tgui auto it = m_data->propertyValuePairs.find("TextSize"); if (it != m_data->propertyValuePairs.end()) return static_cast(it->second.getNumber()); - else - return 0; + return 0; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -205,8 +203,7 @@ namespace tgui auto it = m_data->propertyValuePairs.find(property); if (it != m_data->propertyValuePairs.end()) return it->second; - else - return {}; + return {}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/SignalManager.cpp b/src/SignalManager.cpp index a24b315cd..db76592c3 100644 --- a/src/SignalManager.cpp +++ b/src/SignalManager.cpp @@ -68,10 +68,8 @@ namespace tgui m_signals.erase(it); return true; } - else - { - return false; - } + + return false; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/String.cpp b/src/String.cpp index 288106704..ba8cb9815 100644 --- a/src/String.cpp +++ b/src/String.cpp @@ -46,10 +46,9 @@ namespace tgui TGUI_NODISCARD static inline bool compareCharIgnoreCase(char32_t char1, char32_t char2) { if (char1 == char2) return true; - else if ((char1 < 128) && (char2 < 128)) + if ((char1 < 128) && (char2 < 128)) return std::tolower(static_cast(char1)) == std::tolower(static_cast(char2)); - else - return false; + return false; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -167,8 +166,7 @@ namespace tgui int result; if (attemptToInt(result)) return result; - else - return defaultValue; + return defaultValue; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -178,8 +176,7 @@ namespace tgui unsigned int result; if (attemptToUInt(result)) return result; - else - return defaultValue; + return defaultValue; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -189,8 +186,7 @@ namespace tgui float result; if (attemptToFloat(result)) return result; - else - return defaultValue; + return defaultValue; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/SvgImage.cpp b/src/SvgImage.cpp index 83a9c0e65..487cf500d 100644 --- a/src/SvgImage.cpp +++ b/src/SvgImage.cpp @@ -84,8 +84,7 @@ namespace tgui { if (m_data->svg) return {static_cast(m_data->svg->width), static_cast(m_data->svg->height)}; - else - return {0, 0}; + return {0, 0}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Text.cpp b/src/Text.cpp index 72b204ee6..6e6574dd7 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -291,9 +291,9 @@ namespace tgui float charWidth; if (curChar == '\n') break; - else if (curChar == U'\r') + if (curChar == U'\r') continue; // Skip carriage return characters which aren't rendered (we only use line feed characters to indicate a new line) - else if (curChar == '\t') + if (curChar == '\t') charWidth = font.getGlyph(' ', characterSize, bold).advance * 4.0f; else charWidth = font.getGlyph(curChar, characterSize, bold).advance; @@ -335,15 +335,13 @@ namespace tgui if (fit < 0) return *low; - else if (fit > 0) + if (fit > 0) return *high; - else - { - if (std::abs(height - lowLineSpacing) < std::abs(height - highLineSpacing)) - return *low; - else - return *high; - } + + if (std::abs(height - lowLineSpacing) < std::abs(height - highLineSpacing)) + return *low; + + return *high; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -371,13 +369,13 @@ namespace tgui index++; break; } - else if (curChar == U'\r') + if (curChar == U'\r') { // Skip carriage return characters which aren't rendered (we only use line feed characters to indicate a new line) index++; continue; } - else if (curChar == U'\t') + if (curChar == U'\t') charWidth = font.getGlyph(U' ', textSize, bold).advance * 4; else charWidth = font.getGlyph(curChar, textSize, bold).advance; diff --git a/src/Texture.cpp b/src/Texture.cpp index 37dafc410..e02bd9f58 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -293,8 +293,7 @@ TGUI_IGNORE_DEPRECATED_WARNINGS_END if (m_data->svgImage) return Vector2u{m_data->svgImage->getSize()}; - else - return getPartRect().getSize(); + return getPartRect().getSize(); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -310,8 +309,7 @@ TGUI_IGNORE_DEPRECATED_WARNINGS_END { if (m_data && m_data->backendTexture) return m_data->backendTexture->isSmooth(); - else - return true; + return true; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Transform.cpp b/src/Transform.cpp index e4da0bf69..5a7e3e6c3 100644 --- a/src/Transform.cpp +++ b/src/Transform.cpp @@ -90,8 +90,7 @@ namespace tgui -(m_matrix[7] * m_matrix[0] - m_matrix[3] * m_matrix[4]) / det, (m_matrix[5] * m_matrix[0] - m_matrix[1] * m_matrix[4]) / det}; } - else - return {}; + return {}; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Widget.cpp b/src/Widget.cpp index 14dc394d5..7a76b4435 100644 --- a/src/Widget.cpp +++ b/src/Widget.cpp @@ -652,8 +652,7 @@ namespace tgui if (m_parent) return m_parent->getAbsolutePosition(pos + m_parent->getChildWidgetsOffset()); - else - return pos; + return pos; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -708,8 +707,7 @@ namespace tgui { if (m_scaleOrigin) return *m_scaleOrigin; - else - return m_origin; + return m_origin; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -734,8 +732,7 @@ namespace tgui { if (m_rotationOrigin) return *m_rotationOrigin; - else - return m_origin; + return m_origin; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1518,8 +1515,7 @@ namespace tgui { if (m_toolTip && isMouseOnWidget(mousePos)) return getToolTip(); - else - return nullptr; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1556,19 +1552,19 @@ namespace tgui { if (signalName == onPositionChange.getName()) return onPositionChange; - else if (signalName == onSizeChange.getName()) + if (signalName == onSizeChange.getName()) return onSizeChange; - else if (signalName == onFocus.getName()) + if (signalName == onFocus.getName()) return onFocus; - else if (signalName == onUnfocus.getName()) + if (signalName == onUnfocus.getName()) return onUnfocus; - else if (signalName == onMouseEnter.getName()) + if (signalName == onMouseEnter.getName()) return onMouseEnter; - else if (signalName == onMouseLeave.getName()) + if (signalName == onMouseLeave.getName()) return onMouseLeave; - else if (signalName == onAnimationFinish.getName()) + if (signalName == onAnimationFinish.getName()) return onAnimationFinish; - else if (signalName == onShowEffectFinish.getName()) + if (signalName == onShowEffectFinish.getName()) return onShowEffectFinish; throw Exception{U"No signal exists with name '" + std::move(signalName) + U"'."}; diff --git a/src/Widgets/BitmapButton.cpp b/src/Widgets/BitmapButton.cpp index 959c01bda..320aa578f 100644 --- a/src/Widgets/BitmapButton.cpp +++ b/src/Widgets/BitmapButton.cpp @@ -119,8 +119,7 @@ namespace tgui { if (button) return std::static_pointer_cast(button->clone()); - else - return nullptr; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Widgets/BoxLayout.cpp b/src/Widgets/BoxLayout.cpp index b183c66df..5d1396d32 100644 --- a/src/Widgets/BoxLayout.cpp +++ b/src/Widgets/BoxLayout.cpp @@ -124,8 +124,7 @@ namespace tgui { if (index < m_widgets.size()) return m_widgets[index]; - else - return nullptr; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Widgets/Button.cpp b/src/Widgets/Button.cpp index ed877a790..5674701f4 100644 --- a/src/Widgets/Button.cpp +++ b/src/Widgets/Button.cpp @@ -57,8 +57,7 @@ namespace tgui { if (button) return std::static_pointer_cast