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>
25 #include <adaptor-impl.h>
26 #include <singleton-service-impl.h>
42 BaseHandle handle( StyleMonitor::Get() );
44 if ( !handle && Adaptor::IsAvailable() )
46 Dali::SingletonService service( SingletonService::Get() );
49 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
50 Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
51 service.Register( typeid( styleMonitor ), styleMonitor );
52 handle = styleMonitor;
58 TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
60 } // unnamed namespace
62 Dali::StyleMonitor StyleMonitor::Get()
64 Dali::StyleMonitor styleMonitor;
66 Dali::SingletonService service( SingletonService::Get() );
69 // Check whether the singleton is already created
70 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::StyleMonitor ) );
73 // If so, downcast the handle
74 styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
81 StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
82 : mPlatformAbstraction(platformAbstraction)
86 StyleMonitor::~StyleMonitor()
90 void StyleMonitor::StyleChanged(StyleChange styleChange)
92 if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
94 mPlatformAbstraction.UpdateDefaultsFromDevice();
97 EmitStyleChangeSignal(styleChange);
100 std::string StyleMonitor::GetDefaultFontFamily() const
102 return mPlatformAbstraction.GetDefaultFontFamily();
105 float StyleMonitor::GetDefaultFontSize() const
107 return mPlatformAbstraction.GetDefaultFontSize();
110 const std::string& StyleMonitor::GetTheme() const
112 return mUserDefinedThemeFilePath;
115 void StyleMonitor::SetTheme(const std::string& path)
117 StyleChange styleChange;
118 styleChange.themeChange = true;
119 styleChange.themeFilePath = path;
120 mUserDefinedThemeFilePath = path;
122 EmitStyleChangeSignal(styleChange);
125 Dali::StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal()
127 return mStyleChangeSignal;
130 void StyleMonitor::EmitStyleChangeSignal(StyleChange styleChange)
132 if( !mStyleChangeSignal.Empty() )
134 Dali::StyleMonitor handle( this );
135 mStyleChangeSignal.Emit( handle, styleChange );
139 } // namespace Adaptor
141 } // namespace Internal