Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
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
videolan
vlc
Commits
e7e451fb
Commit
e7e451fb
authored
Aug 09, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
text_style: add text_style_Merge()
parent
acd27a20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
0 deletions
+71
-0
include/vlc_text_style.h
include/vlc_text_style.h
+22
-0
src/libvlccore.sym
src/libvlccore.sym
+1
-0
src/misc/text_style.c
src/misc/text_style.c
+48
-0
No files found.
include/vlc_text_style.h
View file @
e7e451fb
...
...
@@ -144,6 +144,28 @@ VLC_API text_style_t * text_style_Copy( text_style_t *, const text_style_t * );
*/
VLC_API
text_style_t
*
text_style_Duplicate
(
const
text_style_t
*
);
/**
* Merge two styles using non default values
*
* Set b_override to true if you also want to overwrite non-defaults
*/
VLC_API
void
text_style_Merge
(
text_style_t
*
,
const
text_style_t
*
,
bool
b_override
);
inline
void
text_style_Reset
(
text_style_t
*
p_style
)
{
free
(
p_style
->
psz_fontname
);
p_style
->
psz_fontname
=
NULL
;
free
(
p_style
->
psz_monofontname
);
p_style
->
psz_monofontname
=
NULL
;
p_style
->
i_features
=
STYLE_NO_DEFAULTS
;
p_style
->
i_style_flags
=
0
;
p_style
->
f_font_relsize
=
0
.
0
;
p_style
->
i_font_size
=
0
;
p_style
->
i_outline_width
=
0
;
p_style
->
i_shadow_width
=
0
;
p_style
->
i_spacing
=
-
0
;
}
/**
* Delete a text style created by text_style_New or text_style_Duplicate
*/
...
...
src/libvlccore.sym
View file @
e7e451fb
...
...
@@ -673,6 +673,7 @@ xml_Create
text_style_Copy
text_style_Delete
text_style_Duplicate
text_style_Merge
text_style_New
xml_Delete
xml_ReaderCreate
...
...
src/misc/text_style.c
View file @
e7e451fb
...
...
@@ -76,6 +76,54 @@ text_style_t *text_style_Copy( text_style_t *p_dst, const text_style_t *p_src )
return
p_dst
;
}
#define MERGE(var, fflag) \
if( (p_src->i_features & fflag) && (b_override || !(p_dst->i_features & fflag)) )\
p_dst->var = p_src->var
#define MERGE_SIZE(var) \
if( p_src->var > 0 && (b_override || p_dst->var <= 0) )\
p_dst->var = p_src->var
void
text_style_Merge
(
text_style_t
*
p_dst
,
const
text_style_t
*
p_src
,
bool
b_override
)
{
if
(
p_src
->
psz_fontname
&&
(
!
p_dst
->
psz_fontname
||
b_override
)
)
{
free
(
p_dst
->
psz_fontname
);
p_dst
->
psz_fontname
=
strdup
(
p_src
->
psz_fontname
);
}
if
(
p_src
->
psz_monofontname
&&
(
!
p_dst
->
psz_monofontname
||
b_override
)
)
{
free
(
p_dst
->
psz_monofontname
);
p_dst
->
psz_monofontname
=
strdup
(
p_src
->
psz_monofontname
);
}
if
(
p_src
->
i_features
!=
STYLE_NO_DEFAULTS
)
{
MERGE
(
i_font_color
,
STYLE_HAS_FONT_COLOR
);
MERGE
(
i_font_alpha
,
STYLE_HAS_FONT_ALPHA
);
MERGE
(
i_outline_color
,
STYLE_HAS_OUTLINE_COLOR
);
MERGE
(
i_outline_alpha
,
STYLE_HAS_OUTLINE_ALPHA
);
MERGE
(
i_shadow_color
,
STYLE_HAS_SHADOW_COLOR
);
MERGE
(
i_shadow_alpha
,
STYLE_HAS_SHADOW_ALPHA
);
MERGE
(
i_background_color
,
STYLE_HAS_BACKGROUND_COLOR
);
MERGE
(
i_background_alpha
,
STYLE_HAS_BACKGROUND_ALPHA
);
MERGE
(
i_karaoke_background_color
,
STYLE_HAS_K_BACKGROUND_COLOR
);
MERGE
(
i_karaoke_background_alpha
,
STYLE_HAS_K_BACKGROUND_ALPHA
);
p_dst
->
i_features
|=
p_src
->
i_features
;
p_dst
->
i_style_flags
|=
p_src
->
i_style_flags
;
}
MERGE_SIZE
(
f_font_relsize
);
MERGE_SIZE
(
i_font_size
);
MERGE_SIZE
(
i_outline_width
);
MERGE_SIZE
(
i_shadow_width
);
MERGE_SIZE
(
i_spacing
);
}
#undef MERGE
#undef MERGE_SIZE
text_style_t
*
text_style_Duplicate
(
const
text_style_t
*
p_src
)
{
if
(
!
p_src
)
...
...
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