/*
* Copyright(c) 2019 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 System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
namespace Tizen.NUI.UIComponents
{
///
/// The Button class is a base class for different kinds of buttons.
/// This class provides the disabled property and the clicked signal.
/// The clicked event handler is emitted when the button is touched, and the touch point doesn't leave the boundary of the button.
/// When the disabled property is set to true, no signal is emitted.
/// The 'Visual' describes not just traditional images like PNG and BMP, but also refers to whatever is used to show the button. It could be a color, gradient, or some other kind of renderer.
/// The button's appearance can be modified by setting properties for the various visuals or images.
/// It is not mandatory to set all the visuals. A button could be defined only by setting its background visual, or by setting its background and selected visuals.
/// The button visual is shown over the background visual.
/// When pressed, the unselected visuals are replaced by the selected visuals.
/// The text label is always placed on the top of all images.
/// When the button is disabled, the background button and the selected visuals are replaced by their disabled visuals.
///
/// 3
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public class Button : View
{
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty UnselectedVisualProperty = BindableProperty.Create("UnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty SelectedVisualProperty = BindableProperty.Create("SelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty DisabledSelectedVisualProperty = BindableProperty.Create("DisabledSelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty DisabledUnselectedVisualProperty = BindableProperty.Create("DisabledUnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty UnselectedBackgroundVisualProperty = BindableProperty.Create("UnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty SelectedBackgroundVisualProperty = BindableProperty.Create("SelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
public static readonly BindableProperty DisabledUnselectedBackgroundVisualProperty = BindableProperty.Create("DisabledUnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty DisabledSelectedBackgroundVisualProperty = BindableProperty.Create("DisabledSelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty LabelRelativeAlignmentProperty = BindableProperty.Create("LabelRelativeAlignment", typeof(Align), typeof(Button), Align.End, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
string valueToString = "";
if (newValue != null)
{
switch ((Align)newValue)
{
case Align.Begin: { valueToString = "BEGIN"; break; }
case Align.End: { valueToString = "END"; break; }
case Align.Top: { valueToString = "TOP"; break; }
case Align.Bottom: { valueToString = "BOTTOM"; break; }
default: { valueToString = "END"; break; }
}
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
string temp;
if (Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT).Get(out temp) == false)
{
NUILog.Error("LabelRelativeAlignment get error!");
}
switch (temp)
{
case "BEGIN": return Align.Begin;
case "END": return Align.End;
case "TOP": return Align.Top;
case "BOTTOM": return Align.Bottom;
default: return Align.End;
}
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty LabelPaddingProperty = BindableProperty.Create("LabelPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_PADDING).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ForegroundVisualPaddingProperty = BindableProperty.Create("ForegroundVisualPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty AutoRepeatingProperty = BindableProperty.Create("AutoRepeating", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING, new Tizen.NUI.PropertyValue((bool)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
bool temp = false;
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING).Get(out temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty InitialAutoRepeatingDelayProperty = BindableProperty.Create("InitialAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
float temp = 0.0f;
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY).Get(out temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty NextAutoRepeatingDelayProperty = BindableProperty.Create("NextAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
float temp = 0.0f;
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY).Get(out temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty TogglableProperty = BindableProperty.Create("Togglable", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.TOGGLABLE, new Tizen.NUI.PropertyValue((bool)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
bool temp = false;
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.TOGGLABLE).Get(out temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty SelectedProperty = BindableProperty.Create("Selected", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED, new Tizen.NUI.PropertyValue((bool)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
bool temp = false;
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED).Get(out temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty UnselectedColorProperty = BindableProperty.Create("UnselectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
PropertyMap background = new PropertyMap();
background.Add( Visual.Property.Type, new PropertyValue((int)Visual.Type.Color) )
.Add( ColorVisualProperty.MixColor, new PropertyValue((Color)newValue) );
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(background));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL).Get(map);
Tizen.NUI.PropertyValue value = map.Find( Visual.Property.MixColor);
value?.Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty SelectedColorProperty = BindableProperty.Create("SelectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
PropertyMap background = new PropertyMap();
background.Add( Visual.Property.Type, new PropertyValue((int)Visual.Type.Color) )
.Add( ColorVisualProperty.MixColor, new PropertyValue((Color)newValue) );
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(background));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL).Get(map);
Tizen.NUI.PropertyValue value = map.Find( Visual.Property.MixColor);
value?.Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty LabelProperty = BindableProperty.Create("Label", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(temp);
return temp;
});
/// This will be deprecated
[Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty LabelTextProperty = BindableProperty.Create("LabelText", typeof(string), typeof(Button), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
var button = (Button)bindable;
if (newValue != null)
{
Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((string)newValue));
}
},
defaultValueCreator:(bindable) =>
{
var button = (Button)bindable;
Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(map);
Tizen.NUI.PropertyValue value = map.Find( TextVisualProperty.Text, "Text");
string str = "";
value?.Get(out str);
return str;
});
private EventHandlerWithReturnType