(Page) Using registered properties 81/38681/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 24 Apr 2015 10:33:06 +0000 (11:33 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 24 Apr 2015 13:10:13 +0000 (14:10 +0100)
Change-Id: I7e61c64244b9e0b9179287898295eb6778d9cef0

dali-toolkit/internal/controls/navigation-frame/page-impl.cpp
dali-toolkit/internal/controls/navigation-frame/page-impl.h
dali-toolkit/public-api/controls/navigation-frame/page.cpp
dali-toolkit/public-api/controls/navigation-frame/page.h

index 9d17d8c..82fb886 100644 (file)
@@ -40,6 +40,8 @@ BaseHandle Create()
 }
 
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Page, Toolkit::Control, Create )
 }
 
 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Page, Toolkit::Control, Create )
+DALI_PROPERTY_REGISTRATION( Toolkit, Page, "title",     STRING, TITLE     )
+DALI_PROPERTY_REGISTRATION( Toolkit, Page, "sub-title", STRING, SUB_TITLE )
 DALI_TYPE_REGISTRATION_END()
 
 } // unnamed namespace
 DALI_TYPE_REGISTRATION_END()
 
 } // unnamed namespace
@@ -47,9 +49,7 @@ DALI_TYPE_REGISTRATION_END()
 Page::Page()
 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
   mTitle(""),
 Page::Page()
 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
   mTitle(""),
-  mSubTitle(""),
-  mPropertyTitle(Property::INVALID_INDEX),
-  mPropertySubTitle(Property::INVALID_INDEX)
+  mSubTitle("")
 {
 }
 
 {
 }
 
@@ -161,26 +161,54 @@ Toolkit::Popup Page::GetPopupMenu() const
   return mPopupMenu;
 }
 
   return mPopupMenu;
 }
 
-void Page::OnInitialize()
+void Page::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
 {
 {
-  Actor self = Self();
+  Toolkit::Page page = Toolkit::Page::DownCast( Dali::BaseHandle( object ) );
 
 
-  mPropertyTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_TITLE, "", Property::READ_WRITE );
-  mPropertySubTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_SUB_TITLE, "", Property::READ_WRITE );
+  if ( page )
+  {
+    switch ( index )
+    {
+      case Toolkit::Page::Property::TITLE:
+      {
+        GetImpl( page ).SetTitle( value.Get< std::string >() );
+        break;
+      }
+
+      case Toolkit::Page::Property::SUB_TITLE:
+      {
+        GetImpl( page ).SetSubTitle( value.Get< std::string >() );
+        break;
+      }
+    }
+  }
 }
 
 }
 
-void Page::OnPropertySet( Property::Index index, Property::Value propertyValue )
+Property::Value Page::GetProperty( BaseObject* object, Property::Index propertyIndex )
 {
 {
-  if( index == mPropertyTitle )
-  {
-    std::string title( propertyValue.Get<std::string>() );
-    SetTitle(title);
-  }
-  else if( index == mPropertySubTitle )
+  Property::Value value;
+
+  Toolkit::Page page = Toolkit::Page::DownCast( Dali::BaseHandle( object ) );
+
+  if ( page )
   {
   {
-    std::string subTitle( propertyValue.Get<std::string>() );
-    SetSubTitle(subTitle);
+    switch ( propertyIndex )
+    {
+      case Toolkit::Page::Property::TITLE:
+      {
+        value = GetImpl( page ).mTitle;
+        break;
+      }
+
+      case Toolkit::Page::Property::SUB_TITLE:
+      {
+        value = GetImpl( page ).mSubTitle;
+        break;
+      }
+    }
   }
   }
+
+  return value;
 }
 
 } // namespace Internal
 }
 
 } // namespace Internal
index 333aada..8d2711d 100644 (file)
@@ -116,17 +116,23 @@ public:
    */
   Toolkit::Popup GetPopupMenu() const;
 
    */
   Toolkit::Popup GetPopupMenu() const;
 
-private: // From Control
+  // Properties
 
   /**
 
   /**
-   * @copydoc Toolkit::Control::OnInitialize()
+   * Called when a property of an object of this type is set.
+   * @param[in] object The object whose property is set.
+   * @param[in] index The property index.
+   * @param[in] value The new property value.
    */
    */
-  virtual void OnInitialize();
+  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
 
   /**
 
   /**
-   * @copydoc Dali::CustomActorImpl::OnPropertySet()
+   * Called to retrieve a property of an object of this type.
+   * @param[in] object The object whose property is to be retrieved.
+   * @param[in] index The property index.
+   * @return The current value of the property.
    */
    */
-  virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
+  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
 
 private:
 
 
 private:
 
@@ -144,9 +150,6 @@ private:
 
   ActorContainer                        mTitleBarControls;
   Toolkit::Page::ControlOnBarContainer  mToolBarControls;
 
   ActorContainer                        mTitleBarControls;
   Toolkit::Page::ControlOnBarContainer  mToolBarControls;
-
-  Property::Index  mPropertyTitle;       ///< Property index for title.
-  Property::Index  mPropertySubTitle;    ///< Property index for sub title.
 };
 
 } // namespace Internal
 };
 
 } // namespace Internal
index 4de539c..46287a4 100644 (file)
@@ -29,9 +29,6 @@ namespace Dali
 namespace Toolkit
 {
 
 namespace Toolkit
 {
 
-const char* const Page::PROPERTY_TITLE = "title";
-const char* const Page::PROPERTY_SUB_TITLE = "sub-title";
-
 Page::Page()
 {
 }
 Page::Page()
 {
 }
index 8093c7c..e0cf616 100644 (file)
@@ -49,11 +49,25 @@ class DALI_IMPORT_API Page : public Control
 public:
 
   /**
 public:
 
   /**
-   * The names of custom properties installed by this control.
+   * @brief The start and end property ranges for this control.
    */
    */
-  // Property Names
-  static const char* const PROPERTY_TITLE;       ///< name "title", type std::string
-  static const char* const PROPERTY_SUB_TITLE;   ///< name "sub-title", type std::string
+  enum PropertyRange
+  {
+    PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+    PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
+  };
+
+  /**
+   * @brief An enumeration of properties belonging to the Page class.
+   */
+  struct Property
+  {
+    enum
+    {
+      TITLE = PROPERTY_START_INDEX, ///< name "title",          @see SetTitle(),         type string
+      SUB_TITLE,                    ///< name "sub-title",      @see SetSubTitle(),      type string
+    };
+  };
 
   /**
    * Structure to indicate a control on the navigation tool bar and its group (HorizontalLeft, HorizontalRight or HorizontalCenter)
 
   /**
    * Structure to indicate a control on the navigation tool bar and its group (HorizontalLeft, HorizontalRight or HorizontalCenter)