-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.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://floralicense.org/license/
-//
-// 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.
-//
+/*
+ * Copyright (c) 2015 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 <dali/dali.h>
#include <dali-toolkit/dali-toolkit.h>
-#include "../shared/view.h"
+#include "shared/view.h"
#include "radial-sweep-view.h"
#include "radial-sweep-view-impl.h"
namespace
{
-const char* TEST_OUTER_RING_FILENAME = DALI_IMAGE_DIR "layer2.png"; // Image to be masked
-const char* TEST_INNER_RING_FILENAME = DALI_IMAGE_DIR "layer1.png"; // Image to be masked
-const char* TEST_MENU_FILENAME = DALI_IMAGE_DIR "layer3.png"; // Image to be masked
-const char* TEST_DIAL_FILENAME = DALI_IMAGE_DIR "layer4.png"; // Image to be masked
-const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); // Background for toolbar
+const char* TEST_OUTER_RING_FILENAME = DEMO_IMAGE_DIR "layer2.png"; // Image to be masked
+const char* TEST_INNER_RING_FILENAME = DEMO_IMAGE_DIR "layer1.png"; // Image to be masked
+const char* TEST_MENU_FILENAME = DEMO_IMAGE_DIR "layer3.png"; // Image to be masked
+const char* TEST_DIAL_FILENAME = DEMO_IMAGE_DIR "layer4.png"; // Image to be masked
+const char* TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" ); // Background for toolbar
const char* APPLICATION_TITLE( "Radial Menu" );
-const char * const PLAY_ICON( DALI_IMAGE_DIR "icon-play.png" );
-const char * const STOP_ICON( DALI_IMAGE_DIR "icon-stop.png" );
+const char * const PLAY_ICON( DEMO_IMAGE_DIR "icon-play.png" );
+const char * const PLAY_ICON_SELECTED( DEMO_IMAGE_DIR "icon-play-selected.png" );
+const char * const STOP_ICON( DEMO_IMAGE_DIR "icon-stop.png" );
+const char * const STOP_ICON_SELECTED( DEMO_IMAGE_DIR "icon-stop-selected.png" );
}
*/
RadialSweepView CreateSweepView( std::string imageName, Degree initial, Degree final );
+ /**
+ * Start the sweep animation on the menu
+ */
void StartAnimation();
+ /**
+ * Play or pause the animation when the button is clicked
+ */
bool OnButtonClicked( Toolkit::Button button );
+ /**
+ * Update the state flag and change the button icon when the animation is finished
+ */
void OnAnimationFinished( Animation& source );
/**
};
Application mApplication; ///< The application handle
- Toolkit::View mView; ///< The toolbar view
+ Toolkit::Control mView; ///< The toolbar view
Layer mContents; ///< The toolbar contents pane
- ImageActor mImageActor; ///< Image actor shown by stencil mask
+ ImageView mImageView; ///< Image view shown by stencil mask
Animation mAnimation;
AnimState mAnimationState;
- Image mIconPlay;
- Image mIconStop;
Toolkit::PushButton mPlayStopButton;
- ImageActor mDialActor;
+ ImageView mDialView;
RadialSweepView mRadialSweepView1;
RadialSweepView mRadialSweepView2;
RadialSweepView mRadialSweepView3;
void RadialMenuExample::OnInit(Application& app)
{
+ Stage stage = Dali::Stage::GetCurrent();
+
// The Init signal is received once (only) during the Application lifetime
- Stage::GetCurrent().KeyEventSignal().Connect(this, &RadialMenuExample::OnKeyEvent);
+ stage.KeyEventSignal().Connect(this, &RadialMenuExample::OnKeyEvent);
// Create toolbar & view
Toolkit::ToolBar toolBar;
TOOLBAR_IMAGE,
APPLICATION_TITLE );
- mIconPlay = Image::New( PLAY_ICON );
- mIconStop = Image::New( STOP_ICON );
mPlayStopButton = Toolkit::PushButton::New();
- mPlayStopButton.SetBackgroundImage( mIconStop );
+ mPlayStopButton.SetUnselectedImage( STOP_ICON );
+ mPlayStopButton.SetSelectedImage( STOP_ICON_SELECTED );
mPlayStopButton.ClickedSignal().Connect( this, &RadialMenuExample::OnButtonClicked );
Toolkit::Alignment::HorizontalRight,
DemoHelper::DEFAULT_PLAY_PADDING );
- Vector2 imgSize = Image::GetImageSize(TEST_OUTER_RING_FILENAME);
- float scale = Stage::GetCurrent().GetSize().width / imgSize.width;
+
+ const ImageDimensions intImgSize = ResourceImage::GetImageSize(TEST_OUTER_RING_FILENAME);
+ Vector2 imgSize = Vector2( intImgSize.GetWidth(), intImgSize.GetHeight() );
+ Vector2 stageSize = stage.GetSize();
+ float scale = stageSize.width / imgSize.width;
+ float availableHeight = stageSize.height - DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight * 2.0f;
+ if(availableHeight <= stageSize.width)
+ {
+ scale = availableHeight / imgSize.width;
+ }
mRadialSweepView1 = CreateSweepView( TEST_OUTER_RING_FILENAME, Degree(-90.0f), Degree(-90.0f));
mRadialSweepView2 = CreateSweepView( TEST_INNER_RING_FILENAME, Degree(90.0f), Degree(0.0f));
mRadialSweepView3.SetInitialActorAngle(Degree(-110));
mRadialSweepView3.SetFinalActorAngle(Degree(0));
- Image dial = Image::New( TEST_DIAL_FILENAME );
- mDialActor = ImageActor::New( dial );
- mDialActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
- mDialActor.SetScale(scale);
+ mDialView = ImageView::New( TEST_DIAL_FILENAME );
+ mDialView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+ mDialView.SetParentOrigin( ParentOrigin::CENTER );
+ mDialView.SetScale(scale);
Layer dialLayer = Layer::New();
- dialLayer.Add(mDialActor);
- dialLayer.SetPositionInheritanceMode(USE_PARENT_POSITION);
- dialLayer.SetSize(Stage::GetCurrent().GetSize());
+ dialLayer.Add( mDialView );
+ dialLayer.SetParentOrigin( ParentOrigin::CENTER );
+ dialLayer.SetSize(stage.GetSize());
mContents.Add(dialLayer);
mRadialSweepView1.SetScale(scale);
void RadialMenuExample::StartAnimation()
{
- mDialActor.SetOpacity(0.0f);
+ mDialView.SetOpacity(0.0f);
mRadialSweepView1.SetOpacity(0.0f);
mAnimation = Animation::New(6.0f);
mRadialSweepView1.Activate(mAnimation, 0.0f, 3.0f);
mRadialSweepView2.Activate(mAnimation, 1.5f, 3.0f);
mRadialSweepView3.Activate(mAnimation, 3.0f, 3.0f);
- mAnimation.OpacityTo(mDialActor, 1.0f, AlphaFunctions::EaseIn, 0.0f, 0.8f);
- mAnimation.OpacityTo(mRadialSweepView1, 1.0f, AlphaFunctions::EaseIn, 0.0f, 0.5f);
+ mAnimation.AnimateTo( Property( mDialView, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN, TimePeriod( 0.0f, 0.8f ) );
+ mAnimation.AnimateTo( Property( mRadialSweepView1, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN, TimePeriod( 0.0f, 0.5f ) );
mAnimation.FinishedSignal().Connect( this, &RadialMenuExample::OnAnimationFinished );
mAnimationState = PLAYING;
case PLAYING:
{
mAnimation.Pause();
- mPlayStopButton.SetBackgroundImage( mIconPlay );
+ mAnimationState = PAUSED;
+ mPlayStopButton.SetUnselectedImage( PLAY_ICON );
+ mPlayStopButton.SetSelectedImage( PLAY_ICON_SELECTED );
}
break;
case PAUSED:
{
mAnimation.Play();
- mPlayStopButton.SetBackgroundImage( mIconStop );
+ mAnimationState = PLAYING;
+ mPlayStopButton.SetUnselectedImage( STOP_ICON );
+ mPlayStopButton.SetSelectedImage( STOP_ICON_SELECTED );
}
break;
case STOPPED:
{
- mPlayStopButton.SetBackgroundImage( mIconStop );
+ mPlayStopButton.SetUnselectedImage( STOP_ICON );
+ mPlayStopButton.SetSelectedImage( STOP_ICON_SELECTED );
mRadialSweepView1.Deactivate();
mRadialSweepView2.Deactivate();
mRadialSweepView3.Deactivate();
void RadialMenuExample::OnAnimationFinished( Animation& source )
{
mAnimationState = STOPPED;
- mPlayStopButton.SetBackgroundImage( mIconPlay );
+ mPlayStopButton.SetUnselectedImage( PLAY_ICON );
+ mPlayStopButton.SetSelectedImage( PLAY_ICON_SELECTED );
}
RadialSweepView RadialMenuExample::CreateSweepView( std::string imageName,
Degree finalAngle)
{
// Create the image
- Image image = Image::New(imageName);
- mImageActor = ImageActor::New(image);
- mImageActor.SetParentOrigin(ParentOrigin::CENTER);
- mImageActor.SetAnchorPoint(AnchorPoint::CENTER);
+ mImageView = ImageView::New(imageName);
+ mImageView.SetParentOrigin(ParentOrigin::CENTER);
+ mImageView.SetAnchorPoint(AnchorPoint::CENTER);
+ mImageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
// Create the stencil
- float diameter = std::max(image.GetWidth(), image.GetHeight());
+ const ImageDimensions imageSize = ResourceImage::GetImageSize(imageName);
+ float diameter = std::max(imageSize.GetWidth(), imageSize.GetHeight());
RadialSweepView radialSweepView = RadialSweepView::New();
radialSweepView.SetDiameter( diameter );
radialSweepView.SetInitialAngle( initialAngle );
radialSweepView.SetInitialSector( Degree(0.0f) );
radialSweepView.SetFinalSector( Degree(359.999f) );
radialSweepView.SetSize( Stage::GetCurrent().GetSize());
- radialSweepView.SetEasingFunction( Dali::AlphaFunctions::EaseInOut );
- radialSweepView.SetPositionInheritanceMode(USE_PARENT_POSITION);
+ radialSweepView.SetEasingFunction( Dali::AlphaFunction::EASE_IN_OUT );
+ radialSweepView.SetParentOrigin( ParentOrigin::CENTER );
mContents.Add(radialSweepView);
- radialSweepView.Add( mImageActor );
- mImageActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
+ radialSweepView.Add( mImageView );
+ mImageView.SetParentOrigin( ParentOrigin::CENTER );
return radialSweepView;
}
}
// Entry point for Linux & Tizen applications
-int main(int argc, char **argv)
+int DALI_EXPORT_API main(int argc, char **argv)
{
- Application app = Application::New(&argc, &argv);
+ Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
RunTest(app);