mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Fix missing carret in card filter box
Add Ctrl+K as a shortcut for card/keyword filter
This commit is contained in:
@@ -11,6 +11,7 @@ Features:
|
||||
for example `type:Wizard` searches for cards with Wizard in the type.
|
||||
* Added "Select All" to menu (#19)
|
||||
* Added "Save as Directory" to menu
|
||||
* Added a keyboard shortcut for the search box (Ctrl+K)
|
||||
|
||||
Bug fixes:
|
||||
* card variable in console panel now refers to the selected card
|
||||
|
||||
+14
-10
@@ -1,7 +1,7 @@
|
||||
mse version: 2.0.2
|
||||
installer group: translations/English
|
||||
full name: English
|
||||
version: 2029-05-09
|
||||
version: 2020-05-15
|
||||
icon: usgb.png
|
||||
|
||||
############################################################## Menu items
|
||||
@@ -47,6 +47,7 @@ menu:
|
||||
cards: &Cards
|
||||
previous card: Select &Previous Card PgUp
|
||||
next card: Select &Next Card PgDn
|
||||
search cards: &Search Cards Ctrl+K
|
||||
add card: &Add Card Ctrl+Enter
|
||||
add cards: Add &Multiple Cards...
|
||||
remove card: &Delete Selected Card
|
||||
@@ -60,6 +61,7 @@ menu:
|
||||
keywords: &Keywords
|
||||
previous keyword: Select &Previous Keyword PgUp
|
||||
next keyword: Select &Next Keyword PgDn
|
||||
search keywords: &Search Keywords Ctrl+K
|
||||
add keyword: &Add Keyword Ctrl+Enter
|
||||
remove keyword: &Remove Select Keyword Del
|
||||
|
||||
@@ -81,13 +83,13 @@ menu:
|
||||
|
||||
window: &Window
|
||||
new window: &New Window
|
||||
cards tab: &Cards (Alt+1)
|
||||
set info tab: &Set Information (Alt+2)
|
||||
style tab: St&yle (Alt+3)
|
||||
keywords tab: &Keywords (Alt+4)
|
||||
stats tab: S&tatistics (Alt+5)
|
||||
random pack tab: &Random Packs (Alt+6)
|
||||
console tab: &Console (Alt+7)
|
||||
cards tab: &Cards Alt+1
|
||||
set info tab: &Set Information Alt+2
|
||||
style tab: St&yle Alt+3
|
||||
keywords tab: &Keywords Alt+4
|
||||
stats tab: S&tatistics Alt+5
|
||||
random pack tab: &Random Packs Alt+6
|
||||
console tab: &Console Alt+7
|
||||
|
||||
help: &Help
|
||||
index: &Index... F1
|
||||
@@ -161,6 +163,7 @@ help:
|
||||
#cards:
|
||||
previous card: Selects the previous card in the list
|
||||
next card: Selects the next card in the list
|
||||
search cards: Filter the card list using search terms
|
||||
add card: Add a new, blank, card to this set
|
||||
add cards: Add multiple cards to the set
|
||||
remove card: Delete the selected card from this set
|
||||
@@ -175,6 +178,7 @@ help:
|
||||
#keywords:
|
||||
previous keyword: Selects the previous keyword in the list
|
||||
next keyword: Selects the next keyword in the list
|
||||
search keywords: Filter the keyword list using search terms
|
||||
add keyword: Add a new keyword to this set
|
||||
remove keyword: Delete the selected keyword from this set
|
||||
|
||||
@@ -421,10 +425,10 @@ tooltip:
|
||||
label:
|
||||
# Cards tab
|
||||
card notes: Card notes:
|
||||
search cards: Search for cards...
|
||||
search cards: Search cards (Ctrl+K)
|
||||
|
||||
# Keywords tab
|
||||
search keywords: Search for keywords...
|
||||
search keywords: Search keywords (Ctrl+K)
|
||||
keyword: Keyword
|
||||
match: Matches
|
||||
mode: Mode
|
||||
|
||||
@@ -32,24 +32,14 @@ protected:
|
||||
|
||||
// ----------------------------------------------------------------------------- : FilterControl
|
||||
|
||||
/// Text control that forwards focus events to the parent
|
||||
class TextCtrlWithFocus : public wxTextCtrl {
|
||||
public:
|
||||
DECLARE_EVENT_TABLE();
|
||||
void forwardFocusEvent(wxFocusEvent&);
|
||||
void forwardKeyEvent(wxKeyEvent&);
|
||||
};
|
||||
|
||||
FilterCtrl::FilterCtrl(wxWindow* parent, int id, String const& placeholder)
|
||||
: wxControl(parent, id, wxDefaultPosition, wxSize(160,-1), wxSTATIC_BORDER)
|
||||
: wxTextCtrl(parent, id, _(""), wxDefaultPosition, wxSize(160, -1), wxBORDER_THEME)
|
||||
, changing(false)
|
||||
, placeholder(placeholder)
|
||||
{
|
||||
wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
SetBackgroundColour(bg);
|
||||
SetCursor(wxCURSOR_IBEAM);
|
||||
filter_ctrl = new TextCtrlWithFocus();
|
||||
filter_ctrl->Create(this, wxID_ANY, _(""), wxDefaultPosition, wxSize(130,-1), wxNO_BORDER);
|
||||
clear_button = new HoverButton(this, wxID_ANY, _("btn_clear_filter"), bg, false);
|
||||
clear_button->SetCursor(*wxSTANDARD_CURSOR);
|
||||
onSize();
|
||||
@@ -68,24 +58,31 @@ void FilterCtrl::setFilter(const String& new_value, bool event) {
|
||||
}
|
||||
}
|
||||
|
||||
void FilterCtrl::focusAndSelect() {
|
||||
SetFocus();
|
||||
if (!value.empty()) {
|
||||
SetSelection(-1,-1);
|
||||
}
|
||||
}
|
||||
|
||||
void FilterCtrl::update() {
|
||||
changing = true;
|
||||
if (!value.empty() || hasFocus()) {
|
||||
filter_ctrl->SetValue(value);
|
||||
SetValue(value);
|
||||
wxColour fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
filter_ctrl->SetDefaultStyle(wxTextAttr(fg));
|
||||
filter_ctrl->SetForegroundColour(fg);
|
||||
SetDefaultStyle(wxTextAttr(fg));
|
||||
SetForegroundColour(fg);
|
||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
filter_ctrl->SetFont(font);
|
||||
SetFont(font);
|
||||
} else {
|
||||
filter_ctrl->SetValue(placeholder);
|
||||
SetValue(placeholder);
|
||||
wxColour fg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
wxColour bg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
filter_ctrl->SetDefaultStyle(wxTextAttr(lerp(fg,bg,0.5)));
|
||||
filter_ctrl->SetForegroundColour(lerp(fg,bg,0.5));
|
||||
SetDefaultStyle(wxTextAttr(lerp(fg,bg,0.5)));
|
||||
SetForegroundColour(lerp(fg,bg,0.5));
|
||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
font.SetStyle(wxFONTSTYLE_ITALIC);
|
||||
filter_ctrl->SetFont(font);
|
||||
SetFont(font);
|
||||
}
|
||||
clear_button->Show(!value.empty());
|
||||
changing = false;
|
||||
@@ -93,7 +90,7 @@ void FilterCtrl::update() {
|
||||
|
||||
void FilterCtrl::onChangeEvent(wxCommandEvent&) {
|
||||
if (!changing) {
|
||||
setFilter(filter_ctrl->GetValue(),true);
|
||||
setFilter(GetValue(),true);
|
||||
}
|
||||
}
|
||||
void FilterCtrl::onChar(wxKeyEvent& ev) {
|
||||
@@ -114,24 +111,23 @@ void FilterCtrl::onSizeEvent(wxSizeEvent&) {
|
||||
}
|
||||
void FilterCtrl::onSize() {
|
||||
wxSize s = GetClientSize();
|
||||
wxSize fs = filter_ctrl->GetBestSize();
|
||||
wxSize cs = clear_button->GetBestSize();
|
||||
int margin = 2;
|
||||
filter_ctrl ->SetSize(margin, max(margin,(s.y-fs.y)/2), s.x - cs.x - 3*margin, fs.y);
|
||||
clear_button->SetSize(s.x - cs.x - margin, (s.y-cs.y)/2, cs.x, cs.y);
|
||||
}
|
||||
|
||||
void FilterCtrl::onSetFocus(wxFocusEvent&) {
|
||||
filter_ctrl->SetFocus();
|
||||
void FilterCtrl::onSetFocus(wxFocusEvent& ev) {
|
||||
update();
|
||||
ev.Skip();
|
||||
}
|
||||
void FilterCtrl::onKillFocus(wxFocusEvent&) {
|
||||
void FilterCtrl::onKillFocus(wxFocusEvent& ev) {
|
||||
update();
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
bool FilterCtrl::hasFocus() {
|
||||
wxWindow* focus = wxWindow::FindFocus();
|
||||
return focus == this || focus == filter_ctrl || focus == clear_button;
|
||||
return focus == this || focus == clear_button;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(FilterCtrl, wxControl)
|
||||
@@ -142,19 +138,3 @@ BEGIN_EVENT_TABLE(FilterCtrl, wxControl)
|
||||
EVT_KILL_FOCUS(FilterCtrl::onKillFocus)
|
||||
EVT_CHAR (FilterCtrl::onChar)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextCtrlWithFocus
|
||||
|
||||
void TextCtrlWithFocus::forwardFocusEvent(wxFocusEvent& ev) {
|
||||
GetParent()->HandleWindowEvent(ev);
|
||||
}
|
||||
void TextCtrlWithFocus::forwardKeyEvent(wxKeyEvent& ev) {
|
||||
GetParent()->HandleWindowEvent(ev);
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(TextCtrlWithFocus, wxTextCtrl)
|
||||
EVT_SET_FOCUS (TextCtrlWithFocus::forwardFocusEvent)
|
||||
EVT_KILL_FOCUS(TextCtrlWithFocus::forwardFocusEvent)
|
||||
EVT_CHAR (TextCtrlWithFocus::forwardKeyEvent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
@@ -12,12 +12,11 @@
|
||||
#include <data/filter.hpp>
|
||||
|
||||
class HoverButton;
|
||||
class TextCtrlWithFocus;
|
||||
|
||||
// ----------------------------------------------------------------------------- : FilterCtrl
|
||||
|
||||
/// A search/filter textbox
|
||||
class FilterCtrl : public wxControl {
|
||||
class FilterCtrl : public wxTextCtrl {
|
||||
public:
|
||||
FilterCtrl(wxWindow* parent, int id, String const& placeholder);
|
||||
|
||||
@@ -26,9 +25,10 @@ public:
|
||||
void clearFilter(bool send_event = false) { setFilter(String(),send_event); }
|
||||
bool hasFilter() const { return !value.empty(); }
|
||||
String const& getFilterString() const { return value; }
|
||||
void focusAndSelect();
|
||||
|
||||
template <typename T>
|
||||
intrusive_ptr<Filter<T> > getFilter() const {
|
||||
intrusive_ptr<Filter<T>> getFilter() const {
|
||||
if (hasFilter()) {
|
||||
return make_intrusive<QuickFilter<T>>(getFilterString());
|
||||
} else {
|
||||
@@ -41,7 +41,6 @@ private:
|
||||
bool changing;
|
||||
String value;
|
||||
String placeholder;
|
||||
TextCtrlWithFocus* filter_ctrl;
|
||||
HoverButton* clear_button;
|
||||
|
||||
void update();
|
||||
@@ -54,5 +53,6 @@ private:
|
||||
void onSize();
|
||||
void onSetFocus(wxFocusEvent&);
|
||||
void onKillFocus(wxFocusEvent&);
|
||||
void onPaint(wxPaintEvent&);
|
||||
};
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ CardsPanel::CardsPanel(Window* parent, int id)
|
||||
menuCard = new wxMenu();
|
||||
add_menu_item_tr(menuCard, ID_CARD_PREV, nullptr, "previous card");
|
||||
add_menu_item_tr(menuCard, ID_CARD_NEXT, nullptr, "next card");
|
||||
add_menu_item_tr(menuCard, ID_CARD_SEARCH, nullptr, "search cards");
|
||||
menuCard->AppendSeparator();
|
||||
add_menu_item_tr(menuCard, ID_CARD_ADD, "card_add", "add_card");
|
||||
insertManyCardsMenu = add_menu_item_tr(menuCard, ID_CARD_ADD_MULT, "card_add_multiple", "add cards");
|
||||
@@ -303,6 +304,9 @@ void CardsPanel::onCommand(int id) {
|
||||
// Note: Forwarded events may cause this to occur even at the bottom.
|
||||
if (card_list->canSelectNext()) card_list->selectNext();
|
||||
break;
|
||||
case ID_CARD_SEARCH:
|
||||
filter->focusAndSelect();
|
||||
break;
|
||||
case ID_CARD_ADD:
|
||||
set->actions.addAction(make_unique<AddCardAction>(*set));
|
||||
break;
|
||||
|
||||
@@ -104,6 +104,7 @@ void KeywordsPanel::initControls() {
|
||||
menuKeyword = new wxMenu();
|
||||
add_menu_item_tr(menuKeyword, ID_KEYWORD_PREV, nullptr, "previous_keyword");
|
||||
add_menu_item_tr(menuKeyword, ID_KEYWORD_NEXT, nullptr, "next_keyword");
|
||||
add_menu_item_tr(menuKeyword, ID_KEYWORD_SEARCH, nullptr, "search keywords");
|
||||
menuKeyword->AppendSeparator();
|
||||
add_menu_item_tr(menuKeyword, ID_KEYWORD_ADD, "keyword_add", "add_keyword");
|
||||
// NOTE: space after "Del" prevents wx from making del an accellerator
|
||||
@@ -174,6 +175,9 @@ void KeywordsPanel::onCommand(int id) {
|
||||
case ID_KEYWORD_NEXT:
|
||||
list->selectNext();
|
||||
break;
|
||||
case ID_KEYWORD_SEARCH:
|
||||
filter->focusAndSelect();
|
||||
break;
|
||||
case ID_KEYWORD_ADD:
|
||||
set->actions.addAction(make_unique<AddKeywordAction>(*set));
|
||||
break;
|
||||
|
||||
@@ -97,6 +97,7 @@ enum ChildMenuID {
|
||||
ID_CARD_REMOVE,
|
||||
ID_CARD_PREV,
|
||||
ID_CARD_NEXT,
|
||||
ID_CARD_SEARCH,
|
||||
ID_CARD_ROTATE,
|
||||
ID_CARD_ROTATE_0,
|
||||
ID_CARD_ROTATE_90,
|
||||
@@ -110,6 +111,7 @@ enum ChildMenuID {
|
||||
ID_KEYWORD_REMOVE,
|
||||
ID_KEYWORD_PREV,
|
||||
ID_KEYWORD_NEXT,
|
||||
ID_KEYWORD_SEARCH,
|
||||
|
||||
// Format menu
|
||||
ID_FORMAT_BOLD = 6201,
|
||||
|
||||
Reference in New Issue
Block a user