diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-09 09:47:21 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-13 12:57:16 +0100 |
commit | c70be70cab3615cb36cc5f244671cf5d39f1fda8 (patch) | |
tree | b15e68552ffd6adda832a9ae5d38160ef8299d7f /src/gui/widgets | |
parent | 717eb07c0d51098e319059883b11ba6e2bf4cbb8 (diff) | |
download | mana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.tar.gz mana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.tar.bz2 mana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.tar.xz mana-c70be70cab3615cb36cc5f244671cf5d39f1fda8.zip |
General code cleanups
* Removing unused includes
* Use member initialization
* Use range-based for loops
* Use nullptr
* Removed no longer used aliases
* Use override
* Don't use else after return
* Use '= delete' to remove implicit members
* Use std::string::empty instead of comparing to ""
Diffstat (limited to 'src/gui/widgets')
58 files changed, 169 insertions, 275 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index d397ecfb..6fd0fcfb 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -23,7 +23,6 @@ #include "graphics.h" #include "gui/gui.h" -#include "gui/palette.h" #include "resources/image.h" #include "resources/resourcemanager.h" diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index ab402329..7ee36d1e 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -25,9 +25,7 @@ #include "gui/widgets/listbox.h" -#include <map> #include <string> -#include <vector> class Image; @@ -58,7 +56,6 @@ private: static int instances; static Image *onlineIcon; static Image *offlineIcon; - }; #endif diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 0c5fca68..d40a54fb 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -70,8 +70,7 @@ Button::Button(): Button::Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener): - gcn::Button(caption), - mButtonIcon(nullptr) + gcn::Button(caption) { init(); setActionEventId(actionEventId); diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index e4a28d80..a09b4445 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -91,18 +91,18 @@ class Button : public gcn::Button void removeButtonIcon(bool adjustButtonSize = true); - static ImageRect* mButton; /**< Button state graphics */ - static int mInstances; /**< Number of button instances */ + static ImageRect* mButton; /**< Button state graphics */ + static int mInstances; /**< Number of button instances */ static float mAlpha; - Image** mButtonIcon; /**< Button Icons graphics */ + Image** mButtonIcon = nullptr; /**< Button Icons graphics */ /** * The buttons popup * @note: This is a global object. One for all the buttons. */ static TextPopup* mTextPopup; - std::string mPopupText; /**< the current button text */ + std::string mPopupText; /**< the current button text */ }; #endif diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp index 074ec6fb..e692ff71 100644 --- a/src/gui/widgets/channeltab.cpp +++ b/src/gui/widgets/channeltab.cpp @@ -108,14 +108,14 @@ bool ChannelTab::handleCommand(const std::string &type, else if (type == "op") { // set the user mode 'o' to op a user - if (args != "") + if (!args.empty()) Net::getChatHandler()->setUserMode(mChannel->getId(), args, 'o'); else chatLog(_("Need a user to op!"), BY_CHANNEL); } else if (type == "kick") { - if (args != "") + if (!args.empty()) Net::getChatHandler()->kickUser(mChannel->getId(), args); else chatLog(_("Need a user to kick!"), BY_CHANNEL); diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index ec8af1cd..2894dacd 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -32,7 +32,6 @@ class Channel; class ChannelTab : public ChatTab { public: - Channel *getChannel() const { return mChannel; } void showHelp() override; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 6687198e..166ad102 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -29,7 +29,6 @@ #include "localplayer.h" #include "sound.h" -#include "gui/gui.h" #include "gui/recorder.h" #include "gui/widgets/browserbox.h" diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index f4b377c0..0554bad6 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -24,8 +24,6 @@ #include "configuration.h" #include "graphics.h" -#include "gui/palette.h" - #include "resources/image.h" #include "resources/theme.h" @@ -39,8 +37,7 @@ Image *CheckBox::checkBoxNormalHi; Image *CheckBox::checkBoxCheckedHi; CheckBox::CheckBox(const std::string &caption, bool selected): - gcn::CheckBox(caption, selected), - mHasMouse(false) + gcn::CheckBox(caption, selected) { if (instances == 0) { diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 6eb53c38..f77b1761 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -66,7 +66,7 @@ class CheckBox : public gcn::CheckBox private: static int instances; static float mAlpha; - bool mHasMouse; + bool mHasMouse = false; static Image *checkBoxNormal; static Image *checkBoxChecked; static Image *checkBoxDisabled; diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 74b82f07..582b294b 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -23,8 +23,7 @@ #include "gui/widgets/layouthelper.h" -Container::Container(): - mLayoutHelper(nullptr) +Container::Container() { setOpaque(false); } diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 6c5caa3a..ef44c8cd 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -61,7 +61,7 @@ class Container : public gcn::Container ContainerPlacer getPlacer(int x, int y); private: - LayoutHelper *mLayoutHelper; + LayoutHelper *mLayoutHelper = nullptr; }; #endif diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 3b26ef3a..474aadb0 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -26,8 +26,6 @@ #include "log.h" #include "main.h" -#include "gui/palette.h" - #include "gui/widgets/label.h" #include "resources/image.h" @@ -37,7 +35,6 @@ #include "utils/stringutils.h" Desktop::Desktop() - : mWallpaper(nullptr) { addWidgetListener(this); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index e10813ef..97294423 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -61,7 +61,7 @@ class Desktop : public Container, gcn::WidgetListener private: void setBestFittingWallpaper(); - Image *mWallpaper; + Image *mWallpaper = nullptr; gcn::Label *mVersionLabel; }; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 234d6676..a4b02fe5 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -68,11 +68,11 @@ DropDown::DropDown(gcn::ListModel *listModel): Image *boxBorder = Theme::getImageFromTheme("deepbox.png"); int gridx[4] = {0, 3, 28, 31}; int gridy[4] = {0, 3, 28, 31}; - int a = 0, x, y; + int a = 0; - for (y = 0; y < 3; y++) + for (int y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (int x = 0; x < 3; x++) { skin.grid[a] = boxBorder->getSubImage(gridx[x], gridy[y], gridx[x + 1] - diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index f0b721f6..f92c7dd5 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -50,7 +50,7 @@ class DropDown : public gcn::DropDown /** * Update the alpha value to the graphic components. */ - void updateAlpha(); + static void updateAlpha(); void draw(gcn::Graphics *graphics) override; diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index fa74cf20..b719bc5f 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -24,28 +24,17 @@ #include "configuration.h" #include "emoteshortcut.h" #include "graphics.h" -#include "inventory.h" #include "imagesprite.h" #include "item.h" -#include "itemshortcut.h" #include "keyboardconfig.h" -#include "localplayer.h" -#include "log.h" - -#include "gui/palette.h" #include "resources/emotedb.h" #include "resources/image.h" #include "resources/theme.h" -#include "utils/dtor.h" - static const int MAX_ITEMS = 12; -EmoteShortcutContainer::EmoteShortcutContainer(): - ShortcutContainer(), - mEmoteClicked(false), - mEmoteMoved(0) +EmoteShortcutContainer::EmoteShortcutContainer() { addMouseListener(this); addWidgetListener(this); diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index 2d62b500..209a3725 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -63,8 +63,8 @@ class EmoteShortcutContainer : public ShortcutContainer private: std::vector<const ImageSprite*> mEmoteImg; - bool mEmoteClicked; - int mEmoteMoved; + bool mEmoteClicked = false; + int mEmoteMoved = 0; }; #endif diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 0110c534..087a2a92 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -21,8 +21,8 @@ #include "flowcontainer.h" FlowContainer::FlowContainer(int boxWidth, int boxHeight): - mBoxWidth(boxWidth), mBoxHeight(boxHeight), - mGridWidth(1), mGridHeight(1) + mBoxWidth(boxWidth), + mBoxHeight(boxHeight) { addWidgetListener(this); } diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index 28d148d5..21daae16 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -53,7 +53,8 @@ class FlowContainer : public Container, private: int mBoxWidth; int mBoxHeight; - int mGridWidth, mGridHeight; + int mGridWidth = 1; + int mGridHeight = 1; }; #endif diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 5d7d62f7..eaf5be1c 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -27,12 +27,8 @@ #include "resources/resourcemanager.h" Icon::Icon(const std::string &file) - : mImage(nullptr) -{ - mImage = ResourceManager::getInstance()->getImage(file); - if (mImage) - setSize(mImage->getWidth(), mImage->getHeight()); -} + : Icon(ResourceManager::getInstance()->getImage(file)) +{} Icon::Icon(Image *image) : mImage(image) diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 5b373bb6..37a61c80 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -30,13 +30,8 @@ #include "gui/chatwindow.h" #include "gui/itempopup.h" #include "gui/outfitwindow.h" -#include "gui/palette.h" -#include "gui/sdlinput.h" #include "gui/viewport.h" -#include "net/net.h" -#include "net/inventoryhandler.h" - #include "resources/image.h" #include "resources/iteminfo.h" #include "resources/theme.h" @@ -53,15 +48,7 @@ static const int BOX_WIDTH = 35; static const int BOX_HEIGHT = 43; ItemContainer::ItemContainer(Inventory *inventory): - mInventory(inventory), - mGridColumns(1), - mGridRows(1), - mSelectedIndex(-1), - mHighlightedIndex(-1), - mLastUsedSlot(-1), - mSelectionStatus(SEL_NONE), - mSwapItems(false), - mDescItems(false) + mInventory(inventory) { mItemPopup = new ItemPopup; setFocusable(true); @@ -112,7 +99,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) if (!item || item->getId() == 0) continue; - if (mFilter.size() > 0) + if (!mFilter.empty()) { if (normalize(item->getInfo().getName()).find(mFilter) == std::string::npos) continue; @@ -220,13 +207,10 @@ void ItemContainer::setFilter(const std::string &filter) void ItemContainer::distributeValueChangedEvent() { - SelectionListenerIterator i, i_end; - - for (i = mSelectionListeners.begin(), i_end = mSelectionListeners.end(); - i != i_end; ++i) + for (auto listener : mSelectionListeners) { gcn::SelectionEvent event(this); - (*i)->valueChanged(event); + listener->valueChanged(event); } } diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index fe5b73e5..51807aba 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -176,14 +176,17 @@ class ItemContainer : public gcn::Widget, Item *getItemAt(int) const; Inventory *mInventory; - int mGridColumns, mGridRows; + int mGridColumns = 1; + int mGridRows = 1; Image *mSelImg; - int mSelectedIndex, mHighlightedIndex; - int mLastUsedSlot; - SelectionState mSelectionStatus; - bool mSwapItems; - bool mDescItems; - int mDragPosX, mDragPosY; + int mSelectedIndex = -1; + int mHighlightedIndex = -1; + int mLastUsedSlot = -1; + SelectionState mSelectionStatus = SEL_NONE; + bool mSwapItems = false; + bool mDescItems = false; + int mDragPosX = 0; + int mDragPosY = 0; std::map<int, Item*> mFilteredMap; @@ -191,10 +194,7 @@ class ItemContainer : public gcn::Widget, ItemPopup *mItemPopup; - using SelectionListenerList = std::list<gcn::SelectionListener *>; - using SelectionListenerIterator = SelectionListenerList::iterator; - - SelectionListenerList mSelectionListeners; + std::list<gcn::SelectionListener *> mSelectionListeners; }; #endif // ITEMCONTAINER_H diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index a43596f8..6c57bd00 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -31,19 +31,14 @@ #include "gui/inventorywindow.h" #include "gui/itempopup.h" -#include "gui/palette.h" #include "gui/viewport.h" #include "resources/image.h" -#include "resources/iteminfo.h" #include "resources/theme.h" #include "utils/stringutils.h" -ItemShortcutContainer::ItemShortcutContainer(): - ShortcutContainer(), - mItemClicked(false), - mItemMoved(nullptr) +ItemShortcutContainer::ItemShortcutContainer() { addMouseListener(this); addWidgetListener(this); @@ -86,7 +81,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. const char *key = SDL_GetKeyName( - (SDL_Scancode) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i)); + (SDL_Scancode) keyboard.getKeyValue(KeyboardConfig::KEY_SHORTCUT_1 + i)); graphics->setColor(Theme::getThemeColor(Theme::TEXT)); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); @@ -122,8 +117,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) if (mItemMoved) { // Draw the item image being dragged by the cursor. - Image* image = mItemMoved->getImage(); - if (image) + if (Image* image = mItemMoved->getImage()) { const int tPosX = mCursorPosX - (image->getWidth() / 2); const int tPosY = mCursorPosY - (image->getHeight() / 2); diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 55d14977..243920a0 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -66,8 +66,8 @@ class ItemShortcutContainer : public ShortcutContainer void mouseExited(gcn::MouseEvent &event) override; void mouseMoved(gcn::MouseEvent &event) override; - bool mItemClicked; - Item *mItemMoved; + bool mItemClicked = false; + Item *mItemMoved = nullptr; ItemPopup *mItemPopup; }; diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 3659baa1..f7941889 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -175,14 +175,15 @@ LayoutCell &LayoutArray::place(gcn::Widget *widget, int x, int y, int w, int h) cell.mPadding = 0; cell.mAlign[0] = LayoutCell::FILL; cell.mAlign[1] = LayoutCell::FILL; - short &cs = mSizes[0][x], &rs = mSizes[1][y]; + short &cs = mSizes[0][x]; + short &rs = mSizes[1][y]; if (cs == Layout::AUTO_DEF && w == 1) cs = 0; if (rs == Layout::AUTO_DEF && h == 1) rs = 0; return cell; } void LayoutArray::align(int &pos, int &size, int dim, - LayoutCell const &cell, short *sizes) const + LayoutCell const &cell, const short *sizes) const { int size_max = sizes[0]; for (int i = 1; i < cell.mExtent[dim]; ++i) @@ -207,7 +208,8 @@ void LayoutArray::align(int &pos, int &size, int dim, std::vector< short > LayoutArray::getSizes(int dim, int upp) const { - int gridW = mSizes[0].size(), gridH = mSizes[1].size(); + int gridW = mSizes[0].size(); + int gridH = mSizes[1].size(); std::vector< short > sizes = mSizes[dim]; // Compute minimum sizes. @@ -251,7 +253,8 @@ std::vector< short > LayoutArray::getSizes(int dim, int upp) const for (int i = 0; i < nb; ++i) { - if (mSizes[dim][i] > Layout::AUTO_DEF) continue; + if (mSizes[dim][i] > Layout::AUTO_DEF) + continue; int s = upp / nbFill; sizes[i] += s; upp -= s; @@ -276,7 +279,8 @@ int LayoutArray::getSize(int dim) const void LayoutArray::reflow(int nx, int ny, int nw, int nh) { - int gridW = mSizes[0].size(), gridH = mSizes[1].size(); + int gridW = mSizes[0].size(); + int gridH = mSizes[1].size(); std::vector< short > widths = getSizes(0, nw); std::vector< short > heights = getSizes(1, nh); diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 1c6faf89..4e4b28c5 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -125,7 +125,7 @@ class LayoutArray * Gets the position and size of a widget along a given axis */ void align(int &pos, int &size, int dim, - LayoutCell const &cell, short *sizes) const; + LayoutCell const &cell, const short *sizes) const; /** * Ensures the private vectors are large enough. diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index e696d934..8e2c8311 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -23,7 +23,6 @@ #include "configuration.h" -#include "gui/palette.h" #include "gui/sdlinput.h" #include "resources/theme.h" diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 25787ca7..a453b618 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -58,7 +58,7 @@ class ListBox : public gcn::ListBox /** * Update the alpha value to the graphic components. */ - void updateAlpha(); + static void updateAlpha(); // Inherited from KeyListener diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 4379b4d9..671fad36 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -45,11 +45,11 @@ PlayerBox::PlayerBox(const Being *being): Image *textbox = Theme::getImageFromTheme("deepbox.png"); int bggridx[4] = {0, 3, 28, 31}; int bggridy[4] = {0, 3, 28, 31}; - int a = 0, x, y; + int a = 0; - for (y = 0; y < 3; y++) + for (int y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (int x = 0; x < 3; x++) { background.grid[a] = textbox->getSubImage( bggridx[x], bggridy[y], @@ -98,10 +98,9 @@ void PlayerBox::draw(gcn::Graphics *graphics) void PlayerBox::drawFrame(gcn::Graphics *graphics) { - int w, h, bs; - bs = getFrameSize(); - w = getWidth() + bs * 2; - h = getHeight() + bs * 2; + const int bs = getFrameSize(); + const int w = getWidth() + bs * 2; + const int h = getHeight() + bs * 2; static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, background); } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 298443e7..b79f1370 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -22,7 +22,6 @@ #include "gui/widgets/popup.h" -#include "configuration.h" #include "graphics.h" #include "log.h" @@ -30,15 +29,12 @@ #include "gui/widgets/windowcontainer.h" -#include "resources/image.h" #include "resources/theme.h" #include <guichan/exception.hpp> Popup::Popup(const std::string &name, const std::string &skin): mPopupName(name), - mMinWidth(100), - mMinHeight(40), mMaxWidth(graphics->getWidth()), mMaxHeight(graphics->getHeight()) { @@ -105,10 +101,12 @@ void Popup::setContentSize(int width, int height) void Popup::setLocationRelativeTo(gcn::Widget *widget) { - int wx, wy; - int x, y; - + int wx; + int wy; widget->getAbsolutePosition(wx, wy); + + int x; + int y; getAbsolutePosition(x, y); setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x), diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index af37b211..2aaa63f7 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -23,7 +23,6 @@ #ifndef POPUP_H #define POPUP_H -#include "configuration.h" #include "guichanfwd.h" #include "gui/widgets/container.h" @@ -154,8 +153,8 @@ class Popup : public Container, public gcn::MouseListener private: std::string mPopupName; /**< Name of the popup */ - int mMinWidth; /**< Minimum popup width */ - int mMinHeight; /**< Minimum popup height */ + int mMinWidth = 100; /**< Minimum popup width */ + int mMinHeight = 40; /**< Minimum popup height */ int mMaxWidth; /**< Maximum popup width */ int mMaxHeight; /**< Maximum popup height */ int mPadding; /**< Holds the padding of the popup. */ diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 4190c0e4..523dde1c 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -41,10 +41,7 @@ float ProgressBar::mAlpha = 1.0; ProgressBar::ProgressBar(float progress, int width, int height, int color): - gcn::Widget(), - mSmoothProgress(true), - mProgressPalette(color), - mSmoothColorChange(true) + mProgressPalette(color) { // The progress value is directly set at load time: if (progress > 1.0f || progress < 0.0f) diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index d3a4c100..d7289816 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -54,7 +54,7 @@ class ProgressBar : public gcn::Widget /** * Update the alpha value to the graphic components. */ - void updateAlpha(); + static void updateAlpha(); /** * Draws the progress bar. @@ -120,12 +120,12 @@ class ProgressBar : public gcn::Widget private: float mProgress, mProgressToGo; - bool mSmoothProgress; + bool mSmoothProgress = true; int mProgressPalette; /** < Entry in ProgressPalette or -1 for none. */ gcn::Color mColor; gcn::Color mColorToGo; - bool mSmoothColorChange; + bool mSmoothColorChange = true; std::string mText; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 676daede..bb96d77c 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -38,8 +38,7 @@ Image *RadioButton::radioCheckedHi; RadioButton::RadioButton(const std::string &caption, const std::string &group, bool marked): - gcn::RadioButton(caption, group, marked), - mHasMouse(false) + gcn::RadioButton(caption, group, marked) { if (instances == 0) { @@ -136,4 +135,3 @@ void RadioButton::mouseExited(gcn::MouseEvent& event) { mHasMouse = false; } - diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index 014acd06..2a96ff6e 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -61,7 +61,7 @@ class RadioButton : public gcn::RadioButton private: static int instances; static float mAlpha; - bool mHasMouse; + bool mHasMouse = false; static Image *radioNormal; static Image *radioChecked; static Image *radioDisabled; diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index f4d8007a..e153ba65 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -36,23 +36,14 @@ ImageRect ScrollArea::vMarker; ImageRect ScrollArea::vMarkerHi; Image *ScrollArea::buttons[4][2]; -ScrollArea::ScrollArea(): - gcn::ScrollArea(), - mX(0), - mY(0), - mHasMouse(false), - mOpaque(true) +ScrollArea::ScrollArea() { addWidgetListener(this); init(); } ScrollArea::ScrollArea(gcn::Widget *widget): - gcn::ScrollArea(widget), - mX(0), - mY(0), - mHasMouse(false), - mOpaque(true) + gcn::ScrollArea(widget) { init(); } @@ -97,11 +88,11 @@ void ScrollArea::init() Image *textbox = Theme::getImageFromTheme("deepbox.png"); const int bggridx[4] = {0, 3, 28, 31}; const int bggridy[4] = {0, 3, 28, 31}; - int a = 0, x, y; + int a = 0; - for (y = 0; y < 3; y++) + for (int y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (int x = 0; x < 3; x++) { background.grid[a] = textbox->getSubImage( bggridx[x], bggridy[y], @@ -122,9 +113,9 @@ void ScrollArea::init() int vsgridy[4] = {0, 4, 15, 19}; a = 0; - for (y = 0; y < 3; y++) + for (int y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (int x = 0; x < 3; x++) { vMarker.grid[a] = vscroll->getSubImage( vsgridx[x], vsgridy[y], @@ -384,5 +375,6 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event) void ScrollArea::widgetResized(const gcn::Event &event) { - getContent()->setSize(getWidth() - 2 * getFrameSize(), getHeight() - 2 * getFrameSize()); + getContent()->setSize(getWidth() - 2 * getFrameSize(), + getHeight() - 2 * getFrameSize()); } diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 266b5a31..2fae2d4b 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -67,7 +67,7 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Update the alpha value to the graphic components. */ - void updateAlpha(); + static void updateAlpha(); /** * Draws the scroll area. @@ -136,9 +136,10 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener static ImageRect vMarkerHi; static Image *buttons[4][2]; - int mX,mY; - bool mHasMouse; - bool mOpaque; + int mX = 0; + int mY = 0; + bool mHasMouse = false; + bool mOpaque = true; }; #endif diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index d6dd087a..d0c79af2 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -39,8 +39,7 @@ float ShopListBox::mAlpha = 1.0; ShopListBox::ShopListBox(gcn::ListModel *listModel): - ListBox(listModel), - mPlayerMoney(0) + ListBox(listModel) { mRowHeight = getFont()->getHeight(); mPriceCheck = true; @@ -50,7 +49,6 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel): ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): ListBox(listModel), - mPlayerMoney(0), mShopItems(shopListModel) { mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE); @@ -192,4 +190,3 @@ void ShopListBox::mouseExited(gcn::MouseEvent &event) { mItemPopup->setVisible(false); } - diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index c3d10a4a..b5718ed3 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -83,7 +83,7 @@ class ShopListBox : public ListBox void mouseExited(gcn::MouseEvent &event) override; private: - int mPlayerMoney; + int mPlayerMoney = 0; /** * Keeps another pointer to the same listModel, permitting to diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 5edd88bc..5925752e 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -21,17 +21,9 @@ #include "gui/widgets/shortcutcontainer.h" -#include "configuration.h" - -#include "resources/image.h" - -#include "utils/stringutils.h" - float ShortcutContainer::mAlpha = 1.0; -ShortcutContainer::ShortcutContainer(): - mGridWidth(1), - mGridHeight(1) +ShortcutContainer::ShortcutContainer() { } @@ -52,8 +44,8 @@ void ShortcutContainer::widgetResized(const gcn::Event &event) int ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const { - const gcn::Rectangle tRect = gcn::Rectangle(0, 0, mGridWidth * mBoxWidth, - mGridHeight * mBoxHeight); + const gcn::Rectangle tRect(0, 0, mGridWidth * mBoxWidth, + mGridHeight * mBoxHeight); int index = ((pointY / mBoxHeight) * mGridWidth) + pointX / mBoxWidth; diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index f0f9b730..449a06f3 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -91,11 +91,13 @@ class ShortcutContainer : public gcn::Widget, static float mAlpha; - int mMaxItems; - int mBoxWidth; - int mBoxHeight; - int mCursorPosX, mCursorPosY; - int mGridWidth, mGridHeight; + int mMaxItems = 0; + int mBoxWidth = 0; + int mBoxHeight = 0; + int mCursorPosX = 0; + int mCursorPosY = 0; + int mGridWidth = 1; + int mGridHeight = 1; }; #endif diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 3852159b..fd21becf 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -35,15 +35,13 @@ float Slider::mAlpha = 1.0; int Slider::mInstances = 0; Slider::Slider(double scaleEnd): - gcn::Slider(scaleEnd), - mHasMouse(false) + gcn::Slider(scaleEnd) { init(); } Slider::Slider(double scaleStart, double scaleEnd): - gcn::Slider(scaleStart, scaleEnd), - mHasMouse(false) + gcn::Slider(scaleStart, scaleEnd) { init(); } diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index d5b9d5ec..3896cb52 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -52,7 +52,7 @@ class Slider : public gcn::Slider /** * Update the alpha value to the graphic components. */ - void updateAlpha(); + static void updateAlpha(); /** * Draws the slider. @@ -84,7 +84,7 @@ class Slider : public gcn::Slider static Image *vStart, *vMid, *vEnd, *vGrip; static Image *hStartHi, *hMidHi, *hEndHi, *hGripHi; static Image *vStartHi, *vMidHi, *vEndHi, *vGripHi; - bool mHasMouse; + bool mHasMouse = false; static float mAlpha; static int mInstances; }; diff --git a/src/gui/widgets/spacer.h b/src/gui/widgets/spacer.h index 11e0ac66..f6a210dc 100644 --- a/src/gui/widgets/spacer.h +++ b/src/gui/widgets/spacer.h @@ -23,7 +23,6 @@ #define SPACER_H #include "guichan/graphics.hpp" -#include "guichan/platform.hpp" #include "guichan/widget.hpp" /** diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 223d91ec..08acd245 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -60,7 +60,7 @@ static TabData const data[TAB_COUNT] = { ImageRect Tab::tabImg[TAB_COUNT]; -Tab::Tab() : gcn::Tab(), +Tab::Tab() : mTabColor(&Theme::getThemeColor(Theme::TAB)) { init(); @@ -90,15 +90,13 @@ void Tab::init() // Load the skin Image *tab[TAB_COUNT]; - int a, x, y, mode; - - for (mode = 0; mode < TAB_COUNT; mode++) + for (int mode = 0; mode < TAB_COUNT; mode++) { tab[mode] = Theme::getImageFromTheme(data[mode].file); - a = 0; - for (y = 0; y < 3; y++) + int a = 0; + for (int y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (int x = 0; x < 3; x++) { tabImg[mode].grid[a] = tab[mode]->getSubImage( data[mode].gridX[x], data[mode].gridY[y], diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 9dc5291e..86650257 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -40,7 +40,7 @@ class Tab : public gcn::Tab /** * Update the alpha value to the graphic components. */ - void updateAlpha(); + static void updateAlpha(); /** * Draw the tabbed area. diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 1fdd276f..644adf07 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -25,10 +25,7 @@ #include <guichan/widgets/container.hpp> -TabbedArea::TabbedArea() : gcn::TabbedArea(), - mTabsWidth(0), - mVisibleTabsWidth(0), - mTabScrollIndex(0) +TabbedArea::TabbedArea() { mWidgetContainer->setOpaque(false); addWidgetListener(this); @@ -51,13 +48,10 @@ int TabbedArea::getNumberOfTabs() const Tab *TabbedArea::getTab(const std::string &name) const { - auto itr = mTabs.begin(), itr_end = mTabs.end(); - while (itr != itr_end) + for (auto itr = mTabs.begin(); itr != mTabs.end(); ++itr) { if ((*itr).first->getCaption() == name) return static_cast<Tab*>((*itr).first); - - ++itr; } return nullptr; } @@ -72,13 +66,10 @@ void TabbedArea::draw(gcn::Graphics *graphics) gcn::Widget *TabbedArea::getWidget(const std::string &name) const { - auto itr = mTabs.begin(), itr_end = mTabs.end(); - while (itr != itr_end) + for (const auto &[tab, widget] : mTabs) { - if ((*itr).first->getCaption() == name) - return (*itr).second; - - ++itr; + if (tab->getCaption() == name) + return widget; } return nullptr; diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 53bb2bb2..18e923bf 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -130,7 +130,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener /** * The overall width of all tab. */ - int mTabsWidth; + int mTabsWidth = 0; /** * Update the overall width of visible tab. Used to know whether @@ -141,7 +141,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener /** * The overall width of visible tab. */ - int mVisibleTabsWidth; + int mVisibleTabsWidth = 0; /** @@ -150,7 +150,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener * So the first tab displayed may not be the first in the list. * @note the index must start at 0. */ - unsigned mTabScrollIndex; + unsigned mTabScrollIndex = 0; }; #endif diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp index 465fbc61..a74fc09e 100644 --- a/src/gui/widgets/table.cpp +++ b/src/gui/widgets/table.cpp @@ -173,18 +173,16 @@ void GuiTable::setLinewiseSelection(bool linewise) int GuiTable::getRowHeight() const { - if (mModel) - return mModel->getRowHeight() + 1; // border - else + if (!mModel) return 0; + return mModel->getRowHeight() + 1; // border } int GuiTable::getColumnWidth(int i) const { - if (mModel) - return mModel->getColumnWidth(i) + 1; // border - else + if (!mModel) return 0; + return mModel->getColumnWidth(i) + 1; // border } void GuiTable::setSelectedRow(int selected) diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 2239bed4..872227ea 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -44,10 +44,7 @@ float TextField::mAlpha = 1.0; ImageRect TextField::skin; TextField::TextField(const std::string &text, bool loseFocusOnTab): - gcn::TextField(text), - mNumeric(false), - mAutoComplete(nullptr), - mHistory(nullptr) + gcn::TextField(text) { setFrameSize(2); @@ -59,11 +56,11 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab): Image *textbox = Theme::getImageFromTheme("deepbox.png"); int gridx[4] = {0, 3, 28, 31}; int gridy[4] = {0, 3, 28, 31}; - int a = 0, x, y; + int a = 0; - for (y = 0; y < 3; y++) + for (int y = 0; y < 3; y++) { - for (x = 0; x < 3; x++) + for (int x = 0; x < 3; x++) { skin.grid[a] = textbox->getSubImage( gridx[x], gridy[y], @@ -120,10 +117,9 @@ void TextField::drawFrame(gcn::Graphics *graphics) { //updateAlpha(); -> Not useful... - int w, h, bs; - bs = getFrameSize(); - w = getWidth() + bs * 2; - h = getHeight() + bs * 2; + int bs = getFrameSize(); + int w = getWidth() + bs * 2; + int h = getHeight() + bs * 2; static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin); } @@ -215,7 +211,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) mHistory->current = prevHist; } } - else if (getText() != "") + else if (!getText().empty()) { // Always clear (easy access to useful function) setText(""); @@ -294,13 +290,13 @@ void TextField::textInput(const TextInput &textInput) void TextField::autoComplete() { - if (mAutoComplete && mText.size() > 0) + if (mAutoComplete && !mText.empty()) { const int caretPos = getCaretPosition(); int startName = 0; const std::string inputText = getText(); std::string name = inputText.substr(0, caretPos); - std::string newName(""); + std::string newName; for (int f = caretPos - 1; f > -1; f--) { @@ -320,7 +316,7 @@ void TextField::autoComplete() mAutoComplete->getAutoCompleteList(nameList); newName = autocomplete(nameList, name); - if (newName == "" && mHistory) + if (newName.empty() && mHistory) { auto i = mHistory->history.begin(); @@ -335,7 +331,7 @@ void TextField::autoComplete() f++; } line = line.substr(0, f); - if (line != "") + if (!line.empty()) { nameList.push_back(line); } @@ -345,7 +341,7 @@ void TextField::autoComplete() newName = autocomplete(nameList, name); } - if (newName != "") + if (!newName.empty()) { if(inputText[0] == '@' || inputText[0] == '/') newName = "\"" + newName + "\""; diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index b1b7a6a4..bb39810b 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -33,7 +33,8 @@ class TextField; using TextHistoryList = std::list<std::string>; using TextHistoryIterator = TextHistoryList::iterator; -struct TextHistory { +struct TextHistory +{ TextHistoryList history; /**< Command history. */ TextHistoryIterator current; /**< History iterator. */ @@ -90,7 +91,7 @@ class TextField : public gcn::TextField /** * Update the alpha value to the graphic components. */ - void updateAlpha(); + static void updateAlpha(); /** * Draws the background and border. @@ -168,14 +169,14 @@ class TextField : public gcn::TextField static int instances; static float mAlpha; static ImageRect skin; - bool mNumeric; + bool mNumeric = false; int mMinimum; int mMaximum; bool mLoseFocusOnTab; - AutoCompleteLister *mAutoComplete; + AutoCompleteLister *mAutoComplete = nullptr; - TextHistory *mHistory; /**< Text history. */ + TextHistory *mHistory = nullptr; /**< Text history. */ }; #endif diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index d6ef172c..8b2c3a75 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -25,7 +25,6 @@ #include "textrenderer.h" #include "gui/gui.h" -#include "gui/palette.h" #include "gui/truetypefont.h" #include <typeinfo> @@ -35,12 +34,9 @@ float TextPreview::mAlpha = 1.0; TextPreview::TextPreview(const std::string &text): mText(text) { - mTextAlpha = false; mFont = gui->getFont(); mTextColor = &Theme::getThemeColor(Theme::TEXT); - mTextBGColor = nullptr; mBGColor = &Theme::getThemeColor(Theme::BACKGROUND); - mOpaque = false; } void TextPreview::draw(gcn::Graphics* graphics) diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 0cda7c8b..7e88248f 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -131,12 +131,12 @@ class TextPreview : public gcn::Widget std::string mText; const gcn::Color *mTextColor; const gcn::Color *mBGColor; - const gcn::Color *mTextBGColor; + const gcn::Color *mTextBGColor = nullptr; static float mAlpha; - bool mTextAlpha; - bool mOpaque; - bool mShadow; - bool mOutline; + bool mTextAlpha = false; + bool mOpaque = false; + bool mShadow = false; + bool mOutline = false; }; #endif diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index a0c227ab..89f3abc9 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -21,8 +21,7 @@ #include "gui/widgets/vertcontainer.h" VertContainer::VertContainer(int spacing): - mSpacing(spacing), - mCount(0) + mSpacing(spacing) { addWidgetListener(this); } diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index 439f7ca1..b66957d3 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -40,7 +40,7 @@ class VertContainer : public Container, public gcn::WidgetListener private: int mSpacing; - int mCount; + int mCount = 0; }; #endif diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 31f81e62..636f48dd 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -31,7 +31,6 @@ #include "resources/theme.h" #include "utils/gettext.h" -#include "utils/stringutils.h" WhisperTab::WhisperTab(const std::string &nick) : ChatTab(nick), diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 05638470..6d970b0b 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -25,7 +25,6 @@ #include "log.h" #include "gui/gui.h" -#include "gui/palette.h" #include "gui/viewport.h" #include "gui/widgets/layout.h" @@ -44,19 +43,8 @@ int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, const std::string &skin): gcn::Window(caption), - mGrip(nullptr), mParent(parent), - mLayout(nullptr), - mWindowName("window"), - mShowTitle(true), mModal(modal), - mCloseButton(false), - mDefaultVisible(false), - mSaveVisible(false), - mStickyButton(false), - mSticky(false), - mMinWinWidth(100), - mMinWinHeight(40), mMaxWinWidth(graphics->getWidth()), mMaxWinHeight(graphics->getHeight()) { @@ -167,10 +155,12 @@ void Window::setContentSize(int width, int height) void Window::setLocationRelativeTo(gcn::Widget *widget) { - int wx, wy; - int x, y; - + int wx; + int wy; widget->getAbsolutePosition(wx, wy); + + int x; + int y; getAbsolutePosition(x, y); setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x), @@ -611,7 +601,8 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight, ImageRect::ImagePosition position, int offsetX, int offsetY) { - int x = 0, y = 0; + int x = 0; + int y = 0; if (position == ImageRect::UPPER_LEFT) { diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index fe2b217c..ef529a9f 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -345,9 +345,9 @@ class Window : public gcn::Window, gcn::WidgetListener virtual void close(); /** - * Gets the alpha value used by the window, in a GUIChan usable format. + * Gets the alpha value used by the window, in a Guichan usable format. */ - int getGuiAlpha(); + static int getGuiAlpha(); private: enum ResizeHandles @@ -374,19 +374,19 @@ class Window : public gcn::Window, gcn::WidgetListener */ int getResizeHandles(gcn::MouseEvent &event); - ResizeGrip *mGrip; /**< Resize grip */ + ResizeGrip *mGrip = nullptr; /**< Resize grip */ Window *mParent; /**< The parent window */ - Layout *mLayout; /**< Layout handler */ - std::string mWindowName; /**< Name of the window */ - bool mShowTitle; /**< Window has a title bar */ + Layout *mLayout = nullptr; /**< Layout handler */ + std::string mWindowName = "window"; /**< Name of the window */ + bool mShowTitle = true; /**< Window has a title bar */ bool mModal; /**< Window is modal */ - bool mCloseButton; /**< Window has a close button */ - bool mDefaultVisible; /**< Window's default visibility */ - bool mSaveVisible; /**< Window will save visibility */ - bool mStickyButton; /**< Window has a sticky button */ - bool mSticky; /**< Window resists hiding*/ - int mMinWinWidth; /**< Minimum window width */ - int mMinWinHeight; /**< Minimum window height */ + bool mCloseButton = false; /**< Window has a close button */ + bool mDefaultVisible = false; /**< Window's default visibility */ + bool mSaveVisible = false; /**< Window will save visibility */ + bool mStickyButton = false; /**< Window has a sticky button */ + bool mSticky = false; /**< Window resists hiding*/ + int mMinWinWidth = 100; /**< Minimum window width */ + int mMinWinHeight = 40; /**< Minimum window height */ int mMaxWinWidth; /**< Maximum window width */ int mMaxWinHeight; /**< Maximum window height */ int mDefaultX; /**< Default window X position */ |