From 5a619e4ee7cf3e10b837b2ecc162ac44d394e084 Mon Sep 17 00:00:00 2001 From: twanvl Date: Thu, 5 Jul 2007 17:33:53 +0000 Subject: [PATCH] Card preview on style panel is refreshed when styling changes git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@492 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gui/control/card_viewer.cpp | 4 ++++ src/gui/control/card_viewer.hpp | 2 ++ src/gui/set/style_panel.cpp | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/gui/control/card_viewer.cpp b/src/gui/control/card_viewer.cpp index 35741324..7f2e7278 100644 --- a/src/gui/control/card_viewer.cpp +++ b/src/gui/control/card_viewer.cpp @@ -38,6 +38,10 @@ void CardViewer::redraw(const ValueViewer& v) { } void CardViewer::onChange() { + redraw(); +} + +void CardViewer::redraw() { if (drawing) return; up_to_date = false; Refresh(false); diff --git a/src/gui/control/card_viewer.hpp b/src/gui/control/card_viewer.hpp index b5e74b84..7e1f1df4 100644 --- a/src/gui/control/card_viewer.hpp +++ b/src/gui/control/card_viewer.hpp @@ -30,6 +30,8 @@ class CardViewer : public wxControl, public DataViewer { /** May NOT be called while in onPaint/draw */ shared_ptr overdrawDC(); + /// Invalidate and redraw the entire viewer + void redraw(); /// Invalidate and redraw (the area of) a single value viewer virtual void redraw(const ValueViewer&); diff --git a/src/gui/set/style_panel.cpp b/src/gui/set/style_panel.cpp index b53082b3..05646ddc 100644 --- a/src/gui/set/style_panel.cpp +++ b/src/gui/set/style_panel.cpp @@ -16,6 +16,9 @@ #include #include #include +#include + +DECLARE_TYPEOF_COLLECTION(FieldP); // ----------------------------------------------------------------------------- : StylePanel @@ -68,6 +71,17 @@ void StylePanel::onAction(const Action& action, bool undone) { editor->showCard(card); } } + TYPE_CASE(action, ValueAction) { + // is it a styling action? + const StyleSheet& s = set->stylesheetFor(card); + FOR_EACH_CONST(f, s.styling_fields) { + if (action.valueP->fieldP == f) { + // refresh the viewer + preview->redraw(); + return; + } + } + } use_for_all->Enable(card && card->stylesheet); use_custom_options->Enable(card); use_custom_options->SetValue(card->has_styling);