More work on the GUI. Still useless tho
authorJohn Hodge <[email protected]>
Mon, 26 Apr 2010 01:14:12 +0000 (09:14 +0800)
committerJohn Hodge <[email protected]>
Mon, 26 Apr 2010 01:14:12 +0000 (09:14 +0800)
Usermode/Applications/axwin2_src/WM/Makefile
Usermode/Applications/axwin2_src/WM/interface.c
Usermode/Applications/axwin2_src/WM/wm.c [new file with mode: 0644]
Usermode/Applications/axwin2_src/WM/wm.h

index 6120612..cce4a81 100644 (file)
@@ -7,6 +7,6 @@ CPPFLAGS += -I../include
 DIR := Apps/AxWin/1.0
 BIN := ../AxWinWM
 OBJ := main.o helpers.o commandline.o video.o
-OBJ += messages.o interface.o
+OBJ += messages.o interface.o wm.o
 
 -include ../../Makefile.tpl
index 4d22b50..1eec6b4 100644 (file)
@@ -6,12 +6,61 @@
 
 // === GLOBALS ==
  int   giInterface_Width = 0;
+tElement       *gpInterface_Sidebar;
+tElement       *gpInterface_MainArea;
+tElement       *gpInterface_HeaderBar;
+tElement       *gpInterface_TabBar;
+tElement       *gpInterface_TabContent;
 
 // === CODE ===
-void Interface_Render(void)
+void Interface_Init(void)
 {
+       tElement        *btn, *text;
+       
        giInterface_Width = giScreenWidth/16;
        
+       WM_SetFlags(NULL, ELEFLAG_HORIZONTAL);
+       
+       // Create Sidebar
+       gpInterface_Sidebar = WM_CreateElement(NULL, ELETYPE_TOOLBAR, ELEFLAG_VERTICAL);
+       WM_SetSize( gpInterface_Sidebar, giInterface_Width );
+       // Create Main Area and regions within
+       gpInterface_MainArea = WM_CreateElement(NULL, ELETYPE_BOX, ELEFLAG_VERTICAL);
+       gpInterface_HeaderBar = WM_CreateElement(gpInterface_MainArea, ELETYPE_BOX, ELEFLAG_HORIZONTAL);
+       gpInterface_TabBar = WM_CreateElement(gpInterface_MainArea, ELETYPE_TABBAR, 0);
+       gpInterface_TabContent = WM_CreateElement(gpInterface_MainArea, ELETYPE_BOX, 0);
+       
+       // Menu Button
+       btn = WM_CreateElement(gpInterface_Sidebar, ELETYPE_BUTTON, 0);
+       WM_SetSize(btn, giInterface_Width);
+       //text = WM_CreateElement(btn, ELETYPE_IMAGE, ELEFLAG_SCALE);
+       //WM_SetText(text, "asset://LogoSmall.png");
+       text = WM_CreateElement(btn, ELETYPE_TEXT, 0);
+       WM_SetText(text, "Acess");
+       
+       // Plain <hr/> style spacer
+       WM_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, 0);
+       
+       // Create spacing gap (aligns the rest to the bottom/right)
+       WM_CreateElement(gpInterface_Sidebar, ELETYPE_GAP, 0);
+       
+       // Plain <hr/> style spacer
+       WM_CreateElement(gpInterface_Sidebar, ELETYPE_SPACER, 0);
+       
+       // Version String
+       text = WM_CreateElement(gpInterface_Sidebar, ELETYPE_TEXT, ELEFLAG_WRAP);
+       WM_SetText(text, "AxWin 1.0");
+}
+
+void Interface_Update(void)
+{
+       giInterface_Width = giScreenWidth/16;
+       WM_SetSize( gpInterface_Sidebar, giInterface_Width );
+}
+
+void Interface_Render(void)
+{
+       
        Video_FillRect(
                0, 0,
                giInterface_Width, giScreenHeight,
diff --git a/Usermode/Applications/axwin2_src/WM/wm.c b/Usermode/Applications/axwin2_src/WM/wm.c
new file mode 100644 (file)
index 0000000..7763d3b
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Acess GUI (AxWin) Version 2
+ * By John Hodge (thePowersGang)
+ * 
+ * Window Manager and Widget Control
+ */
+#include "common.h"
+#include <stdlib.h>
+#include <strings.h>
+#include "wm.h"
+
+tElement       gWM_RootElement;
+
+// === PROTOTYPES ===
+tElement       *WM_CreateElement(tElement *Parent, int Type, int Flags);
+void   WM_SetFlags(tElement *Element, int Flags);
+void   WM_SetSize(tElement *Element, int Size);
+void   WM_SetText(tElement *Element, char *Text);
+
+// === CODE ===
+tElement *WM_CreateElement(tElement *Parent, int Type, int Flags)
+{
+       tElement        *ret;
+       
+       if(Type < 0 || Type >= NUM_ELETYPES)    return NULL;
+       
+       ret = calloc(sizeof(tElement), 1);
+       if(!ret)        return NULL;
+       
+       // Prepare
+       ret->Type = Type;
+       ret->Parent = Parent;
+       
+       // Append to parent's list
+       ret->NextSibling = Parent->LastChild;
+       Parent->LastChild = ret;
+       if(!Parent->FirstChild) Parent->FirstChild = ret;
+       
+       return ret;
+}
+
+void WM_SetFlags(tElement *Element, int Flags)
+{
+       // Permissions are handled in the message handler
+       if(!Element) {
+               gWM_RootElement.Flags = Flags;
+               return ;
+       }
+       
+       Element->Flags = Flags;
+       return ;
+}
+
+void WM_SetSize(tElement *Element, int Size)
+{
+       if(!Element)    return ;
+       Element->Size = Size;
+       return ;
+}
+
+void WM_SetText(tElement *Element, char *Text)
+{
+       if(!Element)    return ;
+       if(Element->Text)       free(Element->Text);
+       Element->Text = strdup(Text);
+       return ;
+}
index e7b6bee..38dc1ac 100644 (file)
@@ -4,18 +4,35 @@
 
 typedef struct sElement
 {
+        int    Type;
+       
+       struct sElement *Parent;
+       struct sElement *FirstChild;
+       struct sElement *LastChild;
        struct sElement *NextSibling;
        
+       
        short   CachedX;
        short   CachedY;
        short   CachedW;
        short   CachedH;
        
-       struct sElement *FirstChild;
+       short   Size;   // Size attribute
+       
+       char    *Text;
+       void    *Data;
+       
+       uint32_t        Flags;
 }      tElement;
 
 typedef struct sTab
 {
+        int    Type;   // Should be zero, allows a tab to be the parent of an element
+       
+       struct sElement *Parent;
+       struct sElement *FirstChild;
+       struct sElement *LastChild;
+       
        char    *Name;
        
        tElement        *RootElement;
@@ -31,4 +48,39 @@ typedef struct sApplication
        char    Name[];
 }      tApplication;
 
+// === CONSTANTS ===
+enum eElementFlags
+{
+       ELEFLAG_VISIBLE     = 0x001,    ELEFLAG_INVISIBLE   = 0x000,
+       ELEFLAG_VERTICAL    = 0x002,    ELEFLAG_HORIZONTAL  = 0x000,
+       ELEFLAG_WRAP        = 0x004,    ELEFLAG_NOWRAP      = 0x000,
+};
+/**
+ */
+enum eElementTypes
+{
+       ELETYPE_NONE,
+       
+       ELETYPE_BOX,    //!< Content box
+       ELETYPE_TABBAR, //!< Tab Bar
+       ELETYPE_TOOLBAR,        //!< Tool Bar
+       
+       ELETYPE_BUTTON, //!< Push Button
+       ELETYPE_TEXT,   //!< Text
+       
+       ELETYPE_SPACER, //!< Visual Spacer
+       ELETYPE_GAP,    //!< Alignment Gap
+       
+       NUM_ELETYPES
+};
+
+// === FUNCTIONS ===
+/**
+ * \brief Create a new element as a child of \a Parent
+ */
+extern tElement        *WM_CreateElement(tElement *Parent, int Type, int Flags);
+extern void    WM_SetFlags(tElement *Element, int Flags);
+extern void    WM_SetSize(tElement *Element, int Size);
+extern void    WM_SetText(tElement *Element, char *Text);
+
 #endif

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