[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_TextLabel_Property_TEXT_FIT_get")]
public static extern int TextFitGet();
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_TextFitChangedSignal")]
+ public static extern global::System.IntPtr TextFitChangedSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_TextLabel_Property_MIN_LINE_SIZE_get")]
public static extern int MinLineSizeGet();
selectorData?.Reset(this);
}
+ if (this.HasBody())
+ {
+ if (textLabelTextFitChangedCallbackDelegate != null)
+ {
+ TextFitChangedSignal().Disconnect(textLabelTextFitChangedCallbackDelegate);
+ }
+ }
+
base.Dispose(type);
}
/// <since_tizen> 3 </since_tizen>
public partial class TextLabel
{
+
private EventHandler<AnchorClickedEventArgs> textLabelAnchorClickedEventHandler;
private AnchorClickedCallbackDelegate textLabelAnchorClickedCallbackDelegate;
+ private EventHandler textLabelTextFitChangedEventHandler;
+ private TextFitChangedCallbackDelegate textLabelTextFitChangedCallbackDelegate;
+
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void AnchorClickedCallbackDelegate(IntPtr textLabel, IntPtr href, uint hrefLength);
+ [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+ private delegate void TextFitChangedCallbackDelegate(IntPtr textLabel);
+
/// <summary>
/// The AnchorClicked signal is emitted when the anchor is clicked.
/// </summary>
//here we send all data to user event handlers
textLabelAnchorClickedEventHandler?.Invoke(this, e);
}
+
+ /// <summary>
+ /// An event for the TextFitChanged signal which can be used to subscribe or unsubscribe the event handler
+ /// provided by the user. The TextFitChanged signal is emitted when the text fit properties changes.<br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler TextFitChanged
+ {
+ add
+ {
+ if (textLabelTextFitChangedEventHandler == null)
+ {
+ textLabelTextFitChangedCallbackDelegate = (OnTextFitChanged);
+ TextFitChangedSignal().Connect(textLabelTextFitChangedCallbackDelegate);
+ }
+ textLabelTextFitChangedEventHandler += value;
+ }
+ remove
+ {
+ textLabelTextFitChangedEventHandler -= value;
+ if (textLabelTextFitChangedEventHandler == null && TextFitChangedSignal().Empty() == false)
+ {
+ TextFitChangedSignal().Disconnect(textLabelTextFitChangedCallbackDelegate);
+ }
+ }
+ }
+
+ internal TextLabelSignal TextFitChangedSignal()
+ {
+ TextLabelSignal ret = new TextLabelSignal(Interop.TextLabel.TextFitChangedSignal(SwigCPtr), false);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ return ret;
+ }
+
+ private void OnTextFitChanged(IntPtr textLabel)
+ {
+ // no data to be sent to the user, as in NUI there is no event provide old values.
+ textLabelTextFitChangedEventHandler?.Invoke(this, EventArgs.Empty);
+ }
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static TextFit GetTextFitStruct(PropertyMap map)
{
- map.Find(0, "enable").Get(out bool enable);
- map.Find(0, "minSize").Get(out float minSize);
- map.Find(0, "maxSize").Get(out float maxSize);
- map.Find(0, "stepSize").Get(out float stepSize);
- map.Find(0, "fontSizeType").Get(out string fontSizeType);
+ bool enable = false;
+ float minSize = 0.0f;
+ float maxSize = 0.0f;
+ float stepSize = 0.0f;
+ float fontSize = 0.0f;
+ string fontSizeType = null;
+ map.Find(0, "enable")?.Get(out enable);
+ map.Find(0, "minSize")?.Get(out minSize);
+ map.Find(0, "maxSize")?.Get(out maxSize);
+ map.Find(0, "stepSize")?.Get(out stepSize);
+ map.Find(0, "fontSize")?.Get(out fontSize);
+ map.Find(0, "fontSizeType")?.Get(out fontSizeType);
var textFit = new TextFit();
textFit.Enable = enable;
textFit.MinSize = minSize;
textFit.MaxSize = maxSize;
textFit.StepSize = stepSize;
+ textFit.FontSize = fontSize;
textFit.FontSizeType = GetFontSizeType(fontSizeType);
return textFit;
else if (placeholder.PixelSize != null)
map.Add("pixelSize", new PropertyValue((float)placeholder.PixelSize));
-
+
map.Add("ellipsis", new PropertyValue(placeholder.Ellipsis));
return map;
/// <summary>
/// The offset in pixels of the shadow (if null, the default value is 0, 0). <br />
/// If not provided then the shadow is not enabled. <br />
- ///
+ ///
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector2 Offset { get; set; }
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public FontSizeType FontSizeType { get; set; }
+
+ /// <summary>
+ /// Font Size for text fit
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float? FontSize { get; set; }
}
/// <summary>
--- /dev/null
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using Tizen.NUI.Text;
+
+namespace Tizen.NUI.Samples
+{
+ public class TextFitChangedSample : IExample
+ {
+ private TextLabel label;
+
+ public void Activate()
+ {
+ Window window = NUIApplication.GetDefaultWindow();
+ var fit = new TextFit();
+ fit.Enable = true;
+ fit.MinSize = 5.0f;
+ fit.MaxSize = 50.0f;
+
+ label = new TextLabel()
+ {
+ Text = "ABCDE",
+ Size = new Size(300, 100),
+ PointSize = 10,
+ Position = new Position(100, 100),
+ BackgroundColor = Color.Yellow,
+ };
+ label.SetTextFit(fit);
+
+ window.Add(label);
+
+ label.TextFitChanged +=(s, e) =>
+ {
+ TextFit textfit = label.GetTextFit();
+ Tizen.Log.Error("NUI", $"FontSize : {textfit.FontSize}\n");
+ };
+ }
+
+ public void Deactivate()
+ {
+ }
+ }
+}