Better icon alignment, improve appearance of preview

This commit is contained in:
Simon Robertshaw 2012-05-22 20:30:23 +01:00
parent f86f2a9997
commit adf7a3c720
6 changed files with 36 additions and 21 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ build/*
stamps/* stamps/*
Saves/* Saves/*
generated/* generated/*
generate
Makefile.me Makefile.me
PowderToypp.xcodeproj/* PowderToypp.xcodeproj/*
.DS_Store .DS_Store

View File

@ -599,6 +599,7 @@ void Graphics::textsize(const char * s, int & width, int & height)
void Graphics::draw_icon(int x, int y, Icon icon) void Graphics::draw_icon(int x, int y, Icon icon)
{ {
y--;
switch(icon) switch(icon)
{ {
case IconOpen: case IconOpen:

View File

@ -90,13 +90,13 @@ void Button::Draw(const Point& screenPos)
{ {
g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, Appearance.BackgroundActive.Red, Appearance.BackgroundActive.Green, Appearance.BackgroundActive.Blue, 255); g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, Appearance.BackgroundActive.Red, Appearance.BackgroundActive.Green, Appearance.BackgroundActive.Blue, 255);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BorderActive.Red, Appearance.BorderActive.Green, Appearance.BorderActive.Blue, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BorderActive.Red, Appearance.BorderActive.Green, Appearance.BorderActive.Blue, 255);
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, Appearance.TextActive.Red, Appearance.TextActive.Green, Appearance.TextActive.Blue, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, buttonDisplayText, Appearance.TextActive.Red, Appearance.TextActive.Green, Appearance.TextActive.Blue, 255);
} }
else else
{ {
g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, 255); g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, 255);
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BorderInactive.Red, Appearance.BorderInactive.Green, Appearance.BorderInactive.Blue, 255); g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BorderInactive.Red, Appearance.BorderInactive.Green, Appearance.BorderInactive.Blue, 255);
g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y+1, buttonDisplayText, Appearance.TextInactive.Red, Appearance.TextInactive.Green, Appearance.TextInactive.Blue, 255); g->drawtext(Position.X+textPosition.X, Position.Y+textPosition.Y, buttonDisplayText, Appearance.TextInactive.Red, Appearance.TextInactive.Green, Appearance.TextInactive.Blue, 255);
} }
} }
else else

View File

@ -44,7 +44,7 @@ PreviewView::PreviewView():
} }
}; };
favButton = new ui::Button(ui::Point(51, Size.Y-19), ui::Point(51, 19), "Fav."); favButton = new ui::Button(ui::Point(50, Size.Y-19), ui::Point(51, 19), "Fav.");
favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; favButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
favButton->SetIcon(IconFavourite); favButton->SetIcon(IconFavourite);
favButton->SetActionCallback(new FavAction(this)); favButton->SetActionCallback(new FavAction(this));
@ -71,7 +71,7 @@ PreviewView::PreviewView():
new TextPrompt("Report Save", "Reason for reporting", true, new ReportPromptCallback(v)); new TextPrompt("Report Save", "Reason for reporting", true, new ReportPromptCallback(v));
} }
}; };
reportButton = new ui::Button(ui::Point(102, Size.Y-19), ui::Point(51, 19), "Report"); reportButton = new ui::Button(ui::Point(100, Size.Y-19), ui::Point(51, 19), "Report");
reportButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; reportButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; reportButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; reportButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
reportButton->SetIcon(IconReport); reportButton->SetIcon(IconReport);
reportButton->SetActionCallback(new ReportAction(this)); reportButton->SetActionCallback(new ReportAction(this));
@ -88,7 +88,7 @@ PreviewView::PreviewView():
} }
}; };
browserOpenButton = new ui::Button(ui::Point((XRES/2)-108, Size.Y-19), ui::Point(108, 19), "Open in browser"); browserOpenButton = new ui::Button(ui::Point((XRES/2)-107, Size.Y-19), ui::Point(108, 19), "Open in browser");
browserOpenButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; browserOpenButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle; browserOpenButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; browserOpenButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
browserOpenButton->SetIcon(IconOpen); browserOpenButton->SetIcon(IconOpen);
browserOpenButton->SetActionCallback(new BrowserOpenAction(this)); browserOpenButton->SetActionCallback(new BrowserOpenAction(this));
@ -121,22 +121,32 @@ void PreviewView::OnDraw()
{ {
g->draw_image(savePreview->Data, (Position.X+1)+(((XRES/2)-savePreview->Size.X)/2), (Position.Y+1)+(((YRES/2)-savePreview->Size.Y)/2), savePreview->Size.X, savePreview->Size.Y, 255); g->draw_image(savePreview->Data, (Position.X+1)+(((XRES/2)-savePreview->Size.X)/2), (Position.Y+1)+(((YRES/2)-savePreview->Size.Y)/2), savePreview->Size.X, savePreview->Size.Y, 255);
} }
g->drawrect(Position.X, Position.Y, XRES/2, YRES/2, 255, 255, 255, 100); g->drawrect(Position.X, Position.Y, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 100);
g->draw_line(Position.X+XRES/2, Position.Y, Position.X+XRES/2, Position.Y+Size.Y, 255, 255, 255, XRES+BARSIZE); g->draw_line(Position.X+XRES/2, Position.Y+1, Position.X+XRES/2, Position.Y+Size.Y-2, 200, 200, 200, 255);
g->draw_line(Position.X+1, Position.Y+10+YRES/2, Position.X-2+XRES/2, Position.Y+10+YRES/2, 100, 100, 100, XRES+BARSIZE); g->draw_line(Position.X+1, Position.Y+12+YRES/2, Position.X-1+XRES/2, Position.Y+12+YRES/2, 100, 100, 100,255);
float factor; float factor;
if(!votesUp && !votesDown) if(!votesUp && !votesDown)
return; return;
else else
factor = (float)(((float)(XRES/2)-2)/((float)(votesUp+votesDown))); factor = (float)(((float)(XRES/2)-2)/((float)(votesUp+votesDown)));
g->fillrect(1+Position.X, 1+Position.Y+YRES/2, (XRES/2)-2, 8, 200, 50, 50, 255); g->fillrect(1+Position.X, 2+Position.Y+YRES/2, (XRES/2)-2, 9, 200, 50, 50, 255);
g->fillrect(1+Position.X, 1+Position.Y+YRES/2, (int)(((float)votesUp)*factor), 8, 50, 200, 50, 255); g->fillrect(1+Position.X, 2+Position.Y+YRES/2, (int)(((float)votesUp)*factor), 9, 50, 200, 50, 255);
g->fillrect(1+Position.X, 1+Position.Y+(YRES/2), 14, 8, 0, 0, 0, 100); g->fillrect(1+Position.X, 2+Position.Y+(YRES/2), 14, 9, 0, 0, 0, 100);
g->fillrect(Position.X+(XRES/2)-15, 1+Position.Y+(YRES/2), 14, 8, 0, 0, 0, 100); g->fillrect(Position.X+(XRES/2)-15, 2+Position.Y+(YRES/2), 14, 9, 0, 0, 0, 100);
g->draw_icon(1+Position.X+2, Position.Y+(YRES/2)+2, IconVoteUp); g->draw_icon(1+Position.X+2, Position.Y+(YRES/2)+4, IconVoteUp);
g->draw_icon(Position.X+(XRES/2)-12, Position.Y+(YRES/2)-1, IconVoteDown); g->draw_icon(Position.X+(XRES/2)-12, Position.Y+(YRES/2)+1, IconVoteDown);
for(int i = 0; i < commentTextComponents.size(); i++)
{
g->draw_line(
Position.X+XRES/2,
Position.Y+commentTextComponents[i]->Position.Y+commentTextComponents[i]->Size.Y+4,
Position.X+Size.X-1,
Position.Y+commentTextComponents[i]->Position.Y+commentTextComponents[i]->Size.Y+4,
100, 100, 100, 255);
}
} }
void PreviewView::OnTick(float dt) void PreviewView::OnTick(float dt)
@ -184,6 +194,7 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
delete commentComponents[i]; delete commentComponents[i];
} }
commentComponents.clear(); commentComponents.clear();
commentTextComponents.clear();
int currentY = 0; int currentY = 0;
ui::Label * tempUsername; ui::Label * tempUsername;
@ -213,6 +224,7 @@ void PreviewView::NotifyCommentsChanged(PreviewModel * sender)
AddComponent(tempComment); AddComponent(tempComment);
commentComponents.push_back(tempUsername); commentComponents.push_back(tempUsername);
AddComponent(tempUsername); AddComponent(tempUsername);
commentTextComponents.push_back(tempComment);
} }
} }
} }

View File

@ -30,6 +30,7 @@ class PreviewView: public ui::Window {
ui::Label * authorDateLabel; ui::Label * authorDateLabel;
ui::Textblock * saveDescriptionTextblock; ui::Textblock * saveDescriptionTextblock;
std::vector<ui::Component*> commentComponents; std::vector<ui::Component*> commentComponents;
std::vector<ui::Component*> commentTextComponents;
int votesUp; int votesUp;
int votesDown; int votesDown;
public: public:

View File

@ -28,7 +28,7 @@ SearchView::SearchView():
} }
}; };
searchField = new ui::Textbox(ui::Point(60, 10), ui::Point((XRES+BARSIZE)-226, 16), ""); searchField = new ui::Textbox(ui::Point(60, 10), ui::Point((XRES+BARSIZE)-226, 16), "");
searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; searchField->Appearance.VerticalAlign = ui::Appearance::AlignBottom; searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; searchField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
searchField->SetActionCallback(new SearchAction(this)); searchField->SetActionCallback(new SearchAction(this));
class SortAction : public ui::ButtonAction class SortAction : public ui::ButtonAction
@ -43,7 +43,7 @@ SearchView::SearchView():
}; };
sortButton = new ui::Button(ui::Point(XRES+BARSIZE-140, 10), ui::Point(60, 16), "Sort"); sortButton = new ui::Button(ui::Point(XRES+BARSIZE-140, 10), ui::Point(60, 16), "Sort");
sortButton->SetActionCallback(new SortAction(this)); sortButton->SetActionCallback(new SortAction(this));
sortButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; sortButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom; sortButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; sortButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(sortButton); AddComponent(sortButton);
class MyOwnAction : public ui::ButtonAction class MyOwnAction : public ui::ButtonAction
@ -61,7 +61,7 @@ SearchView::SearchView():
ownButton->SetActionCallback(new MyOwnAction(this)); ownButton->SetActionCallback(new MyOwnAction(this));
if(!Client::Ref().GetAuthUser().ID) if(!Client::Ref().GetAuthUser().ID)
ownButton->Enabled = false; ownButton->Enabled = false;
ownButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; ownButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom; ownButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; ownButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(ownButton); AddComponent(ownButton);
class FavAction : public ui::ButtonAction class FavAction : public ui::ButtonAction
@ -80,7 +80,7 @@ SearchView::SearchView():
favButton->SetActionCallback(new FavAction(this)); favButton->SetActionCallback(new FavAction(this));
if(!Client::Ref().GetAuthUser().ID) if(!Client::Ref().GetAuthUser().ID)
favButton->Enabled = false; favButton->Enabled = false;
favButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; favButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom; favButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(favButton); AddComponent(favButton);
class NextPageAction : public ui::ButtonAction class NextPageAction : public ui::ButtonAction
@ -94,7 +94,7 @@ SearchView::SearchView():
} }
}; };
nextButton->SetActionCallback(new NextPageAction(this)); nextButton->SetActionCallback(new NextPageAction(this));
nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight; nextButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom; nextButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight; nextButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
class PrevPageAction : public ui::ButtonAction class PrevPageAction : public ui::ButtonAction
{ {
SearchView * v; SearchView * v;
@ -106,7 +106,7 @@ SearchView::SearchView():
} }
}; };
previousButton->SetActionCallback(new PrevPageAction(this)); previousButton->SetActionCallback(new PrevPageAction(this));
previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; previousButton->Appearance.VerticalAlign = ui::Appearance::AlignBottom; previousButton->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; previousButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(nextButton); AddComponent(nextButton);
AddComponent(previousButton); AddComponent(previousButton);
AddComponent(searchField); AddComponent(searchField);
@ -116,7 +116,7 @@ SearchView::SearchView():
AddComponent(loadingSpinner); AddComponent(loadingSpinner);
ui::Label * searchPrompt = new ui::Label(ui::Point(10, 10), ui::Point(50, 16), "Search:"); ui::Label * searchPrompt = new ui::Label(ui::Point(10, 10), ui::Point(50, 16), "Search:");
searchPrompt->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; searchPrompt->Appearance.VerticalAlign = ui::Appearance::AlignBottom; searchPrompt->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; searchPrompt->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(searchPrompt); AddComponent(searchPrompt);
class RemoveSelectedAction : public ui::ButtonAction class RemoveSelectedAction : public ui::ButtonAction