Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI|Client: Added a filter widget for the game selection menu
- Loading branch information
Showing
5 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** @file gamefilterwidget.h | ||
* | ||
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_GAMEFILTERWIDGET_H | ||
#define DENG_CLIENT_GAMEFILTERWIDGET_H | ||
|
||
#include <de/GuiWidget> | ||
|
||
/** | ||
* Filtering and sorting parameters for a game selection widget. Allows picking the type | ||
* of games to show (singleplayer or multiplayer) and how the games are sorted. | ||
* | ||
* The widget defines its own height, but width must be set manually. | ||
*/ | ||
class GameFilterWidget : public de::GuiWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
enum SortOrder | ||
{ | ||
SortByTitle, | ||
SortByIdentityKey | ||
}; | ||
|
||
public: | ||
GameFilterWidget(de::String const &name = "gamefilter"); | ||
|
||
signals: | ||
void filterChanged(); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
#endif // DENG_CLIENT_GAMEFILTERWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** @file gamefilterwidget.cpp | ||
* | ||
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "ui/widgets/gamefilterwidget.h" | ||
|
||
#include <de/ButtonWidget> | ||
#include <de/ChoiceWidget> | ||
#include <de/SequentialLayout> | ||
#include <de/DialogContentStylist> | ||
|
||
using namespace de; | ||
|
||
DENG2_PIMPL(GameFilterWidget) | ||
{ | ||
ButtonWidget *sp; | ||
ButtonWidget *mp; | ||
ButtonWidget *all; | ||
LabelWidget *sortLabel; | ||
ChoiceWidget *sortBy; | ||
DialogContentStylist stylist; | ||
|
||
Instance(Public *i) : Base(i) | ||
{ | ||
stylist.setContainer(self); | ||
|
||
// Create widgets. | ||
self.add(sp = new ButtonWidget); | ||
self.add(mp = new ButtonWidget); | ||
self.add(all = new ButtonWidget); | ||
sortLabel = LabelWidget::newWithText(tr("Sort By:"), &self); | ||
self.add(sortBy = new ChoiceWidget); | ||
|
||
sp->setText(tr("Singleplayer")); | ||
mp->setText(tr("Multiplayer")); | ||
all->setText(tr("All")); | ||
sortLabel->setTextColor("inverted.text"); | ||
sortBy->items() | ||
<< new ChoiceItem(tr("Title"), SortByTitle) | ||
<< new ChoiceItem(tr("Identity key"), SortByIdentityKey); | ||
|
||
SequentialLayout layout(self.rule().right(), self.rule().top(), ui::Left); | ||
layout << *sortBy << *sortLabel; | ||
|
||
AutoRef<Rule> sum(sp->rule().width() + mp->rule().width() + all->rule().width()); | ||
SequentialLayout blay(self.rule().left() + self.rule().width() / 2 - sum / 2, | ||
self.rule().top(), ui::Right); | ||
blay << *sp << *mp << *all; | ||
} | ||
}; | ||
|
||
GameFilterWidget::GameFilterWidget(String const &name) | ||
: GuiWidget(name), d(new Instance(this)) | ||
{ | ||
rule().setInput(Rule::Height, d->sp->rule().height()); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters