Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
1f7ec6d4
Commit
1f7ec6d4
authored
Jul 04, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scripts depending on content_something are re-updating after updating the content properties
parent
562ab127
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
63 additions
and
34 deletions
+63
-34
src/data/set.cpp
src/data/set.cpp
+2
-2
src/data/set.hpp
src/data/set.hpp
+1
-1
src/render/card/viewer.cpp
src/render/card/viewer.cpp
+27
-15
src/render/card/viewer.hpp
src/render/card/viewer.hpp
+2
-0
src/render/text/viewer.cpp
src/render/text/viewer.cpp
+4
-1
src/render/text/viewer.hpp
src/render/text/viewer.hpp
+2
-1
src/render/value/text.cpp
src/render/value/text.cpp
+2
-1
src/render/value/text.hpp
src/render/value/text.hpp
+1
-1
src/render/value/viewer.hpp
src/render/value/viewer.hpp
+3
-2
src/script/script_manager.cpp
src/script/script_manager.cpp
+17
-8
src/script/script_manager.hpp
src/script/script_manager.hpp
+2
-2
No files found.
src/data/set.cpp
View file @
1f7ec6d4
...
@@ -53,8 +53,8 @@ Context& Set::getContext(const CardP& card) {
...
@@ -53,8 +53,8 @@ Context& Set::getContext(const CardP& card) {
assert
(
wxThread
::
IsMain
());
assert
(
wxThread
::
IsMain
());
return
script_manager
->
getContext
(
card
);
return
script_manager
->
getContext
(
card
);
}
}
void
Set
::
updateStyles
(
const
CardP
&
card
)
{
void
Set
::
updateStyles
(
const
CardP
&
card
,
bool
only_content_dependent
)
{
script_manager
->
updateStyles
(
card
);
script_manager
->
updateStyles
(
card
,
only_content_dependent
);
}
}
void
Set
::
updateDelayed
()
{
void
Set
::
updateDelayed
()
{
script_manager
->
updateDelayed
();
script_manager
->
updateDelayed
();
...
...
src/data/set.hpp
View file @
1f7ec6d4
...
@@ -66,7 +66,7 @@ class Set : public Packaged {
...
@@ -66,7 +66,7 @@ class Set : public Packaged {
/** Should only be used from the main thread! */
/** Should only be used from the main thread! */
Context
&
getContext
(
const
CardP
&
card
);
Context
&
getContext
(
const
CardP
&
card
);
/// Update styles and extra_card_fields for a card
/// Update styles and extra_card_fields for a card
void
updateStyles
(
const
CardP
&
card
);
void
updateStyles
(
const
CardP
&
card
,
bool
only_content_dependent
);
/// Update scripts that were delayed
/// Update scripts that were delayed
void
updateDelayed
();
void
updateDelayed
();
/// A context for performing scripts
/// A context for performing scripts
...
...
src/render/card/viewer.cpp
View file @
1f7ec6d4
...
@@ -40,30 +40,23 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
...
@@ -40,30 +40,23 @@ void DataViewer::draw(RotatedDC& dc, const Color& background) {
// fill with background color
// fill with background color
clearDC
(
dc
.
getDC
(),
background
);
clearDC
(
dc
.
getDC
(),
background
);
// update style scripts
// update style scripts
try
{
updateStyles
(
false
);
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
);
}
// prepare viewers
// prepare viewers
bool
changed_content_properties
=
false
;
FOR_EACH
(
v
,
viewers
)
{
// draw low z index fields first
FOR_EACH
(
v
,
viewers
)
{
// draw low z index fields first
if
(
v
->
getStyle
()
->
visible
)
{
if
(
v
->
getStyle
()
->
visible
)
{
try
{
try
{
v
->
prepare
(
dc
);
if
(
v
->
prepare
(
dc
))
{
changed_content_properties
=
true
;
}
}
catch
(
const
Error
&
e
)
{
}
catch
(
const
Error
&
e
)
{
handle_error
(
e
,
false
,
false
);
handle_error
(
e
,
false
,
false
);
}
}
}
}
}
}
if
(
changed_content_properties
)
{
updateStyles
(
true
);
}
// draw viewers
// draw viewers
FOR_EACH
(
v
,
viewers
)
{
// draw low z index fields first
FOR_EACH
(
v
,
viewers
)
{
// draw low z index fields first
if
(
v
->
getStyle
()
->
visible
)
{
// visible
if
(
v
->
getStyle
()
->
visible
)
{
// visible
...
@@ -80,6 +73,25 @@ void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
...
@@ -80,6 +73,25 @@ void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
v
.
draw
(
dc
);
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
// ----------------------------------------------------------------------------- : Utility for ValueViewers
bool
DataViewer
::
nativeLook
()
const
{
return
false
;
}
bool
DataViewer
::
nativeLook
()
const
{
return
false
;
}
...
...
src/render/card/viewer.hpp
View file @
1f7ec6d4
...
@@ -75,6 +75,8 @@ class DataViewer : public SetView {
...
@@ -75,6 +75,8 @@ class DataViewer : public SetView {
private:
private:
/// Create some viewers for the given styles
/// Create some viewers for the given styles
void
addStyles
(
IndexMap
<
FieldP
,
StyleP
>&
styles
);
void
addStyles
(
IndexMap
<
FieldP
,
StyleP
>&
styles
);
/// Update style scripts
void
updateStyles
(
bool
only_content_dependent
);
protected:
protected:
/// Set the styles for the data to be shown, recreating the viewers
/// Set the styles for the data to be shown, recreating the viewers
void
setStyles
(
const
StyleSheetP
&
stylesheet
,
IndexMap
<
FieldP
,
StyleP
>&
styles
,
IndexMap
<
FieldP
,
StyleP
>*
extra_styles
=
nullptr
);
void
setStyles
(
const
StyleSheetP
&
stylesheet
,
IndexMap
<
FieldP
,
StyleP
>&
styles
,
IndexMap
<
FieldP
,
StyleP
>*
extra_styles
=
nullptr
);
...
...
src/render/text/viewer.cpp
View file @
1f7ec6d4
...
@@ -131,12 +131,15 @@ void TextViewer::drawSeparators(RotatedDC& dc) {
...
@@ -131,12 +131,15 @@ void TextViewer::drawSeparators(RotatedDC& dc) {
}
}
}
}
void
TextViewer
::
prepare
(
RotatedDC
&
dc
,
const
String
&
text
,
TextStyle
&
style
,
Context
&
ctx
)
{
bool
TextViewer
::
prepare
(
RotatedDC
&
dc
,
const
String
&
text
,
TextStyle
&
style
,
Context
&
ctx
)
{
if
(
lines
.
empty
())
{
if
(
lines
.
empty
())
{
// not prepared yet
// not prepared yet
Rotater
r
(
dc
,
style
.
getRotation
());
Rotater
r
(
dc
,
style
.
getRotation
());
prepareElements
(
text
,
style
,
ctx
);
prepareElements
(
text
,
style
,
ctx
);
prepareLines
(
dc
,
text
,
style
,
ctx
);
prepareLines
(
dc
,
text
,
style
,
ctx
);
return
true
;
}
else
{
return
false
;
}
}
}
}
void
TextViewer
::
reset
()
{
void
TextViewer
::
reset
()
{
...
...
src/render/text/viewer.hpp
View file @
1f7ec6d4
...
@@ -54,7 +54,8 @@ class TextViewer {
...
@@ -54,7 +54,8 @@ class TextViewer {
void
drawSeparators
(
RotatedDC
&
dc
);
void
drawSeparators
(
RotatedDC
&
dc
);
/// Prepare the text for drawing, if it is not already prepared
/// Prepare the text for drawing, if it is not already prepared
void
prepare
(
RotatedDC
&
dc
,
const
String
&
text
,
TextStyle
&
style
,
Context
&
);
/** Returns true if something has been done */
bool
prepare
(
RotatedDC
&
dc
,
const
String
&
text
,
TextStyle
&
style
,
Context
&
);
/// Reset the cached data, at a new call to draw it will be recalculated
/// Reset the cached data, at a new call to draw it will be recalculated
void
reset
();
void
reset
();
...
...
src/render/value/text.cpp
View file @
1f7ec6d4
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
// ----------------------------------------------------------------------------- : TextValueViewer
// ----------------------------------------------------------------------------- : TextValueViewer
void
TextValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
bool
TextValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
if
(
!
style
().
mask_filename
.
empty
()
&&
!
style
().
mask
.
ok
())
{
if
(
!
style
().
mask_filename
.
empty
()
&&
!
style
().
mask
.
ok
())
{
// load contour mask
// load contour mask
Image
image
;
Image
image
;
...
@@ -22,6 +22,7 @@ void TextValueViewer::prepare(RotatedDC& dc) {
...
@@ -22,6 +22,7 @@ void TextValueViewer::prepare(RotatedDC& dc) {
}
}
}
}
v
.
prepare
(
dc
,
value
().
value
(),
style
(),
viewer
.
getContext
());
v
.
prepare
(
dc
,
value
().
value
(),
style
(),
viewer
.
getContext
());
return
true
;
}
}
void
TextValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
TextValueViewer
::
draw
(
RotatedDC
&
dc
)
{
...
...
src/render/value/text.hpp
View file @
1f7ec6d4
...
@@ -21,7 +21,7 @@ class TextValueViewer : public ValueViewer {
...
@@ -21,7 +21,7 @@ class TextValueViewer : public ValueViewer {
public:
public:
DECLARE_VALUE_VIEWER
(
Text
)
:
ValueViewer
(
parent
,
style
)
{}
DECLARE_VALUE_VIEWER
(
Text
)
:
ValueViewer
(
parent
,
style
)
{}
virtual
void
prepare
(
RotatedDC
&
dc
);
virtual
bool
prepare
(
RotatedDC
&
dc
);
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
onValueChange
();
virtual
void
onValueChange
();
virtual
void
onStyleChange
();
virtual
void
onStyleChange
();
...
...
src/render/value/viewer.hpp
View file @
1f7ec6d4
...
@@ -40,8 +40,9 @@ class ValueViewer : public StyleListener {
...
@@ -40,8 +40,9 @@ class ValueViewer : public StyleListener {
inline
const
ValueP
&
getValue
()
const
{
return
valueP
;
}
inline
const
ValueP
&
getValue
()
const
{
return
valueP
;
}
/// Prepare before drawing.
/// Prepare before drawing.
/** Scripts are updated after preparing, allowing */
/** Should return true if a content property has changed
virtual
void
prepare
(
RotatedDC
&
dc
)
{};
* Scripts are re-updated after preparing if they depend on content properties. */
virtual
bool
prepare
(
RotatedDC
&
dc
)
{
return
false
;
};
/// Draw this value
/// Draw this value
virtual
void
draw
(
RotatedDC
&
dc
)
=
0
;
virtual
void
draw
(
RotatedDC
&
dc
)
=
0
;
...
...
src/script/script_manager.cpp
View file @
1f7ec6d4
...
@@ -139,6 +139,12 @@ void SetScriptManager::initDependencies(Context& ctx, StyleSheet& stylesheet) {
...
@@ -139,6 +139,12 @@ void SetScriptManager::initDependencies(Context& ctx, StyleSheet& stylesheet) {
s
->
checkContentDependencies
(
ctx
,
test
);
s
->
checkContentDependencies
(
ctx
,
test
);
if
(
test
.
index
)
s
->
content_dependent
=
true
;
if
(
test
.
index
)
s
->
content_dependent
=
true
;
}
}
FOR_EACH
(
s
,
stylesheet
.
extra_card_style
)
{
// are there dependencies of this style on other style properties?
Dependency
test
(
DEP_DUMMY
,
false
);
s
->
checkContentDependencies
(
ctx
,
test
);
if
(
test
.
index
)
s
->
content_dependent
=
true
;
}
}
}
// ----------------------------------------------------------------------------- : ScriptManager : updating
// ----------------------------------------------------------------------------- : ScriptManager : updating
...
@@ -199,21 +205,24 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
...
@@ -199,21 +205,24 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
}
}
}
}
void
SetScriptManager
::
updateStyles
(
const
CardP
&
card
)
{
void
SetScriptManager
::
updateStyles
(
const
CardP
&
card
,
bool
only_content_dependent
)
{
assert
(
card
);
assert
(
card
);
const
StyleSheet
&
stylesheet
=
set
.
stylesheetFor
(
card
);
const
StyleSheet
&
stylesheet
=
set
.
stylesheetFor
(
card
);
Context
&
ctx
=
getContext
(
card
);
Context
&
ctx
=
getContext
(
card
);
// update extra card fields
if
(
!
only_content_dependent
)
{
IndexMap
<
FieldP
,
ValueP
>&
extra_data
=
card
->
extraDataFor
(
stylesheet
);
// update extra card fields
FOR_EACH
(
v
,
extra_data
)
{
IndexMap
<
FieldP
,
ValueP
>&
extra_data
=
card
->
extraDataFor
(
stylesheet
);
v
->
update
(
ctx
);
FOR_EACH
(
v
,
extra_data
)
{
v
->
update
(
ctx
);
}
}
}
// update all styles
// update all styles
updateStyles
(
ctx
,
stylesheet
.
card_style
);
updateStyles
(
ctx
,
stylesheet
.
card_style
,
only_content_dependent
);
updateStyles
(
ctx
,
stylesheet
.
extra_card_style
);
updateStyles
(
ctx
,
stylesheet
.
extra_card_style
,
only_content_dependent
);
}
}
void
SetScriptManager
::
updateStyles
(
Context
&
ctx
,
const
IndexMap
<
FieldP
,
StyleP
>&
styles
)
{
void
SetScriptManager
::
updateStyles
(
Context
&
ctx
,
const
IndexMap
<
FieldP
,
StyleP
>&
styles
,
bool
only_content_dependent
)
{
FOR_EACH_CONST
(
s
,
styles
)
{
FOR_EACH_CONST
(
s
,
styles
)
{
if
(
only_content_dependent
&&
!
s
->
content_dependent
)
continue
;
try
{
try
{
if
(
s
->
update
(
ctx
))
{
if
(
s
->
update
(
ctx
))
{
// style has changed, tell listeners
// style has changed, tell listeners
...
...
src/script/script_manager.hpp
View file @
1f7ec6d4
...
@@ -61,7 +61,7 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
...
@@ -61,7 +61,7 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
~
SetScriptManager
();
~
SetScriptManager
();
/// Update all styles for a particular card
/// Update all styles for a particular card
void
updateStyles
(
const
CardP
&
card
);
void
updateStyles
(
const
CardP
&
card
,
bool
only_content_dependent
);
/// Update expensive things that were previously delayed
/// Update expensive things that were previously delayed
void
updateDelayed
();
void
updateDelayed
();
...
@@ -79,7 +79,7 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
...
@@ -79,7 +79,7 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
void
initDependencies
(
Context
&
,
StyleSheet
&
);
void
initDependencies
(
Context
&
,
StyleSheet
&
);
/// Update a map of styles
/// Update a map of styles
void
updateStyles
(
Context
&
ctx
,
const
IndexMap
<
FieldP
,
StyleP
>&
styles
);
void
updateStyles
(
Context
&
ctx
,
const
IndexMap
<
FieldP
,
StyleP
>&
styles
,
bool
only_content_dependent
);
/// Updates scripts, starting at some value
/// Updates scripts, starting at some value
/** if the value changes any dependend values are updated as well */
/** if the value changes any dependend values are updated as well */
void
updateValue
(
Value
&
value
,
const
CardP
&
card
);
void
updateValue
(
Value
&
value
,
const
CardP
&
card
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment