2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <common/color-controller-impl.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/type-registry.h>
24 #include <efl_assist_theme.h>
27 #include <common/adaptor-impl.h>
43 return ColorController::Get();
45 Dali::TypeRegistration COLOR_CONTROLLER_TYPE( typeid(Dali::ColorController), typeid(Dali::BaseHandle), Create );
49 Dali::ColorController ColorController::Get()
51 Dali::ColorController colorController;
53 if ( Adaptor::IsAvailable() )
55 // Check whether the singleton is already created
56 Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::ColorController ) );
59 // If so, downcast the handle
60 colorController = Dali::ColorController( dynamic_cast< ColorController* >( handle.GetObjectPtr() ) );
64 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
65 colorController = Dali::ColorController( new ColorController( ) );
66 adaptorImpl.RegisterSingleton( typeid( colorController ), colorController );
70 return colorController;
74 ColorController::ColorController()
78 ColorController::~ColorController()
82 bool ColorController::RetrieveColor( const std::string& colorCode, Vector4& colorValue )
89 if( ea_theme_color_get(colorCode.c_str(), &R, &G, &B, &A, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) )
91 colorValue.r = (float) (R) / 255.0f;
92 colorValue.g = (float) (G) / 255.0f;
93 colorValue.b = (float) (B) / 255.0f;
94 colorValue.a = (float) (A) / 255.0f;
102 bool ColorController::RetrieveColor( const std::string& colorCode , Vector4& textColor, Vector4& textOutlineColor, Vector4& textShadowColor)
119 if( ea_theme_color_get(colorCode.c_str(), &R, &G, &B, &A, &outlineR, &outlineG, &outlineB, &outlineA, &shadowR, &shadowG, &shadowB, &shadowA) )
121 textColor.r = (float) (R) / 255.0f;
122 textColor.g = (float) (G) / 255.0f;
123 textColor.b = (float) (B) / 255.0f;
124 textColor.a = (float) (A) / 255.0f;
126 textOutlineColor.r = (float) (outlineR) / 255.0f;
127 textOutlineColor.g = (float) (outlineG) / 255.0f;
128 textOutlineColor.b = (float) (outlineB) / 255.0f;
129 textOutlineColor.a = (float) (outlineA) / 255.0f;
131 textShadowColor.r = (float) (shadowR) / 255.0f;
132 textShadowColor.g = (float) (shadowG) / 255.0f;
133 textShadowColor.b = (float) (shadowB) / 255.0f;
134 textShadowColor.a = (float) (shadowA) / 255.0f;
142 } // namespace Adaptor
144 } // namespace Internal