Author Topic: Unparented sprite still clipped by panel  (Read 3484 times)

tango209

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Unparented sprite still clipped by panel
« on: June 11, 2013, 01:13:47 AM »
How do I unparent a sprite from its clipping panel so it isn't hidden when dragged outside of the panel?  I tried setting the transform panel to null, but that doesn't seem to help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unparented sprite still clipped by panel
« Reply #1 on: June 11, 2013, 04:01:18 PM »
Exactly how Drag & Drop example does it. :)

tango209

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Unparented sprite still clipped by panel
« Reply #2 on: June 11, 2013, 04:56:34 PM »
I'll look into it some more, but the example did not show the sprite as it was dragged.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Unparented sprite still clipped by panel
« Reply #3 on: June 11, 2013, 05:27:09 PM »
You need to mark it as changed in the panel, I believe. The widget should change which UIPanel it's being drawn by. If it hasn't noticed this, then the old drawcall is still there and that gets clipped as normal.

tango209

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Unparented sprite still clipped by panel
« Reply #4 on: June 11, 2013, 08:13:12 PM »
Thanks for the steer Nicki.  Changed the widget's transform parent to another UIPanel and called the following helper function and it works now.

  1.  
  2. private void ParentHasChanged(UIPanel panel)
  3.   {
  4.     List<UIWidget> list = new List<UIWidget>(panel.widgets.buffer);
  5.  
  6.     foreach (UIWidget widget in list)
  7.     {
  8.       if (widget != null)
  9.       {
  10.         widget.ParentHasChanged();
  11.       }
  12.     }
  13.   }
  14.