return instance.Style?.TextPadding;
});
+ private ImageView overlayImage;
+ private TextLabel buttonText;
+ private ImageView buttonIcon;
+
private EventHandler<StateChangedEventArgs> stateChangeHander;
private bool isSelected = false;
private bool isPressed = false;
/// <summary>
- /// Button's overlay image part.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected ImageView ButtonOverlayImage { get; set; }
-
- /// <summary>
- /// Button's text part.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected TextLabel ButtonText { get; set; }
-
- /// <summary>
- /// Button's icon part.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected ImageView ButtonIcon { get; set; }
-
- /// <summary>
/// The last touch information triggering selected state change.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
}
/// <summary>
- /// Style of the button.
+ /// Button's icon part.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageView ButtonIcon
+ {
+ get
+ {
+ if (null == buttonIcon)
+ {
+ buttonIcon = CreateIcon();
+ if (null != Extension)
+ {
+ buttonIcon = Extension.OnCreateIcon(this, buttonIcon);
+ }
+ Add(buttonIcon);
+ buttonIcon.Relayout += OnIconRelayout;
+ }
+ return buttonIcon;
+ }
+ internal set
+ {
+ buttonIcon = value;
+ }
+ }
+
+ /// <summary>
+ /// Button's overlay image part.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageView ButtonOverlay
+ {
+ get
+ {
+ if (null == overlayImage)
+ {
+ overlayImage = CreateOverlayImage();
+ if (null != Extension)
+ {
+ overlayImage = Extension.OnCreateOverlayImage(this, overlayImage);
+ }
+ overlayImage.WidthResizePolicy = ResizePolicyType.FillToParent;
+ overlayImage.HeightResizePolicy = ResizePolicyType.FillToParent;
+ Add(overlayImage);
+ }
+ return overlayImage;
+ }
+ internal set
+ {
+ overlayImage = value;
+ }
+ }
+
+ /// <summary>
+ /// Button's text part.
/// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TextLabel ButtonText
+ {
+ get
+ {
+ if (null == buttonText)
+ {
+ buttonText = CreateText();
+ if (null != Extension)
+ {
+ buttonText = Extension.OnCreateText(this, buttonText);
+ }
+ buttonText.HorizontalAlignment = HorizontalAlignment.Center;
+ buttonText.VerticalAlignment = VerticalAlignment.Center;
+ Add(buttonText);
+ }
+ return buttonText;
+ }
+ internal set
+ {
+ buttonText = value;
+ }
+ }
+
+ /// <summary>
+ /// Return a copied Style instance of Button
+ /// </summary>
+ /// <remarks>
+ /// It returns copied Style instance and changing it does not effect to the Button.
+ /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+ /// </remarks>
/// <since_tizen> 8 </since_tizen>
public new ButtonStyle Style => ViewStyle as ButtonStyle;
{
Utility.Dispose(ButtonText);
}
- if (ButtonOverlayImage != null)
+ if (ButtonOverlay != null)
{
- Utility.Dispose(ButtonOverlayImage);
+ Utility.Dispose(ButtonOverlay);
}
}
base.ApplyStyle(viewStyle);
ButtonStyle buttonStyle = viewStyle as ButtonStyle;
-
if (null != buttonStyle)
{
- ButtonOverlayImage?.ApplyStyle(buttonStyle.Overlay);
- ButtonText?.ApplyStyle(buttonStyle.Text);
- ButtonIcon?.ApplyStyle(buttonStyle.Icon);
+ Extension = buttonStyle.CreateExtension();
+ if (buttonStyle.Overlay != null)
+ {
+ ButtonOverlay?.ApplyStyle(buttonStyle.Overlay);
+ }
+
+ if (buttonStyle.Text != null)
+ {
+ ButtonText?.ApplyStyle(buttonStyle.Text);
+ }
+
+ if (buttonStyle.Icon != null)
+ {
+ ButtonIcon?.ApplyStyle(buttonStyle.Icon);
+ }
}
}
private void Initialize()
{
var style = (ButtonStyle)Style;
-
- Extension = style.CreateExtension();
-
- CreateComponents();
-
EnableControlStatePropagation = true;
-
- if (ButtonOverlayImage != null)
- {
- Add(ButtonOverlayImage);
- ButtonOverlayImage.ApplyStyle(style.Overlay);
- }
-
- if (ButtonIcon != null)
- {
- Add(ButtonIcon);
- ButtonIcon.ApplyStyle(style.Icon);
- ButtonIcon.Relayout += OnIconRelayout;
- }
-
- if (null != ButtonText)
- {
- Add(ButtonText);
- ButtonText.ApplyStyle(style.Text);
- }
-
UpdateState();
-
LayoutDirectionChanged += OnLayoutDirectionChanged;
}
- private void CreateComponents()
- {
- ButtonOverlayImage = CreateOverlayImage();
- ButtonIcon = CreateIcon();
- ButtonText = CreateText();
-
- if (Extension == null)
- {
- return;
- }
-
- // Update component with extension
- ButtonOverlayImage = Extension.OnCreateOverlayImage(this, ButtonOverlayImage);
- ButtonIcon = Extension.OnCreateIcon(this, ButtonIcon);
- ButtonText = Extension.OnCreateText(this, ButtonText);
- }
-
/// <summary>
/// Measure text, it can be override.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public ImageView GetCurrentOverlayImage(ButtonExtension extension)
{
- return (extension == Extension) ? ButtonOverlayImage : null;
+ return (extension == Extension) ? ButtonOverlay : null;
}
}
}
Right,
}
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// <summary>
+ /// Get or set header text.
+ /// </summary>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TextLabel HeaderText
+ {
+ get
+ {
+ if (null == headerText)
+ {
+ headerText = new TextLabel()
+ {
+ WidthResizePolicy = ResizePolicyType.UseNaturalSize,
+ HeightResizePolicy = ResizePolicyType.UseNaturalSize,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ ParentOrigin = NUI.ParentOrigin.Center,
+ PivotPoint = NUI.ParentOrigin.Center,
+ PositionUsesPivotPoint = true,
+ Name = "DropDownHeaderText"
+ };
+ Add(headerText);
+ }
+ return headerText;
+ }
+ internal set
+ {
+ headerText = value;
+ }
+ }
+
+ /// <summary>
+ /// Get or set button.
+ /// </summary>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
+ public Button Button
+ {
+ get
+ {
+ if (null == button)
+ {
+ button = new Button()
+ {
+ ParentOrigin = NUI.ParentOrigin.CenterLeft,
+ PivotPoint = NUI.PivotPoint.CenterLeft,
+ PositionUsesPivotPoint = true,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ IconRelativeOrientation = Button.IconOrientation.Right,
+ Name = "DropDownButton"
+ };
+ button.ClickEvent += ButtonClickEvent;
+ Add(button);
+
+ if (null == buttonText)
+ {
+ buttonText = new TextLabel();
+ }
+ }
+ return button;
+ }
+ internal set
+ {
+ button = value;
+ }
+ }
+
+ /// <summary>
+ /// Get or set the background image of list.
+ /// </summary>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageView ListBackgroundImage
+ {
+ get
+ {
+ if (null == listBackgroundImage)
+ {
+ listBackgroundImage = new ImageView()
+ {
+ Name = "ListBackgroundImage",
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
+ WidthResizePolicy = ResizePolicyType.FitToChildren,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ };
+ Add(listBackgroundImage);
+
+ if (null == scrollableBase) // scrollableBase used to test of ListContainer Setup invoked already
+ {
+ SetUpListContainer();
+ }
+ }
+ return listBackgroundImage;
+ }
+ internal set
+ {
+ listBackgroundImage = value;
+ }
+ }
+
+ /// <summary>
+ /// Return a copied Style instance of DropDown
+ /// </summary>
+ /// <remarks>
+ /// It returns copied Style instance and changing it does not effect to the DropDown.
+ /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+ /// </remarks>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ //public new DropDownStyle Style
+ //{
+ // get
+ // {
+ // return new DropDownStyle(ViewStyle as DropDownStyle);
+ // }
+ //}
public new DropDownStyle Style => ViewStyle as DropDownStyle;
/// <summary>
DropDownStyle dropDownStyle = viewStyle as DropDownStyle;
if (null != dropDownStyle)
{
- CreateHeaderText();
- CreateButtonText();
- CreateButton();
-
- CreateListBackgroundImage();
- if (null == scrollableBase) // scrollableBase used to test of ListContainer Setup invoked already
+ if (null != dropDownStyle.Button)
{
- SetUpListContainer();
+ Button.ApplyStyle(dropDownStyle.Button);
+ }
+ if (null != dropDownStyle.HeaderText)
+ {
+ HeaderText.ApplyStyle(dropDownStyle.HeaderText);
+ }
+ if (null != dropDownStyle.ListBackgroundImage)
+ {
+ ListBackgroundImage.ApplyStyle(dropDownStyle.ListBackgroundImage);
}
- button.ApplyStyle(dropDownStyle.Button);
- headerText.ApplyStyle(dropDownStyle.HeaderText);
- listBackgroundImage.ApplyStyle(dropDownStyle.ListBackgroundImage);
UpdateDropDown();
}
}
ItemClickEvent?.Invoke(sender, e);
}
- private void CreateHeaderText()
- {
- if (null == headerText)
- {
- headerText = new TextLabel()
- {
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.UseNaturalSize,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- ParentOrigin = NUI.ParentOrigin.Center,
- PivotPoint = NUI.ParentOrigin.Center,
- PositionUsesPivotPoint = true,
- };
- headerText.Name = "DropDownHeaderText";
- Add(headerText);
- }
- }
-
private void CreateButtonText()
{
if (null == buttonText)
}
}
- private void CreateListBackgroundImage()
- {
- if (null == listBackgroundImage)
- {
- listBackgroundImage = new ImageView
- {
- Name = "ListBackgroundImage",
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.FitToChildren,
- HeightResizePolicy = ResizePolicyType.FitToChildren,
- };
- Add(listBackgroundImage);
- }
- }
-
private void SetUpListContainer()
{
LinearLayout linear = new LinearLayout()
public new PopupStyle Style => ViewStyle as PopupStyle;
/// <summary>
+ /// Popup Title.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TextLabel Title
+ {
+ get
+ {
+ if (null == titleText)
+ {
+ titleText = new TextLabel();
+ Add(titleText);
+ }
+ return titleText;
+ }
+ internal set
+ {
+ titleText = value;
+ }
+ }
+
+ /// <summary>
/// Title text string in Popup.
/// </summary>
/// <since_tizen> 6 </since_tizen>
PopupStyle ppStyle = viewStyle as PopupStyle;
if (null != ppStyle)
{
- if (null == titleText)
- {
- titleText = new TextLabel();
- Add(titleText);
- }
- titleText.RaiseToTop();
- titleText.ApplyStyle(ppStyle.Title);
+ Title.ApplyStyle(ppStyle.Title);
+ Title.RaiseToTop();
}
}
Add(ContentView);
ContentView.RaiseToTop();
- // Title
- if (null == titleText)
- {
- titleText = new TextLabel();
- titleText.RaiseToTop();
- Add(titleText);
- }
-
// Button
btGroup = new ButtonGroup(this);
}
public new SliderStyle Style => ViewStyle as SliderStyle;
/// <summary>
+ /// Get or set low indicator text.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TextLabel LowIndicatorText
+ {
+ get
+ {
+ return CreateLowIndicatorText();
+ }
+ internal set
+ {
+ lowIndicatorText = value;
+ }
+ }
+
+ /// <summary>
+ /// Get or set high indicator text.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TextLabel HighIndicatorText
+ {
+ get
+ {
+ return CreateHighIndicatorText();
+ }
+ internal set
+ {
+ highIndicatorText = value;
+ }
+ }
+
+ /// <summary>
/// Gets or sets the direction type of slider.
/// </summary>
/// <since_tizen> 6 </since_tizen>
if (null != sliderStyle?.Progress)
{
- CreateSlidedTrack();
+ CreateSlidedTrack().ApplyStyle(sliderStyle.Progress);
}
if (null != sliderStyle?.LowIndicator)
{
- CreateLowIndicatorText();
+ CreateLowIndicatorText().ApplyStyle(sliderStyle.LowIndicator);
}
if (null != sliderStyle?.HighIndicator)
{
- CreateHighIndicatorText();
+ CreateHighIndicatorText().ApplyStyle(sliderStyle.HighIndicator);
}
if (null != sliderStyle?.Track)
{
- CreateBackgroundTrack();
+ CreateBackgroundTrack().ApplyStyle(sliderStyle.Track);
}
if (null != sliderStyle?.Thumb)
{
- CreateThumb();
+ CreateThumb().ApplyStyle(sliderStyle.Thumb);
}
EnableControlStatePropagation = true;
RelayoutRequest();
}
- private void CreateSlidedTrack()
+ private ImageView CreateSlidedTrack()
{
if (null == slidedTrackImage)
{
}
}
- if (null == Style.Progress)
- {
- Style.Progress = new ImageViewStyle();
- }
-
- slidedTrackImage.ApplyStyle(Style.Progress);
+ return slidedTrackImage;
}
- private void CreateLowIndicatorText()
+ private TextLabel CreateLowIndicatorText()
{
if (null == lowIndicatorText)
{
this.Add(lowIndicatorText);
}
- if (null == Style.LowIndicator)
- {
- Style.LowIndicator = new TextLabelStyle();
- }
-
- lowIndicatorText.ApplyStyle(Style.LowIndicator);
+ return lowIndicatorText;
}
- private void CreateHighIndicatorText()
+ private TextLabel CreateHighIndicatorText()
{
if (null == highIndicatorText)
{
this.Add(highIndicatorText);
}
- if (null == Style.HighIndicator)
- {
- Style.HighIndicator = new TextLabelStyle();
- }
-
- highIndicatorText.ApplyStyle(Style.HighIndicator);
+ return highIndicatorText;
}
- private void CreateBackgroundTrack()
+ private ImageView CreateBackgroundTrack()
{
if (null == bgTrackImage)
{
bgTrackImage.TouchEvent += OnTouchEventForBgTrack;
}
- if (null == Style.Track)
- {
- Style.Track = new ImageViewStyle();
- }
-
- bgTrackImage.ApplyStyle(Style.Track);
+ return bgTrackImage;
}
- private void CreateThumb()
+ private ImageView CreateThumb()
{
if (null == thumbImage)
{
panGestureDetector.Detected += OnPanGestureDetected;
}
- if (null == Style.Thumb)
- {
- Style.Thumb= new ImageViewStyle();
- }
-
- thumbImage.ApplyStyle(Style.Thumb);
+ return thumbImage;
}
private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
/// <since_tizen> 6 </since_tizen>
public class Switch : Button
{
+ private ImageView track = null;
+ private ImageView thumb = null;
+
static Switch() { }
/// <summary>
public new SwitchStyle Style => ViewStyle as SwitchStyle;
/// <summary>
- /// Background image's resource url in Switch.
+ /// Apply style to switch.
+ /// </summary>
+ /// <param name="viewStyle">The style to apply.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle viewStyle)
+ {
+ base.ApplyStyle(viewStyle);
+
+ SwitchStyle swStyle = viewStyle as SwitchStyle;
+
+ if (null != swStyle)
+ {
+ if (swStyle.Track != null)
+ {
+ Track.ApplyStyle(swStyle.Track);
+ }
+
+ if (swStyle.Thumb != null)
+ {
+ Thumb.ApplyStyle(swStyle.Thumb);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Switch's track part.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageView Track
+ {
+ get
+ {
+ if (track == null)
+ {
+ track = new ImageView()
+ {
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ HeightResizePolicy = ResizePolicyType.FillToParent
+ };
+
+ var extension = (SwitchExtension)Extension;
+ if (extension != null)
+ {
+ track = extension.OnCreateTrack(this, track);
+ }
+ Add(track);
+ }
+ return track;
+ }
+ internal set
+ {
+ track = value;
+ }
+ }
+
+ /// <summary>
+ /// Switch's thumb part.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageView Thumb
+ {
+ get
+ {
+ if (thumb == null)
+ {
+ thumb = new ImageView()
+ {
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
+ WidthResizePolicy = ResizePolicyType.Fixed,
+ HeightResizePolicy = ResizePolicyType.Fixed
+ };
+
+ var extension = (SwitchExtension)Extension;
+ if (extension != null)
+ {
+ thumb = extension.OnCreateThumb(this, thumb);
+ }
+ Add(thumb);
+ }
+ return thumb;
+ }
+ internal set
+ {
+ thumb = value;
+ }
+ }
+
+ /// <summary>
+ /// Switch's track part.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
}
/// <summary>
- /// Switch's track part.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected ImageView Track { get; set; }
-
- /// <summary>
- /// Switch's thumb part.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected ImageView Thumb { get; set; }
-
- /// <summary>
- /// Creates Switch's track part.
- /// </summary>
- /// <return>The created Button's icon part.</return>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual ImageView CreateTrack()
- {
- return new ImageView();
- }
-
- /// <summary>
- /// Creates Switch's overlay thumb part.
- /// </summary>
- /// <return>The created Button's overlay image part.</return>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected virtual ImageView CreateThumb()
- {
- return new ImageView();
- }
-
- /// <summary>
/// Dispose Switch and all children on it.
/// </summary>
/// <param name="type">Dispose type.</param>
private void Initialize()
{
Style.IsSelectable = true;
-
- CreateComponents();
-
- if (null != Track)
- {
- Add(Track);
- Track.ApplyStyle(Style.Track);
- }
-
- if (null != Thumb)
- {
- Add(Thumb);
- Thumb.ApplyStyle(Style.Thumb);
- }
- }
-
- private void CreateComponents()
- {
- Track = CreateTrack();
- Thumb = CreateThumb();
-
- if (Extension as SwitchExtension == null)
- {
- return;
- }
-
- // Update component with extension
- var extension = (SwitchExtension)Extension;
- Track = extension.OnCreateTrack(this, Track);
- Thumb = extension.OnCreateThumb(this, Thumb);
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public new TabStyle Style => ViewStyle as TabStyle;
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public View Underline
+ {
+ get
+ {
+ if (null == underline)
+ {
+ underline = new View()
+ {
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
+ };
+ Add(underline);
+ }
+ return underline;
+ }
+ internal set
+ {
+ underline = value;
+ }
+ }
+
/// <summary>
/// Selected item's index in Tab.
/// </summary>
if (null != tabStyle)
{
- if (null == underline)
- {
- underline = new View()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
- PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
- };
- Add(underline);
- CreateUnderLineAnimation();
- }
-
- underline.ApplyStyle(Style.UnderLine);
+ Underline.ApplyStyle(tabStyle.UnderLine);
+ CreateUnderLineAnimation();
}
}