Dali 3D User Interface Engine
system-overlay-impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // INTERNAL INCLUDES
29 
30 namespace Dali
31 {
32 
33 namespace Internal
34 {
35 
37 {
38  SystemOverlay* overlay = new SystemOverlay( eventThreadServices );
39 
40  overlay->Initialize();
41 
42  return overlay;
43 }
44 
46 {
47  if ( mRootLayer )
48  {
49  // we are closing down so just delete the root, no point emit disconnect
50  // signals or send messages to update
51  mRootLayer.Reset();
52  }
53 }
54 
55 void SystemOverlay::Add( Actor& actor )
56 {
57  CreateRootLayer();
58 
59  mRootLayer->Add( actor );
60 }
61 
62 void SystemOverlay::Remove( Actor& actor )
63 {
64  if ( mRootLayer )
65  {
66  mRootLayer->Remove( actor );
67  }
68 }
69 
71 {
72  if ( !mOverlayRenderTaskList )
73  {
74  mOverlayRenderTaskList = RenderTaskList::New( mEventThreadServices, *this, true/*system-overlay*/ );
75  }
76 
77  return *mOverlayRenderTaskList;
78 }
79 
80 void SystemOverlay::SetSize( float width, float height )
81 {
82  mSize = Vector2( width, height );
83 
84  if ( mRootLayer )
85  {
86  mRootLayer->SetSize( mSize.width, mSize.height );
87  }
88 
89  if ( mDefaultCameraActor )
90  {
91  // Sets the default perspective projection for the given size.
92  mDefaultCameraActor->SetPerspectiveProjection( mSize );
93  }
94 }
95 
96 LayerList& SystemOverlay::GetLayerList()
97 {
98  return *mLayerList;
99 }
100 
101 Actor& SystemOverlay::GetDefaultRootActor()
102 {
103  CreateRootLayer();
104 
105  return *mRootLayer;
106 }
107 
108 CameraActor& SystemOverlay::GetDefaultCameraActor()
109 {
110  CreateDefaultCameraActor();
111 
112  return *mDefaultCameraActor;
113 }
114 
116 : mEventThreadServices( eventThreadServices )
117 {
118 }
119 
120 void SystemOverlay::Initialize()
121 {
122  // Create the ordered list of layers
123  mLayerList = LayerList::New( mEventThreadServices.GetUpdateManager(), true/*system layers*/ );
124 }
125 
126 void SystemOverlay::CreateRootLayer()
127 {
128  // Lazy initialization; SystemOverlay may never be used
129  if ( !mRootLayer )
130  {
131  mRootLayer = Layer::NewRoot( *mLayerList, mEventThreadServices.GetUpdateManager(), true/*system layer*/ );
132  mRootLayer->SetName("SystemOverlayRoot");
133  mRootLayer->SetSize( mSize.width, mSize.height );
134  }
135 }
136 
137 void SystemOverlay::CreateDefaultCameraActor()
138 {
139  // Lazy initialization; SystemOverlay may never be used
140  if ( !mDefaultCameraActor )
141  {
142  // Creates a default camera with a default perspective projection.
143  mDefaultCameraActor = CameraActor::New( mSize );
144  mDefaultCameraActor->SetParentOrigin( ParentOrigin::CENTER );
145 
146  Add( *mDefaultCameraActor );
147  }
148 }
149 
150 } // namespace Internal
151 
152 } // namespace Dali
Dali Docs Home
Read more about Dali