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>
39 BaseHandle handle( StyleMonitor::Get() );
41 if ( !handle && Adaptor::IsAvailable() )
43 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
44 Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
45 adaptorImpl.RegisterSingleton( typeid( styleMonitor ), styleMonitor );
46 handle = styleMonitor;
51 TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
53 } // unnamed namespace
55 Dali::StyleMonitor StyleMonitor::Get()
57 Dali::StyleMonitor styleMonitor;
59 if ( Adaptor::IsAvailable() )
61 // Check whether the singleton is already created
62 Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::StyleMonitor ) );
65 // If so, downcast the handle
66 styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
73 StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
74 : mPlatformAbstraction(platformAbstraction)
78 StyleMonitor::~StyleMonitor()
82 void StyleMonitor::StyleChanged(StyleChange styleChange)
84 if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
86 mPlatformAbstraction.UpdateDefaultsFromDevice();
89 EmitStyleChangeSignal(styleChange);
92 std::string StyleMonitor::GetDefaultFontFamily() const
94 return mPlatformAbstraction.GetDefaultFontFamily();
97 float StyleMonitor::GetDefaultFontSize() const
99 return mPlatformAbstraction.GetDefaultFontSize();
102 const std::string& StyleMonitor::GetTheme() const
104 return mUserDefinedThemeFilePath;
107 void StyleMonitor::SetTheme(const std::string& path)
109 StyleChange styleChange;
110 styleChange.themeChange = true;
111 styleChange.themeFilePath = path;
112 mUserDefinedThemeFilePath = path;
114 EmitStyleChangeSignal(styleChange);
117 Dali::StyleMonitor::StyleChangeSignalV2& StyleMonitor::StyleChangeSignal()
119 return mStyleChangeSignalV2;
122 void StyleMonitor::EmitStyleChangeSignal(StyleChange styleChange)
124 if( !mStyleChangeSignalV2.Empty() )
126 Dali::StyleMonitor handle( this );
127 mStyleChangeSignalV2.Emit( handle, styleChange );
131 } // namespace Adaptor
133 } // namespace Internal