Commit 4129a793 authored by twanvl's avatar twanvl

Stats panel stays up to date when cards change;

Shift+Enter inserts soft line break in text editor (TODO: cursor is moved incorrectly)
parent f0ed6fff
......@@ -98,6 +98,7 @@ void StatCategoryList::drawItem(DC& dc, int x, int y, size_t item, bool selected
StatsPanel::StatsPanel(Window* parent, int id)
: SetWindowPanel(parent, id)
, up_to_date(true), active(false)
{
// init controls
wxSplitterWindow* splitter;
......@@ -120,13 +121,25 @@ StatsPanel::StatsPanel(Window* parent, int id)
void StatsPanel::onChangeSet() {
card_list->setSet(set);
categories->show(set->game);
onCategorySelect();
onChange();
}
void StatsPanel::onAction(const Action&, bool undone) {
onChange();
}
void StatsPanel::initUI (wxToolBar*, wxMenuBar*) {
active = true;
if (!up_to_date) showCategory();
}
void StatsPanel::destroyUI(wxToolBar*, wxMenuBar*) {
active = false;
}
void StatsPanel::onCommand(int id) {
switch (id) {
case ID_FIELD_LIST: {
onCategorySelect();
onChange();
break;
}
}
......@@ -151,7 +164,16 @@ class StatsFilter : public CardListFilter {
Set& set;
};
void StatsPanel::onCategorySelect() {
void StatsPanel::onChange() {
if (active) {
showCategory();
} else {
up_to_date = false; // update later
}
}
void StatsPanel::showCategory() {
up_to_date = true;
// change graph data
if (categories->hasSelection()) {
StatsCategory& cat = categories->getSelection();
......
......@@ -26,6 +26,10 @@ class StatsPanel : public SetWindowPanel {
// --------------------------------------------------- : UI
virtual void onChangeSet();
virtual void onAction(const Action&, bool undone);
virtual void initUI (wxToolBar*, wxMenuBar*);
virtual void destroyUI(wxToolBar*, wxMenuBar*);
virtual void onCommand(int id);
// --------------------------------------------------- : Selection
......@@ -40,8 +44,12 @@ class StatsPanel : public SetWindowPanel {
GraphControl* graph;
FilteredCardList* card_list;
void onCategorySelect();
bool up_to_date; ///< Are the graph and card list up to date?
bool active; ///< Is this panel selected?
void onChange();
void onGraphSelect(wxCommandEvent&);
void showCategory();
void filterCards();
};
......
......@@ -192,7 +192,12 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
break;
case WXK_RETURN:
if (field().multi_line) {
replaceSelection(_("\n"), _("Enter"));
if (ev.ShiftDown()) {
// soft line break
replaceSelection(_("<soft-line>\n</soft-line>"), _("Soft line break"));
} else {
replaceSelection(_("\n"), _("Enter"));
}
}
break;
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment