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
d79c79bf
Commit
d79c79bf
authored
Dec 24, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
<sep-soft> support
parent
e18faefd
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
16 deletions
+30
-16
src/data/field/text.cpp
src/data/field/text.cpp
+1
-1
src/render/text/element.cpp
src/render/text/element.cpp
+4
-1
src/render/text/element.hpp
src/render/text/element.hpp
+2
-2
src/render/text/font.cpp
src/render/text/font.cpp
+6
-9
src/render/text/symbol.cpp
src/render/text/symbol.cpp
+1
-1
src/render/text/viewer.cpp
src/render/text/viewer.cpp
+12
-2
src/util/tagged_string.cpp
src/util/tagged_string.cpp
+4
-0
No files found.
src/data/field/text.cpp
View file @
d79c79bf
...
@@ -91,7 +91,7 @@ IMPLEMENT_REFLECTION(TextStyle) {
...
@@ -91,7 +91,7 @@ IMPLEMENT_REFLECTION(TextStyle) {
// ----------------------------------------------------------------------------- : TextValue
// ----------------------------------------------------------------------------- : TextValue
String
TextValue
::
toString
()
const
{
String
TextValue
::
toString
()
const
{
return
untag
(
value
());
return
untag
_hide_sep
(
value
());
}
}
bool
TextValue
::
update
(
Context
&
ctx
)
{
bool
TextValue
::
update
(
Context
&
ctx
)
{
Value
::
update
(
ctx
);
Value
::
update
(
ctx
);
...
...
src/render/text/element.cpp
View file @
d79c79bf
...
@@ -100,7 +100,10 @@ struct TextElementsFromString {
...
@@ -100,7 +100,10 @@ struct TextElementsFromString {
if
(
symbol
>
0
&&
style
.
symbol_font
.
valid
())
{
if
(
symbol
>
0
&&
style
.
symbol_font
.
valid
())
{
te
.
elements
.
push_back
(
new_shared5
<
SymbolTextElement
>
(
text
,
pos
,
pos
+
1
,
style
.
symbol_font
,
&
ctx
));
te
.
elements
.
push_back
(
new_shared5
<
SymbolTextElement
>
(
text
,
pos
,
pos
+
1
,
style
.
symbol_font
,
&
ctx
));
}
else
{
}
else
{
te
.
elements
.
push_back
(
new_shared5
<
FontTextElement
>
(
text
,
pos
,
pos
+
1
,
style
.
font
.
make
(
bold
>
0
,
italic
>
0
),
line
>
0
?
BREAK_LINE
:
BREAK_HARD
));
te
.
elements
.
push_back
(
new_shared6
<
FontTextElement
>
(
text
,
pos
,
pos
+
1
,
style
.
font
.
make
(
bold
>
0
,
italic
>
0
),
soft
>
0
?
DRAW_ACTIVE
:
DRAW_NORMAL
,
line
>
0
?
BREAK_LINE
:
BREAK_HARD
));
}
}
}
}
pos
+=
1
;
pos
+=
1
;
...
...
src/render/text/element.hpp
View file @
d79c79bf
...
@@ -126,9 +126,9 @@ class SimpleTextElement : public TextElement {
...
@@ -126,9 +126,9 @@ class SimpleTextElement : public TextElement {
/// A text element that uses a normal font
/// A text element that uses a normal font
class
FontTextElement
:
public
SimpleTextElement
{
class
FontTextElement
:
public
SimpleTextElement
{
public:
public:
FontTextElement
(
const
String
&
text
,
size_t
start
,
size_t
end
,
const
FontP
&
font
,
LineBreak
break_style
)
FontTextElement
(
const
String
&
text
,
size_t
start
,
size_t
end
,
const
FontP
&
font
,
DrawWhat
draw_as
,
LineBreak
break_style
)
:
SimpleTextElement
(
text
,
start
,
end
)
:
SimpleTextElement
(
text
,
start
,
end
)
,
font
(
font
),
break_style
(
break_style
)
,
font
(
font
),
draw_as
(
draw_as
),
break_style
(
break_style
)
{}
{}
virtual
void
draw
(
RotatedDC
&
dc
,
double
scale
,
const
RealRect
&
rect
,
const
double
*
xs
,
DrawWhat
what
,
size_t
start
,
size_t
end
)
const
;
virtual
void
draw
(
RotatedDC
&
dc
,
double
scale
,
const
RealRect
&
rect
,
const
double
*
xs
,
DrawWhat
what
,
size_t
start
,
size_t
end
)
const
;
...
...
src/render/text/font.cpp
View file @
d79c79bf
...
@@ -12,17 +12,14 @@
...
@@ -12,17 +12,14 @@
// ----------------------------------------------------------------------------- : FontTextElement
// ----------------------------------------------------------------------------- : FontTextElement
void
FontTextElement
::
draw
(
RotatedDC
&
dc
,
double
scale
,
const
RealRect
&
rect
,
const
double
*
xs
,
DrawWhat
what
,
size_t
start
,
size_t
end
)
const
{
void
FontTextElement
::
draw
(
RotatedDC
&
dc
,
double
scale
,
const
RealRect
&
rect
,
const
double
*
xs
,
DrawWhat
what
,
size_t
start
,
size_t
end
)
const
{
if
((
what
&
draw_as
)
!=
draw_as
)
return
;
// don't draw
dc
.
SetFont
(
font
->
font
,
font
->
size
*
scale
);
dc
.
SetFont
(
font
->
font
,
font
->
size
*
scale
);
if
(
end
!=
start
&&
text
.
substr
(
end
-
1
,
1
)
==
_
(
"
\n
"
))
end
-=
1
;
// don't draw the newline character at the end
if
(
end
!=
start
&&
text
.
substr
(
end
-
1
,
1
)
==
_
(
"
\n
"
))
end
-=
1
;
// don't draw the newline character at the end
/* if ((draw & DRAW_NORMAL) != DRAW_NORMAL) {
if
(
draw_as
==
DRAW_ACTIVE
)
{
// don't draw
if (what == DRAW_ACTIVE) {
// we are drawing a separator
// we are drawing a separator
dc
.
SetTextForeground
(
font
->
separator_color
);
dc
.
SetTextForeground
(
font
->
separator_color
);
dc.DrawText(text.substr(start, end-start), rect.position);
dc
.
DrawText
(
text
.
substr
(
start
,
end
-
start
),
rect
.
position
());
}
}
else
{
} else {*/
// draw normally
// draw normally
// draw shadow
// draw shadow
if
(
font
->
hasShadow
())
{
if
(
font
->
hasShadow
())
{
...
@@ -32,7 +29,7 @@ void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, co
...
@@ -32,7 +29,7 @@ void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, co
// draw
// draw
dc
.
SetTextForeground
(
font
->
color
);
dc
.
SetTextForeground
(
font
->
color
);
dc
.
DrawText
(
text
.
substr
(
start
,
end
-
start
),
rect
.
position
());
dc
.
DrawText
(
text
.
substr
(
start
,
end
-
start
),
rect
.
position
());
//
}
}
}
}
void
FontTextElement
::
getCharInfo
(
RotatedDC
&
dc
,
double
scale
,
vector
<
CharInfo
>&
out
)
const
{
void
FontTextElement
::
getCharInfo
(
RotatedDC
&
dc
,
double
scale
,
vector
<
CharInfo
>&
out
)
const
{
...
@@ -52,5 +49,5 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>&
...
@@ -52,5 +49,5 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>&
}
}
double
FontTextElement
::
minScale
()
const
{
double
FontTextElement
::
minScale
()
const
{
return
1
;
// TODO
return
min
(
font
->
size
,
font
->
scale_down_to
)
/
max
(
0.01
,
font
->
size
);
}
}
src/render/text/symbol.cpp
View file @
d79c79bf
...
@@ -24,5 +24,5 @@ void SymbolTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo
...
@@ -24,5 +24,5 @@ void SymbolTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo
}
}
double
SymbolTextElement
::
minScale
()
const
{
double
SymbolTextElement
::
minScale
()
const
{
return
font
.
size
/
min
(
0.001
,
min
(
font
.
size
,
font
.
scale_down_to
)
);
return
min
(
font
.
size
,
font
.
scale_down_to
)
/
max
(
0.01
,
font
.
size
);
}
}
src/render/text/viewer.cpp
View file @
d79c79bf
...
@@ -304,11 +304,14 @@ void TextViewer::prepareElements(const String& text, const TextStyle& style, Con
...
@@ -304,11 +304,14 @@ void TextViewer::prepareElements(const String& text, const TextStyle& style, Con
// ----------------------------------------------------------------------------- : Layout
// ----------------------------------------------------------------------------- : Layout
void
TextViewer
::
prepareLines
(
RotatedDC
&
dc
,
const
String
&
text
,
const
TextStyle
&
style
,
Context
&
ctx
)
{
void
TextViewer
::
prepareLines
(
RotatedDC
&
dc
,
const
String
&
text
,
const
TextStyle
&
style
,
Context
&
ctx
)
{
scale
=
1
;
// find character sizes
// find character sizes
vector
<
CharInfo
>
chars
;
vector
<
CharInfo
>
chars
;
// try to layout, at different scales
scale
=
1
;
// double min_scale = elements.minScale();
// while
chars
.
clear
();
elements
.
getCharInfo
(
dc
,
scale
,
0
,
text
.
size
(),
chars
);
elements
.
getCharInfo
(
dc
,
scale
,
0
,
text
.
size
(),
chars
);
// try to layout
prepareLinesScale
(
dc
,
chars
,
style
,
false
);
prepareLinesScale
(
dc
,
chars
,
style
,
false
);
// no text, find a dummy height for the single line we have
// no text, find a dummy height for the single line we have
if
(
lines
.
size
()
==
1
&&
lines
[
0
].
width
()
<
0.0001
)
{
if
(
lines
.
size
()
==
1
&&
lines
[
0
].
width
()
<
0.0001
)
{
...
@@ -321,6 +324,13 @@ void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle
...
@@ -321,6 +324,13 @@ void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle
}
}
// align
// align
alignLines
(
dc
,
chars
,
style
);
alignLines
(
dc
,
chars
,
style
);
// HACK : fix empty first line before <line>, do this after align, so layout is not affected
if
(
lines
.
size
()
>
1
&&
lines
[
0
].
line_height
==
0
)
{
dc
.
SetFont
(
style
.
font
.
font
);
double
h
=
dc
.
GetCharHeight
();
lines
[
0
].
line_height
=
h
;
lines
[
0
].
top
-=
h
;
}
}
}
bool
TextViewer
::
prepareLinesScale
(
RotatedDC
&
dc
,
const
vector
<
CharInfo
>&
chars
,
const
TextStyle
&
style
,
bool
stop_if_too_long
)
{
bool
TextViewer
::
prepareLinesScale
(
RotatedDC
&
dc
,
const
vector
<
CharInfo
>&
chars
,
const
TextStyle
&
style
,
bool
stop_if_too_long
)
{
...
...
src/util/tagged_string.cpp
View file @
d79c79bf
...
@@ -33,6 +33,10 @@ String untag_no_escape(const String& str) {
...
@@ -33,6 +33,10 @@ String untag_no_escape(const String& str) {
return
ret
;
return
ret
;
}
}
String
untag_hide_sep
(
const
String
&
str
)
{
return
untag
(
remove_tag_contents
(
str
,
_
(
"<sep-soft"
)));
}
String
escape
(
const
String
&
str
)
{
String
escape
(
const
String
&
str
)
{
String
ret
;
ret
.
reserve
(
str
.
size
());
String
ret
;
ret
.
reserve
(
str
.
size
());
FOR_EACH_CONST
(
c
,
str
)
{
FOR_EACH_CONST
(
c
,
str
)
{
...
...
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