[Approved] - AutoAlign not working correctly for Group/StackLayout

Discussion in 'Archive' started by FragKing, January 31, 2012.

  1. FragKing Portal Member

    System Specs
    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 (text):
        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 (text):
    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 (text):
    Children[i + 1].XPosition -= (Children[index].Width + spacing);
    In full:

    Code (text):
    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);
            }
          }
        }
    • Like Like x 3
    • Team MediaPortal

    arion_p Development Group

    System Specs
    • Team MediaPortal

    Sebastiii Development Group

    System Specs
    • Like Like x 1
  2. FragKing Thread Starter Portal Member

    System Specs
    • Team MediaPortal

    elliottmc Release Manager

    System Specs
    This is merged and will be included in 1.3.0Alpha.

    Thanks for the contribution and apologies for the late progress update.
    • Like Like x 1

Share This Page

Users Viewing Thread (Users: 0, Guests: 0)

Running the latest version?

V1.3.0 FINAL - released March 2013
Releasenews | Download
Changelog
 | Requirements
HTPC
Team-MediaPortal
 
About
Contact |  Press
Partners