Commit 0b3b3c66955214e2c66a1358a1bf10d62afa3302
1 parent
87036627
Update progress bar example
Update progress bar example. There are three new buttons to check new properies of Progress bar. Change-Id: I9bf0607e3fb3763b37ca88c80040d9713b731169 Signed-off-by: minho.sun <minho.sun@samsung.com>
Showing
8 changed files
with
78 additions
and
62 deletions
examples/progress-bar/progress-bar-example.cpp
| ... | ... | @@ -53,6 +53,8 @@ public: |
| 53 | 53 | { |
| 54 | 54 | // Connect to the Application's Init signal |
| 55 | 55 | mProgressValue = 0.0f; |
| 56 | + mSecondaryProgressValue = 0.1f; | |
| 57 | + isDefaultTheme = true; | |
| 56 | 58 | mApplication.InitSignal().Connect( this, &ProgressBarExample::Create ); |
| 57 | 59 | } |
| 58 | 60 | |
| ... | ... | @@ -80,20 +82,7 @@ private: |
| 80 | 82 | mProgressBarDefault.SetAnchorPoint(AnchorPoint::TOP_CENTER); |
| 81 | 83 | mProgressBarDefault.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); |
| 82 | 84 | mProgressBarDefault.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); |
| 83 | - | |
| 84 | - mProgressBarCustomStyle1 = ProgressBar::New(); | |
| 85 | - mProgressBarCustomStyle1.SetStyleName( "ProgressBarCustomStyle1" ); | |
| 86 | - mProgressBarCustomStyle1.SetParentOrigin(ParentOrigin::TOP_CENTER); | |
| 87 | - mProgressBarCustomStyle1.SetAnchorPoint(AnchorPoint::TOP_CENTER); | |
| 88 | - mProgressBarCustomStyle1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); | |
| 89 | - mProgressBarCustomStyle1.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); | |
| 90 | - | |
| 91 | - mProgressBarCustomStyle2 = ProgressBar::New(); | |
| 92 | - mProgressBarCustomStyle2.SetStyleName( "ProgressBarCustomStyle2" ); | |
| 93 | - mProgressBarCustomStyle2.SetParentOrigin(ParentOrigin::TOP_CENTER); | |
| 94 | - mProgressBarCustomStyle2.SetAnchorPoint(AnchorPoint::TOP_CENTER); | |
| 95 | - mProgressBarCustomStyle2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); | |
| 96 | - mProgressBarCustomStyle2.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); | |
| 85 | + mProgressBarDefault.ValueChangedSignal().Connect( this, &ProgressBarExample::OnValueChanged ); | |
| 97 | 86 | |
| 98 | 87 | Toolkit::TableView contentTable = Toolkit::TableView::New(2, 1); |
| 99 | 88 | contentTable.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); |
| ... | ... | @@ -111,7 +100,7 @@ private: |
| 111 | 100 | mContentLayer.Add( contentTable ); |
| 112 | 101 | |
| 113 | 102 | // Image selector for progress bar |
| 114 | - Toolkit::TableView progressBackground = Toolkit::TableView::New( 3, 1 ); | |
| 103 | + Toolkit::TableView progressBackground = Toolkit::TableView::New( 1, 1 ); | |
| 115 | 104 | progressBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); |
| 116 | 105 | progressBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); |
| 117 | 106 | progressBackground.SetBackgroundColor( BACKGROUND_COLOUR ); |
| ... | ... | @@ -125,11 +114,9 @@ private: |
| 125 | 114 | |
| 126 | 115 | contentTable.Add( progressBackground ); |
| 127 | 116 | progressBackground.Add( mProgressBarDefault ); |
| 128 | - progressBackground.Add( mProgressBarCustomStyle1 ); | |
| 129 | - progressBackground.Add( mProgressBarCustomStyle2 ); | |
| 130 | 117 | |
| 131 | 118 | // Create buttons |
| 132 | - Toolkit::TableView buttonBackground = Toolkit::TableView::New( 1, 1 ); | |
| 119 | + Toolkit::TableView buttonBackground = Toolkit::TableView::New( 3, 1 ); | |
| 133 | 120 | buttonBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); |
| 134 | 121 | buttonBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); |
| 135 | 122 | buttonBackground.SetBackgroundColor( BACKGROUND_COLOUR ); |
| ... | ... | @@ -150,6 +137,22 @@ private: |
| 150 | 137 | |
| 151 | 138 | buttonBackground.Add( mResetProgressButton ); |
| 152 | 139 | |
| 140 | + mSetIndeterminateButton = Toolkit::PushButton::New(); | |
| 141 | + mSetIndeterminateButton.SetProperty( Toolkit::Button::Property::LABEL, "Toggle Indeterminate" ); | |
| 142 | + mSetIndeterminateButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 143 | + mSetIndeterminateButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | |
| 144 | + mSetIndeterminateButton.ClickedSignal().Connect( this, &ProgressBarExample::OnSetIndeterminateButtonSelected ); | |
| 145 | + | |
| 146 | + buttonBackground.Add( mSetIndeterminateButton ); | |
| 147 | + | |
| 148 | + mChangeThemeButton = Toolkit::PushButton::New(); | |
| 149 | + mChangeThemeButton.SetProperty( Toolkit::Button::Property::LABEL, "Change Theme" ); | |
| 150 | + mChangeThemeButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 151 | + mChangeThemeButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); | |
| 152 | + mChangeThemeButton.ClickedSignal().Connect( this, &ProgressBarExample::OnChangeThemeButtonSelected ); | |
| 153 | + | |
| 154 | + buttonBackground.Add( mChangeThemeButton ); | |
| 155 | + | |
| 153 | 156 | // Create a timer to update the progress of all progress bars |
| 154 | 157 | mTimer = Timer::New( TIMER_TIMEOUT_TIME ); |
| 155 | 158 | mTimer.TickSignal().Connect( this, &ProgressBarExample::OnTimerTick ); |
| ... | ... | @@ -159,9 +162,9 @@ private: |
| 159 | 162 | bool OnTimerTick() |
| 160 | 163 | { |
| 161 | 164 | mProgressValue += PROGRESS_INCREMENT_VALUE; |
| 165 | + mSecondaryProgressValue = mProgressValue + 0.1f; | |
| 162 | 166 | mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); |
| 163 | - mProgressBarCustomStyle1.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); | |
| 164 | - mProgressBarCustomStyle2.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); | |
| 167 | + mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, mSecondaryProgressValue); | |
| 165 | 168 | |
| 166 | 169 | return ( mProgressValue < 1.0f ); // Only call again if progress has NOT got to the end |
| 167 | 170 | } |
| ... | ... | @@ -169,13 +172,51 @@ private: |
| 169 | 172 | bool OnResetProgressButtonSelected( Toolkit::Button button ) |
| 170 | 173 | { |
| 171 | 174 | mProgressValue = 0.0f; |
| 175 | + mSecondaryProgressValue = 0.1f; | |
| 172 | 176 | mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); |
| 173 | - mProgressBarCustomStyle1.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); | |
| 174 | - mProgressBarCustomStyle2.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); | |
| 177 | + mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, 0.1f); | |
| 175 | 178 | mTimer.Start(); |
| 176 | 179 | return true; |
| 177 | 180 | } |
| 178 | 181 | |
| 182 | + void OnValueChanged( ProgressBar progressBar, float value, float secondaryValue ) | |
| 183 | + { | |
| 184 | + std::stringstream newLabel; | |
| 185 | + newLabel.precision( 2 ); | |
| 186 | + newLabel << std::fixed << "current : " << value << " / loaded : " << secondaryValue; | |
| 187 | + | |
| 188 | + mProgressBarDefault.SetProperty(ProgressBar::Property::LABEL_VISUAL, newLabel.str() ); | |
| 189 | + } | |
| 190 | + | |
| 191 | + bool OnSetIndeterminateButtonSelected( Toolkit::Button button ) | |
| 192 | + { | |
| 193 | + if( mProgressBarDefault.GetProperty<bool>(ProgressBar::Property::INDETERMINATE)) | |
| 194 | + { | |
| 195 | + mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, false); | |
| 196 | + } | |
| 197 | + else | |
| 198 | + { | |
| 199 | + mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, true); | |
| 200 | + } | |
| 201 | + return true; | |
| 202 | + } | |
| 203 | + | |
| 204 | + bool OnChangeThemeButtonSelected( Toolkit::Button button ) | |
| 205 | + { | |
| 206 | + StyleManager styleManager = StyleManager::Get(); | |
| 207 | + | |
| 208 | + if( isDefaultTheme ) | |
| 209 | + { | |
| 210 | + styleManager.ApplyTheme( THEME_PATH ); | |
| 211 | + isDefaultTheme = false; | |
| 212 | + } | |
| 213 | + else | |
| 214 | + { | |
| 215 | + styleManager.ApplyDefaultTheme(); | |
| 216 | + isDefaultTheme = true; | |
| 217 | + } | |
| 218 | + return true; | |
| 219 | + } | |
| 179 | 220 | void OnKeyEvent( const KeyEvent& event ) |
| 180 | 221 | { |
| 181 | 222 | if( event.state == KeyEvent::Down ) |
| ... | ... | @@ -196,15 +237,17 @@ private: |
| 196 | 237 | Toolkit::ToolBar mToolBar; ///< The View's Toolbar. |
| 197 | 238 | Layer mContentLayer; ///< Content layer. |
| 198 | 239 | ProgressBar mProgressBarDefault; |
| 199 | - ProgressBar mProgressBarCustomStyle1; | |
| 200 | - ProgressBar mProgressBarCustomStyle2; | |
| 201 | 240 | Toolkit::PushButton mResetProgressButton; |
| 241 | + Toolkit::PushButton mSetIndeterminateButton; | |
| 242 | + Toolkit::PushButton mChangeThemeButton; | |
| 202 | 243 | float mProgressValue; |
| 244 | + float mSecondaryProgressValue; | |
| 245 | + bool isDefaultTheme; | |
| 203 | 246 | }; |
| 204 | 247 | |
| 205 | 248 | int DALI_EXPORT_API main( int argc, char **argv ) |
| 206 | 249 | { |
| 207 | - Application application = Application::New( &argc, &argv, THEME_PATH ); | |
| 250 | + Application application = Application::New( &argc, &argv ); | |
| 208 | 251 | ProgressBarExample test( application ); |
| 209 | 252 | application.MainLoop(); |
| 210 | 253 | return 0; | ... | ... |
resources/images/progress-bar-progress.9.png renamed to resources/images/new-progress-bar-progress.9.png
199 Bytes
resources/images/new-progress-bar-secondary-progress.9.png
0 → 100644
126 Bytes
resources/images/progress-bar.9.png renamed to resources/images/new-progress-bar-track.9.png
182 Bytes
resources/images/progress-bar-2.9.png deleted
177 Bytes
resources/images/progress-bar-progress-2.9.png deleted
182 Bytes
resources/style/mobile/progress-bar-example-theme.json.in
| ... | ... | @@ -14,33 +14,19 @@ |
| 14 | 14 | * limitations under the License. |
| 15 | 15 | * |
| 16 | 16 | */ |
| 17 | - | |
| 18 | 17 | { |
| 19 | 18 | "styles": |
| 20 | 19 | { |
| 21 | - "ProgressBarCustomStyle1": | |
| 20 | + "ProgressBar": | |
| 22 | 21 | { |
| 23 | - "progressValue": 0, | |
| 24 | 22 | "trackVisual":{ |
| 25 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar.9.png", | |
| 26 | - "size":[5,24] | |
| 23 | + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-track.9.png" | |
| 27 | 24 | }, |
| 28 | 25 | "progressVisual":{ |
| 29 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress.9.png", | |
| 30 | - "size":[5,24] | |
| 31 | - } | |
| 32 | - }, | |
| 33 | - | |
| 34 | - "ProgressBarCustomStyle2": | |
| 35 | - { | |
| 36 | - "progressValue": 0, | |
| 37 | - "trackVisual":{ | |
| 38 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-2.9.png", | |
| 39 | - "size":[5,7] | |
| 26 | + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-progress.9.png" | |
| 40 | 27 | }, |
| 41 | - "progressVisual":{ | |
| 42 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress-2.9.png", | |
| 43 | - "size":[5,7] | |
| 28 | + "secondaryProgressVisual":{ | |
| 29 | + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png" | |
| 44 | 30 | } |
| 45 | 31 | } |
| 46 | 32 | } | ... | ... |
resources/style/progress-bar-example-theme.json.in
| ... | ... | @@ -18,29 +18,16 @@ |
| 18 | 18 | { |
| 19 | 19 | "styles": |
| 20 | 20 | { |
| 21 | - "ProgressBarCustomStyle1": | |
| 21 | + "ProgressBar": | |
| 22 | 22 | { |
| 23 | - "progressValue": 0, | |
| 24 | 23 | "trackVisual":{ |
| 25 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar.9.png", | |
| 26 | - "size":[5,24] | |
| 24 | + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-track.9.png" | |
| 27 | 25 | }, |
| 28 | 26 | "progressVisual":{ |
| 29 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress.9.png", | |
| 30 | - "size":[5,24] | |
| 31 | - } | |
| 32 | - }, | |
| 33 | - | |
| 34 | - "ProgressBarCustomStyle2": | |
| 35 | - { | |
| 36 | - "progressValue": 0, | |
| 37 | - "trackVisual":{ | |
| 38 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-2.9.png", | |
| 39 | - "size":[5,7] | |
| 27 | + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-progress.9.png" | |
| 40 | 28 | }, |
| 41 | - "progressVisual":{ | |
| 42 | - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress-2.9.png", | |
| 43 | - "size":[5,7] | |
| 29 | + "secondaryProgressVisual":{ | |
| 30 | + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png" | |
| 44 | 31 | } |
| 45 | 32 | } |
| 46 | 33 | } | ... | ... |