Adjust icon positions

This commit is contained in:
Simon Robertshaw 2012-07-24 15:21:01 +01:00
parent 43ec3af8d7
commit bc2e4ab23f
4 changed files with 48 additions and 37 deletions

View File

@ -92,7 +92,7 @@ GameView::GameView():
v->c->OpenSaveWindow(); v->c->OpenSaveWindow();
} }
}; };
saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(150, 15)); saveSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(150, 15), "[untitled simulation]");
saveSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; saveSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
saveSimulationButton->SetIcon(IconSave); saveSimulationButton->SetIcon(IconSave);
currentX+=151; currentX+=151;
@ -141,7 +141,7 @@ GameView::GameView():
v->c->OpenTags(); v->c->OpenTags();
} }
}; };
tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(250, 15)); tagSimulationButton = new ui::Button(ui::Point(currentX, Size.Y-16), ui::Point(250, 15), "[no tags set]");
tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; tagSimulationButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
tagSimulationButton->SetIcon(IconTag); tagSimulationButton->SetIcon(IconTag);
currentX+=251; currentX+=251;
@ -173,7 +173,7 @@ GameView::GameView():
v->c->OpenLogin(); v->c->OpenLogin();
} }
}; };
loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "Login"); loginButton = new ui::Button(ui::Point(Size.X-141, Size.Y-16), ui::Point(92, 15), "[sign in]");
loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
loginButton->SetIcon(IconLogin); loginButton->SetIcon(IconLogin);
loginButton->SetActionCallback(new LoginAction(this)); loginButton->SetActionCallback(new LoginAction(this));
@ -520,7 +520,7 @@ void GameView::NotifyUserChanged(GameModel * sender)
{ {
if(!sender->GetUser().ID) if(!sender->GetUser().ID)
{ {
loginButton->SetText("Login"); loginButton->SetText("[sign in]");
} }
else else
{ {
@ -567,25 +567,36 @@ void GameView::NotifySaveChanged(GameModel * sender)
{ {
std::stringstream tagsStream; std::stringstream tagsStream;
std::vector<string> tags = sender->GetSave()->GetTags(); std::vector<string> tags = sender->GetSave()->GetTags();
for(int i = 0; i < tags.size(); i++) if(tags.size())
{ {
tagsStream << sender->GetSave()->GetTags()[i]; for(int i = 0; i < tags.size(); i++)
if(i < tags.size()-1) {
tagsStream << " "; tagsStream << sender->GetSave()->GetTags()[i];
if(i < tags.size()-1)
tagsStream << " ";
}
tagSimulationButton->SetText(tagsStream.str());
} }
tagSimulationButton->SetText(tagsStream.str()); else
{
tagSimulationButton->SetText("[no tags set]");
}
}
else
{
tagSimulationButton->SetText("[no tags set]");
} }
} }
else else
{ {
saveSimulationButton->SetText(""); saveSimulationButton->SetText("[untitled simulation]");
reloadButton->Enabled = false; reloadButton->Enabled = false;
upVoteButton->Enabled = false; upVoteButton->Enabled = false;
upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0)); upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
downVoteButton->Enabled = false; downVoteButton->Enabled = false;
upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0)); upVoteButton->Appearance.BackgroundInactive = (ui::Colour(0, 0, 0));
tagSimulationButton->Enabled = false; tagSimulationButton->Enabled = false;
tagSimulationButton->SetText(""); tagSimulationButton->SetText("[no tags set]");
} }
} }

View File

@ -714,73 +714,73 @@ void Graphics::textsize(const char * s, int & width, int & height)
height = cHeight; height = cHeight;
} }
void Graphics::draw_icon(int x, int y, Icon icon) void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha)
{ {
y--; y--;
switch(icon) switch(icon)
{ {
case IconOpen: case IconOpen:
drawchar(x, y, 0x81, 255, 255, 255, 255); drawchar(x, y, 0x81, 255, 255, 255, alpha);
break; break;
case IconReload: case IconReload:
drawchar(x, y, 0x91, 255, 255, 255, 255); drawchar(x, y, 0x91, 255, 255, 255, alpha);
break; break;
case IconSave: case IconSave:
drawchar(x, y, 0x82, 255, 255, 255, 255); drawchar(x, y, 0x82, 255, 255, 255, alpha);
break; break;
case IconVoteUp: case IconVoteUp:
drawchar(x, y, 0xCB, 0, 187, 18, 255); drawchar(x, y, 0xCB, 0, 187, 18, alpha);
break; break;
case IconVoteDown: case IconVoteDown:
drawchar(x, y, 0xCA, 187, 40, 0, 255); drawchar(x, y, 0xCA, 187, 40, 0, alpha);
break; break;
case IconTag: case IconTag:
drawchar(x, y, 0x83, 255, 255, 255, 255); drawchar(x, y, 0x83, 255, 255, 255, alpha);
break; break;
case IconNew: case IconNew:
drawchar(x, y, 0x92, 255, 255, 255, 255); drawchar(x, y, 0x92, 255, 255, 255, alpha);
break; break;
case IconLogin: case IconLogin:
drawchar(x, y, 0x84, 255, 255, 255, 255); drawchar(x, y, 0x84, 255, 255, 255, alpha);
break; break;
case IconSimulationSettings: case IconSimulationSettings:
drawchar(x, y, 0xCF, 255, 255, 255, 255); drawchar(x, y+1, 0xCF, 255, 255, 255, alpha);
break; break;
case IconRenderSettings: case IconRenderSettings:
addchar(x, y, 0xD8, 255, 0, 0, 255); addchar(x, y+1, 0xD8, 255, 0, 0, alpha);
addchar(x, y, 0xD9, 0, 255, 0, 255); addchar(x, y+1, 0xD9, 0, 255, 0, alpha);
addchar(x, y, 0xDA, 0, 0, 255, 255); addchar(x, y+1, 0xDA, 0, 0, 255, alpha);
break; break;
case IconPause: case IconPause:
drawchar(x, y, 0x90, 255, 255, 255, 255); drawchar(x, y, 0x90, 255, 255, 255, alpha);
break; break;
case IconFavourite: case IconFavourite:
drawchar(x, y, 0xCC, 192, 160, 64, 255); drawchar(x, y, 0xCC, 192, 160, 64, alpha);
break; break;
case IconReport: case IconReport:
drawchar(x, y, 0xE3, 255, 255, 0, 255); drawchar(x, y, 0xE3, 255, 255, 0, alpha);
break; break;
case IconUsername: case IconUsername:
drawchar(x, y, 0x8B, 32, 64, 128, 255); drawchar(x, y, 0x8B, 32, 64, 128, alpha);
drawchar(x, y, 0x8A, 255, 255, 255, 255); drawchar(x, y, 0x8A, 255, 255, 255, alpha);
break; break;
case IconPassword: case IconPassword:
drawchar(x, y, 0x8C, 160, 144, 32, 255); drawchar(x, y, 0x8C, 160, 144, 32, alpha);
drawchar(x, y, 0x84, 255, 255, 255, 255); drawchar(x, y, 0x84, 255, 255, 255, alpha);
break; break;
case IconClose: case IconClose:
drawchar(x, y, 0xAA, 230, 230, 230, 255); 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, 255); drawchar(x, y, 0x86, 255, 55, 55, alpha);
drawchar(x, y, 0x85, 255, 255, 255, 255); drawchar(x, y, 0x85, 255, 255, 255, alpha);
break; break;
default: default:
drawchar(x, y, 't', 255, 255, 255, 255); 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); void draw_icon(int x, int y, Icon icon, unsigned char alpha = 255);
void Clear(); void Clear();
void Finalise(); void Finalise();

View File

@ -103,7 +103,7 @@ void Component::TextPosition(std::string displayText)
} }
if(Appearance.icon) if(Appearance.icon)
{ {
iconPosition = textPosition;//-ui::Point(0, 1); iconPosition = textPosition-ui::Point(0, 1);
textPosition.X += 15; textPosition.X += 15;
} }
} }