Clear search button

This commit is contained in:
Simon Robertshaw 2012-08-05 21:07:22 +01:00
parent 8cadc10f8b
commit 0f4bde9394
3 changed files with 39 additions and 2 deletions

View File

@ -1303,6 +1303,8 @@ void GameView::NotifyNotificationsChanged(GameModel * sender)
tempButton = new ui::Button(ui::Point(XRES-20, currentY), ui::Point(15, 15));
tempButton->SetIcon(IconClose);
tempButton->SetActionCallback(new CloseNotificationButtonAction(this, *iter));
tempButton->Appearance.Margin.Left+=2;
tempButton->Appearance.Margin.Top+=2;
tempButton->Appearance.BorderInactive = style::Colour::WarningTitle;
tempButton->Appearance.TextInactive = style::Colour::WarningTitle;
AddComponent(tempButton);

View File

@ -31,12 +31,13 @@ SearchView::SearchView():
v->doSearch();
}
};
searchField = new ui::Textbox(ui::Point(60, 10), ui::Point((XRES+BARSIZE)-226, 16), "", "[search]");
searchField = new ui::Textbox(ui::Point(60, 10), ui::Point((XRES+BARSIZE)-239, 16), "", "[search]");
searchField->Appearance.icon = IconSearch;
searchField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft;
searchField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
searchField->SetActionCallback(new SearchAction(this));
class SortAction : public ui::ButtonAction
{
SearchView * v;
@ -80,13 +81,33 @@ SearchView::SearchView():
v->c->ShowFavourite(sender->GetToggleState());
}
};
favButton = new ui::Button(searchField->Position+ui::Point(searchField->Size.X, 0), ui::Point(16, 16), "");
favButton = new ui::Button(searchField->Position+ui::Point(searchField->Size.X+14, 0), ui::Point(16, 16), "");
favButton->SetIcon(IconFavourite);
favButton->SetTogglable(true);
favButton->Appearance.Margin.Left+=2;
favButton->SetActionCallback(new FavAction(this));
favButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
favButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(favButton);
class ClearSearchAction : public ui::ButtonAction
{
SearchView * v;
public:
ClearSearchAction(SearchView * _v) { v = _v; }
void ActionCallback(ui::Button * sender)
{
v->clearSearch();
}
};
ui::Button * clearSearchButton = new ui::Button(searchField->Position+ui::Point(searchField->Size.X-1, 0), ui::Point(16, 16), "");
clearSearchButton->SetIcon(IconClose);
clearSearchButton->SetActionCallback(new ClearSearchAction(this));
clearSearchButton->Appearance.Margin.Left+=2;
clearSearchButton->Appearance.Margin.Top+=2;
clearSearchButton->Appearance.HorizontalAlign = ui::Appearance::AlignCentre;
clearSearchButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
AddComponent(clearSearchButton);
class NextPageAction : public ui::ButtonAction
{
@ -199,6 +220,18 @@ void SearchView::doSearch()
c->DoSearch(searchField->GetText());
}
void SearchView::clearSearch()
{
searchField->SetText("");
c->DoSearch(searchField->GetText(), true);
}
void SearchView::OnTryOkay(OkayMethod method)
{
c->DoSearch(searchField->GetText(), true);
}
SearchView::~SearchView()
{
Client::Ref().RemoveListener(this);

View File

@ -36,6 +36,7 @@ private:
ui::Button * unpublishSelected;
ui::Button * favouriteSelected;
ui::Button * clearSelection;
void clearSearch();
void doSearch();
public:
void NotifySaveListChanged(SearchModel * sender);
@ -46,6 +47,7 @@ public:
void NotifyShowFavouriteChanged(SearchModel * sender);
void NotifyAuthUserChanged(Client * sender);
void CheckAccess();
virtual void OnTryOkay(OkayMethod method);
SearchView();
virtual ~SearchView();
void AttachController(SearchController * _c) { c = _c; }