diff --git a/CHANGES.md b/CHANGES.md index bdb620d1..c7b0fc20 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,9 @@ Magic Set Editor changelog, for the details see `git log` HEAD: new items added as changes are made ------------------------------------------------------------------------------ +Features: + * You can now check/uncheck all selected cards in the export window (#93) + Template features: * Localization of game/stylesheet/symbol_font names is now done in those templates, instead of via the program-wide locale file. (#100) diff --git a/src/gui/control/select_card_list.cpp b/src/gui/control/select_card_list.cpp index dce47dc3..85567967 100644 --- a/src/gui/control/select_card_list.cpp +++ b/src/gui/control/select_card_list.cpp @@ -74,6 +74,17 @@ void SelectCardList::toggle(const CardP& card) { } } +void SelectCardList::toggleSelected(bool select) { + for (long i = GetFirstSelected(); i != -1; i = GetNextSelected(i)) { + if (select) { + selected.insert(getCard(i)); + } else { + selected.erase(getCard(i)); + } + RefreshItem(i); + } +} + void SelectCardList::onKeyDown(wxKeyEvent& ev) { if (selected_item_pos == -1 || !selected_item) { // no selection @@ -82,18 +93,15 @@ void SelectCardList::onKeyDown(wxKeyEvent& ev) { } switch (ev.GetKeyCode()) { case WXK_SPACE: { - toggle(getCard()); - RefreshItem(selected_item_pos); + toggleSelected(!isSelected(getCard())); break; } case WXK_NUMPAD_ADD: case '+': { - selected.insert(getCard()); - RefreshItem(selected_item_pos); + toggleSelected(true); break; } case WXK_NUMPAD_SUBTRACT: case '-': { - selected.erase(getCard()); - RefreshItem(selected_item_pos); + toggleSelected(false); break; } default: @@ -106,8 +114,14 @@ void SelectCardList::onLeftDown(wxMouseEvent& ev) { long item = HitTest(wxPoint(ev.GetX(), ev.GetY()), flags); if (flags == wxLIST_HITTEST_ONITEMICON) { // only clicking the icon toggles - toggle(getCard(item)); - RefreshItem(item); + if (IsSelected(item)) { + // if multiple items are selected in the view (regardless of checkbox status), check/uncheck them all + toggleSelected(!isSelected(getCard(item))); + return; // don't change selection + } else { + toggle(getCard(item)); + RefreshItem(item); + } } ev.Skip(); } diff --git a/src/gui/control/select_card_list.hpp b/src/gui/control/select_card_list.hpp index 44544d48..a9245179 100644 --- a/src/gui/control/select_card_list.hpp +++ b/src/gui/control/select_card_list.hpp @@ -37,8 +37,9 @@ private: DECLARE_EVENT_TABLE(); std::set selected; ///< which cards are selected? - + void toggle(const CardP& card); + void toggleSelected(bool select); void onKeyDown(wxKeyEvent&); void onLeftDown(wxMouseEvent&);