|
|
@@ -5,7 +5,9 @@ using BansheeEngine;
|
|
|
namespace BansheeEditor
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// Editor GUI element that displays a list box with user-specified elements and an optional label.
|
|
|
+ /// Editor GUI element that displays a list box with user-specified elements and an optional label. List box can be
|
|
|
+ /// a standard list-box that allows a single element to be selected, or a multi-select list box where any number of
|
|
|
+ /// elements can be selected at the same time.
|
|
|
/// </summary>
|
|
|
public sealed class GUIListBoxField : GUIElement
|
|
|
{
|
|
|
@@ -26,11 +28,22 @@ namespace BansheeEditor
|
|
|
set { Internal_SetValue(mCachedPtr, value); }
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// States of all element in the list box (enabled or disabled).
|
|
|
+ /// </summary>
|
|
|
+ public bool[] States
|
|
|
+ {
|
|
|
+ get { return Internal_GetElementStates(mCachedPtr); }
|
|
|
+ set { Internal_SetElementStates(mCachedPtr, value); }
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Creates a new list box with the specified elements and a label.
|
|
|
/// </summary>
|
|
|
/// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
/// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
/// <param name="title">Content to display on the label.</param>
|
|
|
/// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
/// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
|
|
|
@@ -38,10 +51,10 @@ namespace BansheeEditor
|
|
|
/// default element style is used.</param>
|
|
|
/// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
/// override any similar options set by style.</param>
|
|
|
- public GUIListBoxField(LocString[] elements, GUIContent title, int titleWidth = 100, string style = "",
|
|
|
+ public GUIListBoxField(LocString[] elements, bool multiselect, GUIContent title, int titleWidth, string style = "",
|
|
|
params GUIOption[] options)
|
|
|
{
|
|
|
- Internal_CreateInstance(this, elements, title, titleWidth, style, options, true);
|
|
|
+ Internal_CreateInstance(this, elements, multiselect, title, titleWidth, style, options, true);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -49,13 +62,47 @@ namespace BansheeEditor
|
|
|
/// </summary>
|
|
|
/// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
/// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
+ /// <param name="title">Content to display on the label.</param>
|
|
|
+ /// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(LocString[] elements, bool multiselect, GUIContent title, int titleWidth = 100, params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, elements, multiselect, title, titleWidth, "", options, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new single-selection list box with the specified elements and a label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ /// <param name="title">Content to display on the label.</param>
|
|
|
+ /// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
+ /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
|
|
|
+ /// default layout options. Style will be retrieved from the active GUISkin. If not specified
|
|
|
+ /// default element style is used.</param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(LocString[] elements, GUIContent title, int titleWidth, string style = "",
|
|
|
+ params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, elements, false, title, titleWidth, style, options, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new single-selection list box with the specified elements and a label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
/// <param name="title">Content to display on the label.</param>
|
|
|
/// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
/// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
/// override any similar options set by style.</param>
|
|
|
public GUIListBoxField(LocString[] elements, GUIContent title, int titleWidth = 100, params GUIOption[] options)
|
|
|
{
|
|
|
- Internal_CreateInstance(this, elements, title, titleWidth, "", options, true);
|
|
|
+ Internal_CreateInstance(this, elements, false, title, titleWidth, "", options, true);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -63,14 +110,16 @@ namespace BansheeEditor
|
|
|
/// </summary>
|
|
|
/// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
/// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
/// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
|
|
|
/// default layout options. Style will be retrieved from the active GUISkin. If not specified
|
|
|
/// default element style is used.</param>
|
|
|
/// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
/// override any similar options set by style.</param>
|
|
|
- public GUIListBoxField(LocString[] elements, string style = "", params GUIOption[] options)
|
|
|
+ public GUIListBoxField(LocString[] elements, bool multiselect = false, string style = "", params GUIOption[] options)
|
|
|
{
|
|
|
- Internal_CreateInstance(this, elements, null, 0, style, options, false);
|
|
|
+ Internal_CreateInstance(this, elements, multiselect, null, 0, style, options, false);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -78,11 +127,112 @@ namespace BansheeEditor
|
|
|
/// </summary>
|
|
|
/// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
/// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
/// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
/// override any similar options set by style.</param>
|
|
|
- public GUIListBoxField(LocString[] elements, params GUIOption[] options)
|
|
|
+ public GUIListBoxField(LocString[] elements, bool multiselect = false, params GUIOption[] options)
|
|
|
{
|
|
|
- Internal_CreateInstance(this, elements, null, 0, "", options, false);
|
|
|
+ Internal_CreateInstance(this, elements, multiselect, null, 0, "", options, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new list box with the specified elements and a label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
+ /// <param name="title">Content to display on the label.</param>
|
|
|
+ /// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
+ /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
|
|
|
+ /// default layout options. Style will be retrieved from the active GUISkin. If not specified
|
|
|
+ /// default element style is used.</param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(string[] elements, bool multiselect, GUIContent title, int titleWidth, string style = "",
|
|
|
+ params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, ToLocalizedElements(elements), multiselect, title, titleWidth, style, options, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new list box with the specified elements and a label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
+ /// <param name="title">Content to display on the label.</param>
|
|
|
+ /// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(string[] elements, bool multiselect, GUIContent title, int titleWidth = 100, params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, ToLocalizedElements(elements), multiselect, title, titleWidth, "", options, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new single-selection list box with the specified elements and a label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ /// <param name="title">Content to display on the label.</param>
|
|
|
+ /// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
+ /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
|
|
|
+ /// default layout options. Style will be retrieved from the active GUISkin. If not specified
|
|
|
+ /// default element style is used.</param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(string[] elements, GUIContent title, int titleWidth, string style = "",
|
|
|
+ params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, ToLocalizedElements(elements), false, title, titleWidth, style, options, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new single-selection list box with the specified elements and a label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ /// <param name="title">Content to display on the label.</param>
|
|
|
+ /// <param name="titleWidth">Width of the title label in pixels.</param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(string[] elements, GUIContent title, int titleWidth = 100, params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, ToLocalizedElements(elements), false, title, titleWidth, "", options, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new list box with the specified elements and no label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
+ /// <param name="style">Optional style to use for the element. Style controls the look of the element, as well as
|
|
|
+ /// default layout options. Style will be retrieved from the active GUISkin. If not specified
|
|
|
+ /// default element style is used.</param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(string[] elements, bool multiselect = false, string style = "", params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, ToLocalizedElements(elements), multiselect, null, 0, style, options, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new list box with the specified elements and no label.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ /// <param name="multiselect">Determines should the listbox allow multiple elements to be selected or just one.
|
|
|
+ /// </param>
|
|
|
+ /// <param name="options">Options that allow you to control how is the element positioned and sized. This will
|
|
|
+ /// override any similar options set by style.</param>
|
|
|
+ public GUIListBoxField(string[] elements, bool multiselect = false, params GUIOption[] options)
|
|
|
+ {
|
|
|
+ Internal_CreateInstance(this, ToLocalizedElements(elements), multiselect, null, 0, "", options, false);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
@@ -95,6 +245,34 @@ namespace BansheeEditor
|
|
|
Internal_SetElements(mCachedPtr, elements);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Updates the list box with a new set of elements.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Array of elements to display in the list box. Elements will be displayed in the same
|
|
|
+ /// order as in the array.</param>
|
|
|
+ public void SetElements(string[] elements)
|
|
|
+ {
|
|
|
+ Internal_SetElements(mCachedPtr, ToLocalizedElements(elements));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Makes the element with the specified index selected.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="idx">Sequential index in the elements array provided on construction.</param>
|
|
|
+ public void SelectElement(int idx)
|
|
|
+ {
|
|
|
+ Internal_SelectElement(mCachedPtr, idx);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Deselect element the element with the specified index. Only relevant for multi-select list boxes.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="idx">Sequential index in the elements array provided on construction.</param>
|
|
|
+ public void DeselectElement(int idx)
|
|
|
+ {
|
|
|
+ Internal_DeselectElement(mCachedPtr, idx);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Colors the element with a specific tint.
|
|
|
/// </summary>
|
|
|
@@ -104,6 +282,23 @@ namespace BansheeEditor
|
|
|
Internal_SetTint(mCachedPtr, color);
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Converts a set of normal strings to a set of localized strings.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="elements">Strings to convert.</param>
|
|
|
+ /// <returns>Localized strings created from input strings.</returns>
|
|
|
+ private LocString[] ToLocalizedElements(string[] elements)
|
|
|
+ {
|
|
|
+ if (elements == null)
|
|
|
+ return null;
|
|
|
+
|
|
|
+ LocString[] locElements = new LocString[elements.Length];
|
|
|
+ for (int i = 0; i < locElements.Length; i++)
|
|
|
+ locElements[i] = elements[i];
|
|
|
+
|
|
|
+ return locElements;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Triggered by the native interop object when a user selects an object in the list.
|
|
|
/// </summary>
|
|
|
@@ -114,7 +309,7 @@ namespace BansheeEditor
|
|
|
}
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
- private static extern void Internal_CreateInstance(GUIListBoxField instance, LocString[] entries,
|
|
|
+ private static extern void Internal_CreateInstance(GUIListBoxField instance, LocString[] entries, bool multiselect,
|
|
|
GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
@@ -126,6 +321,18 @@ namespace BansheeEditor
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
private static extern void Internal_SetValue(IntPtr nativeInstance, int value);
|
|
|
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
+ private static extern bool[] Internal_GetElementStates(IntPtr nativeInstance);
|
|
|
+
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
+ private static extern void Internal_SetElementStates(IntPtr nativeInstance, bool[] states);
|
|
|
+
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
+ private static extern void Internal_SelectElement(IntPtr nativeInstance, int idx);
|
|
|
+
|
|
|
+ [MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
+ private static extern void Internal_DeselectElement(IntPtr nativeInstance, int idx);
|
|
|
+
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
|
private static extern void Internal_SetTint(IntPtr nativeInstance, Color color);
|
|
|
}
|