Commit 703a3a34cd843dc35f1600eaf16e92830823783e
1 parent
90589dc7
Add circular style example to the progress-bar-example
Change-Id: I6d0b104c63c5ea88a7eebde892161d42352bb015 Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
Showing
4 changed files
with
92 additions
and
1 deletions
examples/progress-bar/progress-bar-example.cpp
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | 17 | ||
| 18 | #include "shared/view.h" | 18 | #include "shared/view.h" |
| 19 | #include <dali-toolkit/dali-toolkit.h> | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | +#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar-devel.h> | ||
| 20 | 21 | ||
| 21 | using namespace Dali; | 22 | using namespace Dali; |
| 22 | using namespace Dali::Toolkit; | 23 | using namespace Dali::Toolkit; |
| @@ -34,6 +35,7 @@ const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f ); | @@ -34,6 +35,7 @@ const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f ); | ||
| 34 | // Layout sizes | 35 | // Layout sizes |
| 35 | const int MARGIN_SIZE = 10; | 36 | const int MARGIN_SIZE = 10; |
| 36 | const int TOP_MARGIN = 85; | 37 | const int TOP_MARGIN = 85; |
| 38 | +const int CIRCULAR_PROGRESS_BAR_SIZE = 64; | ||
| 37 | 39 | ||
| 38 | const unsigned int TIMER_TIMEOUT_TIME = 50; | 40 | const unsigned int TIMER_TIMEOUT_TIME = 50; |
| 39 | const float PROGRESS_INCREMENT_VALUE = 0.01f; | 41 | const float PROGRESS_INCREMENT_VALUE = 0.01f; |
| @@ -83,6 +85,12 @@ private: | @@ -83,6 +85,12 @@ private: | ||
| 83 | mProgressBarDefault.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); | 85 | mProgressBarDefault.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); |
| 84 | mProgressBarDefault.ValueChangedSignal().Connect( this, &ProgressBarExample::OnValueChanged ); | 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 | Toolkit::TableView contentTable = Toolkit::TableView::New(2, 1); | 94 | Toolkit::TableView contentTable = Toolkit::TableView::New(2, 1); |
| 87 | contentTable.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); | 95 | contentTable.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); |
| 88 | contentTable.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); | 96 | contentTable.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); |
| @@ -99,7 +107,7 @@ private: | @@ -99,7 +107,7 @@ private: | ||
| 99 | mContentLayer.Add( contentTable ); | 107 | mContentLayer.Add( contentTable ); |
| 100 | 108 | ||
| 101 | // Image selector for progress bar | 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 | progressBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | 111 | progressBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); |
| 104 | progressBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | 112 | progressBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); |
| 105 | progressBackground.SetBackgroundColor( BACKGROUND_COLOUR ); | 113 | progressBackground.SetBackgroundColor( BACKGROUND_COLOUR ); |
| @@ -113,6 +121,7 @@ private: | @@ -113,6 +121,7 @@ private: | ||
| 113 | 121 | ||
| 114 | contentTable.Add( progressBackground ); | 122 | contentTable.Add( progressBackground ); |
| 115 | progressBackground.Add( mProgressBarDefault ); | 123 | progressBackground.Add( mProgressBarDefault ); |
| 124 | + progressBackground.Add( mProgressBarCircular ); | ||
| 116 | 125 | ||
| 117 | // Create buttons | 126 | // Create buttons |
| 118 | Toolkit::TableView buttonBackground = Toolkit::TableView::New( 3, 1 ); | 127 | Toolkit::TableView buttonBackground = Toolkit::TableView::New( 3, 1 ); |
| @@ -164,6 +173,8 @@ private: | @@ -164,6 +173,8 @@ private: | ||
| 164 | mSecondaryProgressValue = mProgressValue + 0.1f; | 173 | mSecondaryProgressValue = mProgressValue + 0.1f; |
| 165 | mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); | 174 | mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); |
| 166 | mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, mSecondaryProgressValue); | 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 | return ( mProgressValue < 1.0f ); // Only call again if progress has NOT got to the end | 179 | return ( mProgressValue < 1.0f ); // Only call again if progress has NOT got to the end |
| 169 | } | 180 | } |
| @@ -174,6 +185,8 @@ private: | @@ -174,6 +185,8 @@ private: | ||
| 174 | mSecondaryProgressValue = 0.1f; | 185 | mSecondaryProgressValue = 0.1f; |
| 175 | mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); | 186 | mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); |
| 176 | mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, 0.1f); | 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 | mTimer.Start(); | 190 | mTimer.Start(); |
| 178 | return true; | 191 | return true; |
| 179 | } | 192 | } |
| @@ -192,10 +205,12 @@ private: | @@ -192,10 +205,12 @@ private: | ||
| 192 | if( mProgressBarDefault.GetProperty<bool>(ProgressBar::Property::INDETERMINATE)) | 205 | if( mProgressBarDefault.GetProperty<bool>(ProgressBar::Property::INDETERMINATE)) |
| 193 | { | 206 | { |
| 194 | mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, false); | 207 | mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, false); |
| 208 | + mProgressBarCircular.SetProperty( ProgressBar::Property::INDETERMINATE, false ); | ||
| 195 | } | 209 | } |
| 196 | else | 210 | else |
| 197 | { | 211 | { |
| 198 | mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, true); | 212 | mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, true); |
| 213 | + mProgressBarCircular.SetProperty( ProgressBar::Property::INDETERMINATE, true ); | ||
| 199 | } | 214 | } |
| 200 | return true; | 215 | return true; |
| 201 | } | 216 | } |
| @@ -236,6 +251,7 @@ private: | @@ -236,6 +251,7 @@ private: | ||
| 236 | Toolkit::ToolBar mToolBar; ///< The View's Toolbar. | 251 | Toolkit::ToolBar mToolBar; ///< The View's Toolbar. |
| 237 | Layer mContentLayer; ///< Content layer. | 252 | Layer mContentLayer; ///< Content layer. |
| 238 | ProgressBar mProgressBarDefault; | 253 | ProgressBar mProgressBarDefault; |
| 254 | + ProgressBar mProgressBarCircular; | ||
| 239 | Toolkit::PushButton mResetProgressButton; | 255 | Toolkit::PushButton mResetProgressButton; |
| 240 | Toolkit::PushButton mSetIndeterminateButton; | 256 | Toolkit::PushButton mSetIndeterminateButton; |
| 241 | Toolkit::PushButton mChangeThemeButton; | 257 | Toolkit::PushButton mChangeThemeButton; |
resources/style/android/progress-bar-example-theme.json
| @@ -29,6 +29,31 @@ | @@ -29,6 +29,31 @@ | ||
| 29 | "secondaryProgressVisual":{ | 29 | "secondaryProgressVisual":{ |
| 30 | "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png" | 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,6 +28,31 @@ | ||
| 28 | "secondaryProgressVisual":{ | 28 | "secondaryProgressVisual":{ |
| 29 | "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png" | 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,6 +29,31 @@ | ||
| 29 | "secondaryProgressVisual":{ | 29 | "secondaryProgressVisual":{ |
| 30 | "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png" | 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 | } |