Advertisement
eacousineau

GridLayout.diff

Sep 7th, 2011
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.10 KB | None | 0 0
  1. --- /tmp/GridLayout.m
  2. +++ /home/eacousineau/Dropbox/amber/proj/util/manip_gui/third/GridLayout/GridLayout.m
  3. @@ -1,3 +1,5 @@
  4. +% Change in GridLayout.ResizeCell() - eacousineau
  5. +% Enable non-figure parents in constructor, Parent
  6.  classdef GridLayout < handle
  7.      
  8.      properties
  9. @@ -50,7 +52,7 @@
  10.              NamesCell = CellProps.GetCellParamNames();
  11.              [P, PC] = ParseArgs(varargin, Names, NamesCell);
  12.              
  13. -            if isempty(Parent) || ~ishghandle(Parent)
  14. +            if isempty(Parent) % || ~ishghandle(Parent)
  15.                  Parent = gcf;
  16.              end
  17.              Obj.Container = uicontainer( ...
  18. @@ -318,8 +320,21 @@
  19.              end
  20.              assert(isscalar(Child), ...
  21.                  'Cell has more than one child. This is not allowed.');
  22. +            
  23. +            IsAxes = false;
  24. +            % Use bugfix from layout.GridBagLayout.layout(this)
  25. +            % http://www.mathworks.com/matlabcentral/fileexchange/22968-gridbaglayout/
  26. +            if ishghandle(Child, 'axes') && ...
  27. +                    strcmp(get(Child, 'ActivePositionProperty'), 'outerposition')
  28. +                IsAxes = true;
  29. +                OldUnits = get(Child, 'Units');
  30. +                set(Child, 'Units', 'Pixels');
  31. +                ChildPosition = get(Child, 'OuterPosition');
  32. +            else
  33. +                ChildPosition = get(Child, 'Position');
  34. +            end
  35. +            
  36.              % Child offset and size
  37. -            ChildPosition = get(Child,'Position');
  38.              ChildOffset = ChildPosition(1:2);
  39.              ChildSize = ChildPosition(3:4);
  40.              % Cell size
  41. @@ -356,7 +371,12 @@
  42.              % Prevent non-positive sizes
  43.              ChildSize = max(ChildSize,.1);
  44.              % Update child position
  45. -            set(Child,'Position',[ChildOffset ChildSize]);
  46. +            ChildPosition = [ChildOffset ChildSize];
  47. +            if ~IsAxes
  48. +                set(Child,'Position', ChildPosition);
  49. +            else
  50. +                set(Child, 'OuterPosition', ChildPosition, 'Units', OldUnits);
  51. +            end
  52.          end
  53.          
  54.      end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement