Commit ca8e4031 authored by twanvl's avatar twanvl

Fixed: CardViewers fighting over styles when multiple windows are open

parent 7858d5b8
...@@ -37,7 +37,10 @@ wxSize CardViewer::DoGetBestSize() const { ...@@ -37,7 +37,10 @@ wxSize CardViewer::DoGetBestSize() const {
} }
void CardViewer::redraw(const ValueViewer& v) { void CardViewer::redraw(const ValueViewer& v) {
if (drawing) return; // Don't refresh if we OR ANOTHER CardViewer is drawing
// drawing another viewer causes styles to be updated for its active card, which may be different,
// causing the two viewers to continously refresh.
if (drawing_card()) return;
up_to_date = false; up_to_date = false;
RefreshRect(getRotation().trRectToBB(v.boundingBox()), false); RefreshRect(getRotation().trRectToBB(v.boundingBox()), false);
} }
...@@ -47,7 +50,7 @@ void CardViewer::onChange() { ...@@ -47,7 +50,7 @@ void CardViewer::onChange() {
} }
void CardViewer::redraw() { void CardViewer::redraw() {
if (drawing) return; if (drawing_card()) return;
up_to_date = false; up_to_date = false;
Refresh(false); Refresh(false);
} }
......
...@@ -23,11 +23,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>); ...@@ -23,11 +23,13 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>);
// ----------------------------------------------------------------------------- : DataViewer // ----------------------------------------------------------------------------- : DataViewer
DataViewer::DataViewer() : drawing(false) {} DataViewer::DataViewer() {}
DataViewer::~DataViewer() {} DataViewer::~DataViewer() {}
// ----------------------------------------------------------------------------- : Drawing // ----------------------------------------------------------------------------- : Drawing
IMPLEMENT_DYNAMIC_ARG(bool, drawing_card, false);
void DataViewer::draw(DC& dc) { void DataViewer::draw(DC& dc) {
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet); StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
RotatedDC rdc(dc, getRotation(), RotatedDC rdc(dc, getRotation(),
...@@ -36,7 +38,7 @@ void DataViewer::draw(DC& dc) { ...@@ -36,7 +38,7 @@ void DataViewer::draw(DC& dc) {
} }
void DataViewer::draw(RotatedDC& dc, const Color& background) { void DataViewer::draw(RotatedDC& dc, const Color& background) {
if (!set) return; // no set specified, don't draw anything if (!set) return; // no set specified, don't draw anything
drawing = true; WITH_DYNAMIC_ARG(drawing_card, true);
// fill with background color // fill with background color
clearDC(dc.getDC(), background); clearDC(dc.getDC(), background);
// update style scripts // update style scripts
...@@ -69,7 +71,6 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) { ...@@ -69,7 +71,6 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
} }
} }
} }
drawing = false;
} }
void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) { void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
v.draw(dc); v.draw(dc);
......
...@@ -20,6 +20,8 @@ class Context; ...@@ -20,6 +20,8 @@ class Context;
// ----------------------------------------------------------------------------- : DataViewer // ----------------------------------------------------------------------------- : DataViewer
DECLARE_DYNAMIC_ARG(bool, drawing_card);
/// A viewer can generate an image of some values, usually a card. /// A viewer can generate an image of some values, usually a card.
class DataViewer : public SetView { class DataViewer : public SetView {
public: public:
...@@ -98,7 +100,6 @@ class DataViewer : public SetView { ...@@ -98,7 +100,6 @@ class DataViewer : public SetView {
vector<ValueViewerP> viewers; ///< The viewers for the different values in the data vector<ValueViewerP> viewers; ///< The viewers for the different values in the data
CardP card; ///< The card that is currently displayed, if any CardP card; ///< The card that is currently displayed, if any
bool drawing; ///< Are we currently drawing?
mutable StyleSheetP stylesheet; ///< Stylesheet being used mutable StyleSheetP stylesheet; ///< Stylesheet being used
}; };
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include <render/value/choice.hpp> #include <render/value/choice.hpp>
#include <render/card/viewer.hpp> #include <render/card/viewer.hpp>
DECLARE_TYPEOF_COLLECTION(wxPoint);
// ----------------------------------------------------------------------------- : ChoiceValueViewer // ----------------------------------------------------------------------------- : ChoiceValueViewer
IMPLEMENT_VALUE_VIEWER(Choice); IMPLEMENT_VALUE_VIEWER(Choice);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <render/card/viewer.hpp> #include <render/card/viewer.hpp>
DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP); DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP);
DECLARE_TYPEOF_COLLECTION(wxPoint);
// ----------------------------------------------------------------------------- : ColorValueViewer // ----------------------------------------------------------------------------- : ColorValueViewer
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include <render/card/viewer.hpp> #include <render/card/viewer.hpp>
#include <gui/util.hpp> #include <gui/util.hpp>
DECLARE_TYPEOF_COLLECTION(wxPoint);
// ----------------------------------------------------------------------------- : ImageValueViewer // ----------------------------------------------------------------------------- : ImageValueViewer
IMPLEMENT_VALUE_VIEWER(Image); IMPLEMENT_VALUE_VIEWER(Image);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <gui/util.hpp> #include <gui/util.hpp>
DECLARE_TYPEOF_COLLECTION(String); DECLARE_TYPEOF_COLLECTION(String);
DECLARE_TYPEOF_COLLECTION(wxPoint);
// ----------------------------------------------------------------------------- : MultipleChoiceValueViewer // ----------------------------------------------------------------------------- : MultipleChoiceValueViewer
......
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