AxWin2 - Huge changes, getting to the working point
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / common.h
1 /*
2  * Acess GUI (AxWin) Version 2
3  * By John Hodge (thePowersGang)
4  */
5 #ifndef _COMMON_H_
6 #define _COMMON_H_
7
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <acess/sys.h>  // _SysDebug
12
13 typedef void tMessages_Handle_Callback(void*, size_t, void*);
14 typedef struct sFont    tFont;
15
16 #include "wm.h"
17 #include "image.h"
18 //#include "font.h"
19
20 // === MACROS ===
21 static inline uint32_t Video_AlphaBlend(uint32_t _orig, uint32_t _new, uint8_t _alpha)
22 {
23         uint16_t        ao,ro,go,bo;
24         uint16_t        an,rn,gn,bn;
25         if( _alpha == 0 )       return _orig;
26         if( _alpha == 255 )     return _new;
27         
28         ao = (_orig >> 24) & 0xFF;
29         ro = (_orig >> 16) & 0xFF;
30         go = (_orig >>  8) & 0xFF;
31         bo = (_orig >>  0) & 0xFF;
32         
33         an = (_new >> 24) & 0xFF;
34         rn = (_new >> 16) & 0xFF;
35         gn = (_new >>  8) & 0xFF;
36         bn = (_new >>  0) & 0xFF;
37
38         if( _alpha == 0x80 ) {
39                 ao = (ao + an) / 2;
40                 ro = (ro + rn) / 2;
41                 go = (go + gn) / 2;
42                 bo = (bo + bn) / 2;
43         }
44         else {
45                 ao = ao*(255-_alpha) + an*_alpha;
46                 ro = ro*(255-_alpha) + rn*_alpha;
47                 go = go*(255-_alpha) + gn*_alpha;
48                 bo = bo*(255-_alpha) + bn*_alpha;
49                 ao /= 255*2;
50                 ro /= 255*2;
51                 go /= 255*2;
52                 bo /= 255*2;
53         }
54
55         return (ao << 24) | (ro << 16) | (go << 8) | bo;
56 }
57
58 // === GLOBALS ===
59 extern const char       *gsTerminalDevice;
60 extern const char       *gsMouseDevice;
61
62 extern int      giScreenWidth;
63 extern int      giScreenHeight;
64 extern uint32_t *gpScreenBuffer;
65
66 extern int      giTerminalFD;
67 extern int      giMouseFD;
68
69 // === Functions ===
70 extern void     memset32(void *ptr, uint32_t val, size_t count);
71 // --- Initialisation ---
72 extern void     ParseCommandline(int argc, char *argv[]);
73 extern void     IPC_Init(void);
74 extern void     IPC_FillSelect(int *nfds, fd_set *set);
75 extern void     IPC_HandleSelect(fd_set *set);
76 extern void     Input_FillSelect(int *nfds, fd_set *set);
77 extern void     Input_HandleSelect(fd_set *set);
78 // --- Video ---
79 extern void     Video_Setup(void);
80 extern void     Video_Update(void);
81 extern void     Video_FillRect(short X, short Y, short W, short H, uint32_t Color);
82 extern void     Video_DrawRect(short X, short Y, short W, short H, uint32_t Color);
83 extern int      Video_DrawText(short X, short Y, short W, short H, tFont *Font, uint32_t Color, char *Text);
84 extern void     Video_DrawImage(short X, short Y, short W, short H, tImage *Image);
85 // --- Interface ---
86 extern void     Interface_Init(void);
87 extern void     Interface_Update(void);
88 extern void     Interface_Render(void);
89 // --- Decorator ---
90 extern void     Decorator_RenderWidget(tElement *Element);
91
92 #endif

UCC git Repository :: git.ucc.asn.au