NUILog.Debug("[2]_view SizeWidth=" + _view.SizeWidth);
TextLabelLineWrapModeTest();
+ ViewLayoutDirectionTest();
+ }
+
+
+ private View view1, view11, view12, view111, view121;
+ public void ViewLayoutDirectionTest()
+ {
+ view1 = new View();
+ view1.Name = "view 1";
+ view1.LayoutDirection = ViewLayoutDirectionType.RTL;
+ Window.Instance.GetDefaultLayer().Add(view1);
+ view1.LayoutDirectionChanged += View1_LayoutDirectionChanged;
+
+ view11 = new View();
+ view11.Name = "view 11";
+ view11.InheritLayoutDirection = true;
+ view1.Add(view11);
+
+ view12 = new View();
+ view12.Name = "view 12";
+ view12.LayoutDirection = ViewLayoutDirectionType.LTR;
+ view1.Add(view12);
+
+ view111 = new View();
+ view111.Name = "view 111";
+ view111.InheritLayoutDirection = true;
+ view11.Add(view111);
+
+ view121 = new View();
+ view121.Name = "view 121";
+ view121.InheritLayoutDirection = true;
+ view12.Add(view121);
+ }
+
+ private void View1_LayoutDirectionChanged(object sender, View.LayoutDirectionChangedEventArgs e)
+ {
+ NUILog.Error("View1_LayoutDirectionChanged()! e.Type=" + e.Type);
}
public void AnimationFinished(object sender, EventArgs e)
_animation.Finished += AnimationFinished;
cnt++;
NUILog.Debug("AnimationFinished added!");
+ view1.LayoutDirection = ViewLayoutDirectionType.LTR;
+ NUILog.Error("change view1's layout direction as LTR!");
}
pointLabel.TextColorAnimatable = Color.Blue;
pixelLabel.TextColorAnimatable = Color.Blue;
_animation.Finished -= AnimationFinished;
cnt--;
NUILog.Debug("AnimationFinished removed!");
+ view1.LayoutDirection = ViewLayoutDirectionType.RTL;
+ NUILog.Error("change view1's layout direction as RTL!");
}
pointLabel.TextColorAnimatable = Color.Red;
pixelLabel.TextColorAnimatable = Color.Red;
{
_animation.Play();
NUILog.Debug("_animation play here!");
+ NUILog.Error(view1.Name + " = " + view1.LayoutDirection + "(changed by up/down key)");
+ NUILog.Error(view11.Name + " = " + view11.LayoutDirection + "(should same as view 1)");
+ NUILog.Error(view12.Name + " = " + view12.LayoutDirection + "(should be LTR)");
+ NUILog.Error(view111.Name + " = " + view111.LayoutDirection + "(should same as view 11)");
+ NUILog.Error(view121.Name + " = " + view121.LayoutDirection + "(should same as view 12)");
}
}
}
[global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_WidgetData_SWIGUpcast")]
public static extern global::System.IntPtr WidgetData_SWIGUpcast(global::System.IntPtr jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Actor_Property_INHERIT_LAYOUT_DIRECTION_get")]
+ public static extern int Actor_Property_INHERIT_LAYOUT_DIRECTION_get();
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Actor_Property_LAYOUT_DIRECTION_get")]
+ public static extern int Actor_Property_LAYOUT_DIRECTION_get();
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_LayoutDirectionChangedSignal")]
+ public static extern global::System.IntPtr LayoutDirectionChangedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ViewLayoutDirectionChangedSignal_Empty")]
+ public static extern bool ViewLayoutDirectionChangedSignal_Empty(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ViewLayoutDirectionSignal_GetConnectionCount")]
+ public static extern uint ViewLayoutDirectionChangedSignal_GetConnectionCount(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ViewLayoutDirectionSignal_Connect")]
+ public static extern void ViewLayoutDirectionChangedSignal_Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ViewLayoutDirectionSignal_Disconnect")]
+ public static extern void ViewLayoutDirectionChangedSignal_Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ViewLayoutDirectionSignal_Emit")]
+ public static extern void ViewLayoutDirectionChangedSignal_Emit(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_new_ViewLayoutDirectionSignal")]
+ public static extern global::System.IntPtr new_ViewLayoutDirectionChangedSignal();
+
+ [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_delete_ViewLayoutDirectionSignal")]
+ public static extern void delete_ViewLayoutDirectionChangedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
}
}
--- /dev/null
+/** 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.
+*
+*/
+
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI
+{
+
+ internal class ViewLayoutDirectionChangedSignal : global::System.IDisposable
+ {
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ protected bool swigCMemOwn;
+
+ internal ViewLayoutDirectionChangedSignal(global::System.IntPtr cPtr, bool cMemoryOwn)
+ {
+ swigCMemOwn = cMemoryOwn;
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+ }
+
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ViewLayoutDirectionChangedSignal obj)
+ {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+ }
+
+ //A Flag to check who called Dispose(). (By User or DisposeQueue)
+ private bool isDisposeQueued = false;
+ //A Flat to check if it is already disposed.
+ protected bool disposed = false;
+
+ ~ViewLayoutDirectionChangedSignal()
+ {
+ if (!isDisposeQueued)
+ {
+ isDisposeQueued = true;
+ DisposeQueue.Instance.Add(this);
+ }
+ }
+
+ public void Dispose()
+ {
+ //Throw excpetion if Dispose() is called in separate thread.
+ if (!Window.IsInstalled())
+ {
+ throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
+ }
+
+ if (isDisposeQueued)
+ {
+ Dispose(DisposeTypes.Implicit);
+ }
+ else
+ {
+ Dispose(DisposeTypes.Explicit);
+ System.GC.SuppressFinalize(this);
+ }
+ }
+
+ protected virtual void Dispose(DisposeTypes type)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ if (type == DisposeTypes.Explicit)
+ {
+ //Called by User
+ //Release your own managed resources here.
+ //You should release all of your own disposable objects here.
+ }
+
+ //Release your own unmanaged resources here.
+ //You should not access any managed member here except static instance.
+ //because the execution order of Finalizes is non-deterministic.
+
+ if (swigCPtr.Handle != global::System.IntPtr.Zero)
+ {
+ if (swigCMemOwn)
+ {
+ swigCMemOwn = false;
+ NDalicManualPINVOKE.delete_ViewLayoutDirectionChangedSignal(swigCPtr);
+ }
+ swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+ }
+
+ disposed = true;
+ }
+
+ public bool Empty()
+ {
+ bool ret = NDalicManualPINVOKE.ViewLayoutDirectionChangedSignal_Empty(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ public uint GetConnectionCount()
+ {
+ uint ret = NDalicManualPINVOKE.ViewLayoutDirectionChangedSignal_GetConnectionCount(swigCPtr);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ public void Connect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+ {
+ NDalicManualPINVOKE.ViewLayoutDirectionChangedSignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+
+ public void Disconnect(System.Delegate func)
+ {
+ System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func);
+ {
+ NDalicManualPINVOKE.ViewLayoutDirectionChangedSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+ }
+
+ public void Emit(View arg)
+ {
+ NDalicManualPINVOKE.ViewLayoutDirectionChangedSignal_Emit(swigCPtr, View.getCPtr(arg));
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ public ViewLayoutDirectionChangedSignal() : this(NDalicManualPINVOKE.new_ViewLayoutDirectionChangedSignal(), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ }
+}
\ No newline at end of file
}
}
+
+ /// <summary>
+ /// Event arguments of layout direction changed.
+ /// </summary>
+ public class LayoutDirectionChangedEventArgs : EventArgs
+ {
+ private View _view;
+ private ViewLayoutDirectionType _type;
+
+ /// <summary>
+ /// The view, or child of view, whose layout direction has changed.
+ /// </summary>
+ public View View
+ {
+ get
+ {
+ return _view;
+ }
+ set
+ {
+ _view = value;
+ }
+ }
+
+ /// <summary>
+ /// Whether the view's layout direction property has changed or a parent's.
+ /// </summary>
+ public ViewLayoutDirectionType Type
+ {
+ get
+ {
+ return _type;
+ }
+ set
+ {
+ _type = value;
+ }
+ }
+ }
+
+ private EventHandler<LayoutDirectionChangedEventArgs> _layoutDirectionChangedEventHandler;
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
+ private LayoutDirectionChangedEventCallbackType _layoutDirectionChangedEventCallback;
+
+ /// <summary>
+ /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br>
+ /// This signal is emitted when the layout direction property of this or a parent view is changed.<br>
+ /// </summary>
+ public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
+ {
+ add
+ {
+ if (_layoutDirectionChangedEventHandler == null)
+ {
+ _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
+ LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
+ }
+
+ _layoutDirectionChangedEventHandler += value;
+ }
+
+ remove
+ {
+ _layoutDirectionChangedEventHandler -= value;
+
+ if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
+ {
+ LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
+ }
+ }
+ }
+
+ // Callback for View layout direction change signal
+ private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
+ {
+ LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
+ if (data != null)
+ {
+ e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
+ }
+ e.Type = type;
+
+ if (_layoutDirectionChangedEventHandler != null)
+ {
+ _layoutDirectionChangedEventHandler(this, e);
+ }
+ }
+
+
+
+
+
+
+
// Resource Ready Signal
private EventHandler _resourcesLoadedEventHandler;
internal static readonly int MAXIMUM_SIZE = NDalicPINVOKE.Actor_Property_MAXIMUM_SIZE_get();
internal static readonly int INHERIT_POSITION = NDalicPINVOKE.Actor_Property_INHERIT_POSITION_get();
internal static readonly int CLIPPING_MODE = NDalicPINVOKE.Actor_Property_CLIPPING_MODE_get();
+ internal static readonly int INHERIT_LAYOUT_DIRECTION = NDalicManualPINVOKE.Actor_Property_INHERIT_LAYOUT_DIRECTION_get();
+ internal static readonly int LAYOUT_DIRECTION = NDalicManualPINVOKE.Actor_Property_LAYOUT_DIRECTION_get();
}
/// <summary>
return ret;
}
+
+ internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view) {
+ ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(NDalicManualPINVOKE.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+
internal ViewSignal ResourcesLoadedSignal()
{
ViewSignal ret = new ViewSignal(NDalicPINVOKE.ResourceReadySignal(swigCPtr), false);
}
}
+ public bool InheritLayoutDirection
+ {
+ get
+ {
+ bool temp = false;
+ GetProperty(View.Property.INHERIT_LAYOUT_DIRECTION).Get(out temp);
+ return temp;
+ }
+ set
+ {
+ SetProperty(View.Property.INHERIT_LAYOUT_DIRECTION, new Tizen.NUI.PropertyValue(value));
+ }
+ }
+ public ViewLayoutDirectionType LayoutDirection
+ {
+ get
+ {
+ string temp;
+ if (GetProperty(View.Property.LAYOUT_DIRECTION).Get(out temp) == false)
+ {
+ NUILog.Error("LAYOUT_DIRECTION get error!");
+ }
+ switch (temp)
+ {
+ case "LTR":
+ return ViewLayoutDirectionType.LTR;
+ case "RTL":
+ return ViewLayoutDirectionType.RTL;
+ default:
+ return ViewLayoutDirectionType.LTR;
+ }
+ }
+ set
+ {
+ string valueToString = "";
+ switch (value)
+ {
+ case ViewLayoutDirectionType.LTR:
+ {
+ valueToString = "LTR";
+ break;
+ }
+ case ViewLayoutDirectionType.RTL:
+ {
+ valueToString = "RTL";
+ break;
+ }
+ default:
+ {
+ valueToString = "LTR";
+ break;
+ }
+ }
+ SetProperty(View.Property.LAYOUT_DIRECTION, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ }
+ }
-
-
+ public enum ViewLayoutDirectionType
+ {
+ LTR,
+ RTL
}
}