X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-overlap%2Ftext-overlap-example.cpp;h=4c03fe1439c63e517d58466b9494415e15f384f6;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hp=a7c64a24a7210a978503f0d8da41112bbcfaa259;hpb=346c047a487db6b75118680e39ce249a6cdaa8db;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/text-overlap/text-overlap-example.cpp b/examples/text-overlap/text-overlap-example.cpp old mode 100755 new mode 100644 index a7c64a2..4c03fe1 --- a/examples/text-overlap/text-overlap-example.cpp +++ b/examples/text-overlap/text-overlap-example.cpp @@ -1,7 +1,23 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "text-overlap-example.h" #include #include -#include "text-overlap-example.h" #include @@ -10,95 +26,91 @@ using namespace Dali::Toolkit; static const int NUMBER_OF_LABELS(2); - - namespace Demo { - -TextOverlapController::TextOverlapController( Application& app ) -: mApplication( app ), - mTopmostLabel( 1 ) +TextOverlapController::TextOverlapController(Application& app) +: mApplication(app), + mTopmostLabel(1) { - app.InitSignal().Connect( this, &TextOverlapController::Create ); - app.TerminateSignal().Connect( this, &TextOverlapController::Destroy ); + app.InitSignal().Connect(this, &TextOverlapController::Create); + app.TerminateSignal().Connect(this, &TextOverlapController::Destroy); } -void TextOverlapController::Create( Application& app ) +void TextOverlapController::Create(Application& app) { Window window = app.GetWindow(); - window.KeyEventSignal().Connect( this, &TextOverlapController::OnKeyEvent ); + window.KeyEventSignal().Connect(this, &TextOverlapController::OnKeyEvent); Vector2 windowSize = window.GetSize(); mLabels[0] = TextLabel::New("Text Label 1"); mLabels[1] = TextLabel::New("Text Label 2"); - mLabels[0].SetProperty( Dali::Actor::Property::NAME,"Label1"); - mLabels[1].SetProperty( Dali::Actor::Property::NAME,"Label2"); + mLabels[0].SetProperty(Dali::Actor::Property::NAME, "Label1"); + mLabels[1].SetProperty(Dali::Actor::Property::NAME, "Label2"); - mLabels[0].SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 1 ); - mLabels[1].SetProperty( Dali::DevelActor::Property::SIBLING_ORDER, 2 ); + mLabels[0].SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, 1); + mLabels[1].SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, 2); - mLabels[0].SetProperty( Control::Property::BACKGROUND, Color::RED ); - mLabels[1].SetProperty( Control::Property::BACKGROUND, Color::YELLOW ); + mLabels[0].SetProperty(Control::Property::BACKGROUND, Color::RED); + mLabels[1].SetProperty(Control::Property::BACKGROUND, Color::YELLOW); - for(int i=0; i( Actor::Property::POSITION ); - Vector3 size = mLabels[i].GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); - if( gesturePosition.y > position.y - size.y * 0.5f && - gesturePosition.y <= position.y + size.y * 0.5f ) + Vector3 position = mLabels[i].GetCurrentProperty(Actor::Property::POSITION); + Vector3 size = mLabels[i].GetCurrentProperty(Actor::Property::SIZE); + if(gesturePosition.y > position.y - size.y * 0.5f && + gesturePosition.y <= position.y + size.y * 0.5f) { mGrabbedActor = mLabels[i]; break; } } } - else if( mGrabbedActor && state == GestureState::CONTINUING ) + else if(mGrabbedActor && state == GestureState::CONTINUING) { - Vector2 windowSize = mApplication.GetWindow().GetSize(); - Vector3 size = mGrabbedActor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); + Vector2 windowSize = mApplication.GetWindow().GetSize(); + Vector3 size = mGrabbedActor.GetCurrentProperty(Actor::Property::SIZE); const Vector2& gesturePosition = gesture.GetPosition(); - float y = Clamp( gesturePosition.y, size.y * 0.5f, windowSize.y - size.y*0.5f ); - mGrabbedActor.SetProperty( Actor::Property::POSITION, Vector2( 0, y )); + float y = Clamp(gesturePosition.y, size.y * 0.5f, windowSize.y - size.y * 0.5f); + mGrabbedActor.SetProperty(Actor::Property::POSITION, Vector2(0, y)); } else { @@ -106,7 +118,7 @@ void TextOverlapController::OnPan( Actor actor, const PanGesture& gesture ) } } -void TextOverlapController::Destroy( Application& app ) +void TextOverlapController::Destroy(Application& app) { mPanDetector.DetachAll(); UnparentAndReset(mLabels[0]); @@ -114,39 +126,37 @@ void TextOverlapController::Destroy( Application& app ) mGrabbedActor.Reset(); } -bool TextOverlapController::OnClicked( Button button ) +bool TextOverlapController::OnClicked(Button button) { - mTopmostLabel = 1-mTopmostLabel; // toggles between 0 and 1 + mTopmostLabel = 1 - mTopmostLabel; // toggles between 0 and 1 mLabels[mTopmostLabel].RaiseToTop(); return false; } - -void TextOverlapController::OnKeyEvent( const KeyEvent& keyEvent ) +void TextOverlapController::OnKeyEvent(const KeyEvent& keyEvent) { - if( keyEvent.GetState() == KeyEvent::DOWN && - ( IsKey( keyEvent, DALI_KEY_BACK ) || - IsKey( keyEvent, DALI_KEY_ESCAPE ) ) ) + if(keyEvent.GetState() == KeyEvent::DOWN && + (IsKey(keyEvent, DALI_KEY_BACK) || + IsKey(keyEvent, DALI_KEY_ESCAPE))) { mApplication.Quit(); } else { - Dali::Layer l = mApplication.GetWindow().GetRootLayer(); - int so = l.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER); - l.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, so+1); + Dali::Layer l = mApplication.GetWindow().GetRootLayer(); + int so = l.GetProperty(Dali::DevelActor::Property::SIBLING_ORDER); + l.SetProperty(Dali::DevelActor::Property::SIBLING_ORDER, so + 1); } } - } // namespace Demo -int DALI_EXPORT_API main( int argc, char** argv ) +int DALI_EXPORT_API main(int argc, char** argv) { { - Application app = Application::New( &argc, &argv ); - Demo::TextOverlapController controller( app ); + Application app = Application::New(&argc, &argv); + Demo::TextOverlapController controller(app); app.MainLoop(); } - exit( 0 ); + exit(0); }