[vlc-devel] [vlc-commits] text_style: add style members presence flags

Rémi Denis-Courmont remi at remlab.net
Thu Aug 13 15:30:23 CEST 2015


I dunno. We typically define error values for this rather than a bit mask. For float, there is also NaN.

-- 
Rémi Denis-Courmont
Sent from my NVIDIA Tegra-powered device

----- Reply message -----
De : git at videolan.org (Francois Cartegnie)
Pour : <vlc-commits at videolan.org>
Objet : [vlc-commits] text_style: add style members presence flags
Date : jeu., août 13, 2015 16:24

vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Aug  8 22:50:03 2015 +0200| [acd27a20649e71664569c44aad2cbe107cf978a9] | committer: Francois Cartegnie

text_style: add style members presence flags

because you can't tell if members are
have set value or are unset.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=acd27a20649e71664569c44aad2cbe107cf978a9
---

include/vlc_text_style.h |   43 +++++++++++++++++++++++++++++++------------
src/misc/text_style.c    |    4 +++-
2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/include/vlc_text_style.h b/include/vlc_text_style.h
index d0be49c..e0d53db 100644
--- a/include/vlc_text_style.h
+++ b/include/vlc_text_style.h
@@ -42,14 +42,17 @@ typedef struct
char *     psz_fontname;      /**< The name of the font */
char *     psz_monofontname;  /**< The name of the mono font */

+    uint16_t   i_features;        /**< Feature flags (means non default) */
+    uint16_t   i_style_flags;     /**< Formatting style flags */
+
/* Font style */
+    float      f_font_relsize;    /**< The font size in % */
int        i_font_size;       /**< The font size in pixels */
int        i_font_color;      /**< The color of the text 0xRRGGBB
(native endianness) */
uint8_t    i_font_alpha;      /**< The transparency of the text.
0x00 is fully opaque,
0xFF fully transparent */
-    uint16_t   i_style_flags;     /**< Formatting style flags */
int        i_spacing;         /**< The spaceing between glyphs in pixels */

/* Outline */
@@ -77,18 +80,34 @@ typedef struct
0xFF fully transparent */
} text_style_t;

+/* Features flags for \ref i_features */
+#define STYLE_NO_DEFAULTS               0x0
+#define STYLE_FULLY_SET                 0xFFFF
+#define STYLE_HAS_FONT_COLOR            (1 << 0)
+#define STYLE_HAS_FONT_ALPHA            (1 << 1)
+#define STYLE_HAS_FLAGS                 (1 << 2)
+#define STYLE_HAS_OUTLINE_COLOR         (1 << 3)
+#define STYLE_HAS_OUTLINE_ALPHA         (1 << 4)
+#define STYLE_HAS_SHADOW_COLOR          (1 << 5)
+#define STYLE_HAS_SHADOW_ALPHA          (1 << 6)
+#define STYLE_HAS_BACKGROUND_COLOR      (1 << 7)
+#define STYLE_HAS_BACKGROUND_ALPHA      (1 << 8)
+#define STYLE_HAS_K_BACKGROUND_COLOR    (1 << 9)
+#define STYLE_HAS_K_BACKGROUND_ALPHA    (1 << 10)
+
/* Style flags for \ref text_style_t */
-#define STYLE_BOLD        1
-#define STYLE_ITALIC      2
-#define STYLE_OUTLINE     4
-#define STYLE_SHADOW      8
-#define STYLE_BACKGROUND  16
-#define STYLE_UNDERLINE   32
-#define STYLE_STRIKEOUT   64
-#define STYLE_HALFWIDTH   128
-#define STYLE_MONOSPACED  256
-
-#define STYLE_DEFAULT_FONT_SIZE 22
+#define STYLE_BOLD              (1 << 0)
+#define STYLE_ITALIC            (1 << 1)
+#define STYLE_OUTLINE           (1 << 2)
+#define STYLE_SHADOW            (1 << 3)
+#define STYLE_BACKGROUND        (1 << 4)
+#define STYLE_UNDERLINE         (1 << 5)
+#define STYLE_STRIKEOUT         (1 << 6)
+#define STYLE_HALFWIDTH         (1 << 7)
+#define STYLE_MONOSPACED        (1 << 8)
+
+#define STYLE_DEFAULT_FONT_SIZE 20
+#define STYLE_DEFAULT_REL_FONT_SIZE 5.0


typedef struct text_segment_t text_segment_t;
diff --git a/src/misc/text_style.c b/src/misc/text_style.c
index 82c9640..793c0a9 100644
--- a/src/misc/text_style.c
+++ b/src/misc/text_style.c
@@ -38,10 +38,12 @@ text_style_t *text_style_New( void )
/* initialize to default text style */
p_style->psz_fontname = NULL;
p_style->psz_monofontname = NULL;
+    p_style->i_features = STYLE_FULLY_SET;
+    p_style->i_style_flags = STYLE_OUTLINE;
+    p_style->f_font_relsize = STYLE_DEFAULT_REL_FONT_SIZE;
p_style->i_font_size = STYLE_DEFAULT_FONT_SIZE;
p_style->i_font_color = 0xffffff;
p_style->i_font_alpha = 0xff;
-    p_style->i_style_flags = STYLE_OUTLINE;
p_style->i_outline_color = 0x000000;
p_style->i_outline_alpha = 0xff;
p_style->i_shadow_color = 0x000000;

_______________________________________________
vlc-commits mailing list
vlc-commits at videolan.org
https://mailman.videolan.org/listinfo/vlc-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150813/e715cebc/attachment.html>


More information about the vlc-devel mailing list