mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Add help text to the card/keyword filter boxes
This commit is contained in:
@@ -215,6 +215,9 @@ help:
|
||||
# Cards panel
|
||||
collapse notes: Hide 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 seed: Different packs will be generated each time.
|
||||
fixed seed: Using the same seed number gives the same 'random' packs.
|
||||
|
||||
@@ -32,14 +32,13 @@ protected:
|
||||
|
||||
// ----------------------------------------------------------------------------- : 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)
|
||||
, changing(false)
|
||||
, placeholder(placeholder)
|
||||
, help_text(help_text)
|
||||
{
|
||||
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->SetCursor(*wxSTANDARD_CURSOR);
|
||||
onSize();
|
||||
@@ -63,6 +62,7 @@ void FilterCtrl::focusAndSelect() {
|
||||
if (!value.empty()) {
|
||||
SetSelection(-1,-1);
|
||||
}
|
||||
showHelp();
|
||||
}
|
||||
|
||||
void FilterCtrl::update() {
|
||||
@@ -125,16 +125,32 @@ void FilterCtrl::onKillFocus(wxFocusEvent& ev) {
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void FilterCtrl::onMouseEnter(wxMouseEvent& ev) {
|
||||
showHelp();
|
||||
}
|
||||
void FilterCtrl::onMouseLeave(wxMouseEvent& ev) {
|
||||
showHelp(false);
|
||||
}
|
||||
|
||||
bool FilterCtrl::hasFocus() {
|
||||
wxWindow* focus = wxWindow::FindFocus();
|
||||
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)
|
||||
EVT_BUTTON (wxID_ANY, FilterCtrl::onClear)
|
||||
EVT_TEXT (wxID_ANY, FilterCtrl::onChangeEvent)
|
||||
EVT_SIZE (FilterCtrl::onSizeEvent)
|
||||
EVT_SET_FOCUS (FilterCtrl::onSetFocus)
|
||||
EVT_KILL_FOCUS(FilterCtrl::onKillFocus)
|
||||
EVT_ENTER_WINDOW(FilterCtrl::onMouseEnter)
|
||||
EVT_LEAVE_WINDOW(FilterCtrl::onMouseLeave)
|
||||
EVT_CHAR (FilterCtrl::onChar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@@ -18,7 +18,7 @@ class HoverButton;
|
||||
/// A search/filter textbox
|
||||
class FilterCtrl : public wxTextCtrl {
|
||||
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
|
||||
void setFilter(const String& filter, bool send_event = false);
|
||||
@@ -41,10 +41,12 @@ private:
|
||||
bool changing;
|
||||
String value;
|
||||
String placeholder;
|
||||
String help_text;
|
||||
HoverButton* clear_button;
|
||||
|
||||
void update();
|
||||
bool hasFocus();
|
||||
void showHelp(bool show = true);
|
||||
// wxWidgets appears to have developed an overload allergy
|
||||
void onChangeEvent(wxCommandEvent&);
|
||||
void onClear(wxCommandEvent&);
|
||||
@@ -53,6 +55,7 @@ private:
|
||||
void onSize();
|
||||
void onSetFocus(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
|
||||
tb->AddSeparator();
|
||||
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);
|
||||
tb->AddControl(filter);
|
||||
tb->Realize();
|
||||
|
||||
@@ -132,7 +132,7 @@ void KeywordsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
// Filter/search textbox
|
||||
tb->AddSeparator();
|
||||
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);
|
||||
tb->AddControl(filter);
|
||||
tb->Realize();
|
||||
|
||||
Reference in New Issue
Block a user