summaryrefslogtreecommitdiff
path: root/src/search/SearchView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/search/SearchView.cpp')
-rw-r--r--src/search/SearchView.cpp171
1 files changed, 102 insertions, 69 deletions
diff --git a/src/search/SearchView.cpp b/src/search/SearchView.cpp
index 422a040..1211cfc 100644
--- a/src/search/SearchView.cpp
+++ b/src/search/SearchView.cpp
@@ -381,7 +381,7 @@ void SearchView::CheckAccess()
}
}
-void SearchView::NotifySaveListChanged(SearchModel * sender)
+void SearchView::NotifyTagListChanged(SearchModel * sender)
{
int i = 0;
int buttonWidth, buttonHeight, saveX = 0, saveY = 0, savesX = 5, savesY = 4, buttonPadding = 1;
@@ -390,9 +390,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
int tagWidth, tagHeight, tagX = 0, tagY = 0, tagsX = 6, tagsY = 4, tagPadding = 1;
int tagAreaWidth, tagAreaHeight, tagXOffset, tagYOffset;
- vector<SaveInfo*> saves = sender->GetSaveList();
vector<pair<string, int> > tags = sender->GetTagList();
- //string messageOfTheDay = sender->GetMessageOfTheDay();
RemoveComponent(motdLabel);
motdLabel->SetParentWindow(NULL);
@@ -400,19 +398,113 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
RemoveComponent(tagsLabel);
tagsLabel->SetParentWindow(NULL);
+ for(i = 0; i < tagButtons.size(); i++)
+ {
+ RemoveComponent(tagButtons[i]);
+ delete tagButtons[i];
+ }
+ tagButtons.clear();
+
+ buttonYOffset = 28;
+ buttonXOffset = buttonPadding;
+ buttonAreaWidth = Size.X;
+ buttonAreaHeight = Size.Y - buttonYOffset - 18;
+
+ if(sender->GetShowTags())
+ {
+ buttonYOffset += (buttonAreaHeight/savesY) - buttonPadding*2;
+ buttonAreaHeight = Size.Y - buttonYOffset - 18;
+ savesY--;
+
+ tagXOffset = tagPadding;
+ tagYOffset = 60;
+ tagAreaWidth = Size.X;
+ tagAreaHeight = ((buttonAreaHeight/savesY) - buttonPadding*2)-(tagYOffset-28)-5;
+ tagWidth = (tagAreaWidth/tagsX) - tagPadding*2;
+ tagHeight = (tagAreaHeight/tagsY) - tagPadding*2;
+
+ AddComponent(tagsLabel);
+ tagsLabel->Position.Y = tagYOffset-16;
+
+ AddComponent(motdLabel);
+ motdLabel->Position.Y = tagYOffset-28;
+ }
+
+ class TagAction: public ui::ButtonAction
+ {
+ SearchView * v;
+ std::string tag;
+ public:
+ TagAction(SearchView * v, std::string tag) : v(v), tag(tag) {}
+ virtual void ActionCallback(ui::Button * sender)
+ {
+ v->Search(tag);
+ }
+ };
+ if(sender->GetShowTags())
+ {
+ for(i = 0; i < tags.size(); i++)
+ {
+ int maxTagVotes = tags[0].second;
+
+ pair<string, int> tag = tags[i];
+
+ if(tagX == tagsX)
+ {
+ if(tagY == tagsY-1)
+ break;
+ tagX = 0;
+ tagY++;
+ }
+
+ int tagAlpha = 192;
+ if (maxTagVotes)
+ tagAlpha = 127+(128*tag.second)/maxTagVotes;
+
+ ui::Button * tagButton;
+ tagButton = new ui::Button(
+ ui::Point(
+ tagXOffset + tagPadding + tagX*(tagWidth+tagPadding*2),
+ tagYOffset + tagPadding + tagY*(tagHeight+tagPadding*2)
+ ),
+ ui::Point(tagWidth, tagHeight),
+ tag.first
+ );
+ tagButton->SetActionCallback(new TagAction(this, tag.first));
+ tagButton->Appearance.BorderInactive = ui::Colour(0, 0, 0);
+ tagButton->Appearance.BorderHover = ui::Colour(0, 0, 0);
+ tagButton->Appearance.BorderActive = ui::Colour(0, 0, 0);
+ tagButton->Appearance.BackgroundHover = ui::Colour(0, 0, 0);
+
+ tagButton->Appearance.TextInactive = ui::Colour(tagAlpha, tagAlpha, tagAlpha);
+ tagButton->Appearance.TextHover = ui::Colour((tagAlpha*5)/6, (tagAlpha*5)/6, tagAlpha);
+ AddComponent(tagButton);
+ tagButtons.push_back(tagButton);
+ tagX++;
+
+ }
+ }
+}
+
+void SearchView::NotifySaveListChanged(SearchModel * sender)
+{
+ int i = 0;
+ int buttonWidth, buttonHeight, saveX = 0, saveY = 0, savesX = 5, savesY = 4, buttonPadding = 1;
+ int buttonAreaWidth, buttonAreaHeight, buttonXOffset, buttonYOffset;
+
+ int tagWidth, tagHeight, tagX = 0, tagY = 0, tagsX = 6, tagsY = 4, tagPadding = 1;
+ int tagAreaWidth, tagAreaHeight, tagXOffset, tagYOffset;
+
+ vector<SaveInfo*> saves = sender->GetSaveList();
+ //string messageOfTheDay = sender->GetMessageOfTheDay();
+
Client::Ref().ClearThumbnailRequests();
for(i = 0; i < saveButtons.size(); i++)
{
RemoveComponent(saveButtons[i]);
delete saveButtons[i];
}
- for(i = 0; i < tagButtons.size(); i++)
- {
- RemoveComponent(tagButtons[i]);
- delete tagButtons[i];
- }
saveButtons.clear();
- tagButtons.clear();
if(!sender->GetSavesLoaded())
{
nextButton->Enabled = false;
@@ -461,7 +553,7 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
buttonAreaWidth = Size.X;
buttonAreaHeight = Size.Y - buttonYOffset - 18;
- if(tags.size())
+ if(sender->GetShowTags())
{
buttonYOffset += (buttonAreaHeight/savesY) - buttonPadding*2;
buttonAreaHeight = Size.Y - buttonYOffset - 18;
@@ -473,12 +565,6 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
tagAreaHeight = ((buttonAreaHeight/savesY) - buttonPadding*2)-(tagYOffset-28)-5;
tagWidth = (tagAreaWidth/tagsX) - tagPadding*2;
tagHeight = (tagAreaHeight/tagsY) - tagPadding*2;
-
- AddComponent(tagsLabel);
- tagsLabel->Position.Y = tagYOffset-16;
-
- AddComponent(motdLabel);
- motdLabel->Position.Y = tagYOffset-28;
}
buttonWidth = (buttonAreaWidth/savesX) - buttonPadding*2;
@@ -504,59 +590,6 @@ void SearchView::NotifySaveListChanged(SearchModel * sender)
v->Search("user:"+sender->GetSave()->GetUserName());
}
};
-
- class TagAction: public ui::ButtonAction
- {
- SearchView * v;
- std::string tag;
- public:
- TagAction(SearchView * v, std::string tag) : v(v), tag(tag) {}
- virtual void ActionCallback(ui::Button * sender)
- {
- v->Search(tag);
- }
- };
-
- for(i = 0; i < tags.size(); i++)
- {
- int maxTagVotes = tags[0].second;
-
- pair<string, int> tag = tags[i];
-
- if(tagX == tagsX)
- {
- if(tagY == tagsY-1)
- break;
- tagX = 0;
- tagY++;
- }
-
- int tagAlpha = 192;
- if (maxTagVotes)
- tagAlpha = 127+(128*tag.second)/maxTagVotes;
-
- ui::Button * tagButton;
- tagButton = new ui::Button(
- ui::Point(
- tagXOffset + tagPadding + tagX*(tagWidth+tagPadding*2),
- tagYOffset + tagPadding + tagY*(tagHeight+tagPadding*2)
- ),
- ui::Point(tagWidth, tagHeight),
- tag.first
- );
- tagButton->SetActionCallback(new TagAction(this, tag.first));
- tagButton->Appearance.BorderInactive = ui::Colour(0, 0, 0);
- tagButton->Appearance.BorderHover = ui::Colour(0, 0, 0);
- tagButton->Appearance.BorderActive = ui::Colour(0, 0, 0);
- tagButton->Appearance.BackgroundHover = ui::Colour(0, 0, 0);
-
- tagButton->Appearance.TextInactive = ui::Colour(tagAlpha, tagAlpha, tagAlpha);
- tagButton->Appearance.TextHover = ui::Colour((tagAlpha*5)/6, (tagAlpha*5)/6, tagAlpha);
- AddComponent(tagButton);
- tagButtons.push_back(tagButton);
- tagX++;
-
- }
for(i = 0; i < saves.size(); i++)
{
if(saveX == savesX)