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
79b10780
Commit
79b10780
authored
Jul 04, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed: failed to re-prepare text after content dependent script changed
parent
ebe8f653
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
31 additions
and
22 deletions
+31
-22
src/data/field.cpp
src/data/field.cpp
+2
-2
src/data/field.hpp
src/data/field.hpp
+3
-2
src/data/field/choice.cpp
src/data/field/choice.cpp
+1
-1
src/render/card/viewer.cpp
src/render/card/viewer.cpp
+1
-1
src/render/text/viewer.cpp
src/render/text/viewer.cpp
+3
-0
src/render/text/viewer.hpp
src/render/text/viewer.hpp
+2
-0
src/render/value/choice.cpp
src/render/value/choice.cpp
+2
-2
src/render/value/choice.hpp
src/render/value/choice.hpp
+1
-1
src/render/value/color.cpp
src/render/value/color.cpp
+2
-2
src/render/value/color.hpp
src/render/value/color.hpp
+1
-1
src/render/value/image.cpp
src/render/value/image.cpp
+2
-2
src/render/value/image.hpp
src/render/value/image.hpp
+1
-1
src/render/value/text.cpp
src/render/value/text.cpp
+6
-4
src/render/value/text.hpp
src/render/value/text.hpp
+1
-1
src/render/value/viewer.hpp
src/render/value/viewer.hpp
+2
-1
src/script/script_manager.cpp
src/script/script_manager.cpp
+1
-1
No files found.
src/data/field.cpp
View file @
79b10780
...
@@ -183,8 +183,8 @@ void Style::removeListener(StyleListener* listener) {
...
@@ -183,8 +183,8 @@ void Style::removeListener(StyleListener* listener) {
listeners
.
end
()
listeners
.
end
()
);
);
}
}
void
Style
::
tellListeners
()
{
void
Style
::
tellListeners
(
bool
already_prepared
)
{
FOR_EACH
(
l
,
listeners
)
l
->
onStyleChange
();
FOR_EACH
(
l
,
listeners
)
l
->
onStyleChange
(
already_prepared
);
}
}
StyleListener
::
StyleListener
(
const
StyleP
&
style
)
StyleListener
::
StyleListener
(
const
StyleP
&
style
)
...
...
src/data/field.hpp
View file @
79b10780
...
@@ -132,7 +132,7 @@ class Style : public IntrusivePtrVirtualBase {
...
@@ -132,7 +132,7 @@ class Style : public IntrusivePtrVirtualBase {
/// Remove a StyleListener
/// Remove a StyleListener
void
removeListener
(
StyleListener
*
);
void
removeListener
(
StyleListener
*
);
/// Tell the StyleListeners that this style has changed
/// Tell the StyleListeners that this style has changed
void
tellListeners
();
void
tellListeners
(
bool
already_prepared
);
private:
private:
DECLARE_REFLECTION_VIRTUAL
();
DECLARE_REFLECTION_VIRTUAL
();
...
@@ -156,7 +156,8 @@ class StyleListener : public IntrusivePtrVirtualBase {
...
@@ -156,7 +156,8 @@ class StyleListener : public IntrusivePtrVirtualBase {
virtual
~
StyleListener
();
virtual
~
StyleListener
();
/// Called when a (scripted) property of the viewed style has changed
/// Called when a (scripted) property of the viewed style has changed
virtual
void
onStyleChange
()
{}
/** already_prepared indicates that this change happend after preparing text for content properties */
virtual
void
onStyleChange
(
bool
already_prepared
)
{}
protected:
protected:
const
StyleP
styleP
;
///< The style we are listening to
const
StyleP
styleP
;
///< The style we are listening to
};
};
...
...
src/data/field/choice.cpp
View file @
79b10780
...
@@ -252,7 +252,7 @@ void ChoiceStyle::invalidate(Context& ctx) {
...
@@ -252,7 +252,7 @@ void ChoiceStyle::invalidate(Context& ctx) {
thumbnails_status
[
i
]
=
THUMB_CHANGED
;
thumbnails_status
[
i
]
=
THUMB_CHANGED
;
}
}
}
}
if
(
change
)
tellListeners
();
if
(
change
)
tellListeners
(
false
);
}
}
void
ChoiceStyle
::
loadMask
(
Package
&
pkg
)
{
void
ChoiceStyle
::
loadMask
(
Package
&
pkg
)
{
...
...
src/render/card/viewer.cpp
View file @
79b10780
...
@@ -83,7 +83,7 @@ void DataViewer::updateStyles(bool only_content_dependent) {
...
@@ -83,7 +83,7 @@ void DataViewer::updateStyles(bool only_content_dependent) {
Style
&
s
=
*
v
->
getStyle
();
Style
&
s
=
*
v
->
getStyle
();
if
(
only_content_dependent
&&
!
s
.
content_dependent
)
continue
;
if
(
only_content_dependent
&&
!
s
.
content_dependent
)
continue
;
if
(
s
.
update
(
ctx
))
{
if
(
s
.
update
(
ctx
))
{
s
.
tellListeners
();
s
.
tellListeners
(
only_content_dependent
);
}
}
}
}
}
}
...
...
src/render/text/viewer.cpp
View file @
79b10780
...
@@ -146,6 +146,9 @@ void TextViewer::reset() {
...
@@ -146,6 +146,9 @@ void TextViewer::reset() {
elements
.
clear
();
elements
.
clear
();
lines
.
clear
();
lines
.
clear
();
}
}
bool
TextViewer
::
prepared
()
const
{
return
!
lines
.
empty
();
}
// ----------------------------------------------------------------------------- : Positions
// ----------------------------------------------------------------------------- : Positions
...
...
src/render/text/viewer.hpp
View file @
79b10780
...
@@ -58,6 +58,8 @@ class TextViewer {
...
@@ -58,6 +58,8 @@ class TextViewer {
bool
prepare
(
RotatedDC
&
dc
,
const
String
&
text
,
TextStyle
&
style
,
Context
&
);
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
();
/// Is the viewer prepare()d?
bool
prepared
()
const
;
// --------------------------------------------------- : Positions
// --------------------------------------------------- : Positions
...
...
src/render/value/choice.cpp
View file @
79b10780
...
@@ -72,6 +72,6 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
...
@@ -72,6 +72,6 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
}
}
}
}
void
ChoiceValueViewer
::
onStyleChange
()
{
void
ChoiceValueViewer
::
onStyleChange
(
bool
already_prepared
)
{
viewer
.
redraw
(
*
this
);
if
(
!
already_prepared
)
viewer
.
redraw
(
*
this
);
}
}
src/render/value/choice.hpp
View file @
79b10780
...
@@ -21,7 +21,7 @@ class ChoiceValueViewer : public ValueViewer {
...
@@ -21,7 +21,7 @@ class ChoiceValueViewer : public ValueViewer {
DECLARE_VALUE_VIEWER
(
Choice
)
:
ValueViewer
(
parent
,
style
)
{}
DECLARE_VALUE_VIEWER
(
Choice
)
:
ValueViewer
(
parent
,
style
)
{}
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
onStyleChange
();
virtual
void
onStyleChange
(
bool
);
};
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
...
...
src/render/value/color.cpp
View file @
79b10780
...
@@ -86,9 +86,9 @@ bool ColorValueViewer::containsPoint(const RealPoint& p) const {
...
@@ -86,9 +86,9 @@ bool ColorValueViewer::containsPoint(const RealPoint& p) const {
}
}
}
}
void
ColorValueViewer
::
onStyleChange
()
{
void
ColorValueViewer
::
onStyleChange
(
bool
already_prepared
)
{
alpha_mask
=
AlphaMaskP
();
alpha_mask
=
AlphaMaskP
();
viewer
.
redraw
(
*
this
);
if
(
!
already_prepared
)
viewer
.
redraw
(
*
this
);
}
}
void
ColorValueViewer
::
loadMask
(
const
Rotation
&
rot
)
const
{
void
ColorValueViewer
::
loadMask
(
const
Rotation
&
rot
)
const
{
...
...
src/render/value/color.hpp
View file @
79b10780
...
@@ -25,7 +25,7 @@ class ColorValueViewer : public ValueViewer {
...
@@ -25,7 +25,7 @@ class ColorValueViewer : public ValueViewer {
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
bool
containsPoint
(
const
RealPoint
&
p
)
const
;
virtual
bool
containsPoint
(
const
RealPoint
&
p
)
const
;
virtual
void
onStyleChange
();
virtual
void
onStyleChange
(
bool
);
private:
private:
mutable
AlphaMaskP
alpha_mask
;
mutable
AlphaMaskP
alpha_mask
;
...
...
src/render/value/image.cpp
View file @
79b10780
...
@@ -77,10 +77,10 @@ void ImageValueViewer::onValueChange() {
...
@@ -77,10 +77,10 @@ void ImageValueViewer::onValueChange() {
bitmap
=
Bitmap
();
bitmap
=
Bitmap
();
}
}
void
ImageValueViewer
::
onStyleChange
()
{
void
ImageValueViewer
::
onStyleChange
(
bool
already_prepared
)
{
bitmap
=
Bitmap
();
bitmap
=
Bitmap
();
alpha_mask
=
AlphaMaskP
();
// TODO: only reload whatever has changed
alpha_mask
=
AlphaMaskP
();
// TODO: only reload whatever has changed
viewer
.
redraw
(
*
this
);
if
(
!
already_prepared
)
viewer
.
redraw
(
*
this
);
}
}
void
ImageValueViewer
::
loadMask
(
const
Rotation
&
rot
)
const
{
void
ImageValueViewer
::
loadMask
(
const
Rotation
&
rot
)
const
{
...
...
src/render/value/image.hpp
View file @
79b10780
...
@@ -27,7 +27,7 @@ class ImageValueViewer : public ValueViewer {
...
@@ -27,7 +27,7 @@ class ImageValueViewer : public ValueViewer {
virtual
bool
containsPoint
(
const
RealPoint
&
p
)
const
;
virtual
bool
containsPoint
(
const
RealPoint
&
p
)
const
;
virtual
void
onValueChange
();
virtual
void
onValueChange
();
virtual
void
onStyleChange
();
virtual
void
onStyleChange
(
bool
);
private:
private:
Bitmap
bitmap
;
Bitmap
bitmap
;
...
...
src/render/value/text.cpp
View file @
79b10780
...
@@ -21,12 +21,14 @@ bool TextValueViewer::prepare(RotatedDC& dc) {
...
@@ -21,12 +21,14 @@ bool TextValueViewer::prepare(RotatedDC& dc) {
style
().
mask
.
load
(
image
);
style
().
mask
.
load
(
image
);
}
}
}
}
v
.
prepare
(
dc
,
value
().
value
(),
style
(),
viewer
.
getContext
());
return
v
.
prepare
(
dc
,
value
().
value
(),
style
(),
viewer
.
getContext
());
return
true
;
}
}
void
TextValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
TextValueViewer
::
draw
(
RotatedDC
&
dc
)
{
drawFieldBorder
(
dc
);
drawFieldBorder
(
dc
);
if
(
!
v
.
prepared
())
{
v
.
prepare
(
dc
,
value
().
value
(),
style
(),
viewer
.
getContext
());
}
v
.
draw
(
dc
,
style
(),
(
DrawWhat
)(
v
.
draw
(
dc
,
style
(),
(
DrawWhat
)(
DRAW_NORMAL
DRAW_NORMAL
|
(
viewer
.
drawBorders
()
?
DRAW_BORDERS
:
0
)
|
(
viewer
.
drawBorders
()
?
DRAW_BORDERS
:
0
)
...
@@ -38,7 +40,7 @@ void TextValueViewer::onValueChange() {
...
@@ -38,7 +40,7 @@ void TextValueViewer::onValueChange() {
v
.
reset
();
v
.
reset
();
}
}
void
TextValueViewer
::
onStyleChange
()
{
void
TextValueViewer
::
onStyleChange
(
bool
already_prepared
)
{
v
.
reset
();
v
.
reset
();
viewer
.
redraw
(
*
this
);
if
(
!
already_prepared
)
viewer
.
redraw
(
*
this
);
}
}
src/render/value/text.hpp
View file @
79b10780
...
@@ -24,7 +24,7 @@ class TextValueViewer : public ValueViewer {
...
@@ -24,7 +24,7 @@ class TextValueViewer : public ValueViewer {
virtual
bool
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
(
bool
);
protected:
protected:
TextViewer
v
;
TextViewer
v
;
...
...
src/render/value/viewer.hpp
View file @
79b10780
...
@@ -57,7 +57,8 @@ class ValueViewer : public StyleListener {
...
@@ -57,7 +57,8 @@ class ValueViewer : public StyleListener {
*/
*/
virtual
void
onValueChange
()
{}
virtual
void
onValueChange
()
{}
/// Called when a (scripted) property of the associated style has changed
/// Called when a (scripted) property of the associated style has changed
virtual
void
onStyleChange
()
{}
/** If alread_prepared, should make sure the viewer stays in a state similair to that after prepare() */
virtual
void
onStyleChange
(
bool
already_prepared
)
{}
/// Called when an action is performed on the associated value
/// Called when an action is performed on the associated value
virtual
void
onAction
(
const
Action
&
,
bool
undone
)
{
onValueChange
();
}
virtual
void
onAction
(
const
Action
&
,
bool
undone
)
{
onValueChange
();
}
...
...
src/script/script_manager.cpp
View file @
79b10780
...
@@ -226,7 +226,7 @@ void SetScriptManager::updateStyles(Context& ctx, const IndexMap<FieldP,StyleP>&
...
@@ -226,7 +226,7 @@ void SetScriptManager::updateStyles(Context& ctx, const IndexMap<FieldP,StyleP>&
try
{
try
{
if
(
s
->
update
(
ctx
))
{
if
(
s
->
update
(
ctx
))
{
// style has changed, tell listeners
// style has changed, tell listeners
s
->
tellListeners
();
s
->
tellListeners
(
only_content_dependent
);
}
}
}
catch
(
const
ScriptError
&
e
)
{
}
catch
(
const
ScriptError
&
e
)
{
throw
ScriptError
(
e
.
what
()
+
_
(
"
\n
while updating styles for '"
)
+
s
->
fieldP
->
name
+
_
(
"'"
));
throw
ScriptError
(
e
.
what
()
+
_
(
"
\n
while updating styles for '"
)
+
s
->
fieldP
->
name
+
_
(
"'"
));
...
...
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