mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
Add help text to the card/keyword filter boxes
This commit is contained in:
@@ -215,6 +215,9 @@ help:
|
|||||||
# Cards panel
|
# Cards panel
|
||||||
collapse notes: Hide the card notes box
|
collapse notes: Hide the card notes box
|
||||||
expand notes: Show the card notes box
|
expand notes: Show the card notes box
|
||||||
|
search cards control: Filter the card list. Use - to exclude cards. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
|
||||||
|
# Keywords panel
|
||||||
|
search keywords control: Filter the keyword list. Use - to exclude keywords. Use field: to search in a specific field. Use quotes for literal search. Separate multiple queries with a space.
|
||||||
# Random pack panel
|
# Random pack panel
|
||||||
random seed: Different packs will be generated each time.
|
random seed: Different packs will be generated each time.
|
||||||
fixed seed: Using the same seed number gives the same 'random' packs.
|
fixed seed: Using the same seed number gives the same 'random' packs.
|
||||||
|
|||||||
@@ -32,14 +32,13 @@ protected:
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : FilterControl
|
// ----------------------------------------------------------------------------- : FilterControl
|
||||||
|
|
||||||
FilterCtrl::FilterCtrl(wxWindow* parent, int id, String const& placeholder)
|
FilterCtrl::FilterCtrl(wxWindow* parent, int id, String const& placeholder, String const& help_text)
|
||||||
: wxTextCtrl(parent, id, _(""), wxDefaultPosition, wxSize(160, -1), wxBORDER_THEME)
|
: wxTextCtrl(parent, id, _(""), wxDefaultPosition, wxSize(160, -1), wxBORDER_THEME)
|
||||||
, changing(false)
|
, changing(false)
|
||||||
, placeholder(placeholder)
|
, placeholder(placeholder)
|
||||||
|
, help_text(help_text)
|
||||||
{
|
{
|
||||||
wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||||
SetBackgroundColour(bg);
|
|
||||||
SetCursor(wxCURSOR_IBEAM);
|
|
||||||
clear_button = new HoverButton(this, wxID_ANY, _("btn_clear_filter"), bg, false);
|
clear_button = new HoverButton(this, wxID_ANY, _("btn_clear_filter"), bg, false);
|
||||||
clear_button->SetCursor(*wxSTANDARD_CURSOR);
|
clear_button->SetCursor(*wxSTANDARD_CURSOR);
|
||||||
onSize();
|
onSize();
|
||||||
@@ -63,6 +62,7 @@ void FilterCtrl::focusAndSelect() {
|
|||||||
if (!value.empty()) {
|
if (!value.empty()) {
|
||||||
SetSelection(-1,-1);
|
SetSelection(-1,-1);
|
||||||
}
|
}
|
||||||
|
showHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterCtrl::update() {
|
void FilterCtrl::update() {
|
||||||
@@ -125,16 +125,32 @@ void FilterCtrl::onKillFocus(wxFocusEvent& ev) {
|
|||||||
ev.Skip();
|
ev.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FilterCtrl::onMouseEnter(wxMouseEvent& ev) {
|
||||||
|
showHelp();
|
||||||
|
}
|
||||||
|
void FilterCtrl::onMouseLeave(wxMouseEvent& ev) {
|
||||||
|
showHelp(false);
|
||||||
|
}
|
||||||
|
|
||||||
bool FilterCtrl::hasFocus() {
|
bool FilterCtrl::hasFocus() {
|
||||||
wxWindow* focus = wxWindow::FindFocus();
|
wxWindow* focus = wxWindow::FindFocus();
|
||||||
return focus == this || focus == clear_button;
|
return focus == this || focus == clear_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FilterCtrl::showHelp(bool show) {
|
||||||
|
wxFrame* frame = dynamic_cast<wxFrame*>(wxGetTopLevelParent(this));
|
||||||
|
if (frame) {
|
||||||
|
frame->DoGiveHelp(help_text, show);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(FilterCtrl, wxControl)
|
BEGIN_EVENT_TABLE(FilterCtrl, wxControl)
|
||||||
EVT_BUTTON (wxID_ANY, FilterCtrl::onClear)
|
EVT_BUTTON (wxID_ANY, FilterCtrl::onClear)
|
||||||
EVT_TEXT (wxID_ANY, FilterCtrl::onChangeEvent)
|
EVT_TEXT (wxID_ANY, FilterCtrl::onChangeEvent)
|
||||||
EVT_SIZE (FilterCtrl::onSizeEvent)
|
EVT_SIZE (FilterCtrl::onSizeEvent)
|
||||||
EVT_SET_FOCUS (FilterCtrl::onSetFocus)
|
EVT_SET_FOCUS (FilterCtrl::onSetFocus)
|
||||||
EVT_KILL_FOCUS(FilterCtrl::onKillFocus)
|
EVT_KILL_FOCUS(FilterCtrl::onKillFocus)
|
||||||
|
EVT_ENTER_WINDOW(FilterCtrl::onMouseEnter)
|
||||||
|
EVT_LEAVE_WINDOW(FilterCtrl::onMouseLeave)
|
||||||
EVT_CHAR (FilterCtrl::onChar)
|
EVT_CHAR (FilterCtrl::onChar)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class HoverButton;
|
|||||||
/// A search/filter textbox
|
/// A search/filter textbox
|
||||||
class FilterCtrl : public wxTextCtrl {
|
class FilterCtrl : public wxTextCtrl {
|
||||||
public:
|
public:
|
||||||
FilterCtrl(wxWindow* parent, int id, String const& placeholder);
|
FilterCtrl(wxWindow* parent, int id, String const& placeholder, String const& help_text);
|
||||||
|
|
||||||
/// Set the filter text
|
/// Set the filter text
|
||||||
void setFilter(const String& filter, bool send_event = false);
|
void setFilter(const String& filter, bool send_event = false);
|
||||||
@@ -41,10 +41,12 @@ private:
|
|||||||
bool changing;
|
bool changing;
|
||||||
String value;
|
String value;
|
||||||
String placeholder;
|
String placeholder;
|
||||||
|
String help_text;
|
||||||
HoverButton* clear_button;
|
HoverButton* clear_button;
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
bool hasFocus();
|
bool hasFocus();
|
||||||
|
void showHelp(bool show = true);
|
||||||
// wxWidgets appears to have developed an overload allergy
|
// wxWidgets appears to have developed an overload allergy
|
||||||
void onChangeEvent(wxCommandEvent&);
|
void onChangeEvent(wxCommandEvent&);
|
||||||
void onClear(wxCommandEvent&);
|
void onClear(wxCommandEvent&);
|
||||||
@@ -53,6 +55,7 @@ private:
|
|||||||
void onSize();
|
void onSize();
|
||||||
void onSetFocus(wxFocusEvent&);
|
void onSetFocus(wxFocusEvent&);
|
||||||
void onKillFocus(wxFocusEvent&);
|
void onKillFocus(wxFocusEvent&);
|
||||||
void onPaint(wxPaintEvent&);
|
void onMouseEnter(wxMouseEvent&);
|
||||||
|
void onMouseLeave(wxMouseEvent&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
|||||||
// Filter/search textbox
|
// Filter/search textbox
|
||||||
tb->AddSeparator();
|
tb->AddSeparator();
|
||||||
assert(!filter);
|
assert(!filter);
|
||||||
filter = new FilterCtrl(tb, ID_CARD_FILTER, _LABEL_("search cards"));
|
filter = new FilterCtrl(tb, ID_CARD_FILTER, _LABEL_("search cards"), _HELP_("search_cards_control"));
|
||||||
filter->setFilter(filter_value);
|
filter->setFilter(filter_value);
|
||||||
tb->AddControl(filter);
|
tb->AddControl(filter);
|
||||||
tb->Realize();
|
tb->Realize();
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ void KeywordsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
|||||||
// Filter/search textbox
|
// Filter/search textbox
|
||||||
tb->AddSeparator();
|
tb->AddSeparator();
|
||||||
assert(!filter);
|
assert(!filter);
|
||||||
filter = new FilterCtrl(tb, ID_KEYWORD_FILTER, _LABEL_("search keywords"));
|
filter = new FilterCtrl(tb, ID_KEYWORD_FILTER, _LABEL_("search keywords"), _HELP_("search_keywords_control"));
|
||||||
filter->setFilter(filter_value);
|
filter->setFilter(filter_value);
|
||||||
tb->AddControl(filter);
|
tb->AddControl(filter);
|
||||||
tb->Realize();
|
tb->Realize();
|
||||||
|
|||||||
Reference in New Issue
Block a user