2 * Copyright (c) 2016 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 <pepper-dali/internal/object-view-impl.h>
22 #include <pepper-dali/internal/shell-client-impl.h>
25 #include <dali/integration-api/debug.h>
39 #if defined(DEBUG_ENABLED)
40 Integration::Log::Filter* gPepperObjectViewLogging = Integration::Log::Filter::New( Debug::Verbose, false, "LOG_PEPPER_OBJECT_VIEW" );
43 } // unnamed namespace
45 Dali::Pepper::ObjectView ObjectView::New()
47 // Create the implementation, temporarily owned on stack
48 IntrusivePtr< ObjectView > internalObjectView = new ObjectView();
50 // Pass ownership to CustomActor
51 Dali::Pepper::ObjectView objectView( *internalObjectView );
53 // Second-phase init of the implementation
54 // This can only be done after the CustomActor connection has been made...
55 internalObjectView->Initialize();
60 ObjectView::ObjectView()
61 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
68 ObjectView::~ObjectView()
72 void ObjectView::SetImage( Image image )
74 mImageView.SetImage( image );
76 DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::SetImage: size = %d * %d\n", image.GetWidth(), image.GetHeight() );
79 pid_t ObjectView::GetPid() const
82 struct wl_client* client;
86 client = wl_resource_get_client( pepper_surface_get_resource( mSurface ) );
89 wl_client_get_credentials( client, &pid, NULL, NULL );
93 DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::GetPid: pid = %d\n", pid );
98 std::string ObjectView::GetTitle() const
104 Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
107 title = shellClient->GetTitle();
111 DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::GetTitle: title = %s\n", title.c_str() );
116 std::string ObjectView::GetAppId() const
122 Pepper::Internal::ShellClientPtr shellClient = reinterpret_cast< Pepper::Internal::ShellClient* >( pepper_object_get_user_data( reinterpret_cast< pepper_object_t* >( mSurface ), pepper_surface_get_role( mSurface ) ) );
125 appId = shellClient->GetAppId();
129 DALI_LOG_INFO( gPepperObjectViewLogging, Debug::General, "ObjectView::GetAppId: app id = %s\n", appId.c_str() );
134 void ObjectView::SetSurface( pepper_surface_t* surface )
139 void ObjectView::OnInitialize()
141 mImageView = Toolkit::ImageView::New();
142 mImageView.SetParentOrigin( ParentOrigin::CENTER );
143 mImageView.SetAnchorPoint( AnchorPoint::CENTER );
145 Self().Add( mImageView );
146 Self().SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
149 } // namespace Internal
151 } // namespace Pepper