diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/browserbox.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/button.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/flowcontainer.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/layout.cpp | 24 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 17 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/tablemodel.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/vertcontainer.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/windowcontainer.cpp | 4 |
14 files changed, 54 insertions, 82 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index d5b853b2..2fe3b5b1 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -185,9 +185,8 @@ void BrowserBox::addRow(const std::string &row) int tildeWidth = font->getWidth(tilde); int x = 0; - for (auto i = mTextRows.begin(); i != mTextRows.end(); i++) + for (auto row : mTextRows) { - std::string row = *i; for (unsigned int j = 0; j < row.size(); ++j) { std::string character = row.substr(j, 1); @@ -316,11 +315,8 @@ void BrowserBox::draw(gcn::Graphics *graphics) } } - for (auto i = mLineParts.begin(); - i != mLineParts.end(); - i ++) + for (auto &part : mLineParts) { - const LinePart &part = *i; if (part.getY() + 50 < mYStart) continue; if (part.getY() > yEnd) @@ -385,9 +381,8 @@ int BrowserBox::calcHeight() mLineParts.clear(); - for (auto i = mTextRows.begin(); i != mTextRows.end(); i++) + for (auto row : mTextRows) { - const std::string row = *(i); bool wrapped = false; x = 0; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index fb0d4cbe..b2a395e9 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -205,8 +205,7 @@ void Button::updateAlpha() mAlpha = alpha; for (int mode = 0; mode < BUTTON_COUNT; ++mode) { - for (int a = 0; a < 9; ++a) - mButton[mode].grid[a]->setAlpha(mAlpha); + mButton[mode].setAlpha(mAlpha); } } } diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 101afaef..81a0ea46 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -80,11 +80,12 @@ DropDown::DropDown(gcn::ListModel *listModel): gridx[x] + 1, gridy[y + 1] - gridy[y] + 1); - skin.grid[a]->setAlpha(mAlpha); a++; } } + skin.setAlpha(mAlpha); + boxBorder->decRef(); } @@ -122,10 +123,7 @@ void DropDown::updateAlpha() buttons[1][0]->setAlpha(mAlpha); buttons[1][1]->setAlpha(mAlpha); - for (int a = 0; a < 9; a++) - { - skin.grid[a]->setAlpha(mAlpha); - } + skin.setAlpha(mAlpha); } } diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index bf34c4c7..0110c534 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -57,10 +57,10 @@ void FlowContainer::widgetResized(const gcn::Event &event) int i = 0; height = 0; - for (auto it = mWidgets.begin(); it != mWidgets.end(); it++) + for (auto &widget : mWidgets) { int x = i % mGridWidth * mBoxWidth; - (*it)->setPosition(x, height); + widget->setPosition(x, height); i++; diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index ac8488e0..3659baa1 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -71,15 +71,12 @@ void LayoutCell::computeSizes() { assert(mType == ARRAY); - for (auto - i = mArray->mCells.begin(), i_end = mArray->mCells.end(); - i != i_end; ++i) + for (auto &row : mArray->mCells) { - for (auto - j = i->begin(), j_end = i->end(); j != j_end; ++j) + for (auto cell : row) { - LayoutCell *cell = *j; - if (cell && cell->mType == ARRAY) cell->computeSizes(); + if (cell && cell->mType == ARRAY) + cell->computeSizes(); } } @@ -93,13 +90,11 @@ LayoutArray::LayoutArray(): mSpacing(4) LayoutArray::~LayoutArray() { - for (auto - i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i) + for (auto &row : mCells) { - for (auto - j = i->begin(), j_end = i->end(); j != j_end; ++j) + for (auto &cell : row) { - delete *j; + delete cell; } } } @@ -133,10 +128,9 @@ void LayoutArray::resizeGrid(int w, int h) mSizes[0].resize(w, Layout::AUTO_DEF); } - for (auto - i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i) + for (auto &row : mCells) { - i->resize(w, nullptr); + row.resize(w, nullptr); } } diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 1d3325ee..0d63ddf2 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -56,11 +56,12 @@ PlayerBox::PlayerBox(const Being *being): bggridx[x], bggridy[y], bggridx[x + 1] - bggridx[x] + 1, bggridy[y + 1] - bggridy[y] + 1); - background.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } + background.setAlpha(config.getFloatValue("guialpha")); + textbox->decRef(); } @@ -92,10 +93,7 @@ void PlayerBox::draw(gcn::Graphics *graphics) if (config.getFloatValue("guialpha") != mAlpha) { - for (int a = 0; a < 9; a++) - { - background.grid[a]->setAlpha(config.getFloatValue("guialpha")); - } + background.setAlpha(config.getFloatValue("guialpha")); } } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 4695f5ab..9397d59e 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -71,10 +71,7 @@ ProgressBar::ProgressBar(float progress, mBorder.grid[7] = dBorders->getSubImage(4, 15, 3, 4); mBorder.grid[8] = dBorders->getSubImage(7, 15, 4, 4); - for (int i = 0; i < 9; i++) - { - mBorder.grid[i]->setAlpha(mAlpha); - } + mBorder.setAlpha(mAlpha); dBorders->decRef(); } @@ -129,12 +126,8 @@ void ProgressBar::updateAlpha() if (mAlpha != alpha) { mAlpha = alpha; - for (int i = 0; i < 9; i++) - { - mBorder.grid[i]->setAlpha(mAlpha); - } + mBorder.setAlpha(mAlpha); } - } void ProgressBar::draw(gcn::Graphics *graphics) diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index c95adeaa..f4d8007a 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -107,10 +107,10 @@ void ScrollArea::init() bggridx[x], bggridy[y], bggridx[x + 1] - bggridx[x] + 1, bggridy[y + 1] - bggridy[y] + 1); - background.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } + background.setAlpha(config.getFloatValue("guialpha")); textbox->decRef(); @@ -134,12 +134,13 @@ void ScrollArea::init() vsgridx[x], vsgridy[y], vsgridx[x + 1] - vsgridx[x], vsgridy[y + 1] - vsgridy[y]); - vMarker.grid[a]->setAlpha(config.getFloatValue("guialpha")); - vMarkerHi.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } + vMarker.setAlpha(config.getFloatValue("guialpha")); + vMarkerHi.setAlpha(config.getFloatValue("guialpha")); + vscroll->decRef(); vscrollHi->decRef(); @@ -218,12 +219,10 @@ void ScrollArea::updateAlpha() if (alpha != mAlpha) { mAlpha = alpha; - for (int a = 0; a < 9; a++) - { - background.grid[a]->setAlpha(mAlpha); - vMarker.grid[a]->setAlpha(mAlpha); - vMarkerHi.grid[a]->setAlpha(mAlpha); - } + + background.setAlpha(mAlpha); + vMarker.setAlpha(mAlpha); + vMarkerHi.setAlpha(mAlpha); } } diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index c8ed2141..15a10d33 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -74,9 +74,9 @@ Tab::~Tab() if (mInstances == 0) { - for (int mode = 0; mode < TAB_COUNT; mode++) + for (auto &imgRect : tabImg) { - std::for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>()); + std::for_each(imgRect.grid, imgRect.grid + 9, dtor<Image*>()); } } } @@ -106,10 +106,10 @@ void Tab::init() data[mode].gridX[x], data[mode].gridY[y], data[mode].gridX[x + 1] - data[mode].gridX[x] + 1, data[mode].gridY[y + 1] - data[mode].gridY[y] + 1); - tabImg[mode].grid[a]->setAlpha(mAlpha); a++; } } + tabImg[mode].setAlpha(mAlpha); tab[mode]->decRef(); } } @@ -126,12 +126,10 @@ void Tab::updateAlpha() if (alpha != mAlpha) { mAlpha = alpha; - for (int a = 0; a < 9; a++) + + for (auto &t : tabImg) { - for (int t = 0; t < TAB_COUNT; t++) - { - tabImg[t].grid[a]->setAlpha(mAlpha); - } + t.setAlpha(mAlpha); } } } diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index cd2c0f03..1fdd276f 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -214,10 +214,9 @@ void TabbedArea::widgetResized(const gcn::Event &event) void TabbedArea::updateTabsWidth() { mTabsWidth = 0; - for (TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end(); - itr != itr_end; ++itr) + for (const auto &tab : mTabs) { - mTabsWidth += (*itr).first->getWidth(); + mTabsWidth += tab.first->getWidth(); } updateVisibleTabsWidth(); } @@ -234,11 +233,11 @@ void TabbedArea::updateVisibleTabsWidth() void TabbedArea::adjustTabPositions() { int maxTabHeight = 0; - for (unsigned i = 0; i < mTabs.size(); ++i) + for (auto &tab : mTabs) { - if (mTabs[i].first->getHeight() > maxTabHeight) + if (tab.first->getHeight() > maxTabHeight) { - maxTabHeight = mTabs[i].first->getHeight(); + maxTabHeight = tab.first->getHeight(); } } diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index 5273e929..9c7bc92d 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -37,14 +37,14 @@ void TableModel::removeListener(TableModelListener *listener) void TableModel::signalBeforeUpdate() { - for (auto it = listeners.begin(); it != listeners.end(); it++) - (*it)->modelUpdated(false); + for (auto listener : listeners) + listener->modelUpdated(false); } void TableModel::signalAfterUpdate() { - for (auto it = listeners.begin(); it != listeners.end(); it++) - (*it)->modelUpdated(true); + for (auto listener : listeners) + listener->modelUpdated(true); } @@ -146,9 +146,9 @@ int StaticTableModel::getWidth() const { int width = 0; - for (unsigned int i = 0; i < mWidths.size(); i++) + for (int w : mWidths) { - width += mWidths[i]; + width += w; } return width; diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 1609e002..2239bed4 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -69,10 +69,10 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab): gridx[x], gridy[y], gridx[x + 1] - gridx[x] + 1, gridy[y + 1] - gridy[y] + 1); - skin.grid[a]->setAlpha(config.getFloatValue("guialpha")); a++; } } + skin.setAlpha(config.getFloatValue("guialpha")); textbox->decRef(); } @@ -96,8 +96,7 @@ void TextField::updateAlpha() if (alpha != mAlpha) { mAlpha = alpha; - for (int a = 0; a < 9; a++) - skin.grid[a]->setAlpha(mAlpha); + skin.setAlpha(mAlpha); } } diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index ad87788f..a0c227ab 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -45,8 +45,8 @@ void VertContainer::clear() void VertContainer::widgetResized(const gcn::Event &event) { - for (auto it = mWidgets.begin(); it != mWidgets.end(); it++) + for (auto &widget : mWidgets) { - (*it)->setWidth(getWidth()); + widget->setWidth(getWidth()); } } diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index c7ac5d99..8cee550b 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -43,7 +43,7 @@ void WindowContainer::scheduleDelete(gcn::Widget *widget) void WindowContainer::adjustAfterResize(int oldScreenWidth, int oldScreenHeight) { - for (auto i = mWidgets.begin(); i != mWidgets.end(); ++i) - if (auto *window = dynamic_cast<Window*>(*i)) + for (auto &widget : mWidgets) + if (auto *window = dynamic_cast<Window*>(widget)) window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight); } |