ui loader and some refactoring

This commit is contained in:
Eduardo Bart
2011-04-10 17:40:44 -03:00
parent 1f78f93096
commit 992e0a8a6b
36 changed files with 646 additions and 425 deletions

View File

@@ -0,0 +1,33 @@
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "color.h"
Color Color::white(0xFF, 0xFF, 0xFF, 0xFF);
Color Color::black(0x00, 0x00, 0x00, 0xFF);
Color Color::alpha(0x00, 0x00, 0x00, 0x00);
Color Color::red (0xFF, 0x00, 0x00, 0xFF);
Color Color::green(0x00, 0xFF, 0x00, 0xFF);
Color Color::blue (0x00, 0x00, 0xFF, 0xFF);
Color Color::pink (0xFF, 0x00, 0xFF, 0xFF);

View File

@@ -37,10 +37,10 @@ public:
inline Color(const Color& other) : color(other.color) { }
inline Color(RGBA rgba) : color(rgba) { }
inline uint8 red() const { return (color >> 24) & 0xFF; }
inline uint8 green() const { return (color >> 16) & 0xFF; }
inline uint8 blue() const { return (color >> 8) & 0xFF; }
inline uint8 alpha() const { return color & 0xFF; }
inline uint8 r() const { return (color >> 24) & 0xFF; }
inline uint8 g() const { return (color >> 16) & 0xFF; }
inline uint8 b() const { return (color >> 8) & 0xFF; }
inline uint8 a() const { return color & 0xFF; }
inline RGBA rgba() const { return color; }
inline const uint8* rgbaPtr() const { return (const uint8*)&color; }
@@ -55,6 +55,14 @@ public:
inline bool operator==(const Color& other) const { return other.color == color; }
inline bool operator!=(const Color& other) const { return other.color != color; }
static Color white;
static Color black;
static Color alpha;
static Color red;
static Color green;
static Color blue;
static Color pink;
private:
RGBA color;
};
@@ -69,4 +77,13 @@ inline void operator>>(const YAML::Node& node, Color& color)
color.setRGBA(r,g,b,a);
}
inline std::ostream& operator<<(std::ostream& out, const Color& color)
{
out << "Color(" << (int)color.r() << ","
<< (int)color.g() << ","
<< (int)color.b() << ","
<< (int)color.a() << ")";
return out;
}
#endif // COLOR_H

View File

@@ -85,4 +85,12 @@ inline void operator>>(const YAML::Node& node, TPoint<T>& point)
node[1] >> point.y;
}
template <class T>
inline std::ostream& operator<<(std::ostream& out, const TPoint<T>& point)
{
out << "Point(" << point.x << ","
<< point.y << ")";
return out;
}
#endif

View File

@@ -304,4 +304,14 @@ inline void operator>>(const YAML::Node& node, TRect<T>& rect)
rect.setRect(x, y, width, height);
}
template <class T>
inline std::ostream& operator<<(std::ostream& out, const TRect<T>& rect)
{
out << "Rect(" << rect.left() << ","
<< rect.top() << ","
<< rect.width() << ","
<< rect.height() << ")";
return out;
}
#endif // RECT_H

View File

@@ -120,4 +120,12 @@ inline void operator>>(const YAML::Node& node, TSize<T>& size)
size.setSize(w, h);
}
template <class T>
inline std::ostream& operator<<(std::ostream& out, const TSize<T>& size)
{
out << "Size(" << size.width() << ","
<< size.height() << ")";
return out;
}
#endif