Commit 703a3a34cd843dc35f1600eaf16e92830823783e

Authored by Jiyun Yang
1 parent 90589dc7

Add circular style example to the progress-bar-example

Change-Id: I6d0b104c63c5ea88a7eebde892161d42352bb015
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
examples/progress-bar/progress-bar-example.cpp
... ... @@ -17,6 +17,7 @@
17 17  
18 18 #include "shared/view.h"
19 19 #include <dali-toolkit/dali-toolkit.h>
  20 +#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar-devel.h>
20 21  
21 22 using namespace Dali;
22 23 using namespace Dali::Toolkit;
... ... @@ -34,6 +35,7 @@ const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f );
34 35 // Layout sizes
35 36 const int MARGIN_SIZE = 10;
36 37 const int TOP_MARGIN = 85;
  38 +const int CIRCULAR_PROGRESS_BAR_SIZE = 64;
37 39  
38 40 const unsigned int TIMER_TIMEOUT_TIME = 50;
39 41 const float PROGRESS_INCREMENT_VALUE = 0.01f;
... ... @@ -83,6 +85,12 @@ private:
83 85 mProgressBarDefault.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
84 86 mProgressBarDefault.ValueChangedSignal().Connect( this, &ProgressBarExample::OnValueChanged );
85 87  
  88 + // Creates a progress bar in circular style
  89 + mProgressBarCircular = DevelProgressBar::New( DevelProgressBar::Style::CIRCULAR );
  90 + mProgressBarCircular.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
  91 + mProgressBarCircular.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
  92 + mProgressBarCircular.SetProperty( Actor::Property::SIZE, Vector2( CIRCULAR_PROGRESS_BAR_SIZE, CIRCULAR_PROGRESS_BAR_SIZE ) );
  93 +
86 94 Toolkit::TableView contentTable = Toolkit::TableView::New(2, 1);
87 95 contentTable.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
88 96 contentTable.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT);
... ... @@ -99,7 +107,7 @@ private:
99 107 mContentLayer.Add( contentTable );
100 108  
101 109 // Image selector for progress bar
102   - Toolkit::TableView progressBackground = Toolkit::TableView::New( 1, 1 );
  110 + Toolkit::TableView progressBackground = Toolkit::TableView::New( 2, 1 );
103 111 progressBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
104 112 progressBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
105 113 progressBackground.SetBackgroundColor( BACKGROUND_COLOUR );
... ... @@ -113,6 +121,7 @@ private:
113 121  
114 122 contentTable.Add( progressBackground );
115 123 progressBackground.Add( mProgressBarDefault );
  124 + progressBackground.Add( mProgressBarCircular );
116 125  
117 126 // Create buttons
118 127 Toolkit::TableView buttonBackground = Toolkit::TableView::New( 3, 1 );
... ... @@ -164,6 +173,8 @@ private:
164 173 mSecondaryProgressValue = mProgressValue + 0.1f;
165 174 mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue);
166 175 mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, mSecondaryProgressValue);
  176 + mProgressBarCircular.SetProperty( ProgressBar::Property::PROGRESS_VALUE, mProgressValue );
  177 + mProgressBarCircular.SetProperty( ProgressBar::Property::SECONDARY_PROGRESS_VALUE, mSecondaryProgressValue );
167 178  
168 179 return ( mProgressValue < 1.0f ); // Only call again if progress has NOT got to the end
169 180 }
... ... @@ -174,6 +185,8 @@ private:
174 185 mSecondaryProgressValue = 0.1f;
175 186 mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f);
176 187 mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, 0.1f);
  188 + mProgressBarCircular.SetProperty( ProgressBar::Property::PROGRESS_VALUE, 0.0f );
  189 + mProgressBarCircular.SetProperty( ProgressBar::Property::SECONDARY_PROGRESS_VALUE, 0.1f );
177 190 mTimer.Start();
178 191 return true;
179 192 }
... ... @@ -192,10 +205,12 @@ private:
192 205 if( mProgressBarDefault.GetProperty<bool>(ProgressBar::Property::INDETERMINATE))
193 206 {
194 207 mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, false);
  208 + mProgressBarCircular.SetProperty( ProgressBar::Property::INDETERMINATE, false );
195 209 }
196 210 else
197 211 {
198 212 mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, true);
  213 + mProgressBarCircular.SetProperty( ProgressBar::Property::INDETERMINATE, true );
199 214 }
200 215 return true;
201 216 }
... ... @@ -236,6 +251,7 @@ private:
236 251 Toolkit::ToolBar mToolBar; ///< The View's Toolbar.
237 252 Layer mContentLayer; ///< Content layer.
238 253 ProgressBar mProgressBarDefault;
  254 + ProgressBar mProgressBarCircular;
239 255 Toolkit::PushButton mResetProgressButton;
240 256 Toolkit::PushButton mSetIndeterminateButton;
241 257 Toolkit::PushButton mChangeThemeButton;
... ...
resources/style/android/progress-bar-example-theme.json
... ... @@ -29,6 +29,31 @@
29 29 "secondaryProgressVisual":{
30 30 "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png"
31 31 }
  32 + },
  33 + "CircularProgressBar":
  34 + {
  35 + "trackVisual":{
  36 + "visualType":"ARC",
  37 + "mixColor":[1.0, 0.898, 0.769, 1.0],
  38 + "thickness":8.0
  39 + },
  40 + "progressVisual":{
  41 + "visualType":"ARC",
  42 + "mixColor":[0.965, 0.494, 0.49, 1.0],
  43 + "thickness":8.0
  44 + },
  45 + "secondaryProgressVisual":{
  46 + "visualType":"ARC",
  47 + "mixColor":[1.0, 0.757, 0.655, 1.0],
  48 + "thickness":8.0
  49 + },
  50 + "indeterminateVisual":{
  51 + "visualType":"ARC",
  52 + "mixColor":[0.49, 0.478, 0.635, 1.0],
  53 + "thickness":8.0,
  54 + "startAngle":267.0,
  55 + "sweepAngle":75.0
  56 + }
32 57 }
33 58 }
34 59 }
... ...
resources/style/mobile/progress-bar-example-theme.json
... ... @@ -28,6 +28,31 @@
28 28 "secondaryProgressVisual":{
29 29 "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png"
30 30 }
  31 + },
  32 + "CircularProgressBar":
  33 + {
  34 + "trackVisual":{
  35 + "visualType":"ARC",
  36 + "mixColor":[1.0, 0.898, 0.769, 1.0],
  37 + "thickness":8.0
  38 + },
  39 + "progressVisual":{
  40 + "visualType":"ARC",
  41 + "mixColor":[0.965, 0.494, 0.49, 1.0],
  42 + "thickness":8.0
  43 + },
  44 + "secondaryProgressVisual":{
  45 + "visualType":"ARC",
  46 + "mixColor":[1.0, 0.757, 0.655, 1.0],
  47 + "thickness":8.0
  48 + },
  49 + "indeterminateVisual":{
  50 + "visualType":"ARC",
  51 + "mixColor":[0.49, 0.478, 0.635, 1.0],
  52 + "thickness":8.0,
  53 + "startAngle":267.0,
  54 + "sweepAngle":75.0
  55 + }
31 56 }
32 57 }
33 58 }
... ...
resources/style/progress-bar-example-theme.json
... ... @@ -29,6 +29,31 @@
29 29 "secondaryProgressVisual":{
30 30 "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png"
31 31 }
  32 + },
  33 + "CircularProgressBar":
  34 + {
  35 + "trackVisual":{
  36 + "visualType":"ARC",
  37 + "mixColor":[1.0, 0.898, 0.769, 1.0],
  38 + "thickness":8.0
  39 + },
  40 + "progressVisual":{
  41 + "visualType":"ARC",
  42 + "mixColor":[0.965, 0.494, 0.49, 1.0],
  43 + "thickness":8.0
  44 + },
  45 + "secondaryProgressVisual":{
  46 + "visualType":"ARC",
  47 + "mixColor":[1.0, 0.757, 0.655, 1.0],
  48 + "thickness":8.0
  49 + },
  50 + "indeterminateVisual":{
  51 + "visualType":"ARC",
  52 + "mixColor":[0.49, 0.478, 0.635, 1.0],
  53 + "thickness":8.0,
  54 + "startAngle":267.0,
  55 + "sweepAngle":75.0
  56 + }
32 57 }
33 58 }
34 59 }
... ...