[Approved] AutoAlign not working correctly for Group/StackLayout (2 Viewers)

FragKing

Portal Member
November 2, 2008
32
12
Zurich
Home Country
Switzerland Switzerland
Reference: StackLayout shift buttons - MediaPortal Wiki
Related Mantis Bug (Original): 0003241: Auto placing of controls in grouped StackLayout - MediaPortal Bugtracker
Changeset: https://github.com/MichelZ/MediaPortal-1/commit/d7f46f19d49f7be9a3f78e57487ef894688da3dc
Pull Request: https://github.com/MediaPortal/MediaPortal-1/pull/6

If you use StackLayout with "Shift Buttons" enabled, the shifting always takes the size of the wrong control (size of the currently evaluated control), instead of the control which got hidden. This os course works when your controls are all the same size, but if they are not, you're screwed :)

A simple Patch mitigates this Problem:
In core/guilib/GUIGroup.cs:

(This is an example for ShiftControlsLeft(int index), the patch is for ShiftControls Left/Right/Up/Down)

Code:
    private void ShiftControlsLeft(int index)
    {
      int spacing = Spacing(System.Windows.Controls.Orientation.Horizontal);
 
      for (int i = index; i < Children.Count; i++)
      {
        if (i + 1 < Children.Count)
        {
          Children[i + 1].XPosition -= (Children[i].Width + spacing);
        }
      }
    }


Code:
Children[i + 1].XPosition -= (Children[i].Width + spacing);

This changes the Position of the next control (i+1) by substracting the width of the currently evaluated control (i)
However, it SHOULD substract the Width of the Control which has had it's visibility changed (index)

So it should be:

Code:
Children[i + 1].XPosition -= (Children[index].Width + spacing);

In full:

Code:
private void ShiftControlsLeft(int index)
    {
      int spacing = Spacing(System.Windows.Controls.Orientation.Horizontal);
 
      for (int i = index; i < Children.Count; i++)
      {
        if (i + 1 < Children.Count)
        {
          Children[i + 1].XPosition -= (Children[index].Width + spacing);
        }
      }
    }
 
Last edited by a moderator:

elliottmc

Retired Team Member
  • Premium Supporter
  • August 7, 2005
    14,927
    6,061
    Cardiff, UK
    Home Country
    United Kingdom United Kingdom
    This is merged and will be included in 1.3.0Alpha.

    Thanks for the contribution and apologies for the late progress update.
     

    Users who are viewing this thread

    Top Bottom