File: osd.h

package info (click to toggle)
mupen64plus-core 2.5-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,776 kB
  • ctags: 7,778
  • sloc: ansic: 59,320; asm: 1,994; cpp: 1,823; python: 619; makefile: 600; sh: 311
file content (144 lines) | stat: -rw-r--r-- 4,812 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *   Mupen64plus - osd.h                                                   *
 *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
 *   Copyright (C) 2008 Nmn, Ebenblues                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef __OSD_H__
#define __OSD_H__

#include "main/list.h"
#include "osal/preproc.h"

/******************************************************************
   osd_corner
   0    1    2 |
    \ __|__/   | Offset always effects the same:
     |     |   |  +X = Leftward   +Y = Upward
   3-|  4  |-5 |  With no offset, the text will touch the border.
     |_____|   |
    /   |   \  |
   6    7    8 |
*******************************************************************/
enum osd_corner {
    OSD_TOP_LEFT,       // 0 in the picture above
    OSD_TOP_CENTER,     // 1 in the picture above
    OSD_TOP_RIGHT,      // 2 in the picture above

    OSD_MIDDLE_LEFT,    // 3 in the picture above
    OSD_MIDDLE_CENTER,  // 4 in the picture above
    OSD_MIDDLE_RIGHT,   // 5 in the picture above

    OSD_BOTTOM_LEFT,    // 6 in the picture above
    OSD_BOTTOM_CENTER,  // 7 in the picture above
    OSD_BOTTOM_RIGHT,   // 8 in the picture above

    OSD_NUM_CORNERS
};

enum osd_message_state {
    OSD_APPEAR,     // OSD message is appearing on the screen
    OSD_DISPLAY,    // OSD message is being displayed on the screen
    OSD_DISAPPEAR,  // OSD message is disappearing from the screen

    OSD_NUM_STATES
};

enum osd_animation_type {
    OSD_NONE,
    OSD_FADE,

    OSD_NUM_ANIM_TYPES
};

typedef struct {
    char *text;        // Text that this object will have when displayed
    enum osd_corner corner; // One of the 9 corners
    float xoffset;     // Relative X position
    float yoffset;     // Relative Y position
    float color[3];    // Red, Green, Blue values
    float sizebox[4];  // bounding box (xmin, ymin, xmax, ymax)
    int state;         // display state of current message
    enum osd_animation_type animation[OSD_NUM_STATES]; // animations for each display state
    unsigned int timeout[OSD_NUM_STATES]; // timeouts for each display state
#define OSD_INFINITE_TIMEOUT 0xffffffff
    unsigned int frames; // number of frames in this state
    int user_managed; // structure managed by caller and not to be freed by us
    struct list_head list;
} osd_message_t;

enum { R, G, B }; // for referencing color array

#ifdef __cplusplus
extern "C" {
#endif

#ifdef M64P_OSD

void osd_init(int width, int height);
void osd_exit(void);
void osd_render(void);
osd_message_t * osd_new_message(enum osd_corner, const char *, ...) __attribute__ ((format (printf, 2, 3)));
void osd_update_message(osd_message_t *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
void osd_delete_message(osd_message_t *);
void osd_message_set_static(osd_message_t *);
void osd_message_set_user_managed(osd_message_t *);

#else

static osal_inline void osd_init(int width, int height)
{
}

static osal_inline void osd_exit(void)
{
}

static osal_inline void osd_render(void)
{
}

static osal_inline osd_message_t * osd_new_message(enum osd_corner eCorner, const char *fmt, ...)
{
	return NULL;
}

static osal_inline void osd_update_message(osd_message_t *msg, const char *fmt, ...)
{
}

static osal_inline void osd_delete_message(osd_message_t *msg)
{
}

static osal_inline void osd_message_set_static(osd_message_t *msg)
{
}

static osal_inline void osd_message_set_user_managed(osd_message_t *msg)
{
}

#endif

#ifdef __cplusplus
}
#endif

#endif // __OSD_H__