summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-21 13:30:39 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-21 13:30:39 +0300
commit1fcc02e803d83ae8415ff44f9696cb215f475daa (patch)
tree3c4ccb5160624db095a139cb5a81a982e156d81c /src/gui
parent126fa885664da8a8de86f3a38c04469f7006e447 (diff)
downloadmanaverse-1fcc02e803d83ae8415ff44f9696cb215f475daa.tar.gz
manaverse-1fcc02e803d83ae8415ff44f9696cb215f475daa.tar.bz2
manaverse-1fcc02e803d83ae8415ff44f9696cb215f475daa.tar.xz
manaverse-1fcc02e803d83ae8415ff44f9696cb215f475daa.zip
fix signed shifts.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/base/color.cpp39
-rw-r--r--src/gui/base/color.hpp15
-rw-r--r--src/gui/theme.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp2
4 files changed, 32 insertions, 26 deletions
diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp
index 764259efc..485367e6d 100644
--- a/src/gui/base/color.cpp
+++ b/src/gui/base/color.cpp
@@ -72,22 +72,25 @@
namespace gcn
{
Color::Color() :
- r(0),
- g(0),
- b(0),
- a(255)
+ r(0U),
+ g(0U),
+ b(0U),
+ a(255U)
{
}
- Color::Color(const int color) :
+ Color::Color(const unsigned int color) :
r((color >> 16) & 0xFF),
g((color >> 8) & 0xFF),
b(color & 0xFF),
- a(255)
+ a(255U)
{
}
- Color::Color(const int ar, const int ag, const int ab, const int aa) :
+ Color::Color(const unsigned int ar,
+ const unsigned int ag,
+ const unsigned int ab,
+ const unsigned int aa) :
r(ar),
g(ag),
b(ab),
@@ -100,11 +103,11 @@ namespace gcn
Color result(r + color.r,
g + color.g,
b + color.b,
- 255);
+ 255U);
- result.r = (result.r>255?255:(result.r<0?0:result.r));
- result.g = (result.g>255?255:(result.g<0?0:result.g));
- result.b = (result.b>255?255:(result.b<0?0:result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
@@ -114,11 +117,11 @@ namespace gcn
Color result(r - color.r,
g - color.g,
b - color.b,
- 255);
+ 255U);
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
@@ -130,9 +133,9 @@ namespace gcn
static_cast<int>(static_cast<float>(b) * value),
a);
- result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r));
- result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g));
- result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b));
+ result.r = (result.r > 255U ? 255U : result.r);
+ result.g = (result.g > 255U ? 255U : result.g);
+ result.b = (result.b > 255U ? 255U : result.b);
return result;
}
diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp
index c32adb2e9..781b2cb60 100644
--- a/src/gui/base/color.hpp
+++ b/src/gui/base/color.hpp
@@ -93,7 +93,7 @@ namespace gcn
*
* @param color The color to initialise the object with.
*/
- explicit Color(const int color);
+ explicit Color(const unsigned int color);
/**
* Constructor. The default alpha value is 255.
@@ -104,7 +104,10 @@ namespace gcn
* @param a Alpha, used for transparency. A value of 0 means
* totaly transparent, 255 is totaly opaque.
*/
- Color(const int r, const int g, const int b, const int a = 255);
+ Color(const unsigned int r,
+ const unsigned int g,
+ const unsigned int b,
+ const unsigned int a = 255);
/**
* Adds the RGB values of two colors together. The values will be
@@ -169,23 +172,23 @@ namespace gcn
/**
* Holds the red color component (range 0-255).
*/
- int r;
+ unsigned int r;
/**
* Holds the green color component (range 0-255).
*/
- int g;
+ unsigned int g;
/**
* Holds the blue color component (range 0-255).
*/
- int b;
+ unsigned int b;
/**
* Holds the alpha color component. A value of 0 means totally
* transparent while a value of 255 is considered opaque.
*/
- int a;
+ unsigned int a;
};
} // namespace gcn
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 4218aff7c..2a1b0d624 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -982,7 +982,7 @@ static gcn::Color readColor(const std::string &description)
return Palette::BLACK;
}
- int v = 0;
+ unsigned int v = 0;
for (int i = 1; i < 7; ++i)
{
signed const char c = description[i];
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index c30045c02..0d4d53dd3 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -251,7 +251,7 @@ void TextField::keyPressed(KeyEvent &keyEvent)
}
if (len > 1)
- buf[0] |= static_cast<char>(255 << (8 - len));
+ buf[0] |= static_cast<char>(255U << (8 - len));
mText.insert(mCaretPosition, std::string(buf, buf + len));
mCaretPosition += len;