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 ...@@ -98,6 +98,7 @@ void StatCategoryList::drawItem(DC& dc, int x, int y, size_t item, bool selected
StatsPanel::StatsPanel(Window* parent, int id) StatsPanel::StatsPanel(Window* parent, int id)
: SetWindowPanel(parent, id) : SetWindowPanel(parent, id)
, up_to_date(true), active(false)
{ {
// init controls // init controls
wxSplitterWindow* splitter; wxSplitterWindow* splitter;
...@@ -120,13 +121,25 @@ StatsPanel::StatsPanel(Window* parent, int id) ...@@ -120,13 +121,25 @@ StatsPanel::StatsPanel(Window* parent, int id)
void StatsPanel::onChangeSet() { void StatsPanel::onChangeSet() {
card_list->setSet(set); card_list->setSet(set);
categories->show(set->game); 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) { void StatsPanel::onCommand(int id) {
switch (id) { switch (id) {
case ID_FIELD_LIST: { case ID_FIELD_LIST: {
onCategorySelect(); onChange();
break; break;
} }
} }
...@@ -151,7 +164,16 @@ class StatsFilter : public CardListFilter { ...@@ -151,7 +164,16 @@ class StatsFilter : public CardListFilter {
Set& set; 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 // change graph data
if (categories->hasSelection()) { if (categories->hasSelection()) {
StatsCategory& cat = categories->getSelection(); StatsCategory& cat = categories->getSelection();
......
...@@ -26,6 +26,10 @@ class StatsPanel : public SetWindowPanel { ...@@ -26,6 +26,10 @@ class StatsPanel : public SetWindowPanel {
// --------------------------------------------------- : UI // --------------------------------------------------- : UI
virtual void onChangeSet(); 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); virtual void onCommand(int id);
// --------------------------------------------------- : Selection // --------------------------------------------------- : Selection
...@@ -40,8 +44,12 @@ class StatsPanel : public SetWindowPanel { ...@@ -40,8 +44,12 @@ class StatsPanel : public SetWindowPanel {
GraphControl* graph; GraphControl* graph;
FilteredCardList* card_list; 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 onGraphSelect(wxCommandEvent&);
void showCategory();
void filterCards(); void filterCards();
}; };
......
...@@ -192,7 +192,12 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) { ...@@ -192,7 +192,12 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
break; break;
case WXK_RETURN: case WXK_RETURN:
if (field().multi_line) { 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; break;
default: 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