2 * Copyright (c) 2021 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 <dali-toolkit/internal/transition/scale-transition-impl.h>
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali/devel-api/actors/actor-devel.h>
24 #include <dali/integration-api/debug.h>
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/object/type-registry.h>
35 ScaleTransitionPtr ScaleTransition::New(Dali::Toolkit::Control control, const Vector2& scaleFactor, TimePeriod timePeriod)
37 float delaySeconds = timePeriod.delaySeconds;
38 if(delaySeconds < 0.0f)
40 DALI_LOG_WARNING("delay should be greater than 0.0f.\n");
44 float durationSeconds = timePeriod.durationSeconds;
45 if(durationSeconds < 0.0f)
47 DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
48 durationSeconds = 0.0f;
51 ScaleTransitionPtr scaleTransition = new ScaleTransition(control, scaleFactor, TimePeriod(delaySeconds, durationSeconds));
53 // Second-phase construction
54 scaleTransition->Initialize();
56 return scaleTransition;
59 ScaleTransition::ScaleTransition(Dali::Toolkit::Control control, const Vector2& scaleFactor, TimePeriod timePeriod)
61 mTargetControl(control),
62 mScaleFactor(scaleFactor)
65 SetTimePeriod(timePeriod);
68 ScaleTransition::~ScaleTransition()
72 void ScaleTransition::SetScaleFactor(const Vector2& scaleFactor)
74 mScaleFactor = scaleFactor;
77 Vector2 ScaleTransition::GetScaleFactor() const
82 void ScaleTransition::OnPlay()
84 Dali::Toolkit::Control targetControl = mTargetControl.GetHandle();
85 if(!targetControl || !targetControl[Dali::Actor::Property::CONNECTED_TO_SCENE])
87 DALI_LOG_ERROR("The Control is not added on the window\n");
91 Property::Map startPropertyMap;
92 Property::Map finishPropertyMap;
94 Vector3 targetScale = targetControl[Dali::Actor::Property::SCALE];
95 Vector3 scaleFactor = Vector3(mScaleFactor.x, mScaleFactor.y, 1.0f);
96 if(IsAppearingTransition())
98 startPropertyMap.Insert(Dali::Actor::Property::SCALE, scaleFactor * targetScale);
99 finishPropertyMap.Insert(Dali::Actor::Property::SCALE, targetScale);
103 startPropertyMap.Insert(Dali::Actor::Property::SCALE, targetScale);
104 finishPropertyMap.Insert(Dali::Actor::Property::SCALE, scaleFactor * targetScale);
107 SetStartPropertyMap(startPropertyMap);
108 SetFinishPropertyMap(finishPropertyMap);
111 } // namespace Internal
113 } // namespace Toolkit