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 "style-monitor-impl.h"
22 #include <dali/public-api/object/type-registry.h>
23 #include <adaptor-impl.h>
24 #include <singleton-service-impl.h>
40 BaseHandle handle( StyleMonitor::Get() );
42 if ( !handle && Adaptor::IsAvailable() )
44 Dali::SingletonService service( SingletonService::Get() );
47 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
48 Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
49 service.Register( typeid( styleMonitor ), styleMonitor );
50 handle = styleMonitor;
56 TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
58 } // unnamed namespace
60 Dali::StyleMonitor StyleMonitor::Get()
62 Dali::StyleMonitor styleMonitor;
64 Dali::SingletonService service( SingletonService::Get() );
67 // Check whether the singleton is already created
68 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::StyleMonitor ) );
71 // If so, downcast the handle
72 styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
79 StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
80 : mPlatformAbstraction(platformAbstraction)
84 StyleMonitor::~StyleMonitor()
88 void StyleMonitor::StyleChanged(StyleChange styleChange)
90 if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
92 mPlatformAbstraction.UpdateDefaultsFromDevice();
95 EmitStyleChangeSignal(styleChange);
98 std::string StyleMonitor::GetDefaultFontFamily() const
100 return mPlatformAbstraction.GetDefaultFontFamily();
103 float StyleMonitor::GetDefaultFontSize() const
105 return mPlatformAbstraction.GetDefaultFontSize();
108 const std::string& StyleMonitor::GetTheme() const
110 return mUserDefinedThemeFilePath;
113 void StyleMonitor::SetTheme(const std::string& path)
115 StyleChange styleChange;
116 styleChange.themeChange = true;
117 styleChange.themeFilePath = path;
118 mUserDefinedThemeFilePath = path;
120 EmitStyleChangeSignal(styleChange);
123 Dali::StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal()
125 return mStyleChangeSignal;
128 void StyleMonitor::EmitStyleChangeSignal(StyleChange styleChange)
130 if( !mStyleChangeSignal.Empty() )
132 Dali::StyleMonitor handle( this );
133 mStyleChangeSignal.Emit( handle, styleChange );
137 } // namespace Adaptor
139 } // namespace Internal