diff options
-rw-r--r-- | examples/progress-bar/progress-bar-example.cpp | 93 | ||||
-rw-r--r-- | resources/images/new-progress-bar-progress.9.png (renamed from resources/images/progress-bar-progress.9.png) | bin | 199 -> 199 bytes | |||
-rw-r--r-- | resources/images/new-progress-bar-secondary-progress.9.png | bin | 0 -> 126 bytes | |||
-rw-r--r-- | resources/images/new-progress-bar-track.9.png (renamed from resources/images/progress-bar.9.png) | bin | 182 -> 182 bytes | |||
-rw-r--r-- | resources/images/progress-bar-2.9.png | bin | 177 -> 0 bytes | |||
-rw-r--r-- | resources/images/progress-bar-progress-2.9.png | bin | 182 -> 0 bytes | |||
-rw-r--r-- | resources/style/mobile/progress-bar-example-theme.json.in | 24 | ||||
-rw-r--r-- | resources/style/progress-bar-example-theme.json.in | 23 |
8 files changed, 78 insertions, 62 deletions
diff --git a/examples/progress-bar/progress-bar-example.cpp b/examples/progress-bar/progress-bar-example.cpp index aca1a53f..f12fd28a 100644 --- a/examples/progress-bar/progress-bar-example.cpp +++ b/examples/progress-bar/progress-bar-example.cpp @@ -53,6 +53,8 @@ public: { // Connect to the Application's Init signal mProgressValue = 0.0f; + mSecondaryProgressValue = 0.1f; + isDefaultTheme = true; mApplication.InitSignal().Connect( this, &ProgressBarExample::Create ); } @@ -80,20 +82,7 @@ private: mProgressBarDefault.SetAnchorPoint(AnchorPoint::TOP_CENTER); mProgressBarDefault.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); mProgressBarDefault.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); - - mProgressBarCustomStyle1 = ProgressBar::New(); - mProgressBarCustomStyle1.SetStyleName( "ProgressBarCustomStyle1" ); - mProgressBarCustomStyle1.SetParentOrigin(ParentOrigin::TOP_CENTER); - mProgressBarCustomStyle1.SetAnchorPoint(AnchorPoint::TOP_CENTER); - mProgressBarCustomStyle1.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); - mProgressBarCustomStyle1.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); - - mProgressBarCustomStyle2 = ProgressBar::New(); - mProgressBarCustomStyle2.SetStyleName( "ProgressBarCustomStyle2" ); - mProgressBarCustomStyle2.SetParentOrigin(ParentOrigin::TOP_CENTER); - mProgressBarCustomStyle2.SetAnchorPoint(AnchorPoint::TOP_CENTER); - mProgressBarCustomStyle2.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); - mProgressBarCustomStyle2.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT); + mProgressBarDefault.ValueChangedSignal().Connect( this, &ProgressBarExample::OnValueChanged ); Toolkit::TableView contentTable = Toolkit::TableView::New(2, 1); contentTable.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH); @@ -111,7 +100,7 @@ private: mContentLayer.Add( contentTable ); // Image selector for progress bar - Toolkit::TableView progressBackground = Toolkit::TableView::New( 3, 1 ); + Toolkit::TableView progressBackground = Toolkit::TableView::New( 1, 1 ); progressBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); progressBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); progressBackground.SetBackgroundColor( BACKGROUND_COLOUR ); @@ -125,11 +114,9 @@ private: contentTable.Add( progressBackground ); progressBackground.Add( mProgressBarDefault ); - progressBackground.Add( mProgressBarCustomStyle1 ); - progressBackground.Add( mProgressBarCustomStyle2 ); // Create buttons - Toolkit::TableView buttonBackground = Toolkit::TableView::New( 1, 1 ); + Toolkit::TableView buttonBackground = Toolkit::TableView::New( 3, 1 ); buttonBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); buttonBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); buttonBackground.SetBackgroundColor( BACKGROUND_COLOUR ); @@ -150,6 +137,22 @@ private: buttonBackground.Add( mResetProgressButton ); + mSetIndeterminateButton = Toolkit::PushButton::New(); + mSetIndeterminateButton.SetProperty( Toolkit::Button::Property::LABEL, "Toggle Indeterminate" ); + mSetIndeterminateButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mSetIndeterminateButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); + mSetIndeterminateButton.ClickedSignal().Connect( this, &ProgressBarExample::OnSetIndeterminateButtonSelected ); + + buttonBackground.Add( mSetIndeterminateButton ); + + mChangeThemeButton = Toolkit::PushButton::New(); + mChangeThemeButton.SetProperty( Toolkit::Button::Property::LABEL, "Change Theme" ); + mChangeThemeButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + mChangeThemeButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); + mChangeThemeButton.ClickedSignal().Connect( this, &ProgressBarExample::OnChangeThemeButtonSelected ); + + buttonBackground.Add( mChangeThemeButton ); + // Create a timer to update the progress of all progress bars mTimer = Timer::New( TIMER_TIMEOUT_TIME ); mTimer.TickSignal().Connect( this, &ProgressBarExample::OnTimerTick ); @@ -159,9 +162,9 @@ private: bool OnTimerTick() { mProgressValue += PROGRESS_INCREMENT_VALUE; + mSecondaryProgressValue = mProgressValue + 0.1f; mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); - mProgressBarCustomStyle1.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); - mProgressBarCustomStyle2.SetProperty(ProgressBar::Property::PROGRESS_VALUE, mProgressValue); + mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, mSecondaryProgressValue); return ( mProgressValue < 1.0f ); // Only call again if progress has NOT got to the end } @@ -169,13 +172,51 @@ private: bool OnResetProgressButtonSelected( Toolkit::Button button ) { mProgressValue = 0.0f; + mSecondaryProgressValue = 0.1f; mProgressBarDefault.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); - mProgressBarCustomStyle1.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); - mProgressBarCustomStyle2.SetProperty(ProgressBar::Property::PROGRESS_VALUE, 0.0f); + mProgressBarDefault.SetProperty(ProgressBar::Property::SECONDARY_PROGRESS_VALUE, 0.1f); mTimer.Start(); return true; } + void OnValueChanged( ProgressBar progressBar, float value, float secondaryValue ) + { + std::stringstream newLabel; + newLabel.precision( 2 ); + newLabel << std::fixed << "current : " << value << " / loaded : " << secondaryValue; + + mProgressBarDefault.SetProperty(ProgressBar::Property::LABEL_VISUAL, newLabel.str() ); + } + + bool OnSetIndeterminateButtonSelected( Toolkit::Button button ) + { + if( mProgressBarDefault.GetProperty<bool>(ProgressBar::Property::INDETERMINATE)) + { + mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, false); + } + else + { + mProgressBarDefault.SetProperty(ProgressBar::Property::INDETERMINATE, true); + } + return true; + } + + bool OnChangeThemeButtonSelected( Toolkit::Button button ) + { + StyleManager styleManager = StyleManager::Get(); + + if( isDefaultTheme ) + { + styleManager.ApplyTheme( THEME_PATH ); + isDefaultTheme = false; + } + else + { + styleManager.ApplyDefaultTheme(); + isDefaultTheme = true; + } + return true; + } void OnKeyEvent( const KeyEvent& event ) { if( event.state == KeyEvent::Down ) @@ -196,15 +237,17 @@ private: Toolkit::ToolBar mToolBar; ///< The View's Toolbar. Layer mContentLayer; ///< Content layer. ProgressBar mProgressBarDefault; - ProgressBar mProgressBarCustomStyle1; - ProgressBar mProgressBarCustomStyle2; Toolkit::PushButton mResetProgressButton; + Toolkit::PushButton mSetIndeterminateButton; + Toolkit::PushButton mChangeThemeButton; float mProgressValue; + float mSecondaryProgressValue; + bool isDefaultTheme; }; int DALI_EXPORT_API main( int argc, char **argv ) { - Application application = Application::New( &argc, &argv, THEME_PATH ); + Application application = Application::New( &argc, &argv ); ProgressBarExample test( application ); application.MainLoop(); return 0; diff --git a/resources/images/progress-bar-progress.9.png b/resources/images/new-progress-bar-progress.9.png Binary files differindex aa5aa77f..aa5aa77f 100644 --- a/resources/images/progress-bar-progress.9.png +++ b/resources/images/new-progress-bar-progress.9.png diff --git a/resources/images/new-progress-bar-secondary-progress.9.png b/resources/images/new-progress-bar-secondary-progress.9.png Binary files differnew file mode 100644 index 00000000..279bba68 --- /dev/null +++ b/resources/images/new-progress-bar-secondary-progress.9.png diff --git a/resources/images/progress-bar.9.png b/resources/images/new-progress-bar-track.9.png Binary files differindex ec0bc90c..ec0bc90c 100644 --- a/resources/images/progress-bar.9.png +++ b/resources/images/new-progress-bar-track.9.png diff --git a/resources/images/progress-bar-2.9.png b/resources/images/progress-bar-2.9.png Binary files differdeleted file mode 100644 index 1ff4a7da..00000000 --- a/resources/images/progress-bar-2.9.png +++ /dev/null diff --git a/resources/images/progress-bar-progress-2.9.png b/resources/images/progress-bar-progress-2.9.png Binary files differdeleted file mode 100644 index 2d10990c..00000000 --- a/resources/images/progress-bar-progress-2.9.png +++ /dev/null diff --git a/resources/style/mobile/progress-bar-example-theme.json.in b/resources/style/mobile/progress-bar-example-theme.json.in index 670937f1..d9a47ee5 100644 --- a/resources/style/mobile/progress-bar-example-theme.json.in +++ b/resources/style/mobile/progress-bar-example-theme.json.in @@ -14,33 +14,19 @@ * limitations under the License. * */ - { "styles": { - "ProgressBarCustomStyle1": + "ProgressBar": { - "progressValue": 0, "trackVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar.9.png", - "size":[5,24] + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-track.9.png" }, "progressVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress.9.png", - "size":[5,24] - } - }, - - "ProgressBarCustomStyle2": - { - "progressValue": 0, - "trackVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-2.9.png", - "size":[5,7] + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-progress.9.png" }, - "progressVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress-2.9.png", - "size":[5,7] + "secondaryProgressVisual":{ + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png" } } } diff --git a/resources/style/progress-bar-example-theme.json.in b/resources/style/progress-bar-example-theme.json.in index 670937f1..971ee7d7 100644 --- a/resources/style/progress-bar-example-theme.json.in +++ b/resources/style/progress-bar-example-theme.json.in @@ -18,29 +18,16 @@ { "styles": { - "ProgressBarCustomStyle1": + "ProgressBar": { - "progressValue": 0, "trackVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar.9.png", - "size":[5,24] + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-track.9.png" }, "progressVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress.9.png", - "size":[5,24] - } - }, - - "ProgressBarCustomStyle2": - { - "progressValue": 0, - "trackVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-2.9.png", - "size":[5,7] + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-progress.9.png" }, - "progressVisual":{ - "url":"{APPLICATION_RESOURCE_PATH}/images/progress-bar-progress-2.9.png", - "size":[5,7] + "secondaryProgressVisual":{ + "url":"{APPLICATION_RESOURCE_PATH}/images/new-progress-bar-secondary-progress.9.png" } } } |