Skip to content

Commit

Permalink
gui object 1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderC2 committed Oct 7, 2012
1 parent 0105b0e commit 4b56917
Show file tree
Hide file tree
Showing 8 changed files with 681 additions and 12 deletions.
62 changes: 57 additions & 5 deletions src/gui/gui.adb
Expand Up @@ -4,10 +4,55 @@ with Ada.Text_IO; use Ada.Text_IO;

package body GUI is

procedure SetParent
(Object : in out GUIObject_Type;
Parent : access GUIObject_Type'Class) is
begin
null;
end SetParent;
---------------------------------------------------------------------------

procedure SetObjectImplementation
(Object : in out GUIObject_Type;
ObjectImplementation : GUIObjectImplementation_Ref) is
begin
null;
end SetObjectImplementation;
---------------------------------------------------------------------------

procedure ResetObjectImplementation
(Object : in out GUIObject_Type) is
begin
null;
end ResetObjectImplementation;
---------------------------------------------------------------------------

function GetBounds
(Object : GUIObject_Type)
return Bounds_Type is
begin
return Object.Bounds;
end GetBounds;
---------------------------------------------------------------------------

procedure SetBounds
(Object : in out GUIObject_Type;
Bounds : Bounds_Type) is
begin
Object.Bounds:=Bounds;
-- TODO: Update, call resize etc
end SetBounds;
---------------------------------------------------------------------------

procedure ContextCreate
(T : in out GUIGraphicsCallBack_Type) is

GUI : GUI_Type renames T.GUI.all;

begin
null;
GUI.ObjectImplementations := ObjectImplementations.Utilize(GUI.ThemeConfig,GUI.Context.I.GetInfo);
-- TODO: Catch exception and report the failure to bind a theme to the callback
-- TODO: Run ObjectsImpl initialize
end ContextCreate;
---------------------------------------------------------------------------

Expand Down Expand Up @@ -46,20 +91,27 @@ package body GUI is
-- TODO:Cleanup current Objects Implementation
GUI.ObjectImplementations.SetNull;
-- Set new context
GUI.ObjectImplementations.SetNull;
GUI.Context:=Context;
GUI.GraphicsCallBack.GUI:=GUI'Unrestricted_Access;
-- TODO:Reinitialize current Objects Implementation
GUI.ThemeConfig:=Theme;
if Context.I.IsInitialized then
Put_Line("ObjectIMpl");
GUI.ObjectImplementations := ObjectImplementations.Utilize(Theme,Context.I.GetInfo);
Put_Line("ObjectImpl/");
-- TODO: Catch exception
GUI.GraphicsCallBack.ContextCreate;
end if;

Context.I.CallBack:=GUI.GraphicsCallBack'Unrestricted_Access;

end Setup;
---------------------------------------------------------------------------

procedure Finalize
(GUI : in out GUI_Type) is
begin
-- Ensure correct order of finalization
GUI.ObjectImplementations.SetNull;
GUI.Context.SetNull;
end Finalize;
---------------------------------------------------------------------------

end GUI;
53 changes: 51 additions & 2 deletions src/gui/gui.ads
@@ -1,6 +1,6 @@
pragma Ada_2005;

--with GUIBounds;
with GUIBounds; use GUIBounds;
with Graphics;
with RefCount;
with Config;
Expand All @@ -20,10 +20,41 @@ package GUI is

procedure GUIClose
(T : in out GUICallBack_Interface) is null;
---------------------------------------------------------------------------

type GUIObject_Type is new RefCount.Ref_Interface with private;
type GUIObject_ClassAccess is access all GUIObject_Type'Class;

not overriding
function GetBounds
(Object : GUIObject_Type)
return Bounds_Type;

not overriding
procedure SetBounds
(Object : in out GUIObject_Type;
Bounds : Bounds_Type);

not overriding
procedure SetParent
(Object : in out GUIObject_Type;
Parent : access GUIObject_Type'Class);

-- Only called by GUI
not overriding
procedure SetObjectImplementation
(Object : in out GUIObject_Type;
ObjectImplementation : GUIObjectImplementation_Ref);

not overriding
procedure ResetObjectImplementation
(Object : in out GUIObject_Type);

---------------------------------------------------------------------------

type GUI_Interface is abstract new RefCount.Ref_Interface with
record
CallBack : GUICallBack_ClassAccess:=null;
CallBack : GUICallBack_ClassAccess:=null;
end record;
type GUI_ClassAccess is access all GUI_Interface'Class;

Expand All @@ -49,10 +80,24 @@ package GUI is
(GUI : in out GUI_Type;
Context : Graphics.Context_Ref;
Theme : Config.ConfigNode_Type);

overriding
procedure Finalize
(GUI : in out GUI_Type);
---------------------------------------------------------------------------

private

type GUIObject_Type is new RefCount.Ref_Interface with
record
Bounds : Bounds_Type;
Previous : GUIObject_ClassAccess:=null;
Next : GUIObject_ClassAccess:=null;
Parent : GUIObject_ClassAccess:=null;
FirstChild : GUIObject_ClassAccess:=null;
LastChild : GUIObject_ClassAccess:=null;
end record;

type GUI_Access is access all GUI_Type;

type GUIGraphicsCallBack_Type is new Graphics.ContextCallBack_Interface with
Expand Down Expand Up @@ -81,6 +126,10 @@ private

type GUI_Type is new GUI_Interface with
record
ContextLayer : GUIObject_Type;
ModalLayer : GUIObject_Type;
FrontLayer : GUIObject_Type;
BaseLayer : GUIObject_Type;
Context : Graphics.Context_Ref;
ObjectImplementations : GUIObjectImplementation_Ref;
GraphicsCallBack : aliased GUIGraphicsCallBack_Type;
Expand Down

0 comments on commit 4b56917

Please sign in to comment.