From 1e919141627d7a3a002d21fce45163bfd2cd3fc9 Mon Sep 17 00:00:00 2001 From: Emil Abraham Date: Wed, 23 Nov 2016 17:37:07 +0530 Subject: [PATCH] Dali C# binding - Implement the pure C# classes Implementation of Pure high-level C# classes and use C#'s implicit convertion operators to covert from C# Color, Position & Size classes to Dali Vector4, Vector3 and Vector2 classes. Change-Id: I6a68268c8e1511697479ca9f94356961bca5a7bd Signed-off-by: Emil Abraham --- plugins/dali-swig/examples/custom-control.cs | 2 +- plugins/dali-swig/examples/dali-test.cs | 52 +-- plugins/dali-swig/examples/hello-world.cs | 2 +- plugins/dali-swig/examples/scroll-view.cs | 22 +- plugins/dali-swig/examples/spin-control.cs | 18 +- plugins/dali-swig/manual/csharp/Color.cs | 658 +++++++++++++++------------ plugins/dali-swig/manual/csharp/Position.cs | 343 +++++++------- plugins/dali-swig/manual/csharp/Size.cs | 343 +++++++------- 8 files changed, 790 insertions(+), 650 deletions(-) diff --git a/plugins/dali-swig/examples/custom-control.cs b/plugins/dali-swig/examples/custom-control.cs index 9dde85e..92b0610 100644 --- a/plugins/dali-swig/examples/custom-control.cs +++ b/plugins/dali-swig/examples/custom-control.cs @@ -166,7 +166,7 @@ namespace MyCSharpExample public void Initialize(object source, AUIApplicationInitEventArgs e) { Stage stage = Stage.GetCurrent(); - stage.SetBackgroundColor( NDalic.WHITE ); + stage.BackgroundColor = Color.White; // Create a container to layout the rows of image and rating vertically FlexContainer container = new FlexContainer(); diff --git a/plugins/dali-swig/examples/dali-test.cs b/plugins/dali-swig/examples/dali-test.cs index d13b4ea..b6396f7 100644 --- a/plugins/dali-swig/examples/dali-test.cs +++ b/plugins/dali-swig/examples/dali-test.cs @@ -51,7 +51,7 @@ namespace MyCSharpExample 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.x + ", " + myProperty2.y ); + Console.WriteLine( "myProperty2 value: " + myProperty2.W + ", " + myProperty2.H ); Actor actor = new Actor(); actor.Size = new Position(200.0f, 200.0f, 0.0f); @@ -62,10 +62,10 @@ namespace MyCSharpExample Console.WriteLine("Actor name: " + actor.Name); Stage stage = Stage.GetCurrent(); - stage.BackgroundColor = new Color(Colors.White) ; + stage.BackgroundColor = Color.White; Size stageSize = stage.Size; - Console.WriteLine("Stage size: " + stageSize.x + ", " + stageSize.y); + Console.WriteLine("Stage size: " + stageSize.W + ", " + stageSize.H); stage.Add(actor); TextLabel text = new TextLabel("Hello Mono World"); @@ -130,39 +130,37 @@ namespace MyCSharpExample Console.WriteLine( " *************************" ); Size Size = new Size(100, 50); Console.WriteLine( " Created " + Size ); - Console.WriteLine( " Size x = " + Size.x + ", y = " + Size.y ); + Console.WriteLine( " Size x = " + Size.W + ", y = " + Size.H ); Size += new Size(20, 20); - Console.WriteLine( " Size x = " + Size[0] + ", y = " + Size[1] ); - Size.x += 10; - Size.y += 10; - Console.WriteLine( " Size width = " + Size.width + ", height = " + Size.height ); - Size += new Size(15, 15); - Console.WriteLine( " Size width = " + Size[0] + ", height = " + Size[1] ); + 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 ); + Console.WriteLine( " Position x = " + Position.X + ", y = " + Position.Y + ", z = " + Position.Z ); Position += new Position(20, 20, 20); - Console.WriteLine( " Position x = " + Position[0] + ", y = " + Position[1] + ", z = " + Position[2] ); - Position.x += 10; - Position.y += 10; - Position.z += 10; - Console.WriteLine( " Position width = " + Position.width + ", height = " + Position.height + ", depth = " + Position.depth ); + 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( " 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 x = " + Color.x + ", y = " + Color.y + ", z = " + Color.z + ", w = " + Color.w ); - Color += new Color(20, 20, 20, 20); - Console.WriteLine( " Color x = " + Color[0] + ", y = " + Color[1] + ", z = " + Color[2] + ", w = " + Color[3] ); - Color.x += 10; - Color.y += 10; - Color.z += 10; - Color.w += 10; - Console.WriteLine( " Color r = " + Color.r + ", g = " + Color.g + ", b = " + Color.b + ", a = " + Color.a ); + 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 ); } diff --git a/plugins/dali-swig/examples/hello-world.cs b/plugins/dali-swig/examples/hello-world.cs index 7853ce3..be7a11b 100755 --- a/plugins/dali-swig/examples/hello-world.cs +++ b/plugins/dali-swig/examples/hello-world.cs @@ -38,7 +38,7 @@ namespace MyCSharpExample { Console.WriteLine("Customized Application Initialize event handler"); Stage stage = Stage.GetCurrent(); - stage.BackgroundColor = new Color("white"); + stage.BackgroundColor = Color.Green; stage.Touched += OnStageTouched; diff --git a/plugins/dali-swig/examples/scroll-view.cs b/plugins/dali-swig/examples/scroll-view.cs index 342c82b..4e7c3ac 100644 --- a/plugins/dali-swig/examples/scroll-view.cs +++ b/plugins/dali-swig/examples/scroll-view.cs @@ -50,12 +50,12 @@ namespace MyCSharpExample private void CreateScrollView() { Stage stage = Stage.GetCurrent(); - stage.BackgroundColor = new Color("white"); + stage.BackgroundColor = Color.White; // Create a scroll view _scrollView = new ScrollView(); Size stageSize = stage.Size; - _scrollView.Size = new Position(stageSize.x, stageSize.y, 0.0f); + _scrollView.Size = new Position(stageSize.W, stageSize.H, 0.0f); _scrollView.ParentOrigin = NDalic.ParentOriginCenter; _scrollView.AnchorPoint = NDalic.AnchorPointCenter; stage.Add(_scrollView); @@ -71,13 +71,13 @@ namespace MyCSharpExample pageActor.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.ALL_DIMENSIONS); pageActor.ParentOrigin = NDalic.ParentOriginCenter; pageActor.AnchorPoint = NDalic.AnchorPointCenter; - pageActor.Position = new Position(pageColumn * stageSize.x, pageRow * stageSize.y, 0.0f); + pageActor.Position = new Position(pageColumn * stageSize.W, pageRow * stageSize.H, 0.0f); // Add images in a 3x4 grid layout for each page int imageRows = 4; int imageColumns = 3; float margin = 10.0f; - Position imageSize = new Position((stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0f); + Position imageSize = new Position((stageSize.W / imageColumns) - margin, (stageSize.H / imageRows) - margin, 0.0f); for(int row = 0; row < imageRows; row++) { @@ -88,8 +88,8 @@ namespace MyCSharpExample imageView.ParentOrigin = NDalic.ParentOriginCenter; imageView.AnchorPoint = NDalic.AnchorPointCenter; imageView.Size = imageSize; - imageView.Position = new Position( margin * 0.5f + (imageSize.x + margin) * column - stageSize.x * 0.5f + imageSize.x * 0.5f, - margin * 0.5f + (imageSize.y + margin) * row - stageSize.y * 0.5f + imageSize.y * 0.5f, 0.0f ); + imageView.Position = new Position( margin * 0.5f + (imageSize.X + margin) * column - stageSize.W * 0.5f + imageSize.X * 0.5f, + margin * 0.5f + (imageSize.Y + margin) * row - stageSize.H * 0.5f + imageSize.Y * 0.5f, 0.0f ); pageActor.Add(imageView); } } @@ -102,9 +102,9 @@ namespace MyCSharpExample // Set scroll view to have 3 pages in X axis and allow page snapping, // and also disable scrolling in Y axis. - RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.width)); + RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.W)); RulerPtr scrollRulerY = new RulerPtr(new DefaultRuler()); - scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.width * pageColumns, true)); + scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.W * pageColumns, true)); scrollRulerY.Disable(); _scrollView.SetRulerX(scrollRulerX); _scrollView.SetRulerY(scrollRulerY); @@ -115,7 +115,7 @@ namespace MyCSharpExample _scrollBar.AnchorPoint = NDalic.AnchorPointTopLeft; _scrollBar.SetResizePolicy(ResizePolicyType.FIT_TO_CHILDREN, DimensionType.WIDTH); _scrollBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.HEIGHT); - _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Position.ZAXIS ); + _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Vector3.ZAXIS ); _scrollBar.SetScrollDirection(ScrollBar.Direction.Horizontal); _scrollView.Add(_scrollBar); @@ -166,8 +166,8 @@ namespace MyCSharpExample _animation = new Animation(1.0f); // 1 second of duration - _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Position.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f)); - _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Position.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f)); + _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f)); + _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f)); // Connect the signal callback for animaiton finished signal _animation.Finished += AnimationFinished; diff --git a/plugins/dali-swig/examples/spin-control.cs b/plugins/dali-swig/examples/spin-control.cs index 15b0d8b..af74f1e 100644 --- a/plugins/dali-swig/examples/spin-control.cs +++ b/plugins/dali-swig/examples/spin-control.cs @@ -36,8 +36,8 @@ namespace MyCSharpExample private string _fontFamily; private string _fontStyle; private int _pointSize; - private Vector4 _textColor; - private Vector4 _textBackgroundColor; + private Color _textColor; + private Color _textBackgroundColor; private int _maxTextLength; public Spin() : base(ViewWrapperImpl.CustomViewBehaviour.REQUIRES_KEYBOARD_NAVIGATION_SUPPORT | ViewWrapperImpl.CustomViewBehaviour.DISABLE_STYLE_CHANGE_SIGNALS) @@ -48,7 +48,7 @@ namespace MyCSharpExample { // Initialize the properties _arrowImage = "./images/arrow.png"; - _textBackgroundColor = new Vector4(0.6f, 0.6f, 0.6f, 1.0f); + _textBackgroundColor = new Color(0.6f, 0.6f, 0.6f, 1.0f); _currentValue = 0; _minValue = 0; _maxValue = 0; @@ -229,8 +229,8 @@ namespace MyCSharpExample } } - // TextColor property of type Vector4: - public Vector4 TextColor + // TextColor property of type Color: + public Color TextColor { get { @@ -305,7 +305,7 @@ namespace MyCSharpExample public void Initialize(object source, AUIApplicationInitEventArgs e) { Stage stage = Stage.GetCurrent(); - stage.SetBackgroundColor( NDalic.WHITE ); + stage.BackgroundColor = Color.White; // Create a container for the spins _container = new FlexContainer(); @@ -331,7 +331,7 @@ namespace MyCSharpExample _spinYear.Step = 1; _spinYear.MaxTextLength = 4; _spinYear.TextPointSize = 26; - _spinYear.TextColor = NDalic.WHITE; + _spinYear.TextColor = Color.White; _spinYear.SetKeyboardFocusable(true); _spinYear.Name = "_spinYear"; @@ -349,7 +349,7 @@ namespace MyCSharpExample _spinMonth.Step = 1; _spinMonth.MaxTextLength = 2; _spinMonth.TextPointSize = 26; - _spinMonth.TextColor = NDalic.WHITE; + _spinMonth.TextColor = Color.White; _spinMonth.SetKeyboardFocusable(true); _spinMonth.Name = "_spinMonth"; @@ -367,7 +367,7 @@ namespace MyCSharpExample _spinDay.Step = 1; _spinDay.MaxTextLength = 2; _spinDay.TextPointSize = 26; - _spinDay.TextColor = NDalic.WHITE; + _spinDay.TextColor = Color.White; _spinDay.SetKeyboardFocusable(true); _spinDay.Name = "_spinDay"; diff --git a/plugins/dali-swig/manual/csharp/Color.cs b/plugins/dali-swig/manual/csharp/Color.cs index 3115a71..abcb020 100644 --- a/plugins/dali-swig/manual/csharp/Color.cs +++ b/plugins/dali-swig/manual/csharp/Color.cs @@ -1,293 +1,381 @@ -namespace Dali { +namespace Dali +{ + using System; -using System; + public enum Colors + { + Red, + White, + Blue, + Green, + Black, + Yellow, + Magenta, + Cyan + } -public enum Colors -{ - Red, - White, - Blue, - Green, - Black, - Grey, - Yellow, - Azure, - Rose -} + public class Color + { + + private float r; + private float g; + private float b; + private float a; + + /** + * @brief constructor + * + * @since 1.0.0 + */ + public Color() + { + r = 0.0f; + g = 0.0f; + b = 0.0f; + a = 0.0f; + } + + /** + * @brief constructor + * + * @since 1.0.0 + * @param [in] red The Color r. + * @param [in] green The Color g. + * @param [in] blue The Color b. + * @param [in] alpha The Color a. + */ + public Color(float red, float green, float blue, float alpha) + { + r = red; + g = green; + b = blue; + a = alpha; + } + + /** + * @brief constructor + * + * @since 1.0.0 + * @param [in] o The Vector4 having r g b a components + */ + public Color(Vector4 o) + { + r = o.r; + g = o.g; + b = o.b; + a = o.a; + } + + + /** + * @brief constructor + * + * @since 1.0.0 + * @param [in] color as enum Colors. + */ + public Color(Colors color) + { + switch (color) + { + case Colors.Red: + SetColor(1.0f, 0.0f, 0.0f, 1.0f); + break; + case Colors.White: + SetColor(1.0f, 1.0f, 1.0f, 1.0f); + break; + case Colors.Blue: + SetColor(0.0f, 0.0f, 1.0f, 1.0f); + break; + case Colors.Green: + SetColor(0.0f, 1.0f, 0.0f, 1.0f); + break; + case Colors.Black: + SetColor(0.0f, 0.0f, 0.0f, 1.0f); + break; + case Colors.Yellow: + SetColor(1.0f, 1.0f, 0.0f, 1.0f); + break; + case Colors.Cyan: + SetColor(0.0f, 1.0f, 1.0f, 1.0f); + break; + case Colors.Magenta: + SetColor(1.0f, 0.0f, 1.0f, 1.0f); + break; + } + } + + + /** + * @brief SetColor + * + * @since 1.0.0 + * @param [in] red The Color r. + * @param [in] green The Color g. + * @param [in] blue The Color b. + * @param [in] alpha The Color a. + */ + public void SetColor(float red, float green, float blue, float alpha) + { + r = red; + g = green; + b = blue; + a = alpha; + } + + /** + * @brief name "R", type float (Color's Red component) + * @SINCE_1_0.0 + */ + + public float R + { + get { return r; } + set { r = value; } + } + + /** + * @brief name "G", type float (Color's Green component) + * @SINCE_1_0.0 + */ + public float G + { + get { return g; } + set { g = value; } + } + + /** + * @brief name "B", type float (Color's Blue component) + * @SINCE_1_0.0 + */ + public float B + { + get { return b; } + set { b = value; } + } + + /** + * @brief name "A", type float (Color's Alpha value) + * @SINCE_1_0.0 + */ + public float A + { + get { return a; } + set { a = value; } + } + + /** + * @brief operator+ + * + * @since 1.0.0 + * @param [in] l The Color to add. + * @param [in] r The Color to add + * @return A reference to this + */ + public static Color operator +(Color l, Color r) + { + return new Color(l.R + r.R, l.G + r.G, l.B + r.B, l.A + r.A); + } + + /** + * @brief operator- + * + * @since 1.0.0 + * @param [in] l The Color to substract. + * @param [in] r The Color to substract + * @return A reference to this + */ + public static Color operator -(Color l, Color r) + { + return new Color(l.R - r.R, l.G - r.G, l.B - r.B, l.A - r.A); + } + + /** + * @brief operator* + * + * @since 1.0.0 + * @param [in] a The Color to multiply. + * @param [in] b The constant double to multiply. + * @return A reference to this + */ + public static Color operator *(Color a, double b) + { + return new Color((float)(a.R * b), (float)(a.G * b), (float)(a.B * b), (float)(a.A * b)); + } + + /** + * @brief operator/ + * + * @since 1.0.0 + * @param [in] a The Color to divide. + * @param [in] b The Color to divide + * @return float value of division operation + */ + public static float operator /(Color a, Color b) + { + return (float)System.Math.Sqrt((a.R / b.R) * (a.G / b.G) * (a.B / b.B) * (a.A / b.A)); + } + + /** + * @brief Operator == + * + * @since 1.0.0 + * @param [in] x The Color object to compare. + * @param [in] y The Color object to compare. + * @return bool, whether colors are equal or not + */ + public static bool operator == (Color x, Color y) + { + return x.R == y.R && x.G == y.G && x.B == y.B && x.A == y.A; + } + + /** + * @brief Operator != + * + * @since 1.0.0 + * @param [in] x The Color object to compare. + * @param [in] y The Color object to compare. + * @return bool, whether colors are equal or not + */ + public static bool operator != (Color x, Color y) + { + return x.R != y.R || x.G != y.G || x.B != y.B || x.A != y.A; + } + + /** + * @brief GetHashCode + * + * @since 1.0.0 + * @return int, hascode of Color + */ + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /** + * @brief Clone + * + * @since 1.0.0 + * @return Color object + */ + public Color Clone() + { + Color copy = new Color(R, G, B, A); + return copy; + } + + // Create a color for RGBA values ranging from 0..255, useful when dealing with HTML colors + static Color FromRgbaByte( byte red, byte green, byte blue, byte alpha ) + { + return new Color ( red / 255, green / 255, blue / 255, alpha / 255 ); + } + + // User-defined conversion from Color to Vector4 + public static implicit operator Vector4(Color color) + { + return new Vector4(color.r, color.g, color.b, color.a); + } + + public static implicit operator Color(Vector4 vec) + { + return new Color(vec.r, vec.g, vec.b, vec.a); + } + + /** + * @brief name "White", type Color (White Color object) + * @SINCE_1_0.0 + */ + public static Color White + { + get + { + return new Color(Colors.White); + } + } + + /** + * @brief name "Black", type Color (Black Color object) + * @SINCE_1_0.0 + */ + public static Color Black + { + get + { + return new Color(Colors.Black); + } + } + + /** + * @brief name "Red", type Color (Red Color object) + * @SINCE_1_0.0 + */ + public static Color Red + { + get + { + return new Color(Colors.Red); + } + } + + /** + * @brief name "Green", type Color (Green Color object) + * @SINCE_1_0.0 + */ + public static Color Green + { + get + { + return new Color(Colors.Green); + } + } + /** + * @brief name "Blue", type Color (Blue Color object) + * @SINCE_1_0.0 + */ + public static Color Blue + { + get + { + return new Color(Colors.Blue); + } + } + /** + * @brief name "Yellow", type Color (Yellow Color object) + * @SINCE_1_0.0 + */ + public static Color Yellow + { + get + { + return new Color(Colors.Yellow); + } + } -public class Color : Vector4 - { - /** - * @brief constructor - * - * @since 1.0.0 - */ - public Color() - : base() - { } - /** - * @brief constructor - * - * @since 1.0.0 - * @param [in] red The Color r. - * @param [in] green The Color g. - * @param [in] blue The Color b. - * @param [in] alpha The Color a. - */ - public Color(float red, float green, float blue, float alpha) - : base(red, green, blue, alpha) - { } - - /** - * @brief constructor - * - * @since 1.0.0 - * @param [in] o The Vector4 having r g b a components - */ - public Color(Vector4 o) - : base(o.x, o.y, o.z, o.w) - { - - } - - /** - * @brief constructor - * - * @since 1.0.0 - * @param [in] color as string. - */ - public Color(string color) - : base(0, 0, 0, 0) - { - switch (color) - { - case "red": - SetColor(255, 0, 0, 255); - break; - case "white": - SetColor(255, 255, 255, 255); - break; - case "blue": - SetColor(0, 0, 255, 255); - break; - case "green": - SetColor(0, 255, 0, 255); - break; - case "black": - SetColor(0, 0, 0, 255); - break; - case "grey": - SetColor(128, 128, 128, 255); - break; - case "yellow": - SetColor(255, 255, 0, 255); - break; - case "azure": - SetColor(0, 255, 255, 255); - break; - case "rose": - SetColor(255, 0, 255, 255); - break; - } - } - - - /** - * @brief constructor - * - * @since 1.0.0 - * @param [in] color as enum Colors. - */ - public Color(Colors color) - : base(0, 0, 0, 0) - { - switch (color) - { - case Colors.Red: - SetColor(255, 0, 0, 255); - break; - case Colors.White: - SetColor(255, 255, 255, 255); - break; - case Colors.Blue: - SetColor(0, 0, 255, 255); - break; - case Colors.Green: - SetColor(0, 255, 0, 255); - break; - case Colors.Black: - SetColor(0, 0, 0, 255); - break; - case Colors.Grey: - SetColor(128, 128, 128, 255); - break; - case Colors.Yellow: - SetColor(255, 255, 0, 255); - break; - case Colors.Azure: - SetColor(0, 255, 255, 255); - break; - case Colors.Rose: - SetColor(255, 0, 255, 255); - break; - } - } - - - /** - * @brief SetColor - * - * @since 1.0.0 - * @param [in] red The Color r. - * @param [in] green The Color g. - * @param [in] blue The Color b. - * @param [in] alpha The Color a. - */ - public void SetColor(float red, float green, float blue, float alpha) - { - r = red; - g = green; - b = blue; - a = alpha; - } - - /** - * @brief name "R", type float (Color's Red component) - * @SINCE_1_0.0 - */ - - public float R - { - get { return r; } - set { r = value; } - } - - /** - * @brief name "G", type float (Color's Green component) - * @SINCE_1_0.0 - */ - public float G - { - get { return g; } - set { g = value; } - } - - /** - * @brief name "B", type float (Color's Blue component) - * @SINCE_1_0.0 - */ - public float B - { - get { return b; } - set { b = value; } - } - - /** - * @brief name "A", type float (Color's Alpha value) - * @SINCE_1_0.0 - */ - public float A - { - get { return a; } - set { a = value; } - } - - /** - * @brief operator+ - * - * @since 1.0.0 - * @param [in] l The Color to add. - * @param [in] r The Color to add - * @return A reference to this - */ - public static Color operator +(Color l, Color r) - { - return new Color(l.R + r.R, l.G + r.G, l.B + r.B, l.A + r.A); - } - - /** - * @brief operator- - * - * @since 1.0.0 - * @param [in] l The Color to substract. - * @param [in] r The Color to substract - * @return A reference to this - */ - public static Color operator -(Color l, Color r) - { - return new Color(l.R - r.R, l.G - r.G, l.B - r.B, l.A - r.A); - } - - /** - * @brief operator* - * - * @since 1.0.0 - * @param [in] a The Color to multiply. - * @param [in] b The Color to multiply - * @return A reference to this - */ - public static Color operator *(Color a, double b) - { - return new Color((int)(a.R * b), (int)(a.G * b), (int)(a.B * b), (int)(a.A * b)); - } - - /** - * @brief operator/ - * - * @since 1.0.0 - * @param [in] a The Color to divide. - * @param [in] b The Color to divide - * @return float value of division operation - */ - public static float operator /(Color a, Color b) - { - return (float)System.Math.Sqrt((a.R / b.R) * (a.G / b.G) * (a.B / b.B) * (a.A / b.A)); - } - - /** - * @brief Equals - * - * @since 1.0.0 - * @param [in] o The Color object to compare. - * @param [in] r The Color to add - * @return bool, whether object equal or not - */ - public override bool Equals(object obj) - { - Color l = this; - Color r = obj as Color; - if (r == null) - { - return false; - } - return l.R == r.R && l.G == r.G && l.B == r.B && l.A == r.A; - } - - /** - * @brief GetHashCode - * - * @since 1.0.0 - * @return int, hascode of Color - */ - public override int GetHashCode() - { - return base.GetHashCode(); - } - - /** - * @brief Clone - * - * @since 1.0.0 - * @return Color object - */ - public Color Clone() - { - Color copy = new Color(R, G, B, A); - return copy; - } - } + /** + * @brief name "Magenta", type Color (Magenta Color object) + * @SINCE_1_0.0 + */ + public static Color Magenta + { + get + { + return new Color(Colors.Magenta); + } + } + /** + * @brief name "Cyan", type Color (Cyan Color object) + * @SINCE_1_0.0 + */ + public static Color Cyan + { + get + { + return new Color(Colors.Cyan); + } + } + } } diff --git a/plugins/dali-swig/manual/csharp/Position.cs b/plugins/dali-swig/manual/csharp/Position.cs index d56c414..2e58ab4 100644 --- a/plugins/dali-swig/manual/csharp/Position.cs +++ b/plugins/dali-swig/manual/csharp/Position.cs @@ -1,159 +1,188 @@ -namespace Dali { - -using System; - -public class Position : Vector3 - { - - /** - * @brief constructor - * - * @since 1.0.0 - */ - public Position() - : base() - { - } - - /** - * @brief constructor - * - * @since 1.0.0 - * @param [in] a The Position X. - * @param [in] b The Position Y. - * @param [in] c The Position Z. - */ - public Position(float a, float b, float c) - : base(a, b, c) - { - } - - /** - * @brief constructor - * - * @since 1.0.0 - * @param [in] o The Vector Position X, Y, Z. - */ - public Position(Vector3 o) - : base(o.x, o.y, o.z) - { - } - - ///< name "X", type float (Position X value) - //@since 1.0.0 - public float X - { - get { return width; } - set { width = value; } - } - - ///< name "Y", type float (Position Y value) - //@since 1.0.0 - public float Y - { - get { return height; } - set { height = value; } - } - - ///< name "Z", type float (Position Z value) - //@since 1.0.0 - public float Z - { - get { return depth; } - set { depth = value; } - } - - /** - * @brief operator+ - * - * @since 1.0.0 - * @param [in] l The Position to add. - * @param [in] r The Position to add - * @return A reference to this - */ - public static Position operator +(Position l, Position r) - { - return new Position(l.X + r.X, l.Y + r.Y, l.Z + r.Z); - } - - /** - * @brief operator- - * - * @since 1.0.0 - * @param [in] l The Position to substract. - * @param [in] r The Position to substract - * @return A reference to this - */ - public static Position operator -(Position l, Position r) - { - return new Position(l.X - r.X, l.Y - r.Y, l.Z - r.Z); - } - - /** - * @brief operator* - * - * @since 1.0.0 - * @param [in] a The Position to multiply. - * @param [in] b The Position to multiply - * @return A reference to this - */ - public static Position operator *(Position a, double b) - { - return new Position((int)(a.X * b), (int)(a.Y * b), (int)(a.Z * b)); - } - - /** - * @brief operator/ - * - * @since 1.0.0 - * @param [in] a The Position to divide. - * @param [in] b The Position to divide - * @return float value of division operation - */ - public static float operator /(Position a, Position b) - { - return (float)System.Math.Sqrt((a.X / b.X) * (a.Y / b.Y) * (a.Z / b.Z)); - } - - /** - * @brief Equals - * - * @since 1.0.0 - * @param [in] o The Position object to compare. - * @return bool, whether object equal or not - */ - public override bool Equals(object obj) - { - Position r = obj as Position; - if (r == null) - { - return false; - } - return this.X == r.X && this.Y == r.Y && this.Z == r.Z; - } - - /** - * @brief GetHashCode - * - * @since 1.0.0 - * @return int, hascode of position - */ - public override int GetHashCode() - { - return base.GetHashCode(); - } - - /** - * @brief Clone - * - * @since 1.0.0 - * @return Position object - */ - public Position Clone() - { - Position copy = new Position(X, Y, Z); - return copy; - } - } +namespace Dali +{ + using System; + public class Position + { + + private float x; + private float y; + private float z; + + /** + * @brief constructor + * + * @since 1.0.0 + */ + public Position() + { + x = 0.0f; + y = 0.0f; + z = 0.0f; + } + + /** + * @brief constructor + * + * @since 1.0.0 + * @param [in] a The Position X. + * @param [in] b The Position Y. + * @param [in] c The Position Z. + */ + public Position(float a, float b, float c) + { + x = a; + y = b; + z = c; + } + + /** + * @brief constructor + * + * @since 1.0.0 + * @param [in] o The Vector Position X, Y, Z. + */ + public Position(Vector3 o) + { + x = o.x; + y = o.y; + z = o.z; + } + + ///< name "X", type float (Position X value) + //@since 1.0.0 + public float X + { + get { return x; } + set { x = value; } + } + + ///< name "Y", type float (Position Y value) + //@since 1.0.0 + public float Y + { + get { return y; } + set { y = value; } + } + + ///< name "Z", type float (Position Z value) + //@since 1.0.0 + public float Z + { + get { return z; } + set { z = value; } + } + + /** + * @brief operator+ + * + * @since 1.0.0 + * @param [in] l The Position to add. + * @param [in] r The Position to add + * @return A reference to this + */ + public static Position operator +(Position l, Position r) + { + return new Position(l.X + r.X, l.Y + r.Y, l.Z + r.Z); + } + + /** + * @brief operator- + * + * @since 1.0.0 + * @param [in] l The Position to substract. + * @param [in] r The Position to substract + * @return A reference to this + */ + public static Position operator -(Position l, Position r) + { + return new Position(l.X - r.X, l.Y - r.Y, l.Z - r.Z); + } + + /** + * @brief operator* + * + * @since 1.0.0 + * @param [in] a The Position to multiply. + * @param [in] b The constant to multiply of type double. + * @return A reference to this + */ + public static Position operator *(Position a, double b) + { + return new Position((int)(a.X * b), (int)(a.Y * b), (int)(a.Z * b)); + } + + /** + * @brief operator/ + * + * @since 1.0.0 + * @param [in] a The Position to divide. + * @param [in] b The Position to divide + * @return float value of division operation + */ + public static float operator /(Position a, Position b) + { + return (float)System.Math.Sqrt((a.X / b.X) * (a.Y / b.Y) * (a.Z / b.Z)); + } + + /** + * @brief Operator == + * + * @since 1.0.0 + * @param [in] a The Position object to compare. + * @param [in] b The Position object to compare. + * @return bool, whether Position are equal or not + */ + public static bool operator == (Position a, Position b) + { + return a.X == b.X && a.Y == b.Y && a.Z == b.Z; + } + + /** + * @brief Operator != + * + * @since 1.0.0 + * @param [in] a The Position object to compare. + * @param [in] b The Position object to compare. + * @return bool, whether Position are equal or not + */ + public static bool operator != (Position a, Position b) + { + return a.X != b.X || a.Y != b.Y || a.Z == b.Z; + } + + /** + * @brief GetHashCode + * + * @since 1.0.0 + * @return int, hascode of position + */ + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /** + * @brief Clone + * + * @since 1.0.0 + * @return Position object + */ + public Position Clone() + { + Position copy = new Position(X, Y, Z); + return copy; + } + + // User-defined conversion from Position to Vector3 + public static implicit operator Vector3(Position pos) + { + return new Vector3(pos.x, pos.y, pos.z); + } + + public static implicit operator Position(Vector3 vec) + { + return new Position(vec.x, vec.y, vec.z); + } + } } diff --git a/plugins/dali-swig/manual/csharp/Size.cs b/plugins/dali-swig/manual/csharp/Size.cs index 07934ff..f89172a 100644 --- a/plugins/dali-swig/manual/csharp/Size.cs +++ b/plugins/dali-swig/manual/csharp/Size.cs @@ -1,160 +1,185 @@ -namespace Dali { - -using System; - -public class Size : Vector2 - { - - /** - * @brief constructor - * - * @since 1.0.0 - * @param [in] a Width value . - * @param [in] b Height value. - */ - public Size(float a, float b) - : base(a, b) - { - } - /** - * @brief default constructor - * - * @since 1.0.0 - */ - public Size() - : base() - { - } - - /** - * @brief constructor with base class object - * - * @since 1.0.0 - * @param [in] o The Vector2 with Width, Height values. - */ - public Size(Vector2 o) - : base(o.x, o.y) - { - - } - - /** - * @brief Copy constructor - * - * @since 1.0.0 - * @param [in] o The Size having Width & Y. - */ - public Size(Size a) - : base(a.width, a.height) - { - } - - ///< name "W", type float (Size Width value) - //@since 1.0.0 - public float W - { - get { return width; } - set { width = value; } - } - - ///< name "H", type float (Size Height value) - //@since 1.0.0 - public float H - { - get { return height; } - set { height = value; } - } - - /** - * @brief operator+ - * - * @since 1.0.0 - * @param [in] l The Size to add. - * @param [in] r The Size to add - * @return A reference to this - */ - public static Size operator +(Size l, Size r) - { - return new Size(l.W + r.W, l.H + r.H); - } - - /** - * @brief operator- - * - * @since 1.0.0 - * @param [in] l The Size to substract. - * @param [in] r The Size to substract - * @return A reference to this - */ - public static Size operator -(Size l, Size r) - { - return new Size(l.W - r.W, l.H - r.H); - } - - /** - * @brief operator* - * - * @since 1.0.0 - * @param [in] a The Size to multiply - * @param [in] b The Size to multiply - * @return A reference to this - */ - public static Size operator *(Size a, double b) - { - return new Size((int)(a.W * b), (int)(a.H * b)); - } - - /** - * @brief operator/ - * - * @since 1.0.0 - * @param [in] a The Size to divide. - * @param [in] b The Size to divide - * @return float of the size division - */ - public static float operator /(Size a, Size b) - { - return (float)System.Math.Sqrt((a.W / b.W) * (a.H / b.H)); - } - - /** - * @brief Equals - * - * @since 1.0.0 - * @param [in] obj The Size object to compare. - * @return bool, whether object equal or not - */ - public override bool Equals(object obj) - { - Size that = obj as Size; - if (that == null) - { - return false; - } - return this.W == that.W && this.H == that.H; - } - - /** - * @brief GetHashCode - * - * @since 1.0.0 - * @return int, hascode of Size - */ - public override int GetHashCode() - { - return (int)(W + H); - } - - /** - * @brief Clone - * - * @since 1.0.0 - * @return returns a copy of Size object - */ - public Size Clone() - { - Size copy = new Size(W, H); - return copy; - } - } +namespace Dali +{ + using System; + + public class Size + { + private float width; + private float height; + + /** + * @brief constructor + * + * @since 1.0.0 + * @param [in] a Width value . + * @param [in] b Height value. + */ + public Size(float a, float b) + { + width = a; + height = b; + } + /** + * @brief default constructor + * + * @since 1.0.0 + */ + public Size() + { + width = 0.0f; + height = 0.0f; + } + + /** + * @brief constructor with base class object + * + * @since 1.0.0 + * @param [in] o The Vector2 with Width, Height values. + */ + public Size(Vector2 o) + { + width = o.x; + height = o.y; + } + + /** + * @brief Copy constructor + * + * @since 1.0.0 + * @param [in] o The Size having Width & Y. + */ + public Size(Size a) + { + width = a.width; + height = a.height; + } + + ///< name "W", type float (Size Width value) + //@since 1.0.0 + public float W + { + get { return width; } + set { width = value; } + } + + ///< name "H", type float (Size Height value) + //@since 1.0.0 + public float H + { + get { return height; } + set { height = value; } + } + + /** + * @brief operator+ + * + * @since 1.0.0 + * @param [in] l The Size to add. + * @param [in] r The Size to add + * @return A reference to this + */ + public static Size operator +(Size l, Size r) + { + return new Size(l.W + r.W, l.H + r.H); + } + + /** + * @brief operator- + * + * @since 1.0.0 + * @param [in] l The Size to substract. + * @param [in] r The Size to substract + * @return A reference to this + */ + public static Size operator -(Size l, Size r) + { + return new Size(l.W - r.W, l.H - r.H); + } + + /** + * @brief operator* + * + * @since 1.0.0 + * @param [in] a The Size to multiply + * @param [in] b The constant to multiply of type double. + * @return A reference to this + */ + public static Size operator *(Size a, double b) + { + return new Size((float)(a.W * b), (float)(a.H * b)); + } + + /** + * @brief operator/ + * + * @since 1.0.0 + * @param [in] a The Size to divide. + * @param [in] b The Size to divide + * @return float of the size division + */ + public static float operator /(Size a, Size b) + { + return (float)System.Math.Sqrt((a.W / b.W) * (a.H / b.H)); + } + + /** + * @brief Operator == + * + * @since 1.0.0 + * @param [in] a The Size object to compare. + * @param [in] b The Size object to compare. + * @return bool, whether Size are equal or not + */ + public static bool operator == (Size a, Size b) + { + return a.W == b.W && a.H == b.H ; + } + + /** + * @brief Operator != + * + * @since 1.0.0 + * @param [in] a The Size object to compare. + * @param [in] b The Size object to compare. + * @return bool, whether Size are equal or not + */ + public static bool operator != (Size a, Size b) + { + return a.W != b.W || a.H != b.H; + } + + /** + * @brief GetHashCode + * + * @since 1.0.0 + * @return int, hascode of Size + */ + public override int GetHashCode() + { + return (int)(W + H); + } + + /** + * @brief Clone + * + * @since 1.0.0 + * @return returns a copy of Size object + */ + public Size Clone() + { + Size copy = new Size(W, H); + return copy; + } + + // User-defined conversion from Position to Vector3 + public static implicit operator Vector2(Size size) + { + return new Vector2(size.width, size.height); + } + + public static implicit operator Size(Vector2 vec) + { + return new Size(vec.x, vec.y); + } + } } -- 2.7.4