1/* Copyright (C) 2007-2008 The Android Open Source Project
2**
3** This software is licensed under the terms of the GNU General Public
4** License version 2, as published by the Free Software Foundation, and
5** may be copied, distributed, and modified under those terms.
6**
7** This program is distributed in the hope that it will be useful,
8** but WITHOUT ANY WARRANTY; without even the implied warranty of
9** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10** GNU General Public License for more details.
11*/
12#ifndef _ANDROID_SKIN_RECT_H
13#define _ANDROID_SKIN_RECT_H
14
15/**  Rectangles
16 **/
17
18typedef enum {
19    SKIN_ROTATION_0,
20    SKIN_ROTATION_90,
21    SKIN_ROTATION_180,
22    SKIN_ROTATION_270
23} SkinRotation;
24
25typedef struct {
26    int  x, y;
27} SkinPos;
28
29extern void  skin_pos_rotate( SkinPos*  dst, SkinPos*  src, SkinRotation  rot );
30
31typedef struct {
32    int  w, h;
33} SkinSize;
34
35extern void skin_size_rotate( SkinSize*  dst, SkinSize*  src, SkinRotation  rot );
36extern int  skin_size_contains( SkinSize*  size, int  x, int  y );
37
38
39typedef struct {
40    SkinPos   pos;
41    SkinSize  size;
42} SkinRect;
43
44extern void  skin_rect_init     ( SkinRect*  r, int x, int y, int  w, int  h );
45extern void  skin_rect_translate( SkinRect*  r, int  dx, int dy );
46extern void  skin_rect_rotate   ( SkinRect*  dst, SkinRect*  src, SkinRotation  rotation );
47extern int   skin_rect_contains ( SkinRect*  r, int  x, int  y );
48extern int   skin_rect_intersect( SkinRect*  result, SkinRect*  r1, SkinRect*  r2 );
49extern int   skin_rect_equals   ( SkinRect*  r1, SkinRect*  r2 );
50
51typedef enum {
52    SKIN_OUTSIDE = 0,
53    SKIN_INSIDE  = 1,
54    SKIN_OVERLAP = 2
55} SkinOverlap;
56
57extern SkinOverlap  skin_rect_contains_rect( SkinRect  *r1, SkinRect  *r2 );
58
59typedef struct {
60    int  x1, y1;
61    int  x2, y2;
62} SkinBox;
63
64extern void  skin_box_init( SkinBox*  box, int x1, int  y1, int  x2, int  y2 );
65extern void  skin_box_minmax_init( SkinBox*  box );
66extern void  skin_box_minmax_update( SkinBox*  box, SkinRect*  rect );
67extern int   skin_box_minmax_to_rect( SkinBox*  box, SkinRect*  rect );
68extern void  skin_box_from_rect( SkinBox*  box, SkinRect*  rect );
69extern void  skin_box_to_rect( SkinBox*  box, SkinRect*  rect );
70
71#endif /* _ANDROID_SKIN_RECT_H */
72