Conversion to new ScriptableImage complete, this affected quite a bit, including the evil thumbnail thread;

Added StyleListener, so style changes are only propagated to interested viewers.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@329 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-05-10 00:47:27 +00:00
parent 71adbf8545
commit 00b3e3a3cd
28 changed files with 282 additions and 531 deletions
+13 -8
View File
@@ -34,15 +34,19 @@ void DataViewer::draw(DC& dc) {
}
void DataViewer::draw(RotatedDC& dc, const Color& background) {
if (!set) return; // no set specified, don't draw anything
drawing = true;
// fill with background color
clearDC(dc.getDC(), background);
// update style scripts
//%% if (card) set->updateFor(card);
Context& ctx = getContext();
FOR_EACH(v, viewers) {
if (v->getStyle()->update(ctx)) {
v->onStyleChange();
try {
Context& ctx = getContext();
FOR_EACH(v, viewers) {
if (v->getStyle()->update(ctx)) {
v->getStyle()->tellListeners();
}
}
} catch (const Error& e) {
handle_error(e, false, false);
}
// draw values
FOR_EACH(v, viewers) { // draw low z index fields first
@@ -54,6 +58,7 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
}
}
}
drawing = false;
}
void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
v.draw(dc);
@@ -159,16 +164,16 @@ void DataViewer::onAction(const Action& action, bool undone) {
}
}
}
TYPE_CASE(action, ScriptStyleEvent) {
/*//% TYPE_CASE(action, ScriptStyleEvent) {
if (action.stylesheet == stylesheet.get()) {
FOR_EACH(v, viewers) {
if (v->getStyle().get() == action.style) {
// refresh the viewer
v->onStyleChange();
onChange();
if (!drawing) onChange();
return;
}
}
}
}
}*/
}
+5
View File
@@ -22,6 +22,8 @@ class Context;
/// A viewer can generate an image of some values, usually a card.
class DataViewer : public SetView {
public:
DataViewer() : drawing(false) {}
// --------------------------------------------------- : Drawing
/// Draw the current (card/data) to the given dc
@@ -56,6 +58,8 @@ class DataViewer : public SetView {
virtual Rotation getRotation() const;
/// The card we are viewing
inline CardP getCard() const { return card; }
/// Invalidate and redraw (the area of) a single value viewer
virtual void redraw(const ValueViewer&) {}
// --------------------------------------------------- : Setting data
@@ -86,6 +90,7 @@ class DataViewer : public SetView {
vector<ValueViewerP> viewers; ///< The viewers for the different values in the data
CardP card; ///< The card that is currently displayed, if any
bool drawing; ///< Are we currently drawing?
public:
mutable StyleSheetP stylesheet; ///< Stylesheet being used
};