aboutsummaryrefslogtreecommitdiffstats
path: root/android/skin/file.h
blob: 21922e6a0a0c80f43ba0a4fb21402bab99548a88 (plain)
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
/* Copyright (C) 2007-2008 The Android Open Source Project
**
** This software is licensed under the terms of the GNU General Public
** License version 2, as published by the Free Software Foundation, and
** may be copied, distributed, and modified under those terms.
**
** 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.
*/
#ifndef _ANDROID_SKIN_FILE_H
#define _ANDROID_SKIN_FILE_H

#include "android/skin/image.h"
#include "android/config.h"
#include "android/framebuffer.h"

/**  Layout
 **/

typedef struct SkinBackground {
    SkinImage*  image;
    SkinRect    rect;
    char        valid;
} SkinBackground;

typedef struct SkinDisplay {
    SkinRect      rect;      /* display rectangle    */
    SkinRotation  rotation;  /* framebuffer rotation */
    int           bpp;       /* bits per pixel, 32 or 16 */
    char          valid;
    QFrameBuffer  qfbuff[1];
} SkinDisplay;

typedef struct SkinButton {
    struct SkinButton*  next;
    const char*         name;
    SkinImage*          image;
    SkinRect            rect;
    unsigned            keycode;
} SkinButton;

typedef struct SkinPart {
    struct SkinPart*   next;
    const char*        name;
    SkinBackground     background[1];
    SkinDisplay        display[1];
    SkinButton*        buttons;
    SkinRect           rect;    /* bounding box of all parts */
} SkinPart;

#define  SKIN_PART_LOOP_BUTTONS(part,button)              \
    do {                                                  \
        SkinButton*  __button = (part)->buttons;          \
        while (__button != NULL) {                        \
            SkinButton*  __button_next = __button->next;  \
            SkinButton*  button        = __button;

#define   SKIN_PART_LOOP_END             \
            __button = __button_next;    \
        }                                \
    } while (0);

typedef struct SkinLocation {
    SkinPart*             part;
    SkinPos               anchor;
    SkinRotation          rotation;
    struct SkinLocation*  next;
} SkinLocation;

typedef struct SkinLayout {
    struct SkinLayout*  next;
    const char*         name;
    unsigned            color;
    int                 event_type;
    int                 event_code;
    int                 event_value;
    char                has_dpad_rotation;
    SkinRotation        dpad_rotation;
    SkinSize            size;
    SkinLocation*       locations;
} SkinLayout;

#define  SKIN_LAYOUT_LOOP_LOCS(layout,loc)               \
    do {                                                 \
        SkinLocation*  __loc = (layout)->locations;      \
        while (__loc != NULL) {                          \
            SkinLocation*  __loc_next = (__loc)->next;   \
            SkinLocation*  loc        = __loc;

#define  SKIN_LAYOUT_LOOP_END   \
            __loc = __loc_next; \
        }                       \
    } while (0);

extern SkinDisplay*   skin_layout_get_display( SkinLayout*  layout );

extern SkinRotation   skin_layout_get_dpad_rotation( SkinLayout*  layout );

typedef struct SkinFile {
    int             version;  /* 1, 2 or 3 */
    SkinPart*       parts;
    SkinLayout*     layouts;
    int             num_parts;
    int             num_layouts;
} SkinFile;

#define  SKIN_FILE_LOOP_LAYOUTS(file,layout)             \
    do {                                                 \
        SkinLayout*  __layout = (file)->layouts;         \
        while (__layout != NULL) {                       \
            SkinLayout*  __layout_next = __layout->next; \
            SkinLayout*  layout        = __layout;

#define  SKIN_FILE_LOOP_END_LAYOUTS       \
            __layout = __layout_next;     \
        }                                 \
    } while (0);

#define  SKIN_FILE_LOOP_PARTS(file,part)                 \
    do {                                                 \
        SkinPart*   __part = (file)->parts;              \
        while (__part != NULL) {                         \
            SkinPart*  __part_next = __part->next;       \
            SkinPart*  part        = __part;

#define  SKIN_FILE_LOOP_END_PARTS  \
            __part = __part_next;  \
        }                          \
    } while (0);

extern SkinFile*  skin_file_create_from_aconfig( AConfig*   aconfig, const char*  basepath );
extern void       skin_file_free( SkinFile*  file );

#endif /* _ANDROID_SKIN_FILE_H */