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

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