Scripts depending on content_something are re-updating after updating the content properties

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@480 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-07-04 17:15:08 +00:00
parent 95d4ca89f9
commit b3d04fe192
11 changed files with 63 additions and 34 deletions
+27 -15
View File
@@ -40,30 +40,23 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
// fill with background color
clearDC(dc.getDC(), background);
// update style scripts
try {
if (card) {
set->updateStyles(card);
} else {
Context& ctx = getContext();
FOR_EACH(v, viewers) {
if (v->getStyle()->update(ctx)) {
v->getStyle()->tellListeners();
}
}
}
} catch (const Error& e) {
handle_error(e, false, false);
}
updateStyles(false);
// prepare viewers
bool changed_content_properties = false;
FOR_EACH(v, viewers) { // draw low z index fields first
if (v->getStyle()->visible) {
try {
v->prepare(dc);
if (v->prepare(dc)) {
changed_content_properties = true;
}
} catch (const Error& e) {
handle_error(e, false, false);
}
}
}
if (changed_content_properties) {
updateStyles(true);
}
// draw viewers
FOR_EACH(v, viewers) { // draw low z index fields first
if (v->getStyle()->visible) {// visible
@@ -80,6 +73,25 @@ void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
v.draw(dc);
}
void DataViewer::updateStyles(bool only_content_dependent) {
try {
if (card) {
set->updateStyles(card, only_content_dependent);
} else {
Context& ctx = getContext();
FOR_EACH(v, viewers) {
Style& s = *v->getStyle();
if (only_content_dependent && !s.content_dependent) continue;
if (s.update(ctx)) {
s.tellListeners();
}
}
}
} catch (const Error& e) {
handle_error(e, false, false);
}
}
// ----------------------------------------------------------------------------- : Utility for ValueViewers
bool DataViewer::nativeLook() const { return false; }