convenience features (#21)

This commit is contained in:
Sebastian Dine
2026-07-24 08:56:53 +02:00
committed by GitHub
parent ab0e3c5ae2
commit 7cf25d671f
22 changed files with 351 additions and 38 deletions
+15 -3
View File
@@ -134,6 +134,14 @@ void YuGiOhGameView::buildSingleCardsToolbar(wxWindow* parent, wxBoxSizer* pageS
if (filterInput_ == nullptr) return;
setFilter(filterInput_->GetValue().ToStdString(wxConvUTF8));
});
filterInput_->Bind(wxEVT_KEY_DOWN, [this](wxKeyEvent& ev) {
const int code = ev.GetKeyCode();
if (code == WXK_UP || code == WXK_DOWN) {
nudgeSelection(code == WXK_UP ? -1 : 1);
return;
}
ev.Skip();
});
}
void YuGiOhGameView::refreshToolbarIcons(const ThemePalette& palette) {
@@ -308,7 +316,7 @@ wxPanel* YuGiOhGameView::selectedPanel(wxWindow* parent) {
return selectedPanel_;
}
void YuGiOhGameView::refreshCollection() {
void YuGiOhGameView::refreshCollection(std::optional<std::uint32_t> selectId) {
if (contentPanel_ == nullptr && listPanel_ == nullptr) return;
auto loaded = collection_.list(Game::YuGiOh);
@@ -319,7 +327,7 @@ void YuGiOhGameView::refreshCollection() {
}
auto cards = std::move(loaded).value();
if (listPanel_ != nullptr) {
listPanel_->setCards(cards);
listPanel_->setCards(cards, selectId);
listPanel_->activateSelection();
if (selectedPanel_) selectedPanel_->setCard(listPanel_->selected());
}
@@ -391,7 +399,7 @@ void YuGiOhGameView::onAddCard(wxWindow* parentWindow) {
"Card added, but image rename to ID-prefixed format failed: " + normalized.error(),
"Warning", wxOK | wxICON_WARNING);
}
refreshCollection();
refreshCollection(added.value());
}
void YuGiOhGameView::onEditCard(wxWindow* parentWindow) {
@@ -505,6 +513,10 @@ void YuGiOhGameView::setFilter(std::string_view filter) {
if (listPanel_) listPanel_->setFilter(filter);
}
void YuGiOhGameView::nudgeSelection(int delta) {
if (listPanel_) listPanel_->nudgeSelection(delta);
}
void YuGiOhGameView::applyTheme(const ThemePalette& palette) {
if (contentPanel_) applyThemeToWindowTree(contentPanel_, palette, config_.current().theme);
if (listPanel_) listPanel_->applyTheme(palette);