Usermode - Better separation of types and calls in sys.h
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / interface.c
1 /*
2  * Acess GUI (AxWin) Version 2
3  * By John Hodge (thePowersGang)
4  * 
5  * interface.c
6  * > Main Overarching UI
7  */
8 #include "common.h"
9 #include "resources/LogoSmall.sif.res.h"
10
11 // === GLOBALS ==
12  int    giInterface_Width = 0;
13  int    giInterface_HeaderBarSize = 20;
14  int    giInterface_TabBarSize = 20;
15 tElement        *gpInterface_Sidebar;
16 tElement        *gpInterface_ProgramList;
17 tElement        *gpInterface_MainArea;
18 tElement        *gpInterface_HeaderBar;
19 tElement        *gpInterface_TabBar;
20 tElement        *gpInterface_TabContent;
21 const char      csLogoSmall[] = "base64:///"RESOURCE_LogoSmall_sif;
22
23 // === CODE ===
24 /**
25  * \brief Initialise the UI
26  */
27 void Interface_Init(void)
28 {
29         tElement        *btn, *text;
30         tElement        *ele;
31
32         // Calculate sizes
33         giInterface_Width = giScreenWidth/16;
34         
35         // Set root window to no-border
36         WM_SetFlags(NULL, 0);
37         
38         // -- Create Sidebar --
39         gpInterface_Sidebar = WM_CreateElement(NULL, ELETYPE_TOOLBAR, ELEFLAG_VERTICAL, "Sidebar");
40         WM_SetSize( gpInterface_Sidebar, giInterface_Width );
41         
42         // > System Menu Button
43         btn = WM_CreateElement(gpInterface_Sidebar, ELETYPE_BUTTON, ELEFLAG_NOSTRETCH, "SystemMenu");
44         WM_SetSize(btn, giInterface_Width-4);
45         // TODO: Once image loading is implemented, switch to a logo
46         #if 1
47         //text = WM_CreateElement(btn, ELETYPE_IMAGE, ELEFLAG_SCALE);
48         text = WM_CreateElement(btn, ELETYPE_IMAGE, 0, "MenuLogo");
49         //WM_SetText(text, "file:///LogoSmall.sif");
50         WM_SetText(text, csLogoSmall);
51         #else
52         text = WM_CreateElement(btn, ELETYPE_TEXT, 0, NULL);
53         WM_SetText(text, "Acess");
54         #endif
55         // > Plain <hr/> style spacer
56         ele = WM_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Top");
57         WM_SetSize(ele, 4);
58         // > Application List
59         gpInterface_ProgramList = WM_CreateElement(gpInterface_Sidebar, ELETYPE_BOX, ELEFLAG_VERTICAL, "ProgramList");
60         // > Plain <hr/> style spacer
61         ele = WM_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, ELEFLAG_NOSTRETCH, "SideBar Spacer Bottom");
62         WM_SetSize(ele, 4);
63         // > Version/Time
64         text = WM_CreateElement(gpInterface_Sidebar, ELETYPE_TEXT, ELEFLAG_NOSTRETCH, "Version String");
65         WM_SetSize(text, 20);
66         WM_SetText(text, "2.0");
67         
68         // --
69         // -- Create Main Area and regions within --
70         // --
71         // > Righthand Area
72         gpInterface_MainArea = WM_CreateElement(NULL, ELETYPE_BOX, ELEFLAG_VERTICAL, "MainArea");
73         //  > Header Bar (Title)
74         gpInterface_HeaderBar = WM_CreateElement(gpInterface_MainArea, ELETYPE_BOX, 0, "HeaderBar");
75         WM_SetSize(gpInterface_HeaderBar, giInterface_HeaderBarSize);
76         text = WM_CreateElement(gpInterface_HeaderBar, ELETYPE_TEXT, 0, NULL);
77         WM_SetText(text, "Acess2 GUI - By thePowersGang (John Hodge)");
78         //  > Tab Bar (Current windows)
79         gpInterface_TabBar = WM_CreateElement(gpInterface_MainArea, ELETYPE_TABBAR, 0, "TabBar");
80         WM_SetSize(gpInterface_TabBar, giInterface_TabBarSize);
81         //  > Application Space
82         gpInterface_TabContent = WM_CreateElement(gpInterface_MainArea, ELETYPE_BOX, 0, "TabContent");
83 }
84
85 void Interface_Update(void)
86 {
87         giInterface_Width = giScreenWidth/16;
88         WM_SetSize( gpInterface_Sidebar, giInterface_Width );
89 }
90
91 void Interface_Render(void)
92 {
93         
94         Video_FillRect(
95                 0, 0,
96                 giInterface_Width, giScreenHeight,
97                 0xDDDDDD);
98         
99         Video_Update();
100 }

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