2 * Copyright (c) 2018 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 "frame-callback.h"
23 FrameCallback::FrameCallback()
24 : mActorIdContainer(),
25 stageHalfWidth( 0.0f )
29 void FrameCallback::SetStageWidth( float stageWidth )
31 stageHalfWidth = stageWidth * 0.5f;
34 void FrameCallback::AddId( uint32_t id )
36 mActorIdContainer.PushBack( id );
39 void FrameCallback::Update( Dali::UpdateProxy& updateProxy, float /* elapsedSeconds */ )
41 // Go through Actor ID container and check if we've hit the sides.
42 for( auto&& i : mActorIdContainer )
46 if( updateProxy.GetPositionAndSize( i, position, size ) ) // Retrieve the position and size using the Actor ID.
48 float halfWidthPoint = stageHalfWidth - size.width * 0.5f;
49 float xTranslation = std::abs( position.x );
50 if( xTranslation > halfWidthPoint )
52 // Actor has hit the edge, adjust the size accordingly.
53 float adjustment = xTranslation - halfWidthPoint;
54 size.width += adjustment * SIZE_MULTIPLIER;
55 size.height += adjustment * SIZE_MULTIPLIER;
57 updateProxy.SetSize( i, size ); // Set the size using the UpdateProxy.
60 // Retrieve the actor's position and set make it more transparent the closer it is to the middle.
62 if( updateProxy.GetColor( i, color ) )
64 color.a = xTranslation / halfWidthPoint;
65 updateProxy.SetColor( i, color );