Inverted icon state

This commit is contained in:
Simon Robertshaw 2012-07-24 15:38:18 +01:00
parent bc2e4ab23f
commit da77cb809b
3 changed files with 113 additions and 26 deletions

View File

@ -714,73 +714,148 @@ void Graphics::textsize(const char * s, int & width, int & height)
height = cHeight; height = cHeight;
} }
void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha) void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool invert)
{ {
y--; y--;
switch(icon) switch(icon)
{ {
case IconOpen: case IconOpen:
drawchar(x, y, 0x81, 255, 255, 255, alpha); if(invert)
drawchar(x, y, 0x81, 0, 0, 0, alpha);
else
drawchar(x, y, 0x81, 255, 255, 255, alpha);
break; break;
case IconReload: case IconReload:
drawchar(x, y, 0x91, 255, 255, 255, alpha); if(invert)
drawchar(x, y, 0x91, 0, 0, 0, alpha);
else
drawchar(x, y, 0x91, 255, 255, 255, alpha);
break; break;
case IconSave: case IconSave:
drawchar(x, y, 0x82, 255, 255, 255, alpha); if(invert)
drawchar(x, y, 0x82, 0, 0, 0, alpha);
else
drawchar(x, y, 0x82, 255, 255, 255, alpha);
break; break;
case IconVoteUp: case IconVoteUp:
drawchar(x, y, 0xCB, 0, 187, 18, alpha); if(invert)
drawchar(x, y, 0xCB, 0, 100, 0, alpha);
else
drawchar(x, y, 0xCB, 0, 187, 18, alpha);
break; break;
case IconVoteDown: case IconVoteDown:
drawchar(x, y, 0xCA, 187, 40, 0, alpha); if(invert)
drawchar(x, y, 0xCA, 100, 10, 0, alpha);
else
drawchar(x, y, 0xCA, 187, 40, 0, alpha);
break; break;
case IconTag: case IconTag:
drawchar(x, y, 0x83, 255, 255, 255, alpha); if(invert)
drawchar(x, y, 0x83, 0, 0, 0, alpha);
else
drawchar(x, y, 0x83, 255, 255, 255, alpha);
break; break;
case IconNew: case IconNew:
drawchar(x, y, 0x92, 255, 255, 255, alpha); if(invert)
drawchar(x, y, 0x92, 0, 0, 0, alpha);
else
drawchar(x, y, 0x92, 255, 255, 255, alpha);
break; break;
case IconLogin: case IconLogin:
drawchar(x, y, 0x84, 255, 255, 255, alpha); if(invert)
drawchar(x, y, 0x84, 0, 0, 0, alpha);
else
drawchar(x, y, 0x84, 255, 255, 255, alpha);
break; break;
case IconSimulationSettings: case IconSimulationSettings:
drawchar(x, y+1, 0xCF, 255, 255, 255, alpha); if(invert)
drawchar(x, y+1, 0xCF, 0, 0, 0, alpha);
else
drawchar(x, y+1, 0xCF, 255, 255, 255, alpha);
break; break;
case IconRenderSettings: case IconRenderSettings:
addchar(x, y+1, 0xD8, 255, 0, 0, alpha); if(invert)
addchar(x, y+1, 0xD9, 0, 255, 0, alpha); {
addchar(x, y+1, 0xDA, 0, 0, 255, alpha); drawchar(x, y+1, 0xD8, 255, 0, 0, alpha);
drawchar(x, y+1, 0xD9, 0, 255, 0, alpha);
drawchar(x, y+1, 0xDA, 0, 0, 255, alpha);
}
else
{
addchar(x, y+1, 0xD8, 255, 0, 0, alpha);
addchar(x, y+1, 0xD9, 0, 255, 0, alpha);
addchar(x, y+1, 0xDA, 0, 0, 255, alpha);
}
break; break;
case IconPause: case IconPause:
drawchar(x, y, 0x90, 255, 255, 255, alpha); if(invert)
drawchar(x, y, 0x90, 0, 0, 0, alpha);
else
drawchar(x, y, 0x90, 255, 255, 255, alpha);
break; break;
case IconFavourite: case IconFavourite:
drawchar(x, y, 0xCC, 192, 160, 64, alpha); if(invert)
drawchar(x, y, 0xCC, 100, 80, 32, alpha);
else
drawchar(x, y, 0xCC, 192, 160, 64, alpha);
break; break;
case IconReport: case IconReport:
drawchar(x, y, 0xE3, 255, 255, 0, alpha); if(invert)
drawchar(x, y, 0xE3, 140, 140, 0, alpha);
else
drawchar(x, y, 0xE3, 255, 255, 0, alpha);
break; break;
case IconUsername: case IconUsername:
drawchar(x, y, 0x8B, 32, 64, 128, alpha); if(invert)
drawchar(x, y, 0x8A, 255, 255, 255, alpha); {
drawchar(x, y, 0x8B, 32, 64, 128, alpha);
drawchar(x, y, 0x8A, 0, 0, 0, alpha);
}
else
{
drawchar(x, y, 0x8B, 32, 64, 128, alpha);
drawchar(x, y, 0x8A, 255, 255, 255, alpha);
}
break; break;
case IconPassword: case IconPassword:
drawchar(x, y, 0x8C, 160, 144, 32, alpha); if(invert)
drawchar(x, y, 0x84, 255, 255, 255, alpha); {
drawchar(x, y, 0x8C, 160, 144, 32, alpha);
drawchar(x, y, 0x84, 0, 0, 0, alpha);
}
else
{
drawchar(x, y, 0x8C, 160, 144, 32, alpha);
drawchar(x, y, 0x84, 255, 255, 255, alpha);
}
break; break;
case IconClose: case IconClose:
drawchar(x, y, 0xAA, 230, 230, 230, alpha); if(invert)
drawchar(x, y, 0xAA, 20, 20, 20, alpha);
else
drawchar(x, y, 0xAA, 230, 230, 230, alpha);
break; break;
case IconVoteSort: case IconVoteSort:
case IconDateSort: case IconDateSort:
case IconFolder: case IconFolder:
case IconSearch: case IconSearch:
case IconDelete: case IconDelete:
drawchar(x, y, 0x86, 255, 55, 55, alpha); if(invert)
drawchar(x, y, 0x85, 255, 255, 255, alpha); {
drawchar(x, y, 0x86, 255, 55, 55, alpha);
drawchar(x, y, 0x85, 0, 0, 0, alpha);
}
else
{
drawchar(x, y, 0x86, 255, 55, 55, alpha);
drawchar(x, y, 0x85, 255, 255, 255, alpha);
}
break; break;
default: default:
drawchar(x, y, 't', 255, 255, 255, alpha); if(invert)
drawchar(x, y, 't', 0, 0 ,0 ,alpha);
else
drawchar(x, y, 't', 255, 255, 255, alpha);
break; break;
} }
} }

View File

@ -138,7 +138,7 @@ public:
void blendpixel(int x, int y, int r, int g, int b, int a); void blendpixel(int x, int y, int r, int g, int b, int a);
void addpixel(int x, int y, int r, int g, int b, int a); void addpixel(int x, int y, int r, int g, int b, int a);
void draw_icon(int x, int y, Icon icon, unsigned char alpha = 255); void draw_icon(int x, int y, Icon icon, unsigned char alpha = 255, bool invert = false);
void Clear(); void Clear();
void Finalise(); void Finalise();

View File

@ -107,7 +107,19 @@ void Button::Draw(const Point& screenPos)
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, buttonDisplayText, 180, 180, 180, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, buttonDisplayText, 180, 180, 180, 255);
} }
if(Appearance.icon) if(Appearance.icon)
g->draw_icon(Position.X+iconPosition.X, Position.Y+iconPosition.Y, Appearance.icon); {
if(Enabled)
if(isButtonDown || (isTogglable && toggle))
{
g->draw_icon(Position.X+iconPosition.X, Position.Y+iconPosition.Y, Appearance.icon, 255, true);
}
else
{
g->draw_icon(Position.X+iconPosition.X, Position.Y+iconPosition.Y, Appearance.icon, 255);
}
else
g->draw_icon(Position.X+iconPosition.X, Position.Y+iconPosition.Y, Appearance.icon, 180);
}
} }
void Button::OnMouseUp(int x, int y, unsigned int button) void Button::OnMouseUp(int x, int y, unsigned int button)