Update progress bar example 77/111077/8
authorminho.sun <minho.sun@samsung.com>
Thu, 19 Jan 2017 10:05:40 +0000 (19:05 +0900)
committerminho.sun <minho.sun@samsung.com>
Fri, 3 Feb 2017 05:32:01 +0000 (14:32 +0900)
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>
examples/progress-bar/progress-bar-example.cpp
resources/images/new-progress-bar-progress.9.png [moved from resources/images/progress-bar-progress.9.png with 100% similarity]
resources/images/new-progress-bar-secondary-progress.9.png [new file with mode: 0644]
resources/images/new-progress-bar-track.9.png [moved from resources/images/progress-bar.9.png with 100% similarity]
resources/images/progress-bar-2.9.png [deleted file]
resources/images/progress-bar-progress-2.9.png [deleted file]
resources/style/mobile/progress-bar-example-theme.json.in
resources/style/progress-bar-example-theme.json.in

index aca1a53..f12fd28 100644 (file)
@@ -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/new-progress-bar-secondary-progress.9.png b/resources/images/new-progress-bar-secondary-progress.9.png
new file mode 100644 (file)
index 0000000..279bba6
Binary files /dev/null and b/resources/images/new-progress-bar-secondary-progress.9.png differ
diff --git a/resources/images/progress-bar-2.9.png b/resources/images/progress-bar-2.9.png
deleted file mode 100644 (file)
index 1ff4a7d..0000000
Binary files a/resources/images/progress-bar-2.9.png and /dev/null differ
diff --git a/resources/images/progress-bar-progress-2.9.png b/resources/images/progress-bar-progress-2.9.png
deleted file mode 100644 (file)
index 2d10990..0000000
Binary files a/resources/images/progress-bar-progress-2.9.png and /dev/null differ
index 670937f..d9a47ee 100644 (file)
  * 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"
       }
     }
   }
index 670937f..971ee7d 100644 (file)
 {
   "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"
       }
     }
   }