Ejemplo n.º 1
0
 /// <summary>
 /// Called by the child to notice that it wants
 /// to change its size or Visibility.
 /// </summary>
 /// <param name="child">Child willing to resize.</param>
 /// <param name="requestedSize">Size the child wants in the widget.</param>
 /// <returns>True if resizement granted, false otherwise.</returns>
 public bool ResizeForChild(Widget child, Vector2f requestedSize)
 {
     // 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.
     ChildResizeEvent ev = new ChildResizeEvent(child, requestedSize);
     OnEvent(ev);
     if (ev.Accepted)
     {
         OnChildResizeEvent(ev);
         if (ev.Accepted)
         {
             // We actually need to resize.
             if (ev.NecessaryParentSize.X > Size.X || ev.NecessaryParentSize.Y > Size.Y)
             {
                 // Tries to resize to the given size.
                 Vector2f newSize = Resize(ev.NecessaryParentSize);
                 // Check if we resized enough to place the widget in...
                 if (newSize.X < ev.NecessaryParentSize.X || newSize.Y < ev.NecessaryParentSize.Y)
                     return false;
             }
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Raised when a child widget wants to change its size.
        /// </summary>
        /// <param name="childResizeEvent"></param>
        public virtual void OnChildResizeEvent(ChildResizeEvent childResizeEvent)
        {
            childResizeEvent.NecessaryParentSize = _computeNewSizeForChild(childResizeEvent.Child, childResizeEvent.RequestedSize);

            if (childResizeEvent.NecessaryParentSize.X > MaxSize.X || childResizeEvent.NecessaryParentSize.Y > MaxSize.Y)
                childResizeEvent.Accepted = false;
        }