Commit 01646973c29b03f516b6853934ebabf8ca981242
Committed by
Adeel Kazmi
1 parent
3ae7bf67
Added radial menu demo
(Shows off stencil mode and animated meshes) Change-Id: I0ed8f6de271ca914edd570434b27ff37edb1ab6f Signed-off-by: David Steele <david.steele@partner.samsung.com>
Showing
12 changed files
with
1124 additions
and
1 deletions
build/tizen/examples/Makefile.am
| @@ -28,6 +28,7 @@ bin_PROGRAMS = \ | @@ -28,6 +28,7 @@ bin_PROGRAMS = \ | ||
| 28 | motion-blur.example \ | 28 | motion-blur.example \ |
| 29 | motion-stretch.example \ | 29 | motion-stretch.example \ |
| 30 | page-turn-view.example \ | 30 | page-turn-view.example \ |
| 31 | + radial-menu.example \ | ||
| 31 | scroll-view.example \ | 32 | scroll-view.example \ |
| 32 | shadow-bone-lighting.example | 33 | shadow-bone-lighting.example |
| 33 | 34 | ||
| @@ -51,7 +52,7 @@ EXAMPLE_CXXFLAGS = $(DALI_CFLAGS) \ | @@ -51,7 +52,7 @@ EXAMPLE_CXXFLAGS = $(DALI_CFLAGS) \ | ||
| 51 | 52 | ||
| 52 | EXAMPLE_DEPS = | 53 | EXAMPLE_DEPS = |
| 53 | 54 | ||
| 54 | -EXAMPLE_LDADD = $(DALI_LIBS) $(DALI_TOOLKIT_LIBS) $(ECORE_X_LIBS) $(CAPI_MEDIA_PLAYER_LIBS) $(CAPI_APPFW_APPLICATION_LIBS) -lrt | 55 | +EXAMPLE_LDADD = $(DALI_LIBS) $(DALI_TOOLKIT_LIBS) $(ECORE_X_LIBS) $(CAPI_MEDIA_PLAYER_LIBS) $(CAPI_APPFW_APPLICATION_LIBS) -lrt -lEGL |
| 55 | 56 | ||
| 56 | 57 | ||
| 57 | blocks_example_SOURCES = $(examples_src_dir)/blocks/blocks-example.cpp | 58 | blocks_example_SOURCES = $(examples_src_dir)/blocks/blocks-example.cpp |
| @@ -109,6 +110,13 @@ page_turn_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | @@ -109,6 +110,13 @@ page_turn_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | ||
| 109 | page_turn_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) | 110 | page_turn_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) |
| 110 | page_turn_view_example_LDADD = $(EXAMPLE_LDADD) | 111 | page_turn_view_example_LDADD = $(EXAMPLE_LDADD) |
| 111 | 112 | ||
| 113 | +radial_menu_example_SOURCES = $(examples_src_dir)/radial-menu/radial-menu-example.cpp \ | ||
| 114 | + $(examples_src_dir)/radial-menu/radial-sweep-view.cpp \ | ||
| 115 | + $(examples_src_dir)/radial-menu/radial-sweep-view-impl.cpp | ||
| 116 | +radial_menu_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | ||
| 117 | +radial_menu_example_DEPENDENCIES = $(EXAMPLE_DEPS) | ||
| 118 | +radial_menu_example_LDADD = $(EXAMPLE_LDADD) | ||
| 119 | + | ||
| 112 | scroll_view_example_SOURCES = $(examples_src_dir)/scroll-view/scroll-view-example.cpp | 120 | scroll_view_example_SOURCES = $(examples_src_dir)/scroll-view/scroll-view-example.cpp |
| 113 | scroll_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) | 121 | scroll_view_example_CXXFLAGS = $(EXAMPLE_CXXFLAGS) |
| 114 | scroll_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) | 122 | scroll_view_example_DEPENDENCIES = $(EXAMPLE_DEPS) |
com.samsung.dali-demo.xml
| @@ -43,6 +43,9 @@ | @@ -43,6 +43,9 @@ | ||
| 43 | <ui-application appid="motion-stretch.example" exec="/opt/apps/com.samsung.dali-demo/bin/motion-stretch.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 43 | <ui-application appid="motion-stretch.example" exec="/opt/apps/com.samsung.dali-demo/bin/motion-stretch.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 44 | <label>Motion Stretch</label> | 44 | <label>Motion Stretch</label> |
| 45 | </ui-application> | 45 | </ui-application> |
| 46 | + <ui-application appid="radial-menu.example" exec="/opt/apps/com.samsung.dali-demo/bin/radial-menu.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 47 | + <label>Radial Menu</label> | ||
| 48 | + </ui-application> | ||
| 46 | <ui-application appid="scroll-view.example" exec="/opt/apps/com.samsung.dali-demo/bin/scroll-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 49 | <ui-application appid="scroll-view.example" exec="/opt/apps/com.samsung.dali-demo/bin/scroll-view.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 47 | <label>Scroll View</label> | 50 | <label>Scroll View</label> |
| 48 | </ui-application> | 51 | </ui-application> |
demo/dali-demo.cpp
| @@ -34,6 +34,7 @@ int main(int argc, char **argv) | @@ -34,6 +34,7 @@ int main(int argc, char **argv) | ||
| 34 | demo.AddExample(Example("motion-blur.example", "Motion Blur")); | 34 | demo.AddExample(Example("motion-blur.example", "Motion Blur")); |
| 35 | demo.AddExample(Example("motion-stretch.example", "Motion Stretch")); | 35 | demo.AddExample(Example("motion-stretch.example", "Motion Stretch")); |
| 36 | demo.AddExample(Example("page-turn-view.example", "Page Turn View")); | 36 | demo.AddExample(Example("page-turn-view.example", "Page Turn View")); |
| 37 | + demo.AddExample(Example("radial-menu.example", "Radial Menu")); | ||
| 37 | demo.AddExample(Example("scroll-view.example", "Scroll View")); | 38 | demo.AddExample(Example("scroll-view.example", "Scroll View")); |
| 38 | demo.AddExample(Example("shadow-bone-lighting.example", "Lights and shadows")); | 39 | demo.AddExample(Example("shadow-bone-lighting.example", "Lights and shadows")); |
| 39 | app.MainLoop(); | 40 | app.MainLoop(); |
demo/images/layer1.png
0 → 100644
333 KB
demo/images/layer2.png
0 → 100644
196 KB
demo/images/layer3.png
0 → 100644
124 KB
demo/images/layer4.png
0 → 100644
124 KB
examples/radial-menu/radial-menu-example.cpp
0 → 100644
| 1 | +// | ||
| 2 | +// Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 3 | +// | ||
| 4 | +// Licensed under the Flora License, Version 1.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 | ||
| 7 | +// | ||
| 8 | +// http://floralicense.org/license/ | ||
| 9 | +// | ||
| 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. | ||
| 15 | +// | ||
| 16 | + | ||
| 17 | +#include <dali/dali.h> | ||
| 18 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 19 | +#include "../shared/view.h" | ||
| 20 | +#include "radial-sweep-view.h" | ||
| 21 | +#include "radial-sweep-view-impl.h" | ||
| 22 | + | ||
| 23 | +using namespace Dali; | ||
| 24 | +using namespace Dali::Toolkit; | ||
| 25 | + | ||
| 26 | +namespace | ||
| 27 | +{ | ||
| 28 | +const char* TEST_OUTER_RING_FILENAME = DALI_IMAGE_DIR "layer2.png"; // Image to be masked | ||
| 29 | +const char* TEST_INNER_RING_FILENAME = DALI_IMAGE_DIR "layer1.png"; // Image to be masked | ||
| 30 | +const char* TEST_MENU_FILENAME = DALI_IMAGE_DIR "layer3.png"; // Image to be masked | ||
| 31 | +const char* TEST_DIAL_FILENAME = DALI_IMAGE_DIR "layer4.png"; // Image to be masked | ||
| 32 | +const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "desktop_background.png" ); // Background for view | ||
| 33 | +const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); // Background for toolbar | ||
| 34 | +const char* APPLICATION_TITLE( "Radial Menu" ); | ||
| 35 | +const char * const PLAY_ICON( DALI_IMAGE_DIR "icon-play.png" ); | ||
| 36 | +const char * const STOP_ICON( DALI_IMAGE_DIR "icon-stop.png" ); | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | + | ||
| 40 | +/******************************************************************************** | ||
| 41 | + * Application controller class | ||
| 42 | + */ | ||
| 43 | + | ||
| 44 | +// This example shows how to create a mesh actor for use as a stencil buffer | ||
| 45 | +class RadialMenuExample : public ConnectionTracker | ||
| 46 | +{ | ||
| 47 | +public: | ||
| 48 | + /** | ||
| 49 | + * Constructor | ||
| 50 | + * @param[in] app The application handle | ||
| 51 | + */ | ||
| 52 | + RadialMenuExample(Application app); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Destructor | ||
| 56 | + */ | ||
| 57 | + ~RadialMenuExample(); | ||
| 58 | + | ||
| 59 | +private: | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * Initialization signal handler - all actor initialization should happen here | ||
| 63 | + * @param[in] app The application handle | ||
| 64 | + */ | ||
| 65 | + void OnInit(Application& app); | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * Create a sweep view with the given image and parameters | ||
| 69 | + */ | ||
| 70 | + RadialSweepView CreateSweepView( std::string imageName, Degree initial, Degree final ); | ||
| 71 | + | ||
| 72 | + void StartAnimation(); | ||
| 73 | + | ||
| 74 | + bool OnButtonClicked( Toolkit::Button button ); | ||
| 75 | + | ||
| 76 | + void OnAnimationFinished( Animation& source ); | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * Main key event handler | ||
| 80 | + * | ||
| 81 | + * @param[in] event The key event to respond to | ||
| 82 | + */ | ||
| 83 | + void OnKeyEvent(const KeyEvent& event); | ||
| 84 | + | ||
| 85 | +private: // Member variables | ||
| 86 | + enum AnimState | ||
| 87 | + { | ||
| 88 | + STOPPED, | ||
| 89 | + PAUSED, | ||
| 90 | + PLAYING | ||
| 91 | + }; | ||
| 92 | + | ||
| 93 | + Application mApplication; ///< The application handle | ||
| 94 | + Toolkit::View mView; ///< The toolbar view | ||
| 95 | + Layer mContents; ///< The toolbar contents pane | ||
| 96 | + ImageActor mImageActor; ///< Image actor shown by stencil mask | ||
| 97 | + Animation mAnimation; | ||
| 98 | + AnimState mAnimationState; | ||
| 99 | + | ||
| 100 | + Image mIconPlay; | ||
| 101 | + Image mIconStop; | ||
| 102 | + Toolkit::PushButton mPlayStopButton; | ||
| 103 | + ImageActor mDialActor; | ||
| 104 | + RadialSweepView mRadialSweepView1; | ||
| 105 | + RadialSweepView mRadialSweepView2; | ||
| 106 | + RadialSweepView mRadialSweepView3; | ||
| 107 | +}; | ||
| 108 | + | ||
| 109 | +RadialMenuExample::RadialMenuExample(Application app) | ||
| 110 | +: mApplication( app ), | ||
| 111 | + mAnimationState(STOPPED) | ||
| 112 | +{ | ||
| 113 | + // Connect to the Application's Init signal | ||
| 114 | + app.InitSignal().Connect(this, &RadialMenuExample::OnInit); | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +RadialMenuExample::~RadialMenuExample() | ||
| 118 | +{ | ||
| 119 | + // Nothing to do here; actor handles will clean up themselves. | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +void RadialMenuExample::OnInit(Application& app) | ||
| 123 | +{ | ||
| 124 | + // The Init signal is received once (only) during the Application lifetime | ||
| 125 | + Stage::GetCurrent().KeyEventSignal().Connect(this, &RadialMenuExample::OnKeyEvent); | ||
| 126 | + | ||
| 127 | + // Create toolbar & view | ||
| 128 | + Toolkit::ToolBar toolBar; | ||
| 129 | + mContents = DemoHelper::CreateView( mApplication, | ||
| 130 | + mView, | ||
| 131 | + toolBar, | ||
| 132 | + BACKGROUND_IMAGE, | ||
| 133 | + TOOLBAR_IMAGE, | ||
| 134 | + APPLICATION_TITLE ); | ||
| 135 | + | ||
| 136 | + mIconPlay = Image::New( PLAY_ICON ); | ||
| 137 | + mIconStop = Image::New( STOP_ICON ); | ||
| 138 | + mPlayStopButton = Toolkit::PushButton::New(); | ||
| 139 | + mPlayStopButton.SetBackgroundImage( mIconStop ); | ||
| 140 | + | ||
| 141 | + mPlayStopButton.ClickedSignal().Connect( this, &RadialMenuExample::OnButtonClicked ); | ||
| 142 | + | ||
| 143 | + toolBar.AddControl( mPlayStopButton, | ||
| 144 | + DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, | ||
| 145 | + Toolkit::Alignment::HorizontalRight, | ||
| 146 | + DemoHelper::DEFAULT_PLAY_PADDING ); | ||
| 147 | + | ||
| 148 | + Vector2 imgSize = Image::GetImageSize(TEST_OUTER_RING_FILENAME); | ||
| 149 | + float scale = Stage::GetCurrent().GetSize().width / imgSize.width; | ||
| 150 | + | ||
| 151 | + mRadialSweepView1 = CreateSweepView( TEST_OUTER_RING_FILENAME, Degree(-90.0f), Degree(-90.0f)); | ||
| 152 | + mRadialSweepView2 = CreateSweepView( TEST_INNER_RING_FILENAME, Degree(90.0f), Degree(0.0f)); | ||
| 153 | + mRadialSweepView3 = CreateSweepView( TEST_MENU_FILENAME, Degree(100.0f), Degree(0.0f)); | ||
| 154 | + mRadialSweepView3.SetInitialActorAngle(Degree(-110)); | ||
| 155 | + mRadialSweepView3.SetFinalActorAngle(Degree(0)); | ||
| 156 | + | ||
| 157 | + Image dial = Image::New( TEST_DIAL_FILENAME ); | ||
| 158 | + mDialActor = ImageActor::New( dial ); | ||
| 159 | + mDialActor.SetPositionInheritanceMode(USE_PARENT_POSITION); | ||
| 160 | + mDialActor.SetScale(scale); | ||
| 161 | + Layer dialLayer = Layer::New(); | ||
| 162 | + | ||
| 163 | + dialLayer.Add(mDialActor); | ||
| 164 | + dialLayer.SetPositionInheritanceMode(USE_PARENT_POSITION); | ||
| 165 | + dialLayer.SetSize(Stage::GetCurrent().GetSize()); | ||
| 166 | + mContents.Add(dialLayer); | ||
| 167 | + | ||
| 168 | + mRadialSweepView1.SetScale(scale); | ||
| 169 | + mRadialSweepView2.SetScale(scale); | ||
| 170 | + mRadialSweepView3.SetScale(scale); | ||
| 171 | + | ||
| 172 | + StartAnimation(); | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +void RadialMenuExample::StartAnimation() | ||
| 176 | +{ | ||
| 177 | + mDialActor.SetOpacity(0.0f); | ||
| 178 | + mRadialSweepView1.SetOpacity(0.0f); | ||
| 179 | + mAnimation = Animation::New(6.0f); | ||
| 180 | + mRadialSweepView1.Activate(mAnimation, 0.0f, 3.0f); | ||
| 181 | + mRadialSweepView2.Activate(mAnimation, 1.5f, 3.0f); | ||
| 182 | + mRadialSweepView3.Activate(mAnimation, 3.0f, 3.0f); | ||
| 183 | + mAnimation.OpacityTo(mDialActor, 1.0f, AlphaFunctions::EaseIn, 0.0f, 0.8f); | ||
| 184 | + mAnimation.OpacityTo(mRadialSweepView1, 1.0f, AlphaFunctions::EaseIn, 0.0f, 0.5f); | ||
| 185 | + mAnimation.FinishedSignal().Connect( this, &RadialMenuExample::OnAnimationFinished ); | ||
| 186 | + | ||
| 187 | + mAnimationState = PLAYING; | ||
| 188 | + mAnimation.Play(); | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +bool RadialMenuExample::OnButtonClicked( Toolkit::Button button ) | ||
| 192 | +{ | ||
| 193 | + switch( mAnimationState ) | ||
| 194 | + { | ||
| 195 | + case PLAYING: | ||
| 196 | + { | ||
| 197 | + mAnimation.Pause(); | ||
| 198 | + mPlayStopButton.SetBackgroundImage( mIconPlay ); | ||
| 199 | + } | ||
| 200 | + break; | ||
| 201 | + | ||
| 202 | + case PAUSED: | ||
| 203 | + { | ||
| 204 | + mAnimation.Play(); | ||
| 205 | + mPlayStopButton.SetBackgroundImage( mIconStop ); | ||
| 206 | + } | ||
| 207 | + break; | ||
| 208 | + | ||
| 209 | + case STOPPED: | ||
| 210 | + { | ||
| 211 | + mPlayStopButton.SetBackgroundImage( mIconStop ); | ||
| 212 | + mRadialSweepView1.Deactivate(); | ||
| 213 | + mRadialSweepView2.Deactivate(); | ||
| 214 | + mRadialSweepView3.Deactivate(); | ||
| 215 | + StartAnimation(); | ||
| 216 | + } | ||
| 217 | + } | ||
| 218 | + return false; | ||
| 219 | +} | ||
| 220 | + | ||
| 221 | +void RadialMenuExample::OnAnimationFinished( Animation& source ) | ||
| 222 | +{ | ||
| 223 | + mAnimationState = STOPPED; | ||
| 224 | + mPlayStopButton.SetBackgroundImage( mIconPlay ); | ||
| 225 | +} | ||
| 226 | + | ||
| 227 | +RadialSweepView RadialMenuExample::CreateSweepView( std::string imageName, | ||
| 228 | + Degree initialAngle, | ||
| 229 | + Degree finalAngle) | ||
| 230 | +{ | ||
| 231 | + // Create the image | ||
| 232 | + Image image = Image::New(imageName); | ||
| 233 | + mImageActor = ImageActor::New(image); | ||
| 234 | + mImageActor.SetParentOrigin(ParentOrigin::CENTER); | ||
| 235 | + mImageActor.SetAnchorPoint(AnchorPoint::CENTER); | ||
| 236 | + | ||
| 237 | + // Create the stencil | ||
| 238 | + float diameter = std::max(image.GetWidth(), image.GetHeight()); | ||
| 239 | + RadialSweepView radialSweepView = RadialSweepView::New(); | ||
| 240 | + radialSweepView.SetDiameter( diameter ); | ||
| 241 | + radialSweepView.SetInitialAngle( initialAngle ); | ||
| 242 | + radialSweepView.SetFinalAngle( finalAngle ); | ||
| 243 | + radialSweepView.SetInitialSector( Degree(0.0f) ); | ||
| 244 | + radialSweepView.SetFinalSector( Degree(359.999f) ); | ||
| 245 | + radialSweepView.SetSize( Stage::GetCurrent().GetSize()); | ||
| 246 | + radialSweepView.SetEasingFunction( Dali::AlphaFunctions::EaseInOut ); | ||
| 247 | + radialSweepView.SetPositionInheritanceMode(USE_PARENT_POSITION); | ||
| 248 | + mContents.Add(radialSweepView); | ||
| 249 | + radialSweepView.Add( mImageActor ); | ||
| 250 | + mImageActor.SetPositionInheritanceMode(USE_PARENT_POSITION); | ||
| 251 | + | ||
| 252 | + return radialSweepView; | ||
| 253 | +} | ||
| 254 | + | ||
| 255 | + | ||
| 256 | +void RadialMenuExample::OnKeyEvent(const KeyEvent& event) | ||
| 257 | +{ | ||
| 258 | + if(event.state == KeyEvent::Down) | ||
| 259 | + { | ||
| 260 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | ||
| 261 | + { | ||
| 262 | + mApplication.Quit(); | ||
| 263 | + } | ||
| 264 | + } | ||
| 265 | +} | ||
| 266 | + | ||
| 267 | +void RunTest(Application app) | ||
| 268 | +{ | ||
| 269 | + RadialMenuExample test(app); | ||
| 270 | + | ||
| 271 | + app.MainLoop(); | ||
| 272 | +} | ||
| 273 | + | ||
| 274 | +// Entry point for Linux & Tizen applications | ||
| 275 | +int main(int argc, char **argv) | ||
| 276 | +{ | ||
| 277 | + Application app = Application::New(&argc, &argv); | ||
| 278 | + | ||
| 279 | + RunTest(app); | ||
| 280 | + | ||
| 281 | + return 0; | ||
| 282 | +} |
examples/radial-menu/radial-sweep-view-impl.cpp
0 → 100644
| 1 | +// | ||
| 2 | +// Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 3 | +// | ||
| 4 | +// Licensed under the Flora License, Version 1.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 | ||
| 7 | +// | ||
| 8 | +// http://floralicense.org/license/ | ||
| 9 | +// | ||
| 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. | ||
| 15 | +// | ||
| 16 | + | ||
| 17 | +#include "radial-sweep-view-impl.h" | ||
| 18 | + | ||
| 19 | +using namespace Dali; | ||
| 20 | + | ||
| 21 | +namespace | ||
| 22 | +{ | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * Method to project a point on a circle of radius halfSide at given | ||
| 26 | + * angle onto a square of side 2 * halfSide | ||
| 27 | + */ | ||
| 28 | +Vector3 CircleSquareProjection( Degree angle, float halfSide ) | ||
| 29 | +{ | ||
| 30 | + Vector3 position(0.0f, 0.0f, 0.0f); | ||
| 31 | + Radian angleInRadians(angle); | ||
| 32 | + | ||
| 33 | + // 135 90 45 | ||
| 34 | + // +--+--+ | ||
| 35 | + // | \|/ | | ||
| 36 | + // 180 +--+--+ 0 | ||
| 37 | + // | /|\ | | ||
| 38 | + // +--+--+ | ||
| 39 | + // 225 270 315 | ||
| 40 | + if( angle >= 45.0f && angle < 135.0f ) | ||
| 41 | + { | ||
| 42 | + position.x = halfSide * cosf(angleInRadians) / sinf(angleInRadians); | ||
| 43 | + position.y = -halfSide; | ||
| 44 | + } | ||
| 45 | + else if( angle >= 135.0f && angle < 225.0f ) | ||
| 46 | + { | ||
| 47 | + position.x = -halfSide; | ||
| 48 | + position.y = halfSide * sinf(angleInRadians) / cosf(angleInRadians); | ||
| 49 | + } | ||
| 50 | + else if( angle >= 225.0f && angle < 315.0f ) | ||
| 51 | + { | ||
| 52 | + position.x = -halfSide * cosf(angleInRadians) / sinf(angleInRadians); | ||
| 53 | + position.y = halfSide; | ||
| 54 | + } | ||
| 55 | + else | ||
| 56 | + { | ||
| 57 | + position.x = halfSide; | ||
| 58 | + position.y = -halfSide * sinf(angleInRadians) / cosf(angleInRadians); | ||
| 59 | + } | ||
| 60 | + return position; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +float HoldZeroFastEaseInOutHoldOne(float progress) | ||
| 64 | +{ | ||
| 65 | + if( progress < 0.2f) | ||
| 66 | + { | ||
| 67 | + return 0.0f; | ||
| 68 | + } | ||
| 69 | + else if(progress < 0.5f) | ||
| 70 | + { | ||
| 71 | + return AlphaFunctions::EaseIn((progress-0.2) / 0.3f) * 0.5f; | ||
| 72 | + } | ||
| 73 | + else if(progress < 0.8f) | ||
| 74 | + { | ||
| 75 | + return AlphaFunctions::EaseOut((progress - 0.5f) / 0.3f) * 0.5f + 0.5f; | ||
| 76 | + } | ||
| 77 | + else | ||
| 78 | + { | ||
| 79 | + return 1.0f; | ||
| 80 | + } | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +struct SquareFanConstraint | ||
| 84 | +{ | ||
| 85 | + SquareFanConstraint(int sideIndex) | ||
| 86 | + : mSideIndex(sideIndex) | ||
| 87 | + { | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + Vector3 operator()( const Vector3& current, const PropertyInput& start, const PropertyInput& rotation ) | ||
| 91 | + { | ||
| 92 | + float degree = fmodf((start.GetFloat() + rotation.GetFloat()), 360.0f); | ||
| 93 | + if(degree < 0.0f) | ||
| 94 | + { | ||
| 95 | + degree += 360.0f; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + float startAngle = (90.0f*mSideIndex)-45.0f; | ||
| 99 | + float endAngle = (90.0f*mSideIndex)+45.0f; | ||
| 100 | + if(degree < startAngle) | ||
| 101 | + { | ||
| 102 | + return Vector3::ZERO; | ||
| 103 | + } | ||
| 104 | + else if( degree >= endAngle ) | ||
| 105 | + { | ||
| 106 | + degree = endAngle; | ||
| 107 | + } | ||
| 108 | + Vector3 pos = CircleSquareProjection(Degree(degree), 0.5f); | ||
| 109 | + pos.x = -pos.x; // Inverting X makes the animation go anti clockwise from left center | ||
| 110 | + return pos; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + int mSideIndex; | ||
| 114 | +}; | ||
| 115 | + | ||
| 116 | +} // anonymous namespace | ||
| 117 | + | ||
| 118 | + | ||
| 119 | +RadialSweepView RadialSweepViewImpl::New( ) | ||
| 120 | +{ | ||
| 121 | + return New( 2.0f, 100.0f, Degree(0.0f), Degree(0.0f), Degree(0.0f), Degree(359.999f) ); | ||
| 122 | +} | ||
| 123 | + | ||
| 124 | + | ||
| 125 | +RadialSweepView RadialSweepViewImpl::New( float duration, float diameter, Degree initialAngle, Degree finalAngle, Degree initialSector, Degree finalSector ) | ||
| 126 | +{ | ||
| 127 | + RadialSweepViewImpl* impl= new RadialSweepViewImpl(duration, diameter, initialAngle, finalAngle, initialSector, finalSector); | ||
| 128 | + RadialSweepView handle = RadialSweepView(*impl); | ||
| 129 | + return handle; | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +RadialSweepViewImpl::RadialSweepViewImpl( float duration, float diameter, Degree initialAngle, Degree finalAngle, Degree initialSector, Degree finalSector ) | ||
| 133 | +: Control( false ), | ||
| 134 | + mDuration(duration), | ||
| 135 | + mDiameter(diameter), | ||
| 136 | + mInitialAngle(initialAngle), | ||
| 137 | + mFinalAngle(finalAngle), | ||
| 138 | + mInitialSector(initialSector), | ||
| 139 | + mFinalSector(finalSector), | ||
| 140 | + mInitialActorAngle(0), | ||
| 141 | + mFinalActorAngle(0), | ||
| 142 | + mEasingFunction(HoldZeroFastEaseInOutHoldOne), | ||
| 143 | + mRotateActorsWithStencil(false), | ||
| 144 | + mRotateActors(false) | ||
| 145 | +{ | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +void RadialSweepViewImpl::SetDuration(float duration) | ||
| 149 | +{ | ||
| 150 | + mDuration = duration; | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +void RadialSweepViewImpl::SetEasingFunction( Dali::AlphaFunction easingFunction ) | ||
| 154 | +{ | ||
| 155 | + mEasingFunction = easingFunction; | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +void RadialSweepViewImpl::SetDiameter(float diameter) | ||
| 159 | +{ | ||
| 160 | + mDiameter = diameter; | ||
| 161 | +} | ||
| 162 | + | ||
| 163 | +void RadialSweepViewImpl::SetInitialAngle( Dali::Degree initialAngle) | ||
| 164 | +{ | ||
| 165 | + mInitialAngle = initialAngle; | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +void RadialSweepViewImpl::SetFinalAngle( Dali::Degree finalAngle) | ||
| 169 | +{ | ||
| 170 | + mFinalAngle = finalAngle; | ||
| 171 | +} | ||
| 172 | + | ||
| 173 | +void RadialSweepViewImpl::SetInitialSector( Dali::Degree initialSector) | ||
| 174 | +{ | ||
| 175 | + mInitialSector = initialSector; | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | +void RadialSweepViewImpl::SetFinalSector( Dali::Degree finalSector) | ||
| 179 | +{ | ||
| 180 | + mFinalSector = finalSector; | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | +void RadialSweepViewImpl::SetInitialActorAngle( Dali::Degree initialAngle ) | ||
| 184 | +{ | ||
| 185 | + mInitialActorAngle = initialAngle; | ||
| 186 | + mRotateActors = true; | ||
| 187 | +} | ||
| 188 | + | ||
| 189 | +void RadialSweepViewImpl::SetFinalActorAngle( Dali::Degree finalAngle ) | ||
| 190 | +{ | ||
| 191 | + mFinalActorAngle = finalAngle; | ||
| 192 | + mRotateActors = true; | ||
| 193 | +} | ||
| 194 | + | ||
| 195 | +float RadialSweepViewImpl::GetDuration( ) | ||
| 196 | +{ | ||
| 197 | + return mDuration; | ||
| 198 | +} | ||
| 199 | + | ||
| 200 | +float RadialSweepViewImpl::GetDiameter( ) | ||
| 201 | +{ | ||
| 202 | + return mDiameter; | ||
| 203 | +} | ||
| 204 | + | ||
| 205 | +Dali::Degree RadialSweepViewImpl::GetInitialAngle( ) | ||
| 206 | +{ | ||
| 207 | + return mInitialAngle; | ||
| 208 | +} | ||
| 209 | + | ||
| 210 | +Dali::Degree RadialSweepViewImpl::GetFinalAngle( ) | ||
| 211 | +{ | ||
| 212 | + return mFinalAngle; | ||
| 213 | +} | ||
| 214 | + | ||
| 215 | +Dali::Degree RadialSweepViewImpl::GetInitialSector( ) | ||
| 216 | +{ | ||
| 217 | + return mInitialSector; | ||
| 218 | +} | ||
| 219 | + | ||
| 220 | +Dali::Degree RadialSweepViewImpl::GetFinalSector( ) | ||
| 221 | +{ | ||
| 222 | + return mFinalSector; | ||
| 223 | +} | ||
| 224 | + | ||
| 225 | +Dali::Degree RadialSweepViewImpl::GetInitialActorAngle( ) | ||
| 226 | +{ | ||
| 227 | + return mInitialActorAngle; | ||
| 228 | +} | ||
| 229 | + | ||
| 230 | +Dali::Degree RadialSweepViewImpl::GetFinalActorAngle( ) | ||
| 231 | +{ | ||
| 232 | + return mFinalActorAngle; | ||
| 233 | +} | ||
| 234 | + | ||
| 235 | +void RadialSweepViewImpl::RotateActorsWithStencil(bool rotate) | ||
| 236 | +{ | ||
| 237 | + mRotateActorsWithStencil = rotate; | ||
| 238 | +} | ||
| 239 | + | ||
| 240 | +void RadialSweepViewImpl::Add(Actor actor) | ||
| 241 | +{ | ||
| 242 | + if( ! mLayer ) | ||
| 243 | + { | ||
| 244 | + mLayer = Layer::New(); | ||
| 245 | + Self().Add(mLayer); | ||
| 246 | + mLayer.SetSize( Stage::GetCurrent().GetSize() ); | ||
| 247 | + mLayer.SetPositionInheritanceMode(USE_PARENT_POSITION); | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + mLayer.Add(actor); | ||
| 251 | +} | ||
| 252 | + | ||
| 253 | +void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float duration ) | ||
| 254 | +{ | ||
| 255 | + bool startAnimation=false; | ||
| 256 | + if( ! anim ) | ||
| 257 | + { | ||
| 258 | + mAnim = Animation::New( mDuration ); | ||
| 259 | + anim = mAnim; | ||
| 260 | + startAnimation = true; | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + if( ! mStencilActor ) | ||
| 264 | + { | ||
| 265 | + CreateStencil( mInitialSector ); | ||
| 266 | + mLayer.Add( mStencilActor ); | ||
| 267 | + mStencilActor.SetSize(mDiameter, mDiameter); | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + mStencilActor.SetRotation( Degree(mInitialAngle), Vector3::ZAXIS ); | ||
| 271 | + mStencilActor.SetProperty( mRotationAngleIndex, static_cast<float>(mInitialSector) ); | ||
| 272 | + | ||
| 273 | + if( mRotateActors ) | ||
| 274 | + { | ||
| 275 | + for(unsigned int i=0, count=mLayer.GetChildCount(); i<count; i++) | ||
| 276 | + { | ||
| 277 | + Actor actor = mLayer.GetChildAt(i); | ||
| 278 | + if( actor != mStencilActor ) | ||
| 279 | + { | ||
| 280 | + anim.RotateTo( actor, mInitialActorAngle, Vector3::ZAXIS ); | ||
| 281 | + } | ||
| 282 | + } | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + anim.AnimateTo( Property( mStencilActor, mRotationAngleIndex ), static_cast<float>(mFinalSector), mEasingFunction, TimePeriod( offsetTime, duration) ); | ||
| 286 | + anim.RotateTo( mStencilActor, mFinalAngle, Vector3::ZAXIS, mEasingFunction, offsetTime, duration ); | ||
| 287 | + | ||
| 288 | + if( mRotateActorsWithStencil ) | ||
| 289 | + { | ||
| 290 | + for(unsigned int i=0, count=mLayer.GetChildCount(); i<count; i++) | ||
| 291 | + { | ||
| 292 | + Actor actor = mLayer.GetChildAt(i); | ||
| 293 | + if( actor != mStencilActor ) | ||
| 294 | + { | ||
| 295 | + anim.RotateTo( actor, Degree(mFinalAngle - mInitialAngle), Vector3::ZAXIS, mEasingFunction, offsetTime, duration ); | ||
| 296 | + } | ||
| 297 | + } | ||
| 298 | + } | ||
| 299 | + else if( mRotateActors ) | ||
| 300 | + { | ||
| 301 | + for(unsigned int i=0, count=mLayer.GetChildCount(); i<count; i++) | ||
| 302 | + { | ||
| 303 | + Actor actor = mLayer.GetChildAt(i); | ||
| 304 | + if( actor != mStencilActor ) | ||
| 305 | + { | ||
| 306 | + anim.RotateTo( actor, mFinalActorAngle, Vector3::ZAXIS, mEasingFunction, offsetTime, duration ); | ||
| 307 | + } | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | + | ||
| 311 | + | ||
| 312 | + if( startAnimation ) | ||
| 313 | + { | ||
| 314 | + anim.SetLooping(true); | ||
| 315 | + anim.Play(); | ||
| 316 | + } | ||
| 317 | +} | ||
| 318 | + | ||
| 319 | + | ||
| 320 | +void RadialSweepViewImpl::Deactivate() | ||
| 321 | +{ | ||
| 322 | + if( mAnim ) | ||
| 323 | + { | ||
| 324 | + mAnim.Stop(); | ||
| 325 | + } | ||
| 326 | + // mLayer.Remove( mStencilActor ); | ||
| 327 | + // mStencilActor.Reset(); | ||
| 328 | + // mMesh.Reset(); | ||
| 329 | + // mMaterial.Reset(); | ||
| 330 | +} | ||
| 331 | + | ||
| 332 | +void RadialSweepViewImpl::CreateStencil( Degree initialSector ) | ||
| 333 | +{ | ||
| 334 | + mMaterial = Material::New("Material"); | ||
| 335 | + mMaterial.SetDiffuseColor(Color::WHITE); | ||
| 336 | + mMaterial.SetAmbientColor(Vector4(0.0, 0.1, 0.1, 1.0)); | ||
| 337 | + | ||
| 338 | + // Generate a square mesh with a point at the center: | ||
| 339 | + | ||
| 340 | + AnimatableMesh::Faces faces; | ||
| 341 | + // Create triangles joining up the verts | ||
| 342 | + faces.push_back(0); faces.push_back(1); faces.push_back(2); | ||
| 343 | + faces.push_back(0); faces.push_back(2); faces.push_back(3); | ||
| 344 | + faces.push_back(0); faces.push_back(3); faces.push_back(4); | ||
| 345 | + faces.push_back(0); faces.push_back(4); faces.push_back(5); | ||
| 346 | + faces.push_back(0); faces.push_back(5); faces.push_back(6); | ||
| 347 | + | ||
| 348 | + mMesh = AnimatableMesh::New(7, faces, mMaterial); | ||
| 349 | + mMesh[0].SetPosition( Vector3( 0.0f, 0.0f, 0.0f ) ); // Center pt | ||
| 350 | + | ||
| 351 | + mStencilActor = MeshActor::New(mMesh); | ||
| 352 | + mStencilActor.SetAffectedByLighting(false); | ||
| 353 | + mStencilActor.SetCullFace(CullNone); // Allow clockwise & anticlockwise faces | ||
| 354 | + | ||
| 355 | + mStartAngleIndex = mStencilActor.RegisterProperty("start-angle", Property::Value(0.0f)); | ||
| 356 | + mRotationAngleIndex = mStencilActor.RegisterProperty("rotation-angle", Property::Value(initialSector)); | ||
| 357 | + | ||
| 358 | + Source srcStart( mStencilActor, mStartAngleIndex ); | ||
| 359 | + Source srcRot( mStencilActor, mRotationAngleIndex ); | ||
| 360 | + | ||
| 361 | + // Constrain the vertices of the square mesh to sweep out a sector as the | ||
| 362 | + // rotation angle is animated. | ||
| 363 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(1, AnimatableVertex::POSITION), | ||
| 364 | + srcStart, srcStart, SquareFanConstraint(0))); | ||
| 365 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(2, AnimatableVertex::POSITION), | ||
| 366 | + srcStart, srcRot, SquareFanConstraint(0))); | ||
| 367 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(3, AnimatableVertex::POSITION), | ||
| 368 | + srcStart, srcRot, SquareFanConstraint(1))); | ||
| 369 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(4, AnimatableVertex::POSITION), | ||
| 370 | + srcStart, srcRot, SquareFanConstraint(2))); | ||
| 371 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(5, AnimatableVertex::POSITION), | ||
| 372 | + srcStart, srcRot, SquareFanConstraint(3))); | ||
| 373 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(6, AnimatableVertex::POSITION), | ||
| 374 | + srcStart, srcRot, SquareFanConstraint(4))); | ||
| 375 | + | ||
| 376 | + mStencilActor.SetDrawMode( DrawMode::STENCIL ); | ||
| 377 | + mStencilActor.SetPositionInheritanceMode(USE_PARENT_POSITION); | ||
| 378 | +} |
examples/radial-menu/radial-sweep-view-impl.h
0 → 100644
| 1 | +#ifndef DALI_DEMO_RADIAL_SWEEP_VIEW_IMPL_H | ||
| 2 | +#define DALI_DEMO_RADIAL_SWEEP_VIEW_IMPL_H | ||
| 3 | + | ||
| 4 | +// | ||
| 5 | +// Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 6 | +// | ||
| 7 | +// Licensed under the Flora License, Version 1.0 (the License); | ||
| 8 | +// you may not use this file except in compliance with the License. | ||
| 9 | +// You may obtain a copy of the License at | ||
| 10 | +// | ||
| 11 | +// http://floralicense.org/license/ | ||
| 12 | +// | ||
| 13 | +// Unless required by applicable law or agreed to in writing, software | ||
| 14 | +// distributed under the License is distributed on an AS IS BASIS, | ||
| 15 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 16 | +// See the License for the specific language governing permissions and | ||
| 17 | +// limitations under the License. | ||
| 18 | +// | ||
| 19 | + | ||
| 20 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 21 | +#include "radial-sweep-view.h" | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +/******************************************************************************** | ||
| 25 | + * Class to implement a layer with a radial sweep stencil mask and an actor tree | ||
| 26 | + */ | ||
| 27 | +class RadialSweepViewImpl : public Dali::Toolkit::Internal::Control | ||
| 28 | +{ | ||
| 29 | +public: | ||
| 30 | + static RadialSweepView New(); | ||
| 31 | + | ||
| 32 | + static RadialSweepView New( float duration, | ||
| 33 | + float diameter, | ||
| 34 | + Dali::Degree initialAngle, | ||
| 35 | + Dali::Degree finalAngle, | ||
| 36 | + Dali::Degree initialSector, | ||
| 37 | + Dali::Degree finalSector ); | ||
| 38 | + | ||
| 39 | + RadialSweepViewImpl( float duration, | ||
| 40 | + float diameter, | ||
| 41 | + Dali::Degree initialAngle, | ||
| 42 | + Dali::Degree finalAngle, | ||
| 43 | + Dali::Degree initialSector, | ||
| 44 | + Dali::Degree finalSector ); | ||
| 45 | + | ||
| 46 | + void SetDuration(float duration); | ||
| 47 | + void SetEasingFunction( Dali::AlphaFunction easingFunction ); | ||
| 48 | + | ||
| 49 | + void SetDiameter(float diameter); | ||
| 50 | + void SetInitialAngle( Dali::Degree initialAngle); | ||
| 51 | + void SetFinalAngle( Dali::Degree finalAngle); | ||
| 52 | + void SetInitialSector( Dali::Degree initialSector); | ||
| 53 | + void SetFinalSector( Dali::Degree finalSector); | ||
| 54 | + void SetInitialActorAngle( Dali::Degree initialAngle ); | ||
| 55 | + void SetFinalActorAngle( Dali::Degree finalAngle ); | ||
| 56 | + | ||
| 57 | + float GetDuration( ); | ||
| 58 | + float GetDiameter( ); | ||
| 59 | + Dali::Degree GetInitialAngle( ); | ||
| 60 | + Dali::Degree GetFinalAngle( ); | ||
| 61 | + Dali::Degree GetInitialSector( ); | ||
| 62 | + Dali::Degree GetFinalSector( ); | ||
| 63 | + Dali::Degree GetInitialActorAngle( ); | ||
| 64 | + Dali::Degree GetFinalActorAngle( ); | ||
| 65 | + | ||
| 66 | + void RotateActorsWithStencil(bool rotate); | ||
| 67 | + | ||
| 68 | + void Add( Dali::Actor actor ); | ||
| 69 | + | ||
| 70 | + void Activate( Dali::Animation anim = Dali::Animation(), float offsetTime=0, float duration=2.0f ); | ||
| 71 | + | ||
| 72 | + void Deactivate(); | ||
| 73 | + | ||
| 74 | +private: | ||
| 75 | + | ||
| 76 | + /** | ||
| 77 | + * Create the stencil mask | ||
| 78 | + */ | ||
| 79 | + void CreateStencil(Dali::Degree initialSector ); | ||
| 80 | + | ||
| 81 | +private: | ||
| 82 | + Dali::Layer mLayer; | ||
| 83 | + Dali::Animation mAnim; | ||
| 84 | + float mDuration; | ||
| 85 | + float mDiameter; | ||
| 86 | + Dali::Degree mInitialAngle; | ||
| 87 | + Dali::Degree mFinalAngle; | ||
| 88 | + Dali::Degree mInitialSector; | ||
| 89 | + Dali::Degree mFinalSector; | ||
| 90 | + Dali::Degree mInitialActorAngle; | ||
| 91 | + Dali::Degree mFinalActorAngle; | ||
| 92 | + Dali::AlphaFunction mEasingFunction; | ||
| 93 | + Dali::MeshActor mStencilActor; ///< Stencil actor which generates mask | ||
| 94 | + Dali::Material mMaterial; ///< Material for drawing mesh actor | ||
| 95 | + Dali::AnimatableMesh mMesh; ///< Animatable mesh | ||
| 96 | + Dali::Property::Index mStartAngleIndex; ///< Index of start-angle property | ||
| 97 | + Dali::Property::Index mRotationAngleIndex; ///< Index of rotation-angle property | ||
| 98 | + bool mRotateActorsWithStencil:1; | ||
| 99 | + bool mRotateActors; | ||
| 100 | +}; | ||
| 101 | + | ||
| 102 | + | ||
| 103 | +inline RadialSweepViewImpl& GetImpl( RadialSweepView& obj ) | ||
| 104 | +{ | ||
| 105 | + DALI_ASSERT_ALWAYS(obj); | ||
| 106 | + Dali::RefObject& handle = obj.GetImplementation(); | ||
| 107 | + return static_cast<RadialSweepViewImpl&>(handle); | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +inline const RadialSweepViewImpl& GetImpl( const RadialSweepView& obj ) | ||
| 111 | +{ | ||
| 112 | + DALI_ASSERT_ALWAYS(obj); | ||
| 113 | + const Dali::RefObject& handle = obj.GetImplementation(); | ||
| 114 | + return static_cast<const RadialSweepViewImpl&>(handle); | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + | ||
| 119 | +#endif // DALI_DEMO_RADIAL_SWEEP_VIEW_IMPL_H |
examples/radial-menu/radial-sweep-view.cpp
0 → 100644
| 1 | +// | ||
| 2 | +// Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 3 | +// | ||
| 4 | +// Licensed under the Flora License, Version 1.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 | ||
| 7 | +// | ||
| 8 | +// http://floralicense.org/license/ | ||
| 9 | +// | ||
| 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. | ||
| 15 | +// | ||
| 16 | + | ||
| 17 | +#include "radial-sweep-view.h" | ||
| 18 | +#include "radial-sweep-view-impl.h" | ||
| 19 | + | ||
| 20 | +using namespace Dali; | ||
| 21 | + | ||
| 22 | +RadialSweepView::RadialSweepView() | ||
| 23 | +{ | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +RadialSweepView::RadialSweepView(const RadialSweepView& handle) | ||
| 27 | +: Control(handle) | ||
| 28 | +{ | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +RadialSweepView& RadialSweepView::operator=(const RadialSweepView& rhs) | ||
| 32 | +{ | ||
| 33 | + if( &rhs != this ) | ||
| 34 | + { | ||
| 35 | + Control::operator=(rhs); | ||
| 36 | + } | ||
| 37 | + return *this; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +RadialSweepView::~RadialSweepView() | ||
| 41 | +{ | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +RadialSweepView RadialSweepView::DownCast( BaseHandle handle ) | ||
| 45 | +{ | ||
| 46 | + return Control::DownCast<RadialSweepView, RadialSweepViewImpl>(handle); | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +RadialSweepView RadialSweepView::New( ) | ||
| 50 | +{ | ||
| 51 | + return RadialSweepViewImpl::New(); | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +RadialSweepView RadialSweepView::New( float duration, | ||
| 55 | + float diameter, | ||
| 56 | + Degree initialAngle, | ||
| 57 | + Degree finalAngle, | ||
| 58 | + Degree initialSector, | ||
| 59 | + Degree finalSector ) | ||
| 60 | +{ | ||
| 61 | + return RadialSweepViewImpl::New(duration, diameter, initialAngle, finalAngle, initialSector, finalSector ); | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +RadialSweepView::RadialSweepView( RadialSweepViewImpl& impl ) | ||
| 65 | +: Control( impl ) | ||
| 66 | +{ | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +RadialSweepView::RadialSweepView( Dali::Internal::CustomActor* impl ) | ||
| 70 | +: Control( impl ) | ||
| 71 | +{ | ||
| 72 | + VerifyCustomActorPointer<RadialSweepViewImpl>(impl); | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +void RadialSweepView::SetDuration(float duration) | ||
| 76 | +{ | ||
| 77 | + GetImpl(*this).SetDuration(duration); | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +void RadialSweepView::SetEasingFunction( Dali::AlphaFunction easingFunction ) | ||
| 81 | +{ | ||
| 82 | + GetImpl(*this).SetEasingFunction( easingFunction ); | ||
| 83 | +} | ||
| 84 | + | ||
| 85 | +void RadialSweepView::SetDiameter(float diameter) | ||
| 86 | +{ | ||
| 87 | + GetImpl(*this).SetDiameter(diameter); | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +void RadialSweepView::SetInitialAngle( Dali::Degree initialAngle) | ||
| 91 | +{ | ||
| 92 | + GetImpl(*this).SetInitialAngle(initialAngle); | ||
| 93 | +} | ||
| 94 | + | ||
| 95 | +void RadialSweepView::SetFinalAngle( Dali::Degree finalAngle) | ||
| 96 | +{ | ||
| 97 | + GetImpl(*this).SetFinalAngle(finalAngle); | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +void RadialSweepView::SetInitialSector( Dali::Degree initialSector) | ||
| 101 | +{ | ||
| 102 | + GetImpl(*this).SetInitialSector(initialSector); | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +void RadialSweepView::SetFinalSector( Dali::Degree finalSector) | ||
| 106 | +{ | ||
| 107 | + GetImpl(*this).SetFinalSector(finalSector); | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +void RadialSweepView::SetInitialActorAngle( Dali::Degree initialAngle ) | ||
| 111 | +{ | ||
| 112 | + GetImpl(*this).SetInitialActorAngle(initialAngle); | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +void RadialSweepView::SetFinalActorAngle( Dali::Degree finalAngle ) | ||
| 116 | +{ | ||
| 117 | + GetImpl(*this).SetFinalActorAngle(finalAngle); | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +float RadialSweepView::GetDuration( ) | ||
| 121 | +{ | ||
| 122 | + return GetImpl(*this).GetDuration(); | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +float RadialSweepView::GetDiameter( ) | ||
| 126 | +{ | ||
| 127 | + return GetImpl(*this).GetDiameter(); | ||
| 128 | +} | ||
| 129 | + | ||
| 130 | +Dali::Degree RadialSweepView::GetInitialAngle( ) | ||
| 131 | +{ | ||
| 132 | + return GetImpl(*this).GetInitialAngle(); | ||
| 133 | +} | ||
| 134 | + | ||
| 135 | +Dali::Degree RadialSweepView::GetFinalAngle( ) | ||
| 136 | +{ | ||
| 137 | + return GetImpl(*this).GetFinalAngle(); | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +Dali::Degree RadialSweepView::GetInitialSector( ) | ||
| 141 | +{ | ||
| 142 | + return GetImpl(*this).GetInitialSector(); | ||
| 143 | +} | ||
| 144 | + | ||
| 145 | +Dali::Degree RadialSweepView::GetFinalSector( ) | ||
| 146 | +{ | ||
| 147 | + return GetImpl(*this).GetFinalSector(); | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +Dali::Degree RadialSweepView::GetInitialActorAngle( ) | ||
| 151 | +{ | ||
| 152 | + return GetImpl(*this).GetInitialActorAngle(); | ||
| 153 | +} | ||
| 154 | + | ||
| 155 | +Dali::Degree RadialSweepView::GetFinalActorAngle( ) | ||
| 156 | +{ | ||
| 157 | + return GetImpl(*this).GetFinalActorAngle(); | ||
| 158 | +} | ||
| 159 | + | ||
| 160 | +void RadialSweepView::RotateActorsWithStencil(bool rotate) | ||
| 161 | +{ | ||
| 162 | + GetImpl(*this).RotateActorsWithStencil(rotate); | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +void RadialSweepView::Add(Actor actor) | ||
| 166 | +{ | ||
| 167 | + GetImpl(*this).Add(actor); | ||
| 168 | +} | ||
| 169 | + | ||
| 170 | +void RadialSweepView::Activate() | ||
| 171 | +{ | ||
| 172 | + GetImpl(*this).Activate(); | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +void RadialSweepView::Activate( Dali::Animation anim, float offsetTime, float duration ) | ||
| 176 | +{ | ||
| 177 | + GetImpl(*this).Activate(anim, offsetTime, duration); | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +void RadialSweepView::Deactivate() | ||
| 181 | +{ | ||
| 182 | + GetImpl(*this).Deactivate(); | ||
| 183 | +} |
examples/radial-menu/radial-sweep-view.h
0 → 100644
| 1 | +#ifndef DALI_DEMO_RADIAL_SWEEP_VIEW_H | ||
| 2 | +#define DALI_DEMO_RADIAL_SWEEP_VIEW_H | ||
| 3 | + | ||
| 4 | +// | ||
| 5 | +// Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 6 | +// | ||
| 7 | +// Licensed under the Flora License, Version 1.0 (the License); | ||
| 8 | +// you may not use this file except in compliance with the License. | ||
| 9 | +// You may obtain a copy of the License at | ||
| 10 | +// | ||
| 11 | +// http://floralicense.org/license/ | ||
| 12 | +// | ||
| 13 | +// Unless required by applicable law or agreed to in writing, software | ||
| 14 | +// distributed under the License is distributed on an AS IS BASIS, | ||
| 15 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 16 | +// See the License for the specific language governing permissions and | ||
| 17 | +// limitations under the License. | ||
| 18 | +// | ||
| 19 | + | ||
| 20 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 21 | + | ||
| 22 | +class RadialSweepViewImpl; | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +/******************************************************************************** | ||
| 26 | + * Handle to RadialSweepView implementation | ||
| 27 | + */ | ||
| 28 | +class RadialSweepView : public Dali::Toolkit::Control | ||
| 29 | +{ | ||
| 30 | +public: | ||
| 31 | + /** | ||
| 32 | + * Create a new RadialSweepView with default parameters (2 second animation, | ||
| 33 | + * no rotation, sweeping out a full cicle). | ||
| 34 | + */ | ||
| 35 | + static RadialSweepView New( ); | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Create a new RadialSweepView. | ||
| 39 | + * @param[in] duration The duration of the sweep animation | ||
| 40 | + * @param[in] diameter The diameter of the stencil mask | ||
| 41 | + * @param[in] initialAngle The initial angle of the anticlockwise line of the sweep sector | ||
| 42 | + * @param[in] finalAngle The final angle of the anticlockwise line of the sweep sector | ||
| 43 | + * @param[in] initialSector The angle of the starting sector | ||
| 44 | + * @param[in] finalSector The angle of the sector at the end of the animation. | ||
| 45 | + * Note, to cover the entire circle, use a value of 359.9999f, not zero or 360. | ||
| 46 | + * | ||
| 47 | + * initial sector | ||
| 48 | + * \ | . | ||
| 49 | + * \ | . | ||
| 50 | + * initialAngle \ | . final sector | ||
| 51 | + * \| _| | ||
| 52 | + * .________ | ||
| 53 | + */ | ||
| 54 | + static RadialSweepView New( float duration, | ||
| 55 | + float diameter, | ||
| 56 | + Dali::Degree initialAngle, | ||
| 57 | + Dali::Degree finalAngle, | ||
| 58 | + Dali::Degree initialSector, | ||
| 59 | + Dali::Degree finalSector ); | ||
| 60 | + | ||
| 61 | + void SetDuration(float duration); | ||
| 62 | + | ||
| 63 | + void SetEasingFunction( Dali::AlphaFunction easingFunction ); | ||
| 64 | + | ||
| 65 | + void SetDiameter(float diameter); | ||
| 66 | + | ||
| 67 | + void SetInitialAngle( Dali::Degree initialAngle); | ||
| 68 | + | ||
| 69 | + void SetFinalAngle( Dali::Degree finalAngle); | ||
| 70 | + | ||
| 71 | + void SetInitialSector( Dali::Degree initialSector); | ||
| 72 | + | ||
| 73 | + void SetFinalSector( Dali::Degree finalSector); | ||
| 74 | + | ||
| 75 | + void SetInitialActorAngle( Dali::Degree initialAngle ); | ||
| 76 | + | ||
| 77 | + void SetFinalActorAngle( Dali::Degree finalAngle ); | ||
| 78 | + | ||
| 79 | + float GetDuration( ); | ||
| 80 | + | ||
| 81 | + float GetDiameter( ); | ||
| 82 | + | ||
| 83 | + Dali::Degree GetInitialAngle( ); | ||
| 84 | + | ||
| 85 | + Dali::Degree GetFinalAngle( ); | ||
| 86 | + | ||
| 87 | + Dali::Degree GetInitialSector( ); | ||
| 88 | + | ||
| 89 | + Dali::Degree GetFinalSector( ); | ||
| 90 | + | ||
| 91 | + Dali::Degree GetInitialActorAngle( ); | ||
| 92 | + | ||
| 93 | + Dali::Degree GetFinalActorAngle( ); | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * @param[in] rotate True if the actors should rotate with the stencil | ||
| 97 | + */ | ||
| 98 | + void RotateActorsWithStencil(bool rotate); | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * Add actors to the view | ||
| 102 | + */ | ||
| 103 | + void Add(Actor actor); | ||
| 104 | + | ||
| 105 | + /** | ||
| 106 | + * Activate the sweep animation | ||
| 107 | + */ | ||
| 108 | + void Activate( ); | ||
| 109 | + | ||
| 110 | + void Activate( Dali::Animation anim, float offsetTime, float duration ); | ||
| 111 | + | ||
| 112 | + /** | ||
| 113 | + * Deactivate the sweep animation | ||
| 114 | + */ | ||
| 115 | + void Deactivate(); | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * Default constructor. Create an uninitialized handle. | ||
| 119 | + */ | ||
| 120 | + RadialSweepView(); | ||
| 121 | + | ||
| 122 | + /** | ||
| 123 | + * Copy constructor | ||
| 124 | + */ | ||
| 125 | + RadialSweepView(const RadialSweepView& handle); | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * Assignment operator | ||
| 129 | + */ | ||
| 130 | + RadialSweepView& operator=(const RadialSweepView& rhs); | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * Destructor | ||
| 134 | + */ | ||
| 135 | + virtual ~RadialSweepView(); | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * Downcast method | ||
| 139 | + */ | ||
| 140 | + static RadialSweepView DownCast( BaseHandle handle ); | ||
| 141 | + | ||
| 142 | +public: // Not for use by application developers | ||
| 143 | + | ||
| 144 | + RadialSweepView( RadialSweepViewImpl& impl ); | ||
| 145 | + | ||
| 146 | + RadialSweepView( Dali::Internal::CustomActor* impl ); | ||
| 147 | +}; | ||
| 148 | + | ||
| 149 | +#endif |