Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into original
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Sep 13, 2024
2 parents 125b4aa + 2853b32 commit 9cb6bc5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/focushandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ namespace gcn
{
return;
}

unsigned int i = 0;

int toBeFocusedIndex = -1;
for (i = 0; i < mWidgets.size(); ++i)
for (unsigned int i = 0; i < mWidgets.size(); ++i)
{
if (mWidgets[i] == widget)
{
Expand Down
5 changes: 2 additions & 3 deletions src/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ namespace gcn
{
int Font::getStringIndexAt(const std::string& text, int x) const
{
unsigned int i;
int size = 0;

for (i = 0; i < text.size(); ++i)
for (unsigned int i = 0; i < text.size(); ++i)
{
size = getWidth(text.substr(0,i));
size = getWidth(text.substr(0, i));

if (size > x)
{
Expand Down
6 changes: 2 additions & 4 deletions src/imagefont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,9 @@ namespace gcn

int ImageFont::getWidth(const std::string& text) const
{
unsigned int i;
int size = 0;

for (i = 0; i < text.size(); ++i)
for (unsigned int i = 0; i < text.size(); ++i)
{
size += getWidth(text.at(i));
}
Expand All @@ -353,10 +352,9 @@ namespace gcn

int ImageFont::getStringIndexAt(const std::string& text, int x) const
{
unsigned int i;
int size = 0;

for (i = 0; i < text.size(); ++i)
for (unsigned int i = 0; i < text.size(); ++i)
{
size += getWidth(text.at(i));

Expand Down
15 changes: 13 additions & 2 deletions src/widgets/listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
* Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
*
* Js_./
* Per Larsson a.k.a finalman _RqZ{a<^_aa
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
* _Qhm`] _f "'c 1!5m
* Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
* .)j(] .d_/ '-( P . S
Expand Down Expand Up @@ -319,6 +319,17 @@ namespace gcn
{
if (mListModel != NULL)
{
int maxElementWidth = getWidth();
for (int i = 0; i < mListModel->getNumberOfElements(); i++)
{
const auto elementLength = getFont()->getWidth(mListModel->getElementAt(i));
if (elementLength > maxElementWidth)
{
maxElementWidth = elementLength;
}
}
if (maxElementWidth > getWidth())
setWidth(maxElementWidth + 4);
setHeight(getRowHeight() * mListModel->getNumberOfElements());
}
}
Expand Down

0 comments on commit 9cb6bc5

Please sign in to comment.