Add C# bindings for Actor's POSITION_USES_ANCHOR_POINT property
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / manual / csharp / View.cs
index 8589e70..fbc408f 100644 (file)
@@ -28,6 +28,9 @@ public class View : CustomActor {
 
     // Register this instance of view in the view registry.
     ViewRegistry.RegisterView(this);
 
     // Register this instance of view in the view registry.
     ViewRegistry.RegisterView(this);
+
+    // By default, we do not want the position to use the anchor point
+    this.PositionUsesAnchorPoint = false;
   }
 
   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj) {
   }
 
   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj) {
@@ -36,6 +39,9 @@ public class View : CustomActor {
 
   ~View() {
     DisposeQueue.Instance.Add(this);
 
   ~View() {
     DisposeQueue.Instance.Add(this);
+
+    // Unregister this instance of view from the view registry.
+    ViewRegistry.UnregisterView(this);
   }
 
   public override void Dispose() {
   }
 
   public override void Dispose() {
@@ -907,6 +913,10 @@ public class View : CustomActor {
     public static readonly int TOOLTIP = NDalicManualPINVOKE.View_Property_TOOLTIP_get();
     public static readonly int STATE = NDalicManualPINVOKE.View_Property_STATE_get();
     public static readonly int SUB_STATE = NDalicManualPINVOKE.View_Property_SUB_STATE_get();
     public static readonly int TOOLTIP = NDalicManualPINVOKE.View_Property_TOOLTIP_get();
     public static readonly int STATE = NDalicManualPINVOKE.View_Property_STATE_get();
     public static readonly int SUB_STATE = NDalicManualPINVOKE.View_Property_SUB_STATE_get();
+    public static readonly int LEFT_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_LEFT_FOCUSABLE_ACTOR_ID_get();
+    public static readonly int RIGHT_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_RIGHT_FOCUSABLE_ACTOR_ID_get();
+    public static readonly int UP_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_UP_FOCUSABLE_ACTOR_ID_get();
+    public static readonly int DOWN_FOCUSABLE_ACTOR_ID = NDalicManualPINVOKE.View_Property_DOWN_FOCUSABLE_ACTOR_ID_get();
 
     public Property() : this(NDalicPINVOKE.new_View_Property(), true) {
       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
 
     public Property() : this(NDalicPINVOKE.new_View_Property(), true) {
       if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
@@ -989,6 +999,23 @@ public class View : CustomActor {
       return (T)( ViewRegistry.GetViewFromActor( actor ) );
   }
 
       return (T)( ViewRegistry.GetViewFromActor( actor ) );
   }
 
+  private View ConvertIdToView(uint id)
+  {
+    Actor actor = null;
+
+    if (Parent)
+    {
+      actor = Parent.FindChildById(id);
+    }
+
+    if (!actor)
+    {
+      actor = Stage.Instance.GetRootLayer().FindChildById(id);
+    }
+
+    return View.DownCast<View>(actor);
+  }
+
   public void SetKeyInputFocus() {
     NDalicPINVOKE.View_SetKeyInputFocus(swigCPtr);
     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
   public void SetKeyInputFocus() {
     NDalicPINVOKE.View_SetKeyInputFocus(swigCPtr);
     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
@@ -1107,27 +1134,43 @@ public class View : CustomActor {
   {
     get
     {
   {
     get
     {
-      Vector4 temp = new Vector4(0.0f,0.0f,0.0f,0.0f);
-      GetProperty( View.Property.BACKGROUND_COLOR).Get(  temp );
-      return temp;
+      Vector4 backgroundColor = new Vector4(0.0f,0.0f,0.0f,0.0f);
+
+      Dali.Property.Map background = Background;
+      int visualType = 0;
+      background.Find( Dali.Constants.Visual.Property.Type ).Get( ref visualType );
+      if(visualType == (int)Dali.Constants.Visual.Type.Color)
+      {
+        background.Find( Dali.Constants.ColorVisualProperty.MixColor ).Get( backgroundColor );
+      }
+
+      return backgroundColor;
     }
     set
     {
     }
     set
     {
-      SetProperty( View.Property.BACKGROUND_COLOR, new Dali.Property.Value( value ) );
+      SetProperty( View.Property.BACKGROUND, new Dali.Property.Value( value ) );
     }
   }
 
     }
   }
 
-  public Dali.Property.Map BackgroundImage
+  public string BackgroundImage
   {
     get
     {
   {
     get
     {
-      Dali.Property.Map temp = new Dali.Property.Map();
-      GetProperty( View.Property.BACKGROUND_IMAGE).Get(  temp );
-      return temp;
+      string backgroundImage = "";
+
+      Dali.Property.Map background = Background;
+      int visualType = 0;
+      background.Find( Dali.Constants.Visual.Property.Type ).Get( ref visualType );
+      if(visualType == (int)Dali.Constants.Visual.Type.Image)
+      {
+        background.Find( Dali.Constants.ImageVisualProperty.URL ).Get( out backgroundImage );
+      }
+
+      return backgroundImage;
     }
     set
     {
     }
     set
     {
-      SetProperty( View.Property.BACKGROUND_IMAGE, new Dali.Property.Value( value ) );
+      SetProperty( View.Property.BACKGROUND, new Dali.Property.Value( value ) );
     }
   }
 
     }
   }
 
@@ -1209,6 +1252,62 @@ public class View : CustomActor {
     }
   }
 
     }
   }
 
+  private int LeftFocusableActorId
+  {
+    get
+    {
+      int temp = 0;
+      GetProperty( View.Property.LEFT_FOCUSABLE_ACTOR_ID).Get( ref temp );
+      return temp;
+    }
+    set
+    {
+      SetProperty( View.Property.LEFT_FOCUSABLE_ACTOR_ID, new Dali.Property.Value( value ) );
+    }
+  }
+
+  private int RightFocusableActorId
+  {
+    get
+    {
+      int temp = 0;
+      GetProperty( View.Property.RIGHT_FOCUSABLE_ACTOR_ID).Get( ref temp );
+      return temp;
+    }
+    set
+    {
+      SetProperty( View.Property.RIGHT_FOCUSABLE_ACTOR_ID, new Dali.Property.Value( value ) );
+    }
+  }
+
+  private int UpFocusableActorId
+  {
+    get
+    {
+      int temp = 0;
+      GetProperty( View.Property.UP_FOCUSABLE_ACTOR_ID).Get( ref temp );
+      return temp;
+    }
+    set
+    {
+      SetProperty( View.Property.UP_FOCUSABLE_ACTOR_ID, new Dali.Property.Value( value ) );
+    }
+  }
+
+  private int DownFocusableActorId
+  {
+    get
+    {
+      int temp = 0;
+      GetProperty( View.Property.DOWN_FOCUSABLE_ACTOR_ID).Get( ref temp );
+      return temp;
+    }
+    set
+    {
+      SetProperty( View.Property.DOWN_FOCUSABLE_ACTOR_ID, new Dali.Property.Value( value ) );
+    }
+  }
+
   public float Flex
   {
     get
   public float Flex
   {
     get
@@ -1320,6 +1419,98 @@ public class View : CustomActor {
       SetProperty( TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT, new Dali.Property.Value( value ) );
     }
   }
       SetProperty( TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT, new Dali.Property.Value( value ) );
     }
   }
+
+  /**
+   * @brief The left focusable view.
+   * @note This will return NULL if not set.
+   * This will also return NULL if the specified left focusable view is not on stage.
+   *
+   */
+  public View LeftFocusableView
+  {
+    // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
+    get
+    {
+      if (LeftFocusableActorId >= 0)
+      {
+        return ConvertIdToView((uint)LeftFocusableActorId);
+      }
+      return null;
+    }
+    set
+    {
+      LeftFocusableActorId = (int)value.GetId();
+    }
+  }
+
+  /**
+   * @brief The right focusable view.
+   * @note This will return NULL if not set.
+   * This will also return NULL if the specified right focusable view is not on stage.
+   *
+   */
+  public View RightFocusableView
+  {
+    // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
+    get
+    {
+      if (RightFocusableActorId >= 0)
+      {
+        return ConvertIdToView((uint)RightFocusableActorId);
+      }
+      return null;
+    }
+    set
+    {
+      RightFocusableActorId = (int)value.GetId();
+    }
+  }
+
+  /**
+   * @brief The up focusable view.
+   * @note This will return NULL if not set.
+   * This will also return NULL if the specified up focusable view is not on stage.
+   *
+   */
+  public View UpFocusableView
+  {
+    // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
+    get
+    {
+      if (UpFocusableActorId >= 0)
+      {
+        return ConvertIdToView((uint)UpFocusableActorId);
+      }
+      return null;
+    }
+    set
+    {
+      UpFocusableActorId = (int)value.GetId();
+    }
+  }
+
+  /**
+   * @brief The down focusable view.
+   * @note This will return NULL if not set.
+   * This will also return NULL if the specified down focusable view is not on stage.
+   *
+   */
+  public View DownFocusableView
+  {
+    // As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
+    get
+    {
+      if (DownFocusableActorId >= 0)
+      {
+        return ConvertIdToView((uint)DownFocusableActorId);
+      }
+      return null;
+    }
+    set
+    {
+      DownFocusableActorId = (int)value.GetId();
+    }
+  }
 }
 
 }
 }
 
 }