/// <summary> /// Add a widget to the UI. /// </summary> /// <param name="widget">The widget</param> /// <returns>The widget added for ease</returns> public YnWidget Add(YnWidget widget) { // First, test if the widget is not already added if (!_widgets.Contains(widget)) { // Increase the max depth and set it up on the added widget _maxDepth++; widget.Depth = _maxDepth; // Apply skin widget.ApplySkin(); // Add the widget to the list _widgets.Add(widget); // If the widget has no skin, then use the default one // The skin name is defined in default widgets constructors but this // is a double security if (widget.SkinName == null) { widget.SkinName = DEFAULT_SKIN; } } return(widget); }
/// <summary> /// Removes a widget from the GUI. Only widgets added directly in the GUI can be removed by this method. /// </summary> /// <param name="widget">The widget to remove</param> public void Remove(YnWidget widget) { // TODO : make possible to remove any hierarchy level widget with this method if (_widgets.Count > 0) { _widgets.Remove(widget); } }
/// <summary> /// Move the widget up in the layer depth. If the widget is already on top of /// the layer, nothing is done. /// </summary> /// <param name="widget">The widget to move up</param> public void DepthUp(YnWidget widget) { if (widget.Depth < _maxDepth) { // The widget is not already on top of the layer // Swap the widget with the one just above DepthSwap(widget, _widgets[widget.Depth + 1]); } }
/// <summary> /// Move the widget down in the layer depth. If the widget is already on the bottom of /// the layer, nothing is done. /// </summary> /// <param name="widget">The widget to mode down</param> public void DepthDown(YnWidget widget) { if (widget.Depth > 0) { // The widget is not already on the bottom of the layer // Swap the widget with the one just below DepthSwap(widget, _widgets[widget.Depth - 1]); } }
/// <summary> /// Swap the depth of the two widgets. /// </summary> /// <param name="widget1">The first widget</param> /// <param name="widget2">The second widget</param> public void DepthSwap(YnWidget widget1, YnWidget widget2) { // The widget's depth is also it's index in the widget list : magic! // No need to make a temp value as we have the references here with // widget1 and widget2 _widgets[widget1.Depth] = widget2; _widgets[widget2.Depth] = widget1; // Swap depths values in wigets int firstDepth = widget1.Depth; widget1.Depth = widget2.Depth; widget2.Depth = firstDepth; }
/// <summary> /// Move the widget to the top of the lauer depth. All widgets above are moved down. /// </summary> /// <param name="widget">The widget to move to the top</param> public void DepthToTop(YnWidget widget) { // All widgets above the widget have to go down in the depth // Depth + 1 => Depth // Depth + 2 => Depth + 1 // and so on... for (int i = widget.Depth + 1; i <= _maxDepth; i++) { DepthDown(_widgets[i]); } // Now that all other widgets were moved up, just set the widget // new depth widget.Depth = _maxDepth; _widgets[_maxDepth] = widget; }
/// <summary> /// Move the widget to the bottom of the layer depth. All widgets below are moved up. /// </summary> /// <param name="widget">The widget to move to the bottom</param> public void DepthToBottom(YnWidget widget) { // All widgets below the widget have to go up in the depth // Depth - 1 => Depth // Depth - 2 => Depth - 1 // and so on... for (int i = widget.Depth - 1; i >= 0; i--) { DepthUp(_widgets[i]); } // Now that all other widgets were moved up, just set the widget // new depth widget.Depth = 0; _widgets[0] = widget; }
/// <summary> /// Get a widget by its name. /// </summary> /// <param name="name">The widget name</param> /// <returns>A widget or null if the name was not found</returns> public virtual YnWidget GetWidgetByName(string name) { YnWidget widget = null; int size = _widgets.Count; int i = 0; while (i < size && widget == null) { if (_widgets[i].Name == name) { widget = _widgets[i]; } i++; } return(widget); }
public void Add(YnWidget widget) { _guiManager.Add(widget); }
/// <summary> /// Move the widget up in the layer depth. If the widget is already on top of /// the layer, nothing is done. /// </summary> /// <param name="widget">The widget to move up</param> public void DepthUp(YnWidget widget) { if(widget.Depth < _maxDepth) { // The widget is not already on top of the layer // Swap the widget with the one just above DepthSwap(widget, _widgets[widget.Depth + 1]); } }
/// <summary> /// Move the widget down in the layer depth. If the widget is already on the bottom of /// the layer, nothing is done. /// </summary> /// <param name="widget">The widget to mode down</param> public void DepthDown(YnWidget widget) { if(widget.Depth > 0) { // The widget is not already on the bottom of the layer // Swap the widget with the one just below DepthSwap(widget, _widgets[widget.Depth - 1]); } }
/// <summary> /// Move the widget to the bottom of the layer depth. All widgets below are moved up. /// </summary> /// <param name="widget">The widget to move to the bottom</param> public void DepthToBottom(YnWidget widget) { // All widgets below the widget have to go up in the depth // Depth - 1 => Depth // Depth - 2 => Depth - 1 // and so on... for (int i = widget.Depth -1; i >= 0; i--) { DepthUp(_widgets[i]); } // Now that all other widgets were moved up, just set the widget // new depth widget.Depth = 0; _widgets[0] = widget; }
/// <summary> /// Removes a widget from the GUI. Only widgets added directly in the GUI can be removed by this method. /// </summary> /// <param name="widget">The widget to remove</param> public void Remove(YnWidget widget) { // TODO : make possible to remove any hierarchy level widget with this method if (_widgets.Count > 0) _widgets.Remove(widget); }
public void Remove(YnWidget widget) { _guiManager.Remove(widget); }
/// <summary> /// Move the widget to the top of the lauer depth. All widgets above are moved down. /// </summary> /// <param name="widget">The widget to move to the top</param> public void DepthToTop(YnWidget widget) { // All widgets above the widget have to go down in the depth // Depth + 1 => Depth // Depth + 2 => Depth + 1 // and so on... for (int i = widget.Depth +1; i <= _maxDepth; i++) { DepthDown(_widgets[i]); } // Now that all other widgets were moved up, just set the widget // new depth widget.Depth = _maxDepth; _widgets[_maxDepth] = widget; }
/// <summary> /// Add a widget to the UI. /// </summary> /// <param name="widget">The widget</param> /// <returns>The widget added for ease</returns> public YnWidget Add(YnWidget widget) { // First, test if the widget is not already added if(!_widgets.Contains(widget)) { // Increase the max depth and set it up on the added widget _maxDepth++; widget.Depth = _maxDepth; // Apply skin widget.ApplySkin(); // Add the widget to the list _widgets.Add(widget); // If the widget has no skin, then use the default one // The skin name is defined in default widgets constructors but this // is a double security if (widget.SkinName == null) { widget.SkinName = DEFAULT_SKIN; } } return widget; }