1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Widgets.Containers;                use Widgets.Containers; 
  10. with Widgets.Containers.Game_Screens;   use Widgets.Containers.Game_Screens; 
  11.  
  12. package Widgets.Containers.Screen_Managers is 
  13.  
  14.     -- A Screen_Manager manages a collection of Game_Screens as a stack, 
  15.     -- displaying the top screen. A Game_Screen obscures the screens beneath it 
  16.     -- unless it is a lightweight popup screen that is intended to have a 
  17.     -- transparent background. 
  18.     type Screen_Manager is new Container and Animated with private; 
  19.     type A_Screen_Manager is access all Screen_Manager'Class; 
  20.  
  21.     -- Creates a new, empty screen manager. 
  22.     function Create_Screen_Manager( view : not null access Game_Views.Game_View'Class; 
  23.                                     id   : String ) return A_Screen_Manager; 
  24.  
  25.     -- Adds a new screen to the top of the screen stack, activating it. If the 
  26.     -- screen is a popup, then the screen(s) beneath it will remain visible. 
  27.     -- Otherwise 'screen' will obscure the current top screen and the currently 
  28.     -- active screen(s) will be deactivated. 'screen' will be consumed. 
  29.     procedure Add_Screen( this   : not null access Screen_Manager'Class; 
  30.                           screen : in out A_Game_Screen ); 
  31.     pragma Precondition( screen /= null ); 
  32.     pragma Postcondition( screen = null ); 
  33.  
  34. private 
  35.  
  36.     type Screen_Manager is new Container and Animated with null record; 
  37.  
  38.     procedure Construct( this : access Screen_Manager; 
  39.                          view : not null access Game_Views.Game_View'Class; 
  40.                          id   : String ); 
  41.  
  42.     -- Handled notifications when the screen manager becomes shown or unshown on 
  43.     -- the screen. 
  44.     procedure On_Shown( this : access Screen_Manager; shown : Boolean ); 
  45.  
  46.     procedure Tick( this : access Screen_Manager; time : Tick_Time ); 
  47.  
  48.     -- Removes a screen from the manager. The screen's Deactivate procedure will 
  49.     -- be called and the screen(s) at the front of the manager will be activated 
  50.     -- if necessary. 
  51.     procedure Remove_Screen( this   : not null access Screen_Manager'Class; 
  52.                              screen : not null A_Game_Screen ); 
  53.  
  54. end Widgets.Containers.Screen_Managers;