From 0b3b3c66955214e2c66a1358a1bf10d62afa3302 Mon Sep 17 00:00:00 2001 From: "minho.sun" Date: Thu, 19 Jan 2017 19:05:40 +0900 Subject: [PATCH] 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 --- examples/progress-bar/progress-bar-example.cpp | 93 +++++++++++++++------ ...gress.9.png => new-progress-bar-progress.9.png} | Bin .../new-progress-bar-secondary-progress.9.png | Bin 0 -> 126 bytes ...ress-bar.9.png => new-progress-bar-track.9.png} | Bin resources/images/progress-bar-2.9.png | Bin 177 -> 0 bytes resources/images/progress-bar-progress-2.9.png | Bin 182 -> 0 bytes .../mobile/progress-bar-example-theme.json.in | 24 ++---- resources/style/progress-bar-example-theme.json.in | 23 ++--- 8 files changed, 78 insertions(+), 62 deletions(-) rename resources/images/{progress-bar-progress.9.png => new-progress-bar-progress.9.png} (100%) create mode 100644 resources/images/new-progress-bar-secondary-progress.9.png rename resources/images/{progress-bar.9.png => new-progress-bar-track.9.png} (100%) delete mode 100644 resources/images/progress-bar-2.9.png delete mode 100644 resources/images/progress-bar-progress-2.9.png diff --git a/examples/progress-bar/progress-bar-example.cpp b/examples/progress-bar/progress-bar-example.cpp index aca1a53..f12fd28 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(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 similarity index 100% rename from resources/images/progress-bar-progress.9.png rename to 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 new file mode 100644 index 0000000000000000000000000000000000000000..279bba68344e1fdce18c4587b9878661c65f2cf6 GIT binary patch literal 126 zcmeAS@N?(olHy`uVBq!ia0vp^>_9BV!3HF&rQD_gDVAa<&kznEsNqQI0P;;eT^vI+ zCMG91u>P0qVC~@ng8%>jAHQ($1Q0YW;yRn7R&%V+tIx}c!G>3GzFHxJ2s6X^>m0fY TX(^w81~7QK`njxgN@xNALP;ZI literal 0 HcmV?d00001 diff --git a/resources/images/progress-bar.9.png b/resources/images/new-progress-bar-track.9.png similarity index 100% rename from resources/images/progress-bar.9.png rename to 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 deleted file mode 100644 index 1ff4a7da0bc94ca8747e5176648413b2bff4afe0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)P!3HG%MVKuHQfx`y?k)`fL2$v|<�u1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPNkF0=($g@pc$ACh1o-U3d5|_93Z{%c9U^pC RLLX=ngQu&X%Q~loCIIGdHkbea diff --git a/resources/images/progress-bar-progress-2.9.png b/resources/images/progress-bar-progress-2.9.png deleted file mode 100644 index 2d10990cb4b452157528c68da3dc2e5e74e66264..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 182 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)P!3HG%MVKuHQfx`y?k)`fL2$v|<�u1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPNkF0