Added scrollMode property to ScrollView to simplify Rulers
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / visual-factory / visual-factory.cpp
1  /*
2  * Copyright (c) 2015 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
19 #include "visual-factory.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/adaptor-framework/singleton-service.h>
23 #include <dali/devel-api/adaptor-framework/environment-variable.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/visuals/visual-factory-impl.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace
35 {
36   const char * const DALI_DEBUG_RENDERING("DALI_DEBUG_RENDERING");
37 }
38
39 VisualFactory VisualFactory::Get()
40 {
41   VisualFactory factory;
42
43   // Check whether the VisualFactory is already created
44   SingletonService singletonService( SingletonService::Get() );
45   if( singletonService )
46   {
47     BaseHandle handle = singletonService.GetSingleton( typeid(VisualFactory) );
48     if( handle )
49     {
50       //If so, downcast the handle of singleton to VisualFactory
51       factory = VisualFactory( dynamic_cast<Internal::VisualFactory*>(handle.GetObjectPtr()) );
52     }
53
54     if( !factory )// If not, create the VisualFactory and register it as a singleton
55     {
56       // Check whether debug rendering is required
57       if( EnvironmentVariable::GetEnvironmentVariable( DALI_DEBUG_RENDERING ) )
58       {
59         factory = VisualFactory( new Internal::VisualFactory(true) );
60       }
61       else
62       {
63         factory = VisualFactory( new Internal::VisualFactory(false) );
64       }
65       singletonService.Register( typeid(VisualFactory), factory );
66
67     }
68   }
69
70   return factory;
71 }
72
73 VisualFactory::VisualFactory()
74 {
75 }
76
77 VisualFactory::~VisualFactory()
78 {
79 }
80
81 VisualFactory::VisualFactory( const VisualFactory& handle )
82 : BaseHandle( handle )
83 {
84 }
85
86 VisualFactory& VisualFactory::operator=( const VisualFactory& handle )
87 {
88   BaseHandle::operator=( handle );
89   return *this;
90 }
91
92 VisualFactory::VisualFactory(Internal::VisualFactory *impl)
93 : BaseHandle(impl)
94 {
95 }
96
97 Visual::Base VisualFactory::CreateVisual( const Property::Map& propertyMap )
98 {
99   return GetImplementation( *this ).CreateVisual( propertyMap );
100 }
101
102 Visual::Base VisualFactory::CreateVisual( const Image& image )
103 {
104   return GetImplementation( *this ).CreateVisual( image );
105 }
106
107 Visual::Base VisualFactory::CreateVisual( const std::string& url, ImageDimensions size )
108 {
109   return GetImplementation( *this ).CreateVisual( url, size );
110 }
111
112 } // namespace Toolkit
113
114 } // namespace Dali