From: Umar Date: Thu, 9 Feb 2017 18:05:31 +0000 (+0000) Subject: Rectangle Generic class support in C# X-Git-Tag: dali_1.2.27~4 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=5ae64ad505dc063c5b143b99dbcfd99350899838 Rectangle Generic class support in C# Change-Id: I956cbbf59614ef1166c3f774f0d911d8e28b7635 --- diff --git a/plugins/dali-swig/SWIG/dali-core.i b/plugins/dali-swig/SWIG/dali-core.i index 3034cf4..b59ff97 100755 --- a/plugins/dali-swig/SWIG/dali-core.i +++ b/plugins/dali-swig/SWIG/dali-core.i @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -188,6 +188,7 @@ typedef std::pair< Dali::Radian, Dali::Radian > AngleThresholdPair; %include %include %include +%include %include %include @@ -284,10 +285,8 @@ typedef std::pair< Dali::Radian, Dali::Radian > AngleThresholdPair; %template(StringValuePair) std::pair; %template(TouchPointContainer) std::vector; -%template(RectDouble) Dali::Rect; -%template(RectInteger) Dali::Rect; -%template(RectUnsignedInteger) Dali::Rect; -%template(RectFloat) Dali::Rect; +%template(Rectangle) Dali::Rect; +%template(PaddingType) Dali::Rect; %template(VectorInteger) Dali::Vector; %template(VectorFloat) Dali::Vector; %template(VectorUnsignedChar) Dali::Vector; diff --git a/plugins/dali-swig/SWIG/dali-gc.i b/plugins/dali-swig/SWIG/dali-gc.i index df7cfe4..808cd07 100644 --- a/plugins/dali-swig/SWIG/dali-gc.i +++ b/plugins/dali-swig/SWIG/dali-gc.i @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -471,14 +471,10 @@ DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Signal, Ima DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( Dali, Signal, ResourceImageSignal); DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Signal, ResourceImageSignal); -DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( Dali, Rect, RectInteger); -DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Rect, RectInteger); -DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( Dali, Rect, RectDouble); -DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Rect, RectDouble); -DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( Dali, Rect, RectFloat); -DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Rect, RectFloat); -DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( Dali, Rect, RectUnsignedInteger); -DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Rect, RectUnsignedInteger); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( Dali, Rect, Rectangle); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Rect, Rectangle); +DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( Dali, Rect, PaddingType); +DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( Dali, Rect, PaddingType); DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION_RENAME( std, vector, TouchPointContainer); DALI_CREATE_CUSTOM_DISPOSE_FUNCTION_RENAME( std, vector, TouchPointContainer); diff --git a/plugins/dali-swig/SWIG/dali.i b/plugins/dali-swig/SWIG/dali.i index d2d4e28..aeb8558 100755 --- a/plugins/dali-swig/SWIG/dali.i +++ b/plugins/dali-swig/SWIG/dali.i @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -267,7 +267,8 @@ using namespace Dali::Toolkit; %include events/pangesture-event.i %include events/propertynotification-event.i %include events/longpressgesture-event.i -%include events/rectinteger.i +%include events/rectangle.i +%include events/padding.i %include events/resourceimage-event.i %include events/scrollable-event.i %include events/scrollbar-event.i diff --git a/plugins/dali-swig/SWIG/devel-properties.i b/plugins/dali-swig/SWIG/devel-properties.i index 613a656..4d277de 100755 --- a/plugins/dali-swig/SWIG/devel-properties.i +++ b/plugins/dali-swig/SWIG/devel-properties.i @@ -32,6 +32,8 @@ %typemap(cscode) Dali::Toolkit::Control::Property %{ 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(); %} %typemap(cscode) Dali::Toolkit::ItemView::Property %{ diff --git a/plugins/dali-swig/SWIG/events/padding.i b/plugins/dali-swig/SWIG/events/padding.i new file mode 100644 index 0000000..0fa03a6 --- /dev/null +++ b/plugins/dali-swig/SWIG/events/padding.i @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +%csmethodmodifiers Dali::Rect::x "private"; +%csmethodmodifiers Dali::Rect::y "private"; +%csmethodmodifiers Dali::Rect::left "private"; +%csmethodmodifiers Dali::Rect::right "private"; +%csmethodmodifiers Dali::Rect::width "private"; +%csmethodmodifiers Dali::Rect::bottom "private"; +%csmethodmodifiers Dali::Rect::height "private"; +%csmethodmodifiers Dali::Rect::top "private"; +%ignore Dali::Rect::IsEmpty; +%ignore Dali::Rect::Left; +%ignore Dali::Rect::Right; +%ignore Dali::Rect::Top; +%ignore Dali::Rect::Bottom; +%ignore Dali::Rect::Area; +%ignore Dali::Rect::Intersects; +%ignore Dali::Rect::Contains; + +%define DALI_PADDINGTYPE_PROPERTY_PARAM(NameSpace,ClassName) + %typemap(cscode) NameSpace::ClassName %{ + public static bool operator ==(PaddingType a, PaddingType b) + { + // If both are null, or both are same instance, return true. + if (System.Object.ReferenceEquals(a, b)) + { + return true; + } + + // If one is null, but not both, return false. + if (((object)a == null) || ((object)b == null)) + { + return false; + } + + // Return true if the fields match: + return ( System.Math.Abs( a.Left - b.Left ) < NDalic.GetRangedEpsilon(a.Left, b.Left) )&& + ( System.Math.Abs( a.Right - b.Right ) < NDalic.GetRangedEpsilon(a.Right, b.Right) )&& + ( System.Math.Abs( a.Bottom - b.Bottom ) < NDalic.GetRangedEpsilon(a.Bottom, b.Bottom) )&& + ( System.Math.Abs( a.Top - b.Top ) < NDalic.GetRangedEpsilon(a.Top, b.Top) ); + } + + public static bool operator !=(PaddingType a, PaddingType b) + { + return !(a == b); + } + + ///< The Left value + public float Left + { + set + { + left = value; + } + get + { + return left; + } + } + + ///< The Right value + public float Right + { + set + { + right = value; + } + get + { + return right; + } + } + + ///< The Bottom value + public float Bottom + { + set + { + bottom = value; + } + get + { + return bottom; + } + } + + ///< The Top value + public float Top + { + set + { + top = value; + } + get + { + return top; + } + } + +%} + +%enddef + +namespace Dali +{ + DALI_PADDINGTYPE_PROPERTY_PARAM( Dali, Rect); +} diff --git a/plugins/dali-swig/SWIG/events/rectangle.i b/plugins/dali-swig/SWIG/events/rectangle.i new file mode 100644 index 0000000..b9e9c95 --- /dev/null +++ b/plugins/dali-swig/SWIG/events/rectangle.i @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +%csmethodmodifiers Dali::Rect::x "private"; +%csmethodmodifiers Dali::Rect::y "private"; +%csmethodmodifiers Dali::Rect::left "private"; +%csmethodmodifiers Dali::Rect::right "private"; +%csmethodmodifiers Dali::Rect::width "private"; +%csmethodmodifiers Dali::Rect::bottom "private"; +%csmethodmodifiers Dali::Rect::height "private"; +%csmethodmodifiers Dali::Rect::top "private"; + +%define DALI_RECTANGLE_PROPERTY_PARAM(NameSpace,ClassName) + %typemap(cscode) NameSpace::ClassName %{ + public static bool operator ==(Rectangle a, Rectangle b) + { + // If both are null, or both are same instance, return true. + if (System.Object.ReferenceEquals(a, b)) + { + return true; + } + + // If one is null, but not both, return false. + if (((object)a == null) || ((object)b == null)) + { + return false; + } + + // Return true if the fields match: + return a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height; + } + + public static bool operator !=(Rectangle a, Rectangle b) + { + return !(a == b); + } + + ///< X position of the rectangle + public int X + { + set + { + x = value; + } + get + { + return x; + } + } + + ///< Y position of the rectangle + public int Y + { + set + { + y = value; + } + get + { + return y; + } + } + + ///< Width of the rectangle + public int Width + { + set + { + width = value; + } + get + { + return width; + } + } + + ///< Height of the rectangle + public int Height + { + set + { + height = value; + } + get + { + return height; + } + } +%} + +%enddef + +namespace Dali +{ + DALI_RECTANGLE_PROPERTY_PARAM( Dali, Rect); +} diff --git a/plugins/dali-swig/SWIG/events/rectinteger.i b/plugins/dali-swig/SWIG/events/rectinteger.i deleted file mode 100644 index b89d1f5..0000000 --- a/plugins/dali-swig/SWIG/events/rectinteger.i +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -%define DALI_RECTINTEGER_PROPERTY_PARAM(NameSpace,ClassName) - %typemap(cscode) NameSpace::ClassName %{ - - public int X { - set { - NDalicPINVOKE.RectInteger_x_set(swigCPtr, value); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - get { - int ret = NDalicPINVOKE.RectInteger_x_get(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - } - - public int Y { - set { - NDalicPINVOKE.RectInteger_y_set(swigCPtr, value); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - get { - int ret = NDalicPINVOKE.RectInteger_y_get(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - } - - public int W { - set { - NDalicPINVOKE.RectInteger_width_set(swigCPtr, value); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - get { - int ret = NDalicPINVOKE.RectInteger_width_get(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - } - - public int H { - set { - NDalicPINVOKE.RectInteger_height_set(swigCPtr, value); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - get { - int ret = NDalicPINVOKE.RectInteger_height_get(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - } - -%} - -%enddef - -namespace Dali -{ - DALI_RECTINTEGER_PROPERTY_PARAM( Dali, Rect); -} diff --git a/plugins/dali-swig/examples/control-dashboard.cs b/plugins/dali-swig/examples/control-dashboard.cs index ff1e87e..0ddd6f1 100755 --- a/plugins/dali-swig/examples/control-dashboard.cs +++ b/plugins/dali-swig/examples/control-dashboard.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -283,7 +283,7 @@ namespace MyCSharpExample text.MultiLine = true; text.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.WIDTH); text.SetResizePolicy(ResizePolicyType.DIMENSION_DEPENDENCY, DimensionType.HEIGHT); - text.SetPadding(new RectFloat(10.0f, 10.0f, 20.0f, 0.0f)); + text.SetPadding(new PaddingType(10.0f, 10.0f, 20.0f, 0.0f)); _popup.SetContent(text); _popup.SetKeyboardFocusable(true); _popup.SetDisplayState(Popup.DisplayStateType.HIDDEN); diff --git a/plugins/dali-swig/examples/dali-test.cs b/plugins/dali-swig/examples/dali-test.cs index 274b97a..ce7899b 100644 --- a/plugins/dali-swig/examples/dali-test.cs +++ b/plugins/dali-swig/examples/dali-test.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,385 +21,412 @@ using Dali; namespace MyCSharpExample { - class Example - { - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - delegate void CallbackDelegate(IntPtr appPtr); // void, void delgate - - private Dali.Application _application; - - public Example(Dali.Application application) - { - _application = application; - Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() ); - - _application.Initialized += Initialize; - Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() ); - } - - public void Initialize(object source, NUIApplicationInitEventArgs e) - { - OperatorTests(); - - CustomViewPropertyTest(); - - Handle handle = new Handle(); - int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE); - float myProperty = 0.0f; - handle.GetProperty(myPropertyIndex).Get(ref myProperty); - Console.WriteLine( "myProperty value: " + myProperty ); - - int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Size(5.0f, 5.0f)), Property.AccessMode.READ_WRITE); - Size myProperty2 = new Size(0.0f, 0.0f); - handle.GetProperty(myPropertyIndex2).Get(myProperty2); - Console.WriteLine( "myProperty2 value: " + myProperty2.W + ", " + myProperty2.H ); - - Actor actor = new Actor(); - actor.Size = new Position(200.0f, 200.0f, 0.0f); - actor.Name = "MyActor"; - actor.Color = new Color(1.0f, 0.0f, 1.0f, 0.8f); - Console.WriteLine("Actor id: {0}", actor.GetId()); - Console.WriteLine("Actor size: " + actor.Size.X + ", " + actor.Size.Y); - Console.WriteLine("Actor name: " + actor.Name); - - Stage stage = Stage.GetCurrent(); - stage.BackgroundColor = Color.White; - - Size stageSize = stage.Size; - Console.WriteLine("Stage size: " + stageSize.W + ", " + stageSize.H); - stage.Add(actor); - - TextLabel text = new TextLabel("Hello Mono World"); - text.ParentOrigin = NDalic.ParentOriginCenter; - text.AnchorPoint = NDalic.AnchorPointCenter; - text.HorizontalAlignment = "CENTER"; - stage.Add(text); - - Console.WriteLine( "Text label text: " + text.Text ); - - Console.WriteLine( "Text label point size: " + text.PointSize ); - text.PointSize = 32.0f; - Console.WriteLine( "Text label new point size: " + text.PointSize ); - - using (RectInteger ri = new RectInteger(02,05,20,30)) - { - Console.WriteLine( " Created " + ri ); - Console.WriteLine( " IsEmpty() = " + ri.IsEmpty() ); - Console.WriteLine( " Left = " + ri.Left() ); - Console.WriteLine( " Right = " + ri.Right() ); - Console.WriteLine( " Top = " + ri.Top() ); - Console.WriteLine( " Bottom = " + ri.Bottom() ); - Console.WriteLine( " Area = " + ri.Area() ); - } - Console.WriteLine( " *************************" ); - using (RectInteger ri2 = new RectInteger(02,05,20,30)) - { - Console.WriteLine( " Created " + ri2 ); - ri2.Set(1,1,40,40); - Console.WriteLine( " IsEmpty() = " + ri2.IsEmpty() ); - Console.WriteLine( " Left = " + ri2.Left() ); - Console.WriteLine( " Right = " + ri2.Right() ); - Console.WriteLine( " Top = " + ri2.Top() ); - Console.WriteLine( " Bottom = " + ri2.Bottom() ); - Console.WriteLine( " Area = " + ri2.Area() ); - } - Console.WriteLine( " *************************" ); - using (RectDouble rd = new RectDouble(02,05,20.5,30.5)) - { - Console.WriteLine( " Created " + rd ); - Console.WriteLine( " IsEmpty() = " + rd.IsEmpty() ); - Console.WriteLine( " Left = " + rd.Left() ); - Console.WriteLine( " Right = " + rd.Right() ); - Console.WriteLine( " Top = " + rd.Top() ); - Console.WriteLine( " Bottom = " + rd.Bottom() ); - Console.WriteLine( " Area = " + rd.Area() ); - } - Console.WriteLine( " *************************" ); - RectDouble rd2 = new RectDouble(); - rd2.x = 10; - rd2.y = 10; - rd2.width = 20; - rd2.height = 20; - Console.WriteLine( " Created " + rd2 ); - Console.WriteLine( " IsEmpty() = " + rd2.IsEmpty() ); - Console.WriteLine( " Left = " + rd2.Left() ); - Console.WriteLine( " Right = " + rd2.Right() ); - Console.WriteLine( " Top = " + rd2.Top() ); - Console.WriteLine( " Bottom = " + rd2.Bottom() ); - Console.WriteLine( " Area = " + rd2.Area() ); - - Console.WriteLine( " *************************" ); - Size Size = new Size(100, 50); - Console.WriteLine( " Created " + Size ); - Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H ); - Size += new Size(20, 20); - Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H ); - Size.W += 10; - Size.H += 10; - Console.WriteLine( " Size width = " + Size.W + ", height = " + Size.H ); - - Console.WriteLine( " *************************" ); - Position Position = new Position(20, 100, 50); - Console.WriteLine( " Created " + Position ); - Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); - Position += new Position(20, 20, 20); - Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); - Position.X += 10; - Position.Y += 10; - Position.Z += 10; - Console.WriteLine( " Position width = " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z ); - Position parentOrigin = new Dali.Position(NDalic.ParentOriginBottomRight); - Console.WriteLine( " parentOrigin x = " + parentOrigin.X + ", y = " + parentOrigin.Y + ", z = " + parentOrigin.Z ); - - Console.WriteLine( " *************************" ); - Color color = new Color(20, 100, 50, 200); - Console.WriteLine( " Created " + color ); - Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); - color += new Color(20, 20, 20, 20); - Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); - color.R += 10; - color.G += 10; - color.B += 10; - color.A += 10; - Console.WriteLine( " Color r = " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A ); - } - - - public void OperatorTests() - { - Actor actor = new Actor(); - Actor differentActor = new Actor(); - Actor actorSame = actor; - Actor nullActor = null; - - // test the true operator - if ( actor ) - { - Console.WriteLine ("BaseHandle Operator true (actor) : test passed "); - } - else - { - Console.WriteLine ("BaseHandle Operator true (actor): test failed "); - } - - Actor parent = actor.GetParent (); - - if ( parent ) - { - Console.WriteLine ("Handle with Empty body :failed "); - } - else - { - Console.WriteLine ("Valid with Empty body :passed "); - } - - actor.Add( differentActor ); - // here we test two different C# objects, which on the native side have the same body/ ref-object - if ( actor == differentActor.GetParent() ) - { - Console.WriteLine ("actor == differentActor.GetParent() :passed "); - } - else - { - Console.WriteLine ("actor == differentActor.GetParent() :failed "); - } - - if ( differentActor == differentActor.GetParent() ) - { - Console.WriteLine ("differentActor == differentActor.GetParent() :failed "); - } - else - { - Console.WriteLine ("differentActor == differentActor.GetParent() :passed "); - } - - - if ( nullActor ) - { - Console.WriteLine ("BaseHandle Operator true (nullActor) : test failed "); - } - else - { - Console.WriteLine ("BaseHandle Operator true (nullActor): test passed "); - } - - // ! operator - if ( !actor ) - { - Console.WriteLine ("BaseHandle Operator !(actor) : test failed "); - } - else - { - Console.WriteLine ("BaseHandle Operator !(actor): test passed "); - } - - if ( !nullActor ) - { - Console.WriteLine ("BaseHandle Operator !(nullActor) : test passed "); - } - else - { - Console.WriteLine ("BaseHandle Operator !(nullActor): test failed "); - } - - // Note: operator false only used inside & operator - // test equality operator == - if ( actor == actorSame ) - { - Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test passed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test failed"); - } - - if ( actor == differentActor ) + class Example { - Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test failed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test passed"); - } - - if ( actor == nullActor ) - { - Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test failed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test passed"); - } + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void CallbackDelegate(IntPtr appPtr); // void, void delgate - if ( nullActor == nullActor ) - { - Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test passed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test failed"); - } - - // test || operator - if ( actor || actorSame ) - { - Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test passed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test failed"); - } - - if ( actor || nullActor ) - { - Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test passed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test failed"); - } - - if ( nullActor || nullActor ) - { - Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test failed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test passed"); - } + private Dali.Application _application; + public Example(Dali.Application application) + { + _application = application; + Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() ); - // test && operator - if ( actor && actorSame ) - { - Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test passed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test failed"); - } - - if ( actor && nullActor ) - { - Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test failed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test passed"); - } - - if ( nullActor && nullActor ) - { - Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test failed"); - } - else - { - Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test passed"); - } - - } + _application.Initialized += Initialize; + Console.WriteLine( "InitSignal connection count = " + _application.InitSignal().GetConnectionCount() ); + } - public void CustomViewPropertyTest() - { - // Create a Spin control - Spin spin = new Spin(); - - // Background property - Property.Map background = new Property.Map(); - background.Add( Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Color) ) - .Add( Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red) ); - spin.Background = background; - - background = spin.Background; - Vector4 backgroundColor = new Vector4(); - background.Find(Dali.Constants.ColorVisualProperty.MixColor).Get(backgroundColor); - if( backgroundColor == Color.Red ) + public void Initialize(object source, NUIApplicationInitEventArgs e) { - Console.WriteLine ("Custom View Background property : test passed"); + OperatorTests(); + + CustomViewPropertyTest(); + + Handle handle = new Handle(); + int myPropertyIndex = handle.RegisterProperty("myProperty", new Property.Value(10.0f), Property.AccessMode.READ_WRITE); + float myProperty = 0.0f; + handle.GetProperty(myPropertyIndex).Get(ref myProperty); + Console.WriteLine( "myProperty value: " + myProperty ); + + int myPropertyIndex2 = handle.RegisterProperty("myProperty2", new Property.Value(new Size(5.0f, 5.0f)), Property.AccessMode.READ_WRITE); + Size myProperty2 = new Size(0.0f, 0.0f); + handle.GetProperty(myPropertyIndex2).Get(myProperty2); + Console.WriteLine( "myProperty2 value: " + myProperty2.W + ", " + myProperty2.H ); + + Actor actor = new Actor(); + actor.Size = new Position(200.0f, 200.0f, 0.0f); + actor.Name = "MyActor"; + actor.Color = new Color(1.0f, 0.0f, 1.0f, 0.8f); + Console.WriteLine("Actor id: {0}", actor.GetId()); + Console.WriteLine("Actor size: " + actor.Size.X + ", " + actor.Size.Y); + Console.WriteLine("Actor name: " + actor.Name); + + Stage stage = Stage.GetCurrent(); + stage.BackgroundColor = Color.White; + Size stageSize = stage.Size; + Console.WriteLine("Stage size: " + stageSize.W + ", " + stageSize.H); + stage.Add(actor); + + TextLabel text = new TextLabel("Hello Mono World"); + text.ParentOrigin = NDalic.ParentOriginCenter; + text.AnchorPoint = NDalic.AnchorPointCenter; + text.HorizontalAlignment = "CENTER"; + stage.Add(text); + + Console.WriteLine( "Text label text: " + text.Text ); + + Console.WriteLine( "Text label point size: " + text.PointSize ); + text.PointSize = 32.0f; + Console.WriteLine( "Text label new point size: " + text.PointSize ); + + RectanglePaddingClassTest(); + + Console.WriteLine( " *************************" ); + Size Size = new Size(100, 50); + Console.WriteLine( " Created " + Size ); + Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H ); + Size += new Size(20, 20); + Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H ); + Size.W += 10; + Size.H += 10; + Console.WriteLine( " Size width = " + Size.W + ", height = " + Size.H ); + + Console.WriteLine( " *************************" ); + Position Position = new Position(20, 100, 50); + Console.WriteLine( " Created " + Position ); + Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); + Position += new Position(20, 20, 20); + Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); + Position.X += 10; + Position.Y += 10; + Position.Z += 10; + Console.WriteLine( " Position width = " + Position.X + ", height = " + Position.Y + ", depth = " + Position.Z ); + Position parentOrigin = new Dali.Position(NDalic.ParentOriginBottomRight); + Console.WriteLine( " parentOrigin x = " + parentOrigin.X + ", y = " + parentOrigin.Y + ", z = " + parentOrigin.Z ); + + Console.WriteLine( " *************************" ); + Color color = new Color(20, 100, 50, 200); + Console.WriteLine( " Created " + color ); + Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); + color += new Color(20, 20, 20, 20); + Console.WriteLine( " Color R = " + color.R + ", G = " + color.G + ", B = " + color.B + ", A = " + color.A ); + color.R += 10; + color.G += 10; + color.B += 10; + color.A += 10; + Console.WriteLine( " Color r = " + color.R + ", g = " + color.G + ", b = " + color.B + ", a = " + color.A ); } - else + + public void RectanglePaddingClassTest() { - Console.WriteLine ("Custom View Background property : test failed"); + using (Rectangle r1 = new Rectangle(2, 5, 20, 30)) + { + Console.WriteLine( " Created " + r1 ); + Console.WriteLine( " IsEmpty() = " + r1.IsEmpty() ); + Console.WriteLine( " Left = " + r1.Left() ); + Console.WriteLine( " Right = " + r1.Right() ); + Console.WriteLine( " Top = " + r1.Top() ); + Console.WriteLine( " Bottom = " + r1.Bottom() ); + Console.WriteLine( " Area = " + r1.Area() ); + } + + Console.WriteLine( " *************************" ); + + using (Rectangle r2 = new Rectangle(2, 5, 20, 30)) + { + Console.WriteLine( " Created " + r2 ); + r2.Set(1,1,40,40); + Console.WriteLine( " IsEmpty() = " + r2.IsEmpty() ); + Console.WriteLine( " Left = " + r2.Left() ); + Console.WriteLine( " Right = " + r2.Right() ); + Console.WriteLine( " Top = " + r2.Top() ); + Console.WriteLine( " Bottom = " + r2.Bottom() ); + Console.WriteLine( " Area = " + r2.Area() ); + } + + Console.WriteLine( " *************************" ); + + Rectangle r3 = new Rectangle(10, 10, 20, 20); + Rectangle r4 = new Rectangle(10, 10, 20, 20); + + if (r3 == r4) + { + Console.WriteLine("r3 == r4"); + } + else + { + Console.WriteLine("r3 != r4"); + } + + r4 = new Rectangle(12, 10, 20, 20); + + if (r3 == r4) + { + Console.WriteLine("r3 == r4"); + } + else + { + Console.WriteLine("r3 != r4"); + } + + PaddingType p1 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); + PaddingType p2 = new PaddingType(10.5f, 10.7f, 20.8f, 20.8f); + + if (p1 == p2) + { + Console.WriteLine("p1 == p2"); + } + else + { + Console.WriteLine("p1 != p2"); + } + + p2 = new PaddingType(12.0f, 10.7f, 20.2f, 20.0f); + + if (p1 == p2) + { + Console.WriteLine("p1 == p2"); + } + else + { + Console.WriteLine("p1 != p2"); + } } - // BackgroundColor property - spin.BackgroundColor = Color.Yellow; - if(spin.BackgroundColor == Color.Yellow) + public void OperatorTests() { - Console.WriteLine ("Custom View BackgroundColor property : test passed"); + Actor actor = new Actor(); + Actor differentActor = new Actor(); + Actor actorSame = actor; + Actor nullActor = null; + + // test the true operator + if ( actor ) + { + Console.WriteLine ("BaseHandle Operator true (actor) : test passed "); + } + else + { + Console.WriteLine ("BaseHandle Operator true (actor): test failed "); + } + + Actor parent = actor.GetParent (); + + if ( parent ) + { + Console.WriteLine ("Handle with Empty body :failed "); + } + else + { + Console.WriteLine ("Valid with Empty body :passed "); + } + + actor.Add( differentActor ); + + // here we test two different C# objects, which on the native side have the same body/ ref-object + if ( actor == differentActor.GetParent() ) + { + Console.WriteLine ("actor == differentActor.GetParent() :passed "); + } + else + { + Console.WriteLine ("actor == differentActor.GetParent() :failed "); + } + + if ( differentActor == differentActor.GetParent() ) + { + Console.WriteLine ("differentActor == differentActor.GetParent() :failed "); + } + else + { + Console.WriteLine ("differentActor == differentActor.GetParent() :passed "); + } + + if ( nullActor ) + { + Console.WriteLine ("BaseHandle Operator true (nullActor) : test failed "); + } + else + { + Console.WriteLine ("BaseHandle Operator true (nullActor): test passed "); + } + + // ! operator + if ( !actor ) + { + Console.WriteLine ("BaseHandle Operator !(actor) : test failed "); + } + else + { + Console.WriteLine ("BaseHandle Operator !(actor): test passed "); + } + + if ( !nullActor ) + { + Console.WriteLine ("BaseHandle Operator !(nullActor) : test passed "); + } + else + { + Console.WriteLine ("BaseHandle Operator !(nullActor): test failed "); + } + + // Note: operator false only used inside & operator + // test equality operator == + if ( actor == actorSame ) + { + Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test passed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (actor == actorSame) : test failed"); + } + + if ( actor == differentActor ) + { + Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test failed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (actor == differentActor) : test passed"); + } + + if ( actor == nullActor ) + { + Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test failed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (actor == nullActor) : test passed"); + } + + if ( nullActor == nullActor ) + { + Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test passed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (nullActor == nullActor) : test failed"); + } + + // test || operator + if ( actor || actorSame ) + { + Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test passed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (actor || actorSame) : test failed"); + } + + if ( actor || nullActor ) + { + Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test passed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (actor || nullActor) : test failed"); + } + + if ( nullActor || nullActor ) + { + Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test failed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (nullActor || nullActor) : test passed"); + } + + // test && operator + if ( actor && actorSame ) + { + Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test passed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (actor && actorSame) : test failed"); + } + + if ( actor && nullActor ) + { + Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test failed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (actor && nullActor) : test passed"); + } + + if ( nullActor && nullActor ) + { + Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test failed"); + } + else + { + Console.WriteLine ("BaseHandle Operator (nullActor && nullActor) : test passed"); + } } - else + + public void CustomViewPropertyTest() { - Console.WriteLine ("Custom View BackgroundColor property : test failed"); + // Create a Spin control + Spin spin = new Spin(); + + // Background property + Property.Map background = new Property.Map(); + background.Add( Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Color) ) + .Add( Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red) ); + spin.Background = background; + + background = spin.Background; + Vector4 backgroundColor = new Vector4(); + background.Find(Dali.Constants.ColorVisualProperty.MixColor).Get(backgroundColor); + if( backgroundColor == Color.Red ) + { + Console.WriteLine ("Custom View Background property : test passed"); + } + else + { + Console.WriteLine ("Custom View Background property : test failed"); + } + + // BackgroundColor property + spin.BackgroundColor = Color.Yellow; + if(spin.BackgroundColor == Color.Yellow) + { + Console.WriteLine ("Custom View BackgroundColor property : test passed"); + } + else + { + Console.WriteLine ("Custom View BackgroundColor property : test failed"); + } + + // StyleName property + spin.StyleName = "MyCustomStyle"; + if(spin.StyleName == "MyCustomStyle") + { + Console.WriteLine ("Custom View StyleName property : test passed"); + } + else + { + Console.WriteLine ("Custom View StyleName property : test failed"); + } } - // StyleName property - spin.StyleName = "MyCustomStyle"; - if(spin.StyleName == "MyCustomStyle") + public void MainLoop() { - Console.WriteLine ("Custom View StyleName property : test passed"); + _application.MainLoop (); } - else + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) { - Console.WriteLine ("Custom View StyleName property : test failed"); - } - } + Console.WriteLine ("Hello Mono World"); - public void MainLoop() - { - _application.MainLoop (); + Example example = new Example(Application.NewApplication()); + example.MainLoop (); + } } - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - Console.WriteLine ("Hello Mono World"); - - Example example = new Example(Application.NewApplication()); - example.MainLoop (); - } - } } diff --git a/plugins/dali-swig/manual/cpp/devel-property-wrap.cpp b/plugins/dali-swig/manual/cpp/devel-property-wrap.cpp index e8edf38..bbadec9 100755 --- a/plugins/dali-swig/manual/cpp/devel-property-wrap.cpp +++ b/plugins/dali-swig/manual/cpp/devel-property-wrap.cpp @@ -51,6 +51,24 @@ SWIGEXPORT int SWIGSTDCALL CSharp_View_Property_TOOLTIP_get() { return jresult; } +SWIGEXPORT int SWIGSTDCALL CSharp_View_Property_STATE_get() { + int jresult ; + int result; + + result = (int)Dali::Toolkit::DevelControl::Property::STATE; + jresult = (int)result; + return jresult; +} + +SWIGEXPORT int SWIGSTDCALL CSharp_View_Property_SUB_STATE_get() { + int jresult ; + int result; + + result = (int)Dali::Toolkit::DevelControl::Property::SUB_STATE; + jresult = (int)result; + return jresult; +} + SWIGEXPORT int SWIGSTDCALL CSharp_ItemView_Property_LAYOUT_get() { int jresult ; int result; diff --git a/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs b/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs index 09330f4..82c2f2f 100755 --- a/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs +++ b/plugins/dali-swig/manual/csharp/ManualPINVOKE.cs @@ -193,6 +193,12 @@ namespace Dali [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_View_Property_TOOLTIP_get")] public static extern int View_Property_TOOLTIP_get(); + [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_View_Property_STATE_get")] + public static extern int View_Property_STATE_get(); + + [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_View_Property_SUB_STATE_get")] + public static extern int View_Property_SUB_STATE_get(); + [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_ItemView_Property_LAYOUT_get")] public static extern int ItemView_Property_LAYOUT_get(); diff --git a/plugins/dali-swig/property-wrapper.rb b/plugins/dali-swig/property-wrapper.rb index fe2e91c..9d6ea2d 100755 --- a/plugins/dali-swig/property-wrapper.rb +++ b/plugins/dali-swig/property-wrapper.rb @@ -20,7 +20,7 @@ $typeTable = [ ["VECTOR4", "Vector4", "", "Vector4 temp = new Vector4(0.0f,0.0f,0.0f,0.0f);"], ["MATRIX3", "Matrix3", "", "Matrix3 temp = new Matrix3();"], ["MATRIX", "Matrix", "", "Matrix temp = new Matrix();" ], - ["RECTANGLE", "RectInteger", "", "RectInteger temp = new RectInteger(0,0,0,0);"], + ["RECTANGLE", "Rectangle", "", "Rectangle temp = new Rectangle(0,0,0,0);"], ["ROTATION", "Quaternion", "", "Quaternion temp = new Quaternion();"], ["STRING", "string", "out", "string temp;"], ["ARRAY", "Dali.Property.Array", "", "Dali.Property.Array temp = new Dali.Property.Array();"],