• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 typedef enum {
19     SKIN_ROTATION_0,
20     SKIN_ROTATION_90,
21     SKIN_ROTATION_180,
22     SKIN_ROTATION_270
23 } SkinRotation;
24 
25 typedef struct {
26     int  x, y;
27 } SkinPos;
28 
29 extern void  skin_pos_rotate( SkinPos*  dst, SkinPos*  src, SkinRotation  rot );
30 
31 typedef struct {
32     int  w, h;
33 } SkinSize;
34 
35 extern void skin_size_rotate( SkinSize*  dst, SkinSize*  src, SkinRotation  rot );
36 extern int  skin_size_contains( SkinSize*  size, int  x, int  y );
37 
38 
39 typedef struct {
40     SkinPos   pos;
41     SkinSize  size;
42 } SkinRect;
43 
44 extern void  skin_rect_init     ( SkinRect*  r, int x, int y, int  w, int  h );
45 extern void  skin_rect_translate( SkinRect*  r, int  dx, int dy );
46 extern void  skin_rect_rotate   ( SkinRect*  dst, SkinRect*  src, SkinRotation  rotation );
47 extern int   skin_rect_contains ( SkinRect*  r, int  x, int  y );
48 extern int   skin_rect_intersect( SkinRect*  result, SkinRect*  r1, SkinRect*  r2 );
49 extern int   skin_rect_equals   ( SkinRect*  r1, SkinRect*  r2 );
50 
51 typedef enum {
52     SKIN_OUTSIDE = 0,
53     SKIN_INSIDE  = 1,
54     SKIN_OVERLAP = 2
55 } SkinOverlap;
56 
57 extern SkinOverlap  skin_rect_contains_rect( SkinRect  *r1, SkinRect  *r2 );
58 
59 typedef struct {
60     int  x1, y1;
61     int  x2, y2;
62 } SkinBox;
63 
64 extern void  skin_box_init( SkinBox*  box, int x1, int  y1, int  x2, int  y2 );
65 extern void  skin_box_minmax_init( SkinBox*  box );
66 extern void  skin_box_minmax_update( SkinBox*  box, SkinRect*  rect );
67 extern int   skin_box_minmax_to_rect( SkinBox*  box, SkinRect*  rect );
68 extern void  skin_box_from_rect( SkinBox*  box, SkinRect*  rect );
69 extern void  skin_box_to_rect( SkinBox*  box, SkinRect*  rect );
70 
71 #endif /* _ANDROID_SKIN_RECT_H */
72