feat: apply filtering to style list on "style not found" window

This commit is contained in:
Brendan Hagan
2022-06-20 20:06:28 -04:00
parent 9535117050
commit 6893ec3503
2 changed files with 33 additions and 9 deletions
+27 -7
View File
@@ -26,7 +26,7 @@ SetP new_set_window(Window* parent) {
}
NewSetWindow::NewSetWindow(Window* parent)
: wxDialog(parent, wxID_ANY, _TITLE_("new set"), wxDefaultPosition, wxSize(840,360), wxDEFAULT_DIALOG_STYLE)
: wxDialog(parent, wxID_ANY, _TITLE_("new set"), wxDefaultPosition, wxSize(830,360), wxDEFAULT_DIALOG_STYLE)
{
wxBusyCursor wait;
// init controls
@@ -175,18 +175,26 @@ StyleSheetP select_stylesheet(const Game& game, const String& failed_name) {
}
SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game, const String& failed_name)
: wxDialog(parent, wxID_ANY, _TITLE_("select stylesheet"), wxDefaultPosition, wxSize(530,320), wxDEFAULT_DIALOG_STYLE)
: wxDialog(parent, wxID_ANY, _TITLE_("select stylesheet"), wxDefaultPosition, wxSize(830,320), wxDEFAULT_DIALOG_STYLE)
, game(game)
{
wxBusyCursor wait;
// init controls
stylesheet_list = new PackageList (this, ID_STYLESHEET_LIST);
wxStaticText* description = new wxStaticText(this, ID_GAME_LIST, _LABEL_1_("stylesheet not found", failed_name));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
wxStaticText* stylesheet_text = new wxStaticText(this, ID_STYLESHEET_LIST, _LABEL_("style type"));
stylesheet_filter = new FilterCtrl(this, ID_STYLESHEET_FILTER, _LABEL_("search stylesheet list"), _HELP_("search stylesheet list control"));
stylesheet_filter->setFilter(stylesheet_filter_value);
// init sizer
wxSizer* s = new wxBoxSizer(wxVERTICAL);
s->Add(description, 0, wxALL, 4);
s->Add(stylesheet_text, 0, wxALL, 4);
s->Add(description, 0, wxALL, 4);
wxSizer* s2 = new wxBoxSizer(wxHORIZONTAL);
s2->Add(stylesheet_text, 0, wxALL & ~wxLEFT, 4);
s2->AddStretchSpacer();
s2->Add(stylesheet_filter, 1, wxALIGN_RIGHT, 4);
s->Add(s2, wxSizerFlags().Expand().Border(wxALL, 6));
s->Add(stylesheet_list, 0, wxEXPAND | (wxALL & ~wxTOP), 4);
s->Add(CreateButtonSizer(wxOK | wxCANCEL) , 0, wxEXPAND | wxALL, 8);
s->SetSizeHints(this);
@@ -197,7 +205,7 @@ SelectStyleSheetWindow::SelectStyleSheetWindow(Window* parent, const Game& game,
// Resize
Layout();
wxSize min_size = GetSizer()->GetMinSize() + GetSize() - GetClientSize();
SetSize(630,min_size.y);
SetSize(830,min_size.y);
UpdateWindowUI(wxUPDATE_UI_RECURSE);
}
@@ -207,6 +215,17 @@ void SelectStyleSheetWindow::onStyleSheetSelect(wxCommandEvent&) {
}
void SelectStyleSheetWindow::onStyleSheetActivate(wxCommandEvent&) {
done();
}
void SelectStyleSheetWindow::onStylesheetFilterUpdate(wxCommandEvent&) {
if (stylesheet_list->hasSelection()) {
StyleSheetP existingStylesheetSelection = stylesheet_list->getSelection<StyleSheet>(false);
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
stylesheet_list->select(existingStylesheetSelection->name());
}
else {
stylesheet_list->setFilter(stylesheet_filter->getFilter<PackageData>());
}
}
void SelectStyleSheetWindow::OnOK(wxCommandEvent&) {
@@ -238,7 +257,8 @@ void SelectStyleSheetWindow::onIdle(wxIdleEvent& ev) {
BEGIN_EVENT_TABLE(SelectStyleSheetWindow, wxDialog)
EVT_GALLERY_SELECT (ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetSelect)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetActivate)
EVT_GALLERY_ACTIVATE(ID_STYLESHEET_LIST, SelectStyleSheetWindow::onStyleSheetActivate)
EVT_COMMAND_RANGE(ID_STYLESHEET_FILTER, ID_STYLESHEET_FILTER, wxEVT_COMMAND_TEXT_UPDATED, SelectStyleSheetWindow::onStylesheetFilterUpdate)
EVT_BUTTON (wxID_OK, SelectStyleSheetWindow::OnOK)
EVT_UPDATE_UI (wxID_ANY, SelectStyleSheetWindow::onUpdateUI)
EVT_IDLE ( SelectStyleSheetWindow::onIdle)
+6 -2
View File
@@ -81,12 +81,16 @@ private:
const Game& game;
// gui items
PackageList* stylesheet_list;
PackageList* stylesheet_list;
FilterCtrl* stylesheet_filter;
String stylesheet_filter_value;
// --------------------------------------------------- : events
void onStyleSheetSelect (wxCommandEvent&);
void onStyleSheetActivate(wxCommandEvent&);
void onStyleSheetActivate(wxCommandEvent&);
void onStylesheetFilterUpdate(wxCommandEvent&);
virtual void OnOK(wxCommandEvent&);