Buttons for client options

This commit is contained in:
Eduardo Bart
2013-02-06 17:35:59 -02:00
parent cf77df05ca
commit 7ece0ed8c7
11 changed files with 63 additions and 12 deletions

View File

@@ -23,7 +23,7 @@
#include "color.h"
// NOTE: AABBGGRR order
const Color Color::alpha = 0x00000000;
const Color Color::alpha = 0x00000000U;
const Color Color::white = 0xffffffff;
const Color Color::black = 0xff000000;
const Color Color::red = 0xff0000ff;
@@ -42,3 +42,9 @@ const Color Color::gray = 0xffa0a0a0;
const Color Color::darkGray = 0xff808080;
const Color Color::lightGray = 0xffc0c0c0;
const Color Color::orange = 0xffff8c00;
Color::Color(const std::string& coltext)
{
std::stringstream ss(coltext);
ss >> *this;
}

View File

@@ -37,6 +37,7 @@ public:
Color(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) : m_r(r/255.0f), m_g(g/255.0f), m_b(b/255.0f), m_a(a/255.0f) { }
Color(int r, int g, int b, int a = 0xFF) : m_r(r/255.0f), m_g(g/255.0f), m_b(b/255.0f), m_a(a/255.0f) { }
Color(float r, float g, float b, float a = 1.0f) : m_r(r), m_g(g), m_b(b), m_a(a) { }
Color(const std::string& coltext);
uint8 a() const { return m_a*255.0f; }
uint8 b() const { return m_b*255.0f; }
@@ -76,6 +77,14 @@ public:
bool operator==(const Color& other) const { return other.rgba() == rgba(); }
bool operator!=(const Color& other) const { return other.rgba() != rgba(); }
static uint8 to8bit(const Color& color) {
uint8 c = 0;
c += (color.r() / 51) * 36;
c += (color.g() / 51) * 6;
c += (color.b() / 51);
return c;
};
static Color from8bit(int color) {
if(color >= 216 || color <= 0)
return Color(0, 0, 0);