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"
25 #include <dali/public-api/object/type-registry.h>
26 #include <adaptor-impl.h>
42 BaseHandle handle( StyleMonitor::Get() );
44 if ( !handle && Adaptor::IsAvailable() )
46 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
47 Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
48 adaptorImpl.RegisterSingleton( typeid( styleMonitor ), styleMonitor );
49 handle = styleMonitor;
54 TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
56 } // unnamed namespace
58 Dali::StyleMonitor StyleMonitor::Get()
60 Dali::StyleMonitor styleMonitor;
62 if ( Adaptor::IsAvailable() )
64 // Check whether the singleton is already created
65 Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Dali::StyleMonitor ) );
68 // If so, downcast the handle
69 styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
76 StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
77 : mPlatformAbstraction(platformAbstraction)
81 StyleMonitor::~StyleMonitor()
85 void StyleMonitor::StyleChanged(StyleChange styleChange)
87 if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
89 mPlatformAbstraction.UpdateDefaultsFromDevice();
92 EmitStyleChangeSignal(styleChange);
95 std::string StyleMonitor::GetDefaultFontFamily() const
97 return mPlatformAbstraction.GetDefaultFontFamily();
100 float StyleMonitor::GetDefaultFontSize() const
102 return mPlatformAbstraction.GetDefaultFontSize();
105 const std::string& StyleMonitor::GetTheme() const
107 return mUserDefinedThemeFilePath;
110 void StyleMonitor::SetTheme(const std::string& path)
112 StyleChange styleChange;
113 styleChange.themeChange = true;
114 styleChange.themeFilePath = path;
115 mUserDefinedThemeFilePath = path;
117 EmitStyleChangeSignal(styleChange);
120 Dali::StyleMonitor::StyleChangeSignalV2& StyleMonitor::StyleChangeSignal()
122 return mStyleChangeSignalV2;
125 void StyleMonitor::EmitStyleChangeSignal(StyleChange styleChange)
127 if( !mStyleChangeSignalV2.Empty() )
129 Dali::StyleMonitor handle( this );
130 mStyleChangeSignalV2.Emit( handle, styleChange );
134 } // namespace Adaptor
136 } // namespace Internal