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
62b3335a
Commit
62b3335a
authored
Apr 12, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented ContourMask (mask for text fields)
parent
df18ac67
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
71 additions
and
10 deletions
+71
-10
data/vs-standard.mse-style/text-mask.png
data/vs-standard.mse-style/text-mask.png
+0
-0
src/gfx/gfx.hpp
src/gfx/gfx.hpp
+5
-3
src/gfx/mask_image.cpp
src/gfx/mask_image.cpp
+50
-0
src/render/text/viewer.cpp
src/render/text/viewer.cpp
+7
-7
src/render/value/text.cpp
src/render/value/text.cpp
+9
-0
No files found.
data/vs-standard.mse-style/text-mask.png
View replaced file @
df18ac67
View file @
62b3335a
290 Bytes
|
W:
|
H:
386 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
src/gfx/gfx.hpp
View file @
62b3335a
...
@@ -155,9 +155,11 @@ class ContourMask {
...
@@ -155,9 +155,11 @@ class ContourMask {
~
ContourMask
();
~
ContourMask
();
/// Load a contour mask
/// Load a contour mask
void
load
(
const
String
&
filenam
e
);
void
load
(
const
Image
&
imag
e
);
/// Unload the mask
/// Unload the mask
void
unload
();
void
unload
();
/// Is a mask loaded?
inline
bool
ok
()
const
{
return
width
>
0
&&
height
>
0
;
}
/// Returns the start of a row, when the mask were stretched to size
/// Returns the start of a row, when the mask were stretched to size
double
rowLeft
(
double
y
,
RealSize
size
)
const
;
double
rowLeft
(
double
y
,
RealSize
size
)
const
;
...
@@ -165,8 +167,8 @@ class ContourMask {
...
@@ -165,8 +167,8 @@ class ContourMask {
double
rowRight
(
double
y
,
RealSize
size
)
const
;
double
rowRight
(
double
y
,
RealSize
size
)
const
;
private:
private:
UI
nt
width
,
height
;
i
nt
width
,
height
;
UI
nt
*
lefts
,
*
rights
;
i
nt
*
lefts
,
*
rights
;
};
};
// ----------------------------------------------------------------------------- : Color utility functions
// ----------------------------------------------------------------------------- : Color utility functions
...
...
src/gfx/mask_image.cpp
View file @
62b3335a
...
@@ -49,3 +49,53 @@ bool AlphaMask::isTransparent(int x, int y) const {
...
@@ -49,3 +49,53 @@ bool AlphaMask::isTransparent(int x, int y) const {
}
}
// ----------------------------------------------------------------------------- : ContourMask
// ----------------------------------------------------------------------------- : ContourMask
ContourMask
::
ContourMask
()
:
width
(
0
),
height
(
0
),
lefts
(
nullptr
),
rights
(
nullptr
)
{}
ContourMask
::~
ContourMask
()
{
unload
();
}
void
ContourMask
::
load
(
const
Image
&
image
)
{
unload
();
width
=
image
.
GetWidth
();
height
=
image
.
GetHeight
();
lefts
=
new
int
[
height
];
rights
=
new
int
[
height
];
// for each row: determine left and rightmost white pixel
Byte
*
data
=
image
.
GetData
();
for
(
int
y
=
0
;
y
<
height
;
++
y
)
{
lefts
[
y
]
=
width
;
rights
[
y
]
=
width
;
for
(
int
x
=
0
;
x
<
width
;
++
x
)
{
int
v
=
data
[
0
]
+
data
[
1
]
+
data
[
2
];
if
(
v
>
50
)
{
// white enough
rights
[
y
]
=
x
;
if
(
x
<
lefts
[
y
])
lefts
[
y
]
=
x
;
}
data
+=
3
;
}
}
}
void
ContourMask
::
unload
()
{
delete
lefts
;
delete
rights
;
lefts
=
rights
=
nullptr
;
width
=
height
=
0
;
}
double
ContourMask
::
rowLeft
(
double
y
,
RealSize
size
)
const
{
if
(
!
ok
()
||
y
<
0
||
y
>=
size
.
height
)
{
// no mask, or outside it
return
0
;
}
return
lefts
[(
int
)(
y
*
size
.
height
/
height
)]
*
size
.
width
/
width
;
}
double
ContourMask
::
rowRight
(
double
y
,
RealSize
size
)
const
{
if
(
!
ok
()
||
y
<
0
||
y
>=
size
.
height
)
{
// no mask, or outside it
return
size
.
width
;
}
return
rights
[(
int
)(
y
*
size
.
height
/
height
)]
*
size
.
width
/
width
;
}
src/render/text/viewer.cpp
View file @
62b3335a
...
@@ -468,6 +468,11 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars,
...
@@ -468,6 +468,11 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars,
line
.
separator_after
=
false
;
line
.
separator_after
=
false
;
// reset line_size
// reset line_size
line_size
=
RealSize
(
lineLeft
(
dc
,
style
,
line
.
top
),
0
);
line_size
=
RealSize
(
lineLeft
(
dc
,
style
,
line
.
top
),
0
);
while
(
line
.
top
<
style
.
height
&&
line_size
.
width
+
1
>=
style
.
width
-
style
.
padding_right
)
{
// nothing fits on this line, move down one pixel
line
.
top
+=
1
;
line_size
=
RealSize
(
lineLeft
(
dc
,
style
,
line
.
top
),
0
);
}
line
.
positions
.
push_back
(
line_size
.
width
);
// start position
line
.
positions
.
push_back
(
line_size
.
width
);
// start position
}
}
}
}
...
@@ -487,17 +492,12 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars,
...
@@ -487,17 +492,12 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars,
}
}
double
TextViewer
::
lineLeft
(
RotatedDC
&
dc
,
const
TextStyle
&
style
,
double
y
)
{
double
TextViewer
::
lineLeft
(
RotatedDC
&
dc
,
const
TextStyle
&
style
,
double
y
)
{
return
0
+
style
.
padding_left
;
return
style
.
mask
.
rowLeft
(
y
,
dc
.
getInternalSize
())
+
style
.
padding_left
;
// return style.mask.rowLeft(y, dc.getInternalSize()) + style.padding_left;
}
}
double
TextViewer
::
lineRight
(
RotatedDC
&
dc
,
const
TextStyle
&
style
,
double
y
)
{
double
TextViewer
::
lineRight
(
RotatedDC
&
dc
,
const
TextStyle
&
style
,
double
y
)
{
return
style
.
width
-
style
.
padding_right
;
return
style
.
mask
.
rowRight
(
y
,
dc
.
getInternalSize
())
-
style
.
padding_right
;
// return style.mask.rowRight(y, dc.getInternalSize()) - style.padding_right;
}
}
ContourMask
::
ContourMask
()
{}
// MOVEME //@@
ContourMask
::~
ContourMask
()
{}
void
TextViewer
::
alignLines
(
RotatedDC
&
dc
,
const
vector
<
CharInfo
>&
chars
,
const
TextStyle
&
style
)
{
void
TextViewer
::
alignLines
(
RotatedDC
&
dc
,
const
vector
<
CharInfo
>&
chars
,
const
TextStyle
&
style
)
{
if
(
style
.
alignment
==
ALIGN_TOP_LEFT
)
return
;
if
(
style
.
alignment
==
ALIGN_TOP_LEFT
)
return
;
// Find height of the text, don't count the last lines if they are empty
// Find height of the text, don't count the last lines if they are empty
...
...
src/render/value/text.cpp
View file @
62b3335a
...
@@ -8,10 +8,19 @@
...
@@ -8,10 +8,19 @@
#include <render/value/text.hpp>
#include <render/value/text.hpp>
#include <render/card/viewer.hpp>
#include <render/card/viewer.hpp>
#include <data/stylesheet.hpp>
// ----------------------------------------------------------------------------- : TextValueViewer
// ----------------------------------------------------------------------------- : TextValueViewer
void
TextValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
TextValueViewer
::
draw
(
RotatedDC
&
dc
)
{
if
(
!
style
().
mask_filename
.
empty
()
&&
!
style
().
mask
.
ok
())
{
// load contour mask
Image
image
;
InputStreamP
image_file
=
viewer
.
stylesheet
->
openIn
(
style
().
mask_filename
);
if
(
image
.
LoadFile
(
*
image_file
))
{
style
().
mask
.
load
(
image
);
}
}
drawFieldBorder
(
dc
);
drawFieldBorder
(
dc
);
v
.
prepare
(
dc
,
value
().
value
(),
style
(),
viewer
.
getContext
());
v
.
prepare
(
dc
,
value
().
value
(),
style
(),
viewer
.
getContext
());
v
.
draw
(
dc
,
style
(),
(
DrawWhat
)(
v
.
draw
(
dc
,
style
(),
(
DrawWhat
)(
...
...
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