/// <summary> /// Tries to resize the widget to the new size. /// </summary> /// <param name="newSize">Size to give to the widget.</param> /// <returns>Size of the widget after the resizement.</returns> public Vector2f Resize(Vector2f newSize) { // May be position of the child widget has changed // and we just want to update the parent accordingly // so we musn't check if requestedSize is the same as before // in the view to NOT froward properly the event. ResizeEvent ev = new ResizeEvent(newSize); OnEvent(ev); if (ev.Accepted) { OnResizeEvent(ev); if (ev.Accepted) { if ((Parent != null && Parent.ResizeForChild(this, newSize)) || Parent == null) { DoResize(newSize); if (Parent != null) Parent.EndChildResize(this, newSize); } } } return Size; }
/// <summary> /// Raised when the size of the widget is about to change. /// </summary> /// <param name="resizeEvent"></param> public virtual void OnResizeEvent(ResizeEvent resizeEvent) { if ((resizeEvent.RequestedSize.X > MaxSize.X || resizeEvent.RequestedSize.Y > MaxSize.Y) || (resizeEvent.RequestedSize.X < MinSize.X || resizeEvent.RequestedSize.Y < MinSize.Y)) resizeEvent.Accepted = false; }