File Exchange

image thumbnail

GUI Layout Toolbox

version 2.3.4 (841 KB) by David Sampson
Layout manager for MATLAB graphical user interfaces

969 Downloads

Updated 04 Feb 2019

View License

Editor's Note: Popular File 2017 2018

This file was selected as MATLAB Central Pick of the Week

This toolbox provides tools to create sophisticated MATLAB graphical user interfaces that resize gracefully. The classes supplied can be used in combination to produce virtually any user interface layout.

* Arrange MATLAB user interface components horizontally, vertically or in grids
* Mix fixed- and variable-size components
* Resize components interactively by dragging dividers
* Show and hide components using tabs and panels
* Show part of a large component in a scrollable panel

This toolbox was developed by David Sampson and Ben Tordoff from the [Consulting Services](http://www.mathworks.com/services/consulting/) group at MathWorks.

This version is for MATLAB R2014b and later. For R2014a and earlier, see [version 1](http://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox).

Cite As

David Sampson (2019). GUI Layout Toolbox (https://www.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (569)

Brilliant submission!

I've wandered into an unusual problem, when I use a BoxFlex of any type, and the Tab button is pressed, the parent figure does not trigger WindowKeyPress events anymore, until a child graphics object on the figure is reselected by mouse click. This implies that the main figure has lost focus due to tab controls, which is somewhat expected if we were listening for a KeyPress event, but WindowKeyPress events are lost as well. I suspect that tab controls are focusing to an element which is not a child of the main window (or somehow hidden). This does not occur with non-flex boxes. This isn't too big of an issue, as I can avoid using 'Tab' as a keyboard shortcut, but it would be good to understand what is going on.

Cheers!

Good contents!

David Sampson

Kaveh, please look at the GUI Layout Toolbox documentation, section 6 "Deploying GUIs using the MATLAB Compiler". You must explicitly include the "Resources" folder within the +uix package.

Many thanks to Mr. Sampson for developing this amazing toolbox.
I have a problem when I try to create an executable file for one of my GUIs, in which I've used this toolbox elements.
It seems that MATLAB's compilers don't support the graphical elements of this toolbox, if I'm not mistaken. Is there any solution to that problem?

David Sampson

Thomas, the package is a MATLAB toolbox. You can download and install it using your regular web browser. You can also get it through Add-Ons > Get Add-Ons in the MATLAB toolstrip.

For more information on toolboxes, see: https://www.mathworks.com/help/matlab/matlab_prog/create-and-share-custom-matlab-toolboxes.html

Hi David, Hi all,
I think installing this toolbox is the solution for one error I get while working with GUI related functions. However, I apologize for this "beginner" question, but I cannot figure out how to install the toolbox. Is this supposed to be an App ? or an Add-on ? I cannot see any installing function within the package.
Sorry again, any help would be appreciated !
Thanks

Hasun Khan

David Sampson

Patrick, thank you for your feedback on the scrollbar. Does JScrollBar provide superior functionality, appearance, or both, when compared to uicontrol('Style','slider')?

Related, I have been looking at how uix.ScrollingPanel could be implemented for uifigures. Unfortunately there is no MATLAB scrollbar component provided, and embedding a Java-based scrollbar won't work. Maybe uihtml will open up some more possibilities.

Hi David, great toolbox.
I have one question. I'm using your toolbox in combination with Widget Toolbox. The uiw.widget.Tree seems to use a javax.swing.JScrollBar as scroolbar. Your uix.ScrollingPanel seems to use a uicontrol('style', 'slider') as scrollbar. Is there any possibility to chnage the scrollbar in uix.ScrollingPanel to a javax.swing.JScrollBar?
BR

Cihan Ulas

Ok.
Thank you for the feedback.

David Sampson

Cihan, that is not supported, but is a fair request.

Cihan Ulas

How can set a maximum height for HBox?

Chris

@Jordan Smith, I don't know if your problem was solved, but I had a similar one. For whatever reason, when I nested the axes in another VBox by itself, it fixed the problem for me (for data tip, but not for color bar. that still messes it up).

Yifan Gao

mark

David Sampson

Yanjun, the behavior of waitforbuttonpress does not depend on the contents of the figure.

I don't recognize the function names waitforbuttonmove and waitforbuttonup.

David Sampson

Yanjun, see section 5 "Using layouts inside GUIDE GUIs" in the documentation. You add placeholder panels graphically to GUIDE, and then add GUI Layout Toolbox containers and their contents programmatically.

Chris

Yanjun Han

Dear David,
When I use Layout to put an axis because the parents of axis is not a figure, how can I use interactive functions like getcurrentPoint, waitforbuttonpress, waitforbuttonmove, and waitforbuttonup ????

Z Liu

Yanjun Han

Hi David
For using layouts inside GUIDE guis, how to add elements in the layouts????

Adam

Dani

Poke. PNG-free version of uix.TabGroup?

David Sampson

Jordan, do you need to set XLimMode to 'manual'? (Setting XLim should do this, but other subsequent operations may set it back to 'auto'.)

Hi David, this package is fantastic! I'm encountering a problem where if I have an axes placed within a VBox, I want to prevent the axes from rescaling after placing an element on the axes, such as a Marker at a specific X and Y coordinate. Calling the 'axis' function to rescale the axes to its original limits only works for the Y-axis, the X-axis remains at the rescaled limits. I took a look at modifying the DataAspectRatio, but that only messed up the resizing functionality of the axes in the uix.Panel. I want to keep the axes limits fixed so that I can drag the marker around the axes with the mouse callback(s). Any feedback on maintaining the X limits would be greatly appreciated!

David Sampson

Laxmi, please share a simple example, either with the GLT community through these comments, or with me directly via the "contact author" button.

Thanks David, We have written the code and done re-parenting of the child, my question is when we undock the figure all the figures automatically shuffle leaving the blank panels at the end, I want to know if we can stop this shuffling and retain the position of the figures that was before undocking.

David Sampson

Laxmi, you need to (and can) code up the dock/undock behavior yourself. Specifically, your dock code should both reparent the child -- which puts the child at the end of the Contents -- and then reorder the Contents.

I tried the example of dock/undock of panel as per the documentation,
I see that the position of the panel changes when the figure is docked back, is there a way to retain the original position?

Ouch, 2 stars.

uix.BoxPanel does not support subplots.
Solution: use uipanel inside of uix.BoxPanel.

Adam

Zhen Liang

Iv, we don't support case insensitive or truncated property matching in GLT.

lv yafei

An amazing tool ! Very Useful !
Here is a little problem I found : It cannot recognize 'parent' in the code below, you have to capitalize the first letter as 'Parent' to make the the code result correct.
>> f = figure();
>>b = uiextras.VBox( 'parent', f );
>>b1 = uiextras.HBox('parent',b);
>>b2 = uiextras.HBox('parent',b);
>>uicontrol( 'parent', b1, 'Background', 'r' )
>>uicontrol( 'parent', b2, 'Background', 'b' )
Actually, it is sure a bad habit to write the PropertyName in lowercase. But it can also work in MATLAB when used. And it is really hard to fix this strange bug when you do not notice it.

Scofieldgzf

OK, thanks for the info. Might be worth adding to the help. However, catching the crash and displaying a friendly warning would be much appreciated. Great toolbox otherwise.

David Sampson

Kai, please see my comment dated 6 October 2018 which addresses this topic.

When saving a figure with a layout to a .fig file and reloading it, Matlab crashes and must be closed.

Warning: While loading an object of class 'listener':
No constructor 'event.listener' with matching signature found.
> In matlab.graphics.internal.figfile.FigFile/read (line 31)
In matlab.graphics.internal.figfile.FigFile
In loadFigure (line 31)
In openfig>localOpenFigure (line 69)
In openfig (line 40)
In open (line 141)
In uiopen (line 167)
Warning: During load:
An invalid default object has been detected while loading a
heterogeneous array of class event.listener. An empty array of class
event.listener will be returned.
> In matlab.graphics.internal.figfile.FigFile/read (line 31)
In matlab.graphics.internal.figfile.FigFile
In loadFigure (line 31)
In openfig>localOpenFigure (line 69)
In openfig (line 40)
In open (line 141)
In uiopen (line 167)

David Sampson

Patta, thanks for bringing this issue to my attention. For that right click, the HitObject on the right click is unexpectedly empty. The following change to uix.Divider/isMouseOver is required:

tf(ii) = tf(ii) && ~isempty( eventData.HitObject ) && obj(ii).Control == eventData.HitObject;

patta

patta

Strange thing happen to the comments, my first one vanished.

Again:

There is a problem when using a HBoxFlex with visible divider and drawpolygon from the Image Processing Toolbox when one uses the right mouse button to finish the ROI.

Code:

hb = uix.HBoxFlex('Parent', figure()); axes('Parent', hb); axes('Parent', hb);
imagesc(rand(64, 64));
drawpolygon

Error is

-------------------------------------------------------------------
Warning: Error occurred while executing the listener callback for event WindowMousePress defined for class
matlab.ui.Figure:
Operands to the || and && operators must be convertible to logical scalar values.

Error in uix.Divider/isMouseOver (line 261)
tf(ii) = tf(ii) && obj(ii).Control == eventData.HitObject;

Error in uix.HBoxFlex/onMousePress (line 103)
loc = find( obj.ColumnDividers.isMouseOver( eventData ) );

Error in uix.HBoxFlex>@(varargin)obj.onMousePress(varargin{:}) (line 307)
'WindowMousePress', @obj.onMousePress );

Error in uiwait (line 81)
waitfor (hFigDlg, 'WaitStatus', 'inactive');

Error in images.roi.internal.ROI/draw

Error in drawpolygon (line 174)
h.draw;
> In uiwait (line 81)
In images.roi.internal.ROI/draw
In drawpolygon (line 174)
-------------------------------------------------------------------

However, drawpolygon returns a ROI which looks correct at first glance. Nevertheless, I guess its a bug.

Matlab version is '9.6.0.1099231 (R2019a) Update 1', Toolbox version is the newest installed a few minutes ago.

Thanks for this very helpful piece of software!

patta

I forgot:

version: 9.6.0.1099231 (R2019a) Update 1

Toolbox Version newest, installed a few minutes ago.

Tong, please look at the GUI Layout Toolbox documentation, section 6 "Deploying GUIs using the MATLAB Compiler". You must explicitly include the "Resources" folder within the +uix package.

Jiancheng

Hi David,
When I launch my application generated from "MATLAB Compiler" I always got error message:
Error using uix.loadIcon (line 34)
Invalid default value for property 'DividerMask' in class 'uix.TabPanel':
Cannot open file 'tab_NoEdge_NotSelected.png'.
Error in uix.TabPanel/getDividerMask (line 902)
Error in viewMain/createGui (line 62)
Error in viewMain (line 45)
Error in main (line 2)

But it is strange that the main file can be successfully launched without any errors or warnings in MATLAB.

Thanks in advance for your feedback!
Tong

Rakshan, that's an involved task, that we would typically support through consulting, although feel free to take that as a challenge! Broadly you need to detect button down on the target(s) of interest, then track and update on mouse motion, then release on button up.

The main challenges are:
(1) What is the button down target -- the panel title, the panel background, the panel contents?
(2) Inventing and implementing sensible logic for what goes where as the mouse moves
(3) Avoiding unwanted interactions with the flex panel dividers -- are you sure you want draggable dividers *and* reorderable panels?

Hi David,

I want to be able to shuffle the box panels positions inside the uix.Gridflex preferably by dragging the panels. Can you please suggest whether it is possible to do using the provided features ?

Thanks,
Rakshan

Vyshakh Pv

David Sampson

Andreas, the TabPanel follows the programming model of the other GLT containers. To add contents, set the Parent of the new child to the TabPanel. To reorder contents, set the Contents property to a permutation of itself.

As a reminder to all, please use uitab and uitabgroup unless you require disabled tabs, or are writing code that needs to run prior to R2014b.

If I had a TabPanel with some arbitrary content (i have panels and or tables) and i would wish to change that content, how would i do that?
addChild, removeChild and reorder all are protected methods..

Adam

Depends how much effort you want to put in. You can create a regular GUI with AppDesigner and then start inserting layouts programmatically and re-parenting all the components, but it is potentially a lot of effort. As with GUIDE though, you can leave some blank panels in AppDesigner and fill them up programmatically, but you can't drag widgets from this toolbox around in the visual GUI designer part.

bing yan

Can this work on AppDesigner?

| Matthew, I presume that you want not just the blanking plate, but the scrollbar trough too, to change color with the panel background color. It's not possible to change the colors of the scrollbar buttons and slider.

I think the trough is fine as default. It contains the scroll buttons and slider so think its fine to stay as grey.

David, thank you for the explanation. The workaround is a good alternative.

@Randy Souza, thanks for fixing!

@David Sampson, yep, new zip perfectly works, thanks!

David Sampson

Geovany, you are right that GLT containers do not play well with legends and colorbars. There are technical reasons why we cannot do better. There is further discussion in the documentation, section 2.3 "colorbars and legends".

The workaround is to put the axes in question in a uicontainer (or uipanel with Title '') that fills a GLT container.

b = uix.BoxPanel( ... );
c = uicontainer( 'Parent', b, ... );
a = axes( 'Parent', c, ... );
legend( a, ... )

Legend is not compatible with 'uix.Panel'. Here is a minimal example where the plot disappears after using 'legend'

f = uix.Panel('Parent', figure);
axesH = axes('Parent',f);
plotH = plot(axesH, 1:5, rand(1,5));
legend

Of course, I can use a 'uipanel' instead, but I'm interested in use many uix.* elements.

Randy Souza

@Terry Brennan, @Igor, we've fixed the empty zip issue and replaced the zip package with one that has the correct files. Apologies for the inconvenience this caused.

David Sampson

Terry and Igor, thank you, you are right. I'll ask the File Exchange team to get right onto this.

Igor

@David Sampson the "empty zip" issue is not fixed. The file I've just downloaded is 36.8kB and only contains 0-size files.

I'm not sure the zip is fixed. I attempted to download the zip version and all the files are empty.

David Sampson

Dear zip file users, the case of the missing pluses is now solved.

GUI Layout Toolbox is uploaded in mltbx format, but File Exchange has a routine to produce an equivalent zip file for those who prefer that format. The routine had a bug that was losing the "+" from package folder names. The bug has now been fixed.

Jun

Problem solved.

Jun

When I launching my application using GUI Layout Toolbox 2.3.4 version, I always got error message:

Error using uix.loadIcon (line 34)
Invalid default value for property 'DividerMask' in class 'uix.TabPanel':
Cannot open file 'tab_NoEdge_NotSelected.png'.

Error in uix.TabPanel/getDividerMask (line 902)
mask.EF = indexColor( uix.loadIcon( 'tab_NoEdge_NotSelected.png' ) );

Error in FGECTorqueTool.TorqueTool (line 37)
tabs = uix.TabPanel( 'Parent', fig, 'Padding', 5 );

When the first time install the toolbox, it works fine. But after re-start the MATLAB and launch the application, then it stop working and show the error message. Any idea why cause these errors?

David Sampson

Adrian, I have two suggestions. The first is li = listener(a,'XLim','PostSet',@cb), where a is the axes of interest. The second is to use m = zoom(f), m.ActionPostCallback = @cb, where f is the figure of interest.

I have an App based on the demoBrowser example, I am plotting data in one of the boxes. Is there a way to capture when the user zooms in and redraw the scatter plot with labels on each data point when the user has zoomed in enough. I assume I need to add a Callback function some where but can't find the appropriate object ?

Jun

Thanks David for help. The toolbox has been installed.

David Sampson

Jun, please download the "Toolbox" (.mltbx) rather than the "Zip". MATLAB will extract the contents to its "Add-ons" area and add the required folders to the path.

For more information on toolboxes, see: https://www.mathworks.com/help/matlab/matlab_prog/create-and-share-custom-matlab-toolboxes.html

Jun

I have difficulty in installing this toolbox. After downloaded GUI Layout Toolbox 2.3.4.zip, I extracted into folder of GUI Layout Toolbox 2.3.4 and add this path into matlab search path, but MATLAB still can not find this installation. Command ver does not show this toolbox has been installed. What is the correct way in install this toolbox?

Adam

Just to add to comments below, since I also just noticed the problem with the missing + on folders (the same as when I also downloaded the Widgets Toolbox) from the zip file. We also always use zip files for the same reason as Dani, that we keep all our code, including 3rd party code, in a repository so that we can all checkout code from the repository and run it without having to individually install toolboxes. I haven't looked too much into the toolbox install, but I'm not aware that this would be an option using that.

David Sampson

Michala, the error indicates that you are running GUI Layout Toolbox 1.x on MATLAB R2014b or later. You need GUI Layout Toolbox 2.x, which you can download from this page.

The changes in MATLAB graphics from R2014a to R2014b were significant and it was not possible to create a single GUI Layout Toolbox that would work for both. User ("your") code should work against both 1.x and 2.x, apart from specific items listed in the 2.x documentation, section 2.2 "Compatibility with version 1".

David Sampson

Erich, an update. The fix was straightforward and the issue will be resolved in the next release.

David Sampson

Erich, you are right. Unfortunately the documentation is generated using an old internal tool which is no longer maintained. I will see what I can do.

Aaron Chang

Erich

The help HTML files have inconsistent case in the image source reference, which causes some images not to be displayed for case-sensitive filesystems.

E.g.: In Getting_Started2.html at the top of the page has:
<td width="36" bgcolor="#e4f0f8"><A HREF="Getting_Started1.html"><IMG SRC="Images/leftarrow.png" BORDER="0" ALT="previous page"/></A><A HREF="Getting_Started3.html"><IMG SRC="Images/rightarrow.png" BORDER="0" ALT="next page"/></A></td>
which correctly shows the left and right arrows, but at the bottom of the page has:
<td width="18" height="15" bgcolor="#e4f0f8" align="right"><a href="Getting_Started3.html"><img src="images/rightarrow.png" border="0" alt="next page"/></a></td>
which causes the "image broken link" icon to display along with the alt text.

Hi guys,
I am having compatibility problem. I have been successfully using this toolbox for at least two years on Win7, Matlab 2016a. Now I have changed to Win10 and Matlab 2018a. Since I was having problem with the toolbox afterwards, I installed 2016a as well (on Win10). Getting still errors.

Problem is already in the beginning with this:
p = figure('Units', 'Pixels', 'OuterPosition', [100 100 1000 800], ...
'Toolbar', 'none', 'Menu', 'none', 'name','EMGAT16 setting');

b1 = uiextras.HBox('Parent', p, 'Spacing', 5);

In Matlab 2016a, win10 the error is:
Error using uiextras.Container (line 66)
Trying to run using double-handle MATLAB graphics against the new graphics system. Please re-install.

In Matlab 2018b,Win10 it is different:
No constructor 'handle.listener' with matching signature found.
Error in uiextras.Container (line 95)

What is wrong?

Matthew, I presume that you want not just the blanking plate, but the scrollbar trough too, to change color with the panel background color. It's not possible to change the colors of the scrollbar buttons and slider.

Matthew, good call, I will fix this.

Hi David,

Small visual issue with uix.ScrollingPanel. When both horizontal and vertical scrollbars are displayed, the 'blanking plate' displayed in the bottom right corner does not match the background color of the ScrollingPanel as I would expect. e.g. If i set background to black, it still displays as the default grey.

This causes GUIs where the main background color is not the default gey to look a little weird.

Code to reproduce:
f = figure('Color', [0 0 0])
scrl = uix.ScrollingPanel('Parent', f, 'BackgroundColor', [0 0 0])
vbox = uix.VBox('Parent', scrl, 'BackgroundColor', [0 0 0])
scrl.MinimumHeights = 2000;
scrl.MinimumWidths = 2000;

David Sampson

Rakshan, you have not provided complete reproduction steps, but nevertheless, I have some feedback.
1. copyobj is for copying an object, not moving it. You move an object from one parent to another by setting its Parent property.
2. You can create the axes in the panel -- a = axes( 'Parent', p ) -- rather than creating them in gcf and moving them -- a = axes(); a.Parent = p.
3. If you reparent axes then MATLAB will reparent the corresponding legend.
4. Looks like you already know this, but for axes with legends and colorbars, you need to put them in a uipanel in a GLT container, not directly in a GLT container.

I am using GUI Layout Toolbox to create a multiple figure uipanel inside a uix.GridFlex().

However, I am unable to set the figure to the uipanel as child object and get all figure objects copied to the panel, I have to do following steps

for i = 1:numFigures
set(uiPanelFig(i), 'Title', get(figureHandles(i),'name'));
selectedFigAxes = findobj(figureHandles(i),'type','axes');
figAxes = findobj(selectedFigAxes, 'type', 'axes', '-not', 'Tag', 'legend', '-not', 'Tag', 'Colorbar');
for ii = length(figAxes) : -1 : 1
legendAxes = figAxes(ii).Legend;
if ~isempty(legendAxes)
copyobj([legendAxes, figAxes(ii)], uiPanelFig(i), 'legacy');
else
copyobj(figAxes, uiPanelFig(i), 'legacy');
end
end
end
copyobj() is taking almost 22 sec for certain figures to be copied to uiPanel. Please suggest if there is any alternate solution to reparent the uipanel to figure with all its objects.

David Sampson

Batuhan, ver('layout') is what you need.

Related, we will start releasing new functionality in R2019a to retrieve toolbox dependencies.

Hello David,

Somewhat unrelated and a newbie question here about your amazing toolbox! I am currently trying to develop an open-source project based on "GUI Layout Toolbox" to make creating Matlab toolstrip like menus very easy on legacy figures. Anyway, first I have to check whether the user has the GUI Layout Toolbox installed or not, obviously.

license('test', 'GUI Layout Toolbox') tends to return 0 all the time which I believe is because I need to use the actual feature name of the toolbox rather than the name it is listed as by the command "ver".

I want to learn what that name is. Or do you have any other solutions for this? I did not want to implement some dirty solution like getting all license names using "ver" and checking for the name "GUI Layout Toolbox" by using the function "isfield" or anything similar.

Please keep up the great work.
Thank you very much,
Batuhan

David Sampson

Dani, until the FX issue is fixed, you install the updated mltbx, and grab the updated code from your add-ons folder.

David Sampson

Hi Dani, thank you for the feedback on the zip files. There is indeed a problem with the FX mltbx-to-zip converter, and a member of the FX team is working on fixing it.

Related, we have some functionality coming along to encode and retrieve toolbox dependencies.

Unrelated, thanks for the prod on the PNG-free tabs!

Dani

Hi David,
the reason why we still use the zip is because the GUI Layout Toolbox is part of several larger development projects. We have everything in a source control system and everybody that checks it out should get the whole thing including all the required external libraries such as the GLT. This is why we avoid mltbx.
When does the PNG-free version of uix.TabGroup come?
Cheers,
Dani

David Sampson

Swaroop, uix.Panel positions its contents to fill the available space, less padding. If you set the contents position explicitly then it will be reset on the next uix.Panel resize. If you want a panel that does not reposition its contents then use uipanel. If you want to plug in your own resizer then use uipanel with SizeChangedFcn.

SWAROOP HP

Hi David,
I need some help in positioning the uitable inside a uix.panel. I am trying to position the uitable by specifying position property [x y w h], but it is not working, table is getting created at the top left corner in the parent component. Find the code below.
Also I wanted to know whether the table size gets adjusted according to different resolutions, if it is placed inside a uix.Panel.

f=figure();
p1=uix.Panel( 'Parent',f);
RowName = {'A','B','C','D','E','F','G','H','I'};
Data = zeros(9,1);
p2=uitable('Parent',p1,...
'units','normalized','Position',[0.2 0.55 0.45 0.38],...
'FontSize',14,...
'RowName',RowName,'Columnname',{'Value'},...
'Data',Data,'ColumnEditable',~[0],'RearrangeableColumns','on');

Dani, thank you for spotting this issue. The zip file is generated automatically from the mltbx file, and it seems like this is not working. The issue has been reported to the File Exchange development team.

Out of interest, why are you using the zip file rather than the mltbx file? GLT2 supports R2014b onwards... the same release where mltbx files were introduced. I hadn't expected any GLT2 users to use the zip file.

Dani

In the ZIP of the newest version the folders uix, uiextras, and mixin do not have a leading + (replaced by space).

Michele, a few thoughts. Yes we would like to improve in-product support for layout management in MATLAB, and uigridlayout is a step in that direction. New development in this area will take time and is only targeting Javascript-based graphics. The rate of customer adoption will also vary, since large customers do not take new releases immediately. We also need to support the many thousands of users of GUI Layout Toolbox to transition smoothly, and we have several ideas on how to do this.

Hi David,
I have not yet installed the 2018b version, but I have read about the new object uigridlayout (https://it.mathworks.com/help/matlab/ref/uigridlayout.html).
Its functionalities seems very similar to your toolbox. Does this mean that for the uifigure you are going to develop a documented/internal implementation of the GUI layout toolbox functionalities?

Hi, I got a problem with the uix.Panel.
If the height of Scrolling Panel is set to 1806 or more, incorrect blank space will appear under the panel.
Can you help me solving this issue.
simple code that demonstrates the problem as is shown below.

f1 = figure('Units', 'normalized'); % Units arent pixels
sp1 = uix.ScrollingPanel('Parent', f1);
%p1 = uipanel('Parent', sp1);
p1 = uix.Panel('Parent', sp1);
sp1.Heights = 2000;
ViewAxes1 = axes(p1,'unit','pixels','position',[1 1 200 200],'XTick',[],'YTick',[],'visible','on','color','k');

Oli Fairfax

David, thanks for your comment. I have another interesting question... I am trying to overlay numerous axes so that each plot can have their own yaxis for clarity. I know the concept works (I've seen it before) but I am having difficulties with the GUI Layout Toolbox when it resizes using the Flex. I have put the axes in a VBox (which is in an HBoxFlex), forced the Positions to all be equal and set 'color' to 'none'. So far so good, but when I try to resize the parent HBoxFlex, all the axes reset back to being vertically stacked. I have tried putting them directly into a Panel but each new axes overwrites the previous one... Is there a way to use a callback from resizing so I can re stack them perhaps? Or another way of overlaying multiple axes? Thanks!

New release 2.3.4 fixes a bug in R2018b onwards that was causing unexpected reordering of contents due to an implementation subtlety of the axes toolbar.

The issue was noticed through internal here use at MathWorks, but I did not receive any customer bug reports. I guess that means that many of you are not on R2018b yet.

David Sampson

GUI Layout Toolbox is now the File Exchange submission with the most comments, if you consider v1 and v2. Thank you to the user community for providing feedback including bug reports and enhancement requests, and for asking and answering questions.

David Sampson

Oli, to delete all contents of a GUI Layout Toolbox container c, it's delete( c.Contents ). In most cases, c.Contents and c.Children will contain the same elements, so delete( c.Children ) will work too. (Contents also shows children with HandleVisibility off, like allchild( c ).) This is your only option for uipanel and uicontainer, since Contents is a GUI Layout Toolbox property.

David Sampson

Will, thank you for your interest in using GUI Layout Toolbox with the new MATLAB web graphics. I presume that you like the look of some of the new components that have been introduced in recent releases. I have recently done some further work on this, but cannot commit to a release date. It is technically challenging task!

David Sampson

Deepak, there is some discussion of using GUI Layout Toolbox in combination with GUIDE in the GLT documentation. However, as Adam says, once you are familiar with the programmatic workflow, there isn't much point in using GUIDE.

David Sampson

Roland, I think you want to be using a uix.CardPanel inside b2 to switch between Panel_one and Panel_two. You use set the Selection property of the CardPanel to switch -- c.Selection = 1 will show the first element of c.Contents, etc.

Two other remarks:
* uix.Panel does provide a Selection property, like uix.CardPanel. However, I regret that choice, and may remove it in a future release. I think that uix.Panel should simply maximize its contents and not touch their visibility.
* uistack will cause objects to be removed from and added to the tree, which will confuse GLT.

Oli Fairfax

Hi, how can I remove all contents (boxes) within a panel?

Will Grant

Any status updates on porting for use with App Designer?

Adam

Adam

I sometimes mix GUIDE and the GUI Layout toolbox by simply putting a place-holder panel in GUIDE that I will than use, within the code as a parent for layouts and other components I wish to add. It must be done programmatically though, within the panel so if you want to use layouts for the whole UI there isn't much advantage to using GUIDE.

HI,
I am using guide to design GUI for my project. I am wondering how can i use your toolbox inside guide GUI ?

Hi David,

I'm working on a GUI with stacked panels with tabgroups in a nested HBoxFlex and VBoxFlex.
To make switching between the two panels possible I set the propertie 'visible' of the switch panels to on and off. This results however in the fact that the tabs in the switch panesl stay invisible. After changing the size of the HBoxFlex they appear again.
Can you help me solving this issue.

simple code that demonstrates the problem as is shown below.
f=figure;

b=uix.HBoxFlex( 'Parent', f );
b1=uix.Panel('Parent',b,'Title', 'b1');
b2=uix.Panel('Parent',b,'Title', 'b2');

%Switch panel 1
Panel_one.c=uix.HBoxFlex( 'Parent',b2 );
Panel_one.c1=uix.Panel('Parent',Panel_one.c,'Title', 'c1-1');
Panel_one.c2=uix.Panel('Parent',Panel_one.c,'Title', 'c2-1');
Panel_one.e=uitabgroup( 'Parent', Panel_one.c2 );
Panel_one.e1=uitab('Parent',Panel_one.e,'Title','e1-1');
Panel_one.e2=uitab('Parent',Panel_one.e,'Title','e2-1');

%Switch panel 1
Panel_two.c=uix.HBoxFlex( 'Parent', b2 );
Panel_two.c1=uix.Panel('Parent',Panel_two.c,'Title', 'c1-2');
Panel_two.c2=uix.Panel('Parent',Panel_two.c,'Title', 'c2-2');
Panel_two.e=uitabgroup( 'Parent', Panel_two.c2 );
Panel_two.e1=uitab('Parent',Panel_two.e,'Title','e1-2');

pause(1)
set(Panel_one.c,'visible','off');
set(Panel_two.c,'visible','off');
pause(1)
set(Panel_one.c,'visible','on');
uistack(Panel_one.c,'top');
pause(1)
set(Panel_one.c,'visible','off');
set(Panel_two.c,'visible','off');
pause(1)
set(Panel_two.c,'visible','on');
uistack(Panel_two.c,'top');
pause(1)
set(Panel_one.c,'visible','off');
set(Panel_two.c,'visible','off');
pause(1)
set(Panel_one.c,'visible','on');
uistack(Panel_one.c,'top');

many thanks
Roland

He Zhu Zhu

Eddie, good suggestion to have a property to control row-major versus column-major. Column-major would remain the default for compatibility.

Eddie

Hi David, any chance of integrating the grid orientation options that I messaged you about? Currently the grid is ordered column by column, it'd be nice to have an option to order the gird row by row.

Current grid ordering (column by column) -
1 3
2 4

Row by row ordering (optional) -
1 2
3 4

My current workaround for row ordering is to change line 252 in Grid.m from
[iy, ix] = ind2sub( [r c], transpose( 1:n ) );
to
[ix, iy] = ind2sub( [c r], transpose( 1:n ) );

TADA

Finding this toolbox was almost like discovering JQuery back in the days of IE6
It doesn't cover everything but it does a great job, and it's object oriented! ^_^

So why isn't this part of Matlabs core?

Well done, stable and super useful to make GUIs layout flexible and changeable.

Thank you for this

Regards

Hermann

Sven, I have a few comments. Your description of the code suggests you are using something like version 2.2.1. The issue that you describe relates to the new "axes toolbar" in R2018b. A fix was released in version 2.3.3, which is the latest version.

Hitting a breakpoint that you didn't set is possible if you have dbstop if all error, or dbstop in <filename> if all error, or similar.

Yesterday I was notified of another issue with R2018b whereby the order of axes within Contents can be incorrect. We are investigating. If you hit this error then please post here or contact me directly via the author link above.

Sven

David: Perhaps it's already addressed in the stuff you've done this month however here's another reproducible strange behaviour likely to do with the change in the underlying axes objects in 2018b:

f = figure();
g = uix.GridFlex( 'Parent', f, 'Spacing', 5 );
axes( 'Parent', g)

Code above runs fine in 2018a.
No error is thrown but in 2018b the code stops within Grid.m at line 258 as if a breakpoint was placed there (it wasn't). Line reads "child.Units = 'pixels';"

Workaround is to wrap axes objects within a uicontainer:

f = figure();
g = uix.GridFlex( 'Parent', f, 'Spacing', 5 );
axes( 'Parent', uicontainer('Parent',g) )

Thanks David.

Matt, I have found and fixed the issue, and will include it in a release this month.

David, code to reproduce below.
---------------
% Buggy behaviour
f1 = figure('Units', 'normalized'); % Units arent pixels
sp1 = uix.ScrollingPanel('Parent', f1);
t1 = uicontrol('Parent', sp1, ...
'Style', 'text', ...
'String', 'Can''t scroll with mousewheel');
sp1.Heights = 1000;

% Expected behaviour
f2 = figure;
sp2 = uix.ScrollingPanel('Parent', f2);
t2 = uicontrol('Parent', sp2, ...
'Style', 'text', ...
'String', 'Can scroll with mousewheel');
sp2.Heights = 1000;

Matt, could you please share simple reproduction steps, either here or by email?

David,

Been using uix.ScrollingPanel in a recent project and have been having issues with mousewheel scroll not working. Seems to occur when the parent figure units are not pixels. Using 2017b.

Regards,
Matt

I installed the GUI Layout Toolbox 2.3.mltbx and it worked.

Hi everyone,

I'm new to matlab and I'm trying to run a script at the moment to which I'm also new.

I have the following error: Undefined variable "uix" or class "uix.HBox".

Could you please help me, is some package not installed properly or my Matlab does not support 'uix' ?

Cheers,
Vasil

yubin yu

David Sampson

Bryant, it appears that the issue that you have reported was introduced in GUI Layout Toolbox version 2.3.3. At least that's what my tests of various versions in R2018b is showing. If anyone is experiencing the issue in an earlier version of GUI Layout Toolbox then please post so that I can expand the search space.

David Sampson

Thanks Bryant for those minimal reproduction steps. Now we -- including the MATLAB Graphics team -- can investigate.

Bryant

David, I've sent via the snippet via email, but I figured I'd also share it here:

fh = figure();
vb = uix.VBox('Parent', fh);
ax = axes('Parent', fh);
ax.Parent = vb;

Error occurred while moving node between canvases

David Sampson

uix.BoxPanel inherits from uipanel which is the owner of the property 'TitlePosition'. Currently BoxPanel ignores this property value and always draws the title box at the top and the title at the left of the box. I could make BoxPanel honor TitlePosition and have created an enhancement request. This is not a trivial change.

David Barry

David,

I would like to center the title string in uix.BoxPanel and noticed the TitlePosition property but changing this property doesn't seem to do anything.

1) Is there a way I can center the title string?
2) What is TitlePosition property meant for?

Regards
David

David Sampson

Bryant, please send reproduction steps via my File Exchange profile to enable investigation.

Bryant

I'm seeing an issue in MATLAB R2018a reparenting any axes that has just been created.

"Error occurred while moving node between canvases"

There is an easy workaround of trying again after it fails the first time after a pause (or probably a drawnow, though I haven't tried it).

David Sampson

The latest update fixes a bug that was affecting users of MATLAB R2018b.

David Sampson

Hooman, this issue relates to the new "axes toolbar" in R2018b. I will put together a fix as soon as possible.

Thank you for all your hard work. I have released a signal processing toolbox that employs your GUI layout toolbox for visualization. However, one of our users has reported a bug that seems to be related to your toolbox. I appreciate if you could address it or shed some light on it to see how it might be resolved.

Bug report:
Operation System and Matlab version: MATLAB 2018b on Linux (Ubuntu 18.04).

Error report:
Warning: Error occurred while executing the listener callback for event ChildAdded defined for class uix.ChildObserver:
Unrecognized property 'Units' for class 'matlab.ui.controls.ToolbarStateButton'.

Error in uix.setPosition (line 13)
o.Units = u;

Error in uix.Panel/redraw (line 56)
uix.setPosition( obj.Contents_(selection), position, 'pixels' )

Error in uix.mixin.Container/set.Dirty (line 132)
obj.redraw() % redraw now

Error in uix.mixin.Container/addChild (line 222)
obj.Dirty = true;

Error in uix.mixin.Panel/addChild (line 88)
addChild@uix.mixin.Container( obj, child )

Error in uix.mixin.Container/onChildAdded (line 162)
obj.addChild( eventData.Child )

Error in uix.mixin.Container>@(varargin)obj.onChildAdded(varargin{:}) (line 51)
childObserver, 'ChildAdded', @obj.onChildAdded );

Error in uix.ChildObserver/addChild (line 109)
notify( obj, 'ChildAdded', uix.ChildEvent( oChild ) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver>@(~,e)obj.addChild(nChild,e.Child) (line 96)
@(~,e)obj.addChild(nChild,e.Child) );

Error in matlab.graphics.controls.AxesToolbar/parentToolbarToAxesPane

Error in matlab.graphics.controls.ToolbarController/handleMouseMotion

Error in matlab.graphics.controls.ToolbarController>@(e,d)obj.handleMouseMotion(e,d)
> In uix.ChildObserver/addChild (line 109)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver>@(~,e)obj.addChild(nChild,e.Child) (line 96)
In matlab.graphics.controls.AxesToolbar/parentToolbarToAxesPane
In matlab.graphics.controls.ToolbarController/handleMouseMotion
In matlab.graphics.controls.ToolbarController>@(e,d)obj.handleMouseMotion(e,d)

Bryant, see my response from 7 November 2017.

R2018b updates:
* A grid layout has been added to MATLAB. GUI Layout Toolbox users may want to take a look.
* Mouse events are supported for uifigures. Thus it will be possible to support flex containers for Javascript-based graphics from this release. Watch this space.

Bryant

Does this work with appdesigner? If not, will support be added?

Ian, saving figures containing GUI Layout Toolbox containers is not supported.

I have not looked at this issue for some time, but my recollection is as follows. The toolbox uses listeners to detect children being added and removed. Listeners are not serializable. It is possible to recreate listeners on loading by forcing the constructor to run, but at that time, the objects are not connected into the tree, and there is not a subsequent event in the loading process when they are added.

I can prevent the crash, but the resulting containers would be zombies.

Great toolbox.

I was wondering if it is possible to save the GUI generated by this toolbox as a '.fig' file.?
I have tried (see code below). It appears to save ok, but when I try to load the file, Matlab crashes with an access violation error message.
I have tried Matlab 2017b and 2018a.

Any advice / thoughts what might be causing this issue?

--------------------------------------------------------------
fig_name = sprintf('TEST Summary GUI ');
hMainFig = figure( 'Name', fig_name, ...'
'NumberTitle', 'off', ...
'position',[400 100 1000 800]);

% create a tab panel
tabTitle = [""];
hHorTabGrp = uix.TabPanel( 'Parent', ...
hMainFig, ...
'Padding', 0);

%% Define the summary tab
tabTitle(1) = "Summary";
hTabSum = uix.Panel( 'Parent', hHorTabGrp, 'Padding', 3, 'Title', '');
g1 = uix.GridFlex( 'Parent', hTabSum, 'Spacing', 3);
p1 = uix.Panel('Parent', g1);
panel{3} = uix.BoxPanel('Title', 'P3 - Phase', 'Parent', g1);
panel{4} = uix.BoxPanel('Title', 'P4 - Const', 'Parent', g1);

p2 = uix.Panel('Parent', g1);
set( g1, 'Widths', [-1 -2], 'Heights', [-2 -1] );

g2 = uix.GridFlex('Parent', p1, 'Spacing', 3);
panel{1} = uix.BoxPanel('Title', 'P1 - PolRot1', 'Parent', g2);
panel{2} = uix.BoxPanel('Title', 'P2 - Spectrum', 'Parent', g2);
set(g2, 'Heights', [-1 -1]);

g3 = uix.GridFlex('Parent', p2, 'Spacing', 3);
panel{5} = uix.BoxPanel('Title', 'P5 - Taps', 'Parent', g3);
panel{6} = uix.BoxPanel('Title', 'P6 - BER', 'Parent', g3);
set(g3, 'Widths', [-1 -1]);

fig_path = 'GUI_Test.fig';
savefig(hMainFig, fig_path);

Dani

David, would be nice to get that update (and not to depend on the PNGs). The reason why I have to use the uix.TabGroup is indeed because I need to disable tabs.

Adam

David Sampson

Dani, I have been reworking uix.TabGroup to use real uitabs, with a hack to simulate disabling. I want to get rid of the PNGs and the code that stitches them together. However I don't plan to backport this to GLT 1.x.

As a reminder to all, please use uitab and uitabgroup unless you require disabled tabs, or are writing code that needs to run prior to R2014b.

David Sampson

Ian, thanks for the feedback. Many have now requested such support. I have been looking at this.

Dani

I like the more rectangular look of the standard uitab in Matlab more than the curly version used here. Would be nice if there would be a choice to select one or the other look. I know I can modify the PNGs in Resources, but I will still lack the top horizontal line.

yijiawanjia

Ian

Are there any plans to update this to deal with uifigure and friends (or release a seperate toolbox for that)? I think there are several advantages to the new GUI system, yet programmatic use is still tedious without the help of a toolbox like this!!!

Thanks David and Ben for such a great toolbox!

Harald Voit

David,
That was indeed the problem. I download V2 and now it's perfectly working.
Thanks a lot !

David Sampson

Remy, there are two versions of GUI Layout Toolbox:
* Version 1.x, at https://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox, for MATLAB R2014a and earlier
* Version 2.x, at https://www.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox, for MATLAB R2014b and later

Your error suggests that you are using 1.x with R2014b or later. To confirm:
* >> ver matlab will report the MATLAB version
* >> ver layout will report the GUI Layout Toolbox version

Hello David,

I just download your toolbox which looks very usefull, however each time I try a function as "uiextras.VBox()" I got the following issue : No constructor 'handle.listener' with matching signature found.

Do you know where the problem might come from ?

thanks,

I must have missed that, thank you for the quick reaction

Florian, it sounds like you are experiencing issues with legends. Are your axes with legend inside a uicontainer, as per section 2.3 "colorbars and legends" of the GUI Layout Toolbox documentation?

Ian, docking and undocking is supported for uix.BoxPanel but not uix.TabPanel. Are you looking for something along the lines of what we provide for figure docking in the MATLAB desktop. I know that we are looking at providing something along those lines.

Great tool!

Anyone else has problems using 'DisplayName' in a plot and then legend('-DynamicLegend')?

Excellent Toolbox.
David, I would like to dock/undock different tabs, where each tab contains a plot.
I have tried editing the "dockexample.m" but I run into the error "There is no DockFcn property on the Panel class."
Is this possible? is there a workaround?

David Max

Very Good!

LSalvation

lin yim

David Sampson

Great hack, Mohammad. Looks like CData NaN(1,1,3) sets the checkbox to a single, transparent pixel. There is a small amount of padding on the left edge, but that's fine.

https://undocumentedmatlab.com/blog/transparency-in-uicontrols

Tyler Cumby

Adding to Mohammad's cross-platform validation: I found the same results on Linux, MATLAB 2017b and Windows 10, MATLAB 2018b prerelease.

David, I have a suggestion that may help fix the box panel title issues. As far as I know, you are using checkboxes for the box panel title and dock/minimizer tools and you try to offset the position based on MATLAB''s version and operating system such that the checkbox icon is hidden. I just simply came across a solution to hide the checkbox without offsetting. I wasn't sure if you are aware of this, so I just thought to share. This is simply done by setting the 'CData' property of a checkbox to NaN(1,1,3). I just tried the following code on Mac and Windows 10, MATLAB 2017b and the results were identical (https://image.ibb.co/mA5qZo/david.png).

figure;
uicontrol('Style','checkbox','Position',[10 10 50 15],'String','ABC','Background','c');
uicontrol('Style','checkbox','Position',[10 30 50 15],'String','ABC','Background','c','CData',NaN(1,1,3));

IM NOT FISH

Seb Biass

I did try what you suggested earlier. It did not make the ellipsis disappear, it only shifted it forward by the number of trailing spaces added to the end of the title string. So if the title was originally "Sample" and was printed as "Sam...", adding 5 spaces would make it print like "Sample ..."

Mohammad, as an alternative, can you check whether reverting to the original margin and adding a trailing space to the title works? Unfortunately it looks like you have identified a case where on-screen and printed behaviors differ.

Thanks David. I fixed the problem by changing the margin to 22. When it was set to 20, everything looked fine visually on screen and the ellipsis was showing up only when I was saving the figure (I tried both png and pdf). After changing it to 22, this did not happen anymore but the label got too close to the edge so I fixed it by adding a single space to the beginning of my boxpanel title strings with an ismac if statement.

David Sampson

Michele, a good question on managing dependencies. Personally I do not favor bundling GUI Layout Toolbox with your application. If everyone did that then the last installed toolbox would win, and it would be hard to tell which version was running. Rather, I suggest that you check for GUI Layout Toolbox in your code, and help the user get it if they don't have it.

For checking:
v = ver( 'layout' )

For retrieving:
web( 'https://www.mathworks.com/matlabcentral/fileexchange/47982-gui-layout-toolbox' )
The URLs of the submissions themselves are of the form
https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/47982/versions/12/download/mltbx
but there is no way to ask what for the number of the latest version.

Within MathWorks, we have been discussing adding dependency-aware toolbox management features to MATLAB, and we have been working with large companies on implementing internal toolbox stores.

David Sampson

Mohammad, oh that is annoying. The title is rendered as a checkbox so that it can be clicked, but I need to offset it so that only the string is visible. The offset required is a magic number that varies with both platform and MATLAB version. If the offset is wrong then there is not enough room for the label and you see an ellipsis. The offset is specified in the helper function checkBoxLabelOffset in uix.Text. You should see that the number is 20 for Mac. Could you please play around a bit and see whether a different number works better for you? I do not have easy access to a Mac.

Thanks for your support and quick feedback David. I actually used the contact button on your profile to send you a private message a few days ago regarding the issue I shared with you but I'm not sure if it ever reached you. I am using your toolbox version 2.3.2 and MATLAB R2017b on latest version of Mac OSX. It'd be great if you have any solution to the boxpanel title problem.

Hi David, I have created a toolbox using the GUI layout toolbox for the GUI (https://www.mathworks.com/matlabcentral/fileexchange/67508-kview-interface-for-signal-data-easy-visualization-and-processing)
At the moment of packing my toolbox I have a dilemma: what should be the best practice to pack my toolbox that depends on yours?
One obvious solution could be to insert the +uiextras folder inside my toolbox. But if someone has already installed your toolbox then he wil have duplicated functions. That can be annoying.
I have also tried to place +extras into a private subfolder but that does not work with + folders.
Another thought was to pack your .mltbx inside my toolbox (I have to zip it or it won't be packed); then if your toolbox is not detected when the GUI is launched, an error dialog will give the possibility to automatically install it.
At the moment what I do is simply check if your tollbox is installed and if not throw an error where I give a link to this page to download it. It could be perfect if I could send the user to right page on the addon-explorer, this will make the process very friendly.

Do you have any particular suggestion?

David Sampson

Blanca, GUI Layout Toolbox supports a programmatic workflow. It is not a GUIDE add-on. Please take a look at the documentation to learn about how GUI Layout Toolbox works and whether it will help you to be more productive.

Hi, I have downloaded this toolbox and installed it. I do not see any change in the GUIDE interface, nos new features appear. How can I solve this?
Thanks!

David Sampson

Mohammad, great looking GUI. There has been an issue with truncated box panel titles on MacOS but I thought that it was fixed in version 2.3.2, released last week. If you have the latest version and are still experiencing the issue then please contact me via the "contact author" button and we can look into it.

Hi David,
thanks for this flawless toolbox, it has made my life making a GUI much easier. There's only one issue I'm having with the BoxPanels. When printing the GUI to pdf, the title of the boxpanels are not displayed correctly and the last few letters are randomly cut off. Take a look at the following figure (the top is what I see on screen, and the bottom is what is saved as pdf)
https://ibb.co/i7F5fo

p.s. I'm using MATLAB on Mac OS and here's part of my code

GUI.BottomContainer = uix.HBox('Parent',GUI.MainContainer,'BackgroundColor','w','Spacing',5,'Tag','BottomContainer');
GUI.ExportPanel = uix.BoxPanel('Parent',GUI.BottomContainer,'Title','Export Settings', 'BackgroundColor','w','FontWeight','bold');
GUI.FCWPanel = uix.BoxPanel('Parent',GUI.BottomContainer,'Title','3D Figure Control Widget (FCW)','BackgroundColor','w','FontWeight','bold');
GUI.SimulationPanel = uix.BoxPanel('Parent',GUI.BottomContainer,'Title','Dynamic Simulation Settings', 'BackgroundColor','w','FontWeight','bold');
GUI.ResultsPanel = uix.BoxPanel('Parent',GUI.BottomContainer,'Title','Results & State Variables', 'BackgroundColor','w','FontWeight','bold');
GUI.BottomContainer.Widths = [-1 -4 -5 -15];
GUI.BottomContainer.MinimumWidths = [100 375 0 0];

Qazi Nuhman

Hi David,
you can add one more people to those interested in a GUI layout toolbox for apps (uifigure).
I am exploring the possibility to port some GUI I have in uifigure format.

Carsten, when I said panel, I meant GLT container, which could in turn be placed inside another GLT container.

I'm aware, that I could do it the way you propose, but I would then have to manually take care of the size, position and resizing, etc.. The GLT is so nice because as it does all these things for you!

But many thanks for your comment - I will code it "manually".

Carsten, your question is not specific to GUI Layout Toolbox. You need to create a popup menu and a list box, with the popup menu callback setting the list box strings. Furthermore, since the popup menu and list box go together, you might put them in a panel, and create a custom class to represent that component.

Hi,

Thanks for a great toolbox!

I have a construction like this:

LevelTypes = {'Level 1','Level 2','Level 3'}
txt{1} = {'L1 - a','L1 - b','L1 - c','L1 - d'};
txt{2} = {'L2 - 1','L1 - 2'};
txt{3} = {'L3 - i','L1 - ii','L1 - ii','L1 - iii','L1 - iv','L1 - v','L1 - vi'};

fig = figure;
vbox = uix.VBoxFlex('Parent',fig, 'Tag', 'vbox');

% Create some panels (one for each LevelTypes) each with one listbox.
% Use the panel-title to show which "item" (LevelType) the listbox concerns
N = numel(LevelTypes);
for lno = 1:N
panel_Listbox(lno) = uix.Panel('Parent', vbox, 'Padding', 5, 'BorderType','none', 'Tag', ['panel_Listbox',int2str(lno)], 'Title', LevelTypes{lno});
uicontrol('Parent', panel_Listbox(lno), 'Style', 'listbox', 'String',txt{lno});
end

Now my problem:

I want the title ( i.e. the “item”) to be a popup-menu instead of just an inactive title. The users selection in the popup-menu will then decide the content of the corresponding listbox.

Is this possible and how can I make this happen?

Kind regards
Carsten

Version 2.3.2 of GUI Layout Toolbox is now available. Highlights:
* Configure box panel tooltips
* Non-zero default spacing for containers with draggable dividers
* Use variable-sized contents in scrolling panels
* Fixed bug displaying box panel title on Mac

David Sampson

Christian, thanks for clarifying. Effectively you want subplot-like behavior combined with GLT-style layouts. I will think about whether I can make this easier although there are some technical hurdles due to the way that subplot is implemented.

David - Thank you for making GLT! And thank for your input.
In answer to your question... I think maybe the 'difference' in what I'm after is, that I don't want each of the axes-objects to take up as much space as they individually can, because I want the axes to line up vertically. I am building an interface that allows viewing and scrolling through recordings from a device that simultaneously records multiple signals. I display these signals on a number of axes-objects, one axes-object per BoxPanel, distributed vertically in the GUI. And I want exact alignment of the axes objects, so the signals line up in terms of time displayed.
If I allow each axes-object to individually fill out the BoxPanel (or uicontainer) I will not get that alignment, since the individual decorations may take up different amounts of space. That is why I want to specifically set positions within the BoxPanels, so axes-objects line up vertically across the GUI.

In any case, as mentioned before, problem has been solved. I gave the uicontainers a go, but so far they don't seem to be a must. I will keep your advice in mind, and add them if I observe undesired bahaviour. Thanks!

David Sampson

Christian, some additional comments, and a question. All GLT containers lay out their contents. So if you have axes in a BoxPanel, they will fill it, and resize when the BoxPanel resizes. You should not set Position of GLT container children directly, because you can expect the container to change these positions on resize.

Whether the axes decorations are clipped or not will depend on the ActivePositionProperty of the axes -- 'position' to show just the axes, 'outposition' to show the decorations too. There is more information on this in the documentation. Normally you would want axes to fill a BoxPanel, and possibly add some padding, so I wonder what you need that is different.

The SizeChangedFcn property comes from the fact that GLT containers are subclasses of uicontainer. I would not advise hooking custom code to reposition contents into GLT container SizeChangedFcn, since that is what the container itself provides. Instead, as Robyn suggests, put a plain uicontainer into the BoxPanel and hook into the uicontainer SizeChangedFcn.

Robyn - thank you for your feedback! Turns out the BoxPanel actually has a SizeChangedFcn callback property. It just wasn't listed explicitly in the documentation, although it states that "The properties available are largely the same as the builtin UIPANEL object."
Problem solved.

Robyn Jackey

Christian - you may be able to achieve this placing the axes inside a uicontainer, and the uicontainer on the BoxPanel. Then use the SizeChangedFcn on the uicontainer to do what you want.

Excellent toolbox! Thank you!
It would be great to have a callback function for the Flex boxes, when the divider has been dragged. Inside a VBoxFlex I have a number of BoxPanels, and the BoxPanels each has axes with a specified position and size. But if I drag a divider, the axes suddenly fill out all of the BoxPanel, cropping the tick labels. A callback on the divider could help put things in order again. (This issue with axes suddenly taking up the entire BoxPanel space, also happens when resizing the figure window containing the BoxPanels - however, in this case it can be fixed through the figure resize callback.)
Using R2017b.

Yang Tao

Great toolbox! It would be wonderful if it supports figures created by uifigure. I wish you have a plan for this. Thank you.

Stanislav, it sounds like one of your operations is causing the axes to be unparented and reparented. Can you please send specific reproduction steps to me directly? Thanks!

lcy_joe

Hi,
I have a strange bug:
Assuming I created a VBox with, say, 8 axis objects: 1, 2, ..., 8.
If I place a data point on one of the axes the order flips, i.e. it becomes 8, 7, ..., 1 !
Placing more data points has no effect and the order of the axes stays reversed (8, 7,..., 1).

Any ideas what might be causing this?

Sebastian

Luc, usage logging gives me an indication of total usage trends, and what toolbox versions, MATLAB versions, and operating systems are prevalent among users. Usage logging is voluntary, and no personally identifiable information is sent.

Bowoon, I agree with your observation that responsiveness of uitables with lots of HTML content is sluggish. This is a uitable issue, not a GUI Layout Toolbox issue. I expect that each HTML-containing cell gets its own JxBrowser.

Many of us have wanted more formatting control in uitables for many years. Background colors and editability are top of my list. There is now a uitable component in the new Javascript-based graphics system, and the team is accepting enhancement requests, so please lobby your local MathWorks application engineer, etc.

HTML content is nice because it doesn't require custom Java code, but it offers limited functionality. Another option is to write MATLAB wrappers for custom Java tables. This requires quite a bit of knowledge and experience, though. Your local MathWorks consultant is likely to be able to help.

Curtis, thank you for your interest in GUI Layout Toolbox with Javascript-based graphics. Please see my post from 7 November 2017. If others are interested in this capability then please post here.

To keep expectations in check, there is not yet any compatibility layer between Java- or Javascript-based graphics. For example, Java uicontrol('Style','pushbutton',...) is Javascript uibutton(...).

Which usage do you make for data sent to google analytics ?

Are there any plans to add support for uifigure?

not downloading.... any idea whats wrong?

ping lu

Hi,
I got a problem with the HboxFlex:
When creating a GUI with a panel hosting the HboxFlex with two holders for images, I experience a problem with the pointer image that was stuck on the ‘left’ state, the ‘unset’ maybe don’t work in the pointer manager?

A quick fix I’ve done is by replacing ‘unset’ with ‘arrow’ in the updateMousePointer function of the HBoxFlex file

bowoon kim

Johannes

Hello,
I have a problem with multiple axes as it does not show the second one. Without the layout box it works properly.
Here is my code:
f1 = figure(1);
hv = uix.VBox('Parent', f1);
hAx1 = axes('Parent', uicontainer('Parent',hv));
hAx2 = axes('Position',hAx1.Position,'XAxisLocation','top','YAxisLocation','right','Color', 'none','XColor','r','YColor','r');

f2 = figure(2);
hAx3 = axes('Parent', f2);
hAx4 = axes('Position',hAx3.Position,'XAxisLocation','top','YAxisLocation','right','Color', 'none','XColor','r','YColor','r');

What am I doing wrong?
Thank you very much.

Bryant, there are no current plans to move development of GUI Layout Toolbox to GitHub at present. Interesting idea though.

Hello,

I am trying to add a legend to the dockexample as shown below. But when I do this, the plot gets erased and I can only see the legend notations on the axes. How do I plot and add a legend.

Please see the code below

function dockexample()
%DOCKEXAMPLE: An example of using the panelbox dock/undock functionality

% Copyright 2009-2013 The MathWorks Ltd.

% Create the window and main layout
fig = figure()
box = uix.HBox( 'Parent', fig );

uicontrol( 'Style', 'listbox', 'Parent', box, 'String', {'Item 1','Item 2'} );

% Add three panels to the box
panel{1} = uix.BoxPanel( 'Title', 'Panel 1', 'Parent', box );
panel{2} = uix.BoxPanel( 'Title', 'Panel 2', 'Parent', box );
panel{3} = uix.BoxPanel( 'Title', 'Panel 3', 'Parent', box );

% Add some contents
uicontrol( 'Style', 'PushButton', 'String', 'Button 1', 'Parent', panel{1} );
uicontrol( 'Style', 'PushButton', 'String', 'Button 2', 'Parent', panel{2} );
box1 = uix.VBox( 'Parent', panel{3} );
box2 = uix.HBox( 'Parent', box1 );
uicontrol( 'Style', 'PushButton', 'String', 'Button 3', 'Parent', box1 );
uicontrol( 'Style', 'PushButton', 'String', 'Button 4', 'Parent', box2 );
uicontrol( 'Style', 'PushButton', 'String', 'Button 5', 'Parent', box2 );

% Set the dock/undock callback
set( panel{1}, 'DockFcn', {@nDock, 1} );
set( panel{2}, 'DockFcn', {@nDock, 2} );
set( panel{3}, 'DockFcn', {@nDock, 3} );

axes1 = axes( 'Parent', panel{1})
theta = 0:360;
plot(axes1,theta, sind(theta), theta, cosd(theta))
legend('sin','cos')

%-------------------------------------------------------------------------%
function nDock( eventSource, eventData, whichpanel ) %#ok<INUSL>
% Set the flag
panel{whichpanel}.Docked = ~panel{whichpanel}.Docked;
if panel{whichpanel}.Docked
% Put it back into the layout
newfig = get( panel{whichpanel}, 'Parent' );
set( panel{whichpanel}, 'Parent', box );
delete( newfig );
else
% Take it out of the layout
pos = getpixelposition( panel{whichpanel} );
newfig = figure( ...
'Name', get( panel{whichpanel}, 'Title' ), ...
'NumberTitle', 'off', ...
'MenuBar', 'none', ...
'Toolbar', 'none', ...
'CloseRequestFcn', {@nDock, whichpanel} );
figpos = get( newfig, 'Position' );
set( newfig, 'Position', [figpos(1,1:2), pos(1,3:4)] );
set( panel{whichpanel}, 'Parent', newfig, ...
'Units', 'Normalized', ...
'Position', [0 0 1 1] );
end
end % nDock

%-------------------------------------------------------------------------%
function nCloseAll( ~, ~ )
% User wished to close the application, so we need to tidy up

% Delete all windows, including undocked ones. We can do this by
% getting the window for each panel in turn and deleting it.
for ii=1:numel( panel )
if isvalid( panel{ii} ) && ~strcmpi( panel{ii}.BeingDeleted, 'on' )
figh = ancestor( panel{ii}, 'figure' );
delete( figh );
end
end

end % nCloseAll

end % Main function

Shane L

bowoon kim

Dear David, Thank you very much for the great work.

When I resize my figure including HTMLs, the speed is very slow.
My code is now similar in form to this;

h = figure(10);
tb = uix.TabPanel('Parent',h);
panel(1) = uix.Panel( 'Parent', tb, 'Padding', 5 );
panel(2) = uix.Panel( 'Parent',tb, 'Padding', 5 );
panel(3) = uix.Panel( 'Parent',tb, 'Padding', 5 );

for k =1:3
vbox = uix.VBox('parent',panel(k));
for j=1:2
listbox = uicontrol('style','listbox','max',100,'Parent',vbox);
rn = rand(50,2);
for i=1:50
s{i} = ['<html><tr class="4"><td bgcolor="rgb(254,198,183)" width="30" align="center">',num2str(rn(i,1)),'</td><td>',num2str(rn(i,2)),'</td></tr></html>'];
end
set(listbox,'String',s)
end
end

Markus

David many thanks for your quick answer. Will there possibly be a GUI for this toolbox in the future, similar like the App designer or QT designer?

Sorry, it is not planned to publish this because it is an internal company development.

Bryant

Are there any plans to put this on GitHub and start accepting pull requests?

David Sampson

Markus, I am planning a release in March. Sorry it has been a while. GUI Layout Toolbox is very much alive and well. However I don't have any massive new features planned, since most use cases can be addressed by using various combinations of containers. What requests do people have?

David Sampson

Bryant, the issue that you describe has been reported as an issue with box panel titles, and I have a fix. However, uix.Text is undocumented... caveat emptor.

Markus

David short question:
Has the development of the "GUI Layout Toolbox" been discontinued or will it be further developed? I ask because I plan to write a more complex GUI but the last update was 13 months ago.

Many thanks

Bryant

Something I've noticed: uix.Text elements look poor on macOS, cutting off the text and leaving some of the checkbox visible.

Thank you Isaac, we will correct these documentation issues in the next release.

There are two little bugs in the function "nDock" of "4.3 Dock and undock" in "User Guide" (Version 2.3.1):
1. `IsDocked` is no longer a property of `uix.BoxPanel`. It should be replaced by `Docked`.
2. `set( p{whichpanel} ...)` should be `set(panel{whichpanel})`

Also, in the beginning lines of the function `dockexample`:
You may need to add `panel = {};` before assign values to it, or an error may appear.

Thanks a lot for your amazing work!

David Sampson

Yuri, you may have seen a discussion of this topic at:
https://undocumentedmatlab.com/blog/transparent-uipanels

If you had a transparent uipanel, how specifically would you use it? (I am interested in whether there are other solutions that would support your requirements.)

Bell Sam

Dear David,
I was just looking for a way of making transparent panels, to be able to manage the background behind the UI panels. I found in the comments other people looking for the same thing. Please, make us all happy and add such functionality to this beautiful toolbox. Thanks

David Sampson

Sherif, that is an obscure error. I have been asking around internally but no suggestions yet. If I get any information then I will post it.

Additional information to my previous post: I got the error with Matlab R2017b. No errors when the program is compiled with Matlab R2016b

Neelakanthu, at present, you cannot use GUI Layout Toolbox with App Designer. We are working on incorporating layout management features along the lines of GUI Layout Toolbox with the Javascript-based ("new") graphics used by App Designer, for both interactive and programmatic workflows.

Until then, I have also been working on porting GUI Layout Toolbox to work with new graphics. If there is interest in the user community then I could consider making that available. Compared to the Java-based graphics, mouse events are not yet exposed, so no draggable dividers. Also, some performance optimizations that are present in Java-based graphics are not yet implemented in Javascript-based.

Hi David Sampson ... How can use this toolbox with Appdesigner. Is it possible?

Hi David - Thank you very much. I hope I have send you a message with the information now :-)

David Sampson

Kasper, we had some reports of this problem earlier, and made some changes to address it. Specifically, the issues were on Mac with Retina displays. I don't recall if there was any variation with MATLAB version.

Can you please get in touch with me directly via the "contact" button on my File Exchange profile page, with details of: OS, MATLAB version, toolbox version, and display settings.

Works very well. One question in relation to the BoxPanel title property. In the following example the upper box panel will have a title displaying "T...." and the lower will have a title displaying "Test ...". Why is the whole title not displayed, even when there is enough space for it?
f = figure, vb = uix.VBox('parent',f), uix.BoxPanel('Parent',vb,'title','Test'), uix.BoxPanel('Parent',vb,'title','Test Bla')

Sebastian

Great work! Thanks!

David Sampson

Matt, are your axes with legend inside a uicontainer, as per section 2.3 "colorbars and legends" of the GUI Layout Toolbox documentation?

Matt

Love the toolbox. Has anyone else had a problem with putting a legend on an axes while using this. I get -

Warning: Error updating Legend.

Attempt to modify the tree during an update traversal
I do not get this error when adding a legend to an axes within a figure outside of the gui.

felinsinap

felinsinap

That's an absolut nice toolbox. It is possible to implement a solution that the 'Padding' property could also allow a vector of size 1x4 to use it like [left right above below] and if the padding is scalar, all values inside the vector will be equal to that value?

Thanks David, I appreciate your continuing support of this toolbox. Your suggestion was one of the versions I trialled but in the end I went with assigning a uicontainer to each element of my uix.Grid objects and then assigning the axes to each uicontainer. (I believe this was suggested a few comments down). I wanted to continue to use the uix.Grid object as it offers a lot in terms of layout and expansion (i.e. if there are suddenly 10 quantities to plot instead of 6) and I really want to maximise the size of the data on the screen which can be a bit fiddly with subplots . (Hence why I looked into "subplotplus"). My code is now similar in form to this:

x = 0:0.1:10; % some data

f = figure(); % initialise figure
g = uix.Grid('Parent', f); % create uix.Grid object
u = gobjects(1, 6); % preallocate variable for uicontainers
for iG = 1 : 6 % loop through number of quantities and create an axes for each quantity
u(iG) = uicontainer('parent', g, 'Units', 'normalized', 'Position', [0 0 1 1]);
axes(u(iG))
plot(x, sin(iG.*x)) % plot data
legend(sprintf('y = sin(%ix)', iG)) % add legend
end
set(g, 'Widths', [-1 -1 -1], 'Heights', [-1 -1]); % set uix.Grid formatting

Christophe

David, thank you for your reply. I have two boxplots in a VBoxFlex object. On one of the boxplot, I have an axes, I would like to detect when the divider moved because I want to change the axes limits (XLim and YLim) according to the height of the boxplot.

Hi David,

On the topic of dividers, I would also have liked to have an event for "divider moved". The purpose is to remember the position of the dividers after they have been moved by the user, so the GUI can be re-opened with the same layout. To do that at the moment I wait for the objects to be deleted (Gui being closed) and save the widths/heights at this point.

David Sampson

Chris, for simple cases, you can use subplot within a standard uipanel, and in turn, put that panel inside a GUI Layout Toolbox container. For example:

f = figure();
b = uix.HBoxFlex( 'Parent', f, 'Padding', 10, 'Spacing', 10 );
p = uipanel( 'Parent', b, 'Title', 'My Panel', ...
'Units', 'normalized', 'Position', [0.1 0.1 0.8 0.8] );
x = 0:0.1:10; % some data
a11 = subplot( 2, 2, 1, 'Parent', p );
plot( a11, x, sin( x ), 'b-' )
legend( a11, 'blue' )
a12 = subplot( 2, 2, 2, 'Parent', p );
plot( a12, x, cos( x ), 'r--' )
title( a12, 'No legend' ) % but title
a21 = subplot( 2, 2, 4, 'Parent', p );
peaks();
legend( a21, 'peaks', 'Location', 'northeast' )
a22 = subplot( 2, 2, 3, 'Parent', p );
plot( a22, x, tan( x ), 'g-.' )
legend( a22, 'green' )
c = uicontrol( 'Parent', b, 'FontSize', 50, 'String', 'Push!' );
b.Widths(2) = 300;

Let me know if that meets your needs.

David Sampson

Christophe, no there is not a callback for mouse over divider, divider moving, or divider moved. It would be helpful to understand what specifically you are looking to do, and whether it is modifying or augmenting the current behavior.

Christophe

David, great toolbox. I have been using the toolbox for a while now and I would like to know if there is a callback function for the divider ? I would like to run a function when the user clicks on the divider. If there is no callback, how can I easily know if the pointer is on top of the divider ?

David, thank you for an excellent file submission. This package was recommended to me by one of your consultants Philip Rottier and I must say it is very easy to use and very well documented.

My one concern is the difficulty with adding legends to axes inside some of the uix objects. Currently, I am trying to create a 2x3 grid of axes using the uix.Grid object and would like to assign a legend to each axes, however, when I do this I end up with 12 objects in total (6 axes and 6 legends).

I had some limited success with assigning 6 uix.Panels to the uix.Grid object and then embedding the axes and legend inside a uix.HBox/uix.VBox but the formatting is not as clean as a simple MatLab axes/plot/legend sequence. My current fix is to use another FEX function "subplotplus.m" to generate my grid of subplots and assign these to a normal uitab object. Not as pretty but it will do for the meantime.

Your mention of a new object similar to the uiaxes component sounds ideal and would really compliment an already excellent toolbox. I look forward to when this capability is added.

David Sampson

Eugen, the programming model for GUI Layout Toolbox is that sizes of contents are specified through properties of the parent container. Can you please provide some more information on how you want to specify contents sizes and how you expect contents positions to change when the parent resizes so that we can advise on how this could be achieved (or not) with GUI Layout Toolbox?

Drew, no progress on supporting axes with legends as direct children of a GLT container. For layout purposes, you really need something that contains both the axes and the container.

This past week, I have been looking at getting GUI Layout Toolbox working with the web graphics system that underpins App Designer. Here there is a new component -- uiaxes -- that contains both the axes and its associated items (e.g., legend).

Hi David,
great work. I'm trying to implement this in one of my GUIs I wrote and currently it is a bit frustrating. So far I was always placing everything manually and created kind of GUI objects which are packed into a panel. These "objects" should be fixed in size and I don't want to have a scaling, but it would be great to arrange these panels automatically, so I wouldn't have to worry about exact position in the figure anymore. Is it possible to include panels with fixed size into HBox or Grid, without using the Widths and Heights property?
Thanks,
Eugen

DrewVam55

Hello David,

I have used this in a few different GUIs now and have loved it. Did you ever come up with a solution to uicontainer being needed for appropriate legend behavior?
I need legends for a GUI, but the uicontainer and associated axis/legend seem to resize poorly within my VBox, getting cut off on the top after the figure shrinks considerably as opposed to resizing the axes. I have tried making the uicontainers the direct children of my VBox as well as wrapping them in a Panel or Box. Also, my ItemHitFcn (clickToggleVisibility) for my legend in these uicontainers does not seem to work within the GUI Layout Toolbox, but I'm not sure if that's a GUI Layout Toolbox issue.

Thanks,
Andrew

David Sampson

Martin, I believe that prior to R2014b, it was possible to set the BackgroundColor of a uipanel to 'none'. For example, see http://undocumentedmatlab.com/blog/transparent-uipanels. However, from R2014b, that is no longer the case. I will capture this as an enhancement request.

David

Great Toolbox, I’ve been using it for several years now (including the pre 14b release).

I have very much enjoyed controlling the layout with HBoxes, VBoxes, etc, but now I’d like to put an image as a background to the whole GUI. Unfortunately, I can’t seem to find a way to make the Hboxes / Panels transparent, so that the image in the background is visible. I know how to make uicontrols and text labels transparent (thanks to Yair’s undocumentedmatlab.com blog), but I’m struggling to make uipanels transparent. Can you think of a way how to have a GUI with background image while utilizing your great toolbox?

David Sampson

Alain, regarding uitab versus uix.TabPanel, please see my reply to Tim dated 14 April 2017.

ScrollingPanel slider positions are controlled by properties VerticalOffsets and HorizontalOffsets.

Very Nice Toolbox. Have worked with version 2.2 so far and extended the uix.TabPanel so that the BackgroundColor is applied to the dividers UIControl too:

Index: TabPanel.m
===================================================================
--- TabPanel.m (revision 336)
+++ TabPanel.m (working copy)
@@ -79,7 +79,8 @@

% Create dividers
dividers = matlab.ui.control.UIControl( 'Internal', true, ...
- 'Parent', obj, 'Units', 'pixels', 'Style', 'checkbox' );
+ 'Parent', obj, 'Units', 'pixels', 'Style', 'checkbox',...
+ 'BackgroundColor', obj.BackgroundColor);

% Create listeners
backgroundColorListener = event.proplistener( obj, ...
@@ -795,6 +796,9 @@

function onBackgroundColorChange( obj, ~, ~ )

+ % propagate to dividers ui element
+ set(obj.Dividers, 'BackgroundColor', obj.BackgroundColor)
+
% Mark as dirty
obj.Dirty = true;

Hi David
Fantastic Toolbox!!! However some questions.
Using uix.BoxPanel( ) same remark as Team. It would be nice to have the solution within this toolbox without refering to uitab.
Using uix.ScrollingPanel( ) how to set properly the slider initial position (hiden property perhaps)
I have probably missed Something with uix.ScrollingPanel trying to scroll many axes with some fixed number visible at the same time on screen. See the following m file. Best regards. Alain
function TestUIEXTRA(Flag)
if nargin==0, Flag=1;end
close all
f = figure('Name', 'Scrolling sevral axes' ,'unit','norm','outerposition', [0 0 1 1]);
p = uix.ScrollingPanel( 'Parent', f );
hh=uipanel('parent',p);
hhpos=getpixelposition(hh);W=hhpos(3);H=hhpos(4);y=0;
ns=3;%I want 3 axes visibles at the same time (on screen)
n=8;%total number of axes
ax=gobjects(n,1);
%first possiblilty
if Flag
for k=1:n
ax=axes('parent',hh,'unit','pixel','outerposition',[0 y W H/ns]);y=y+H/ns;
title(num2str(k))
end
end
set( p, 'Widths', .98*W, 'Heights', n*H/ns, 'HorizontalOffsets', 0, 'VerticalOffsets', 0)
%second possiblity axes are set up after the p settings
if Flag~=1
for k=1:n
ax(k)=axes('parent',hh,'unit','pixel','outerposition',[0.025*W y .95*W H/ns]);y=y+H/ns;
title(num2str(k))
end
end
% very strange results in any case but different
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Brecht

confirmed David, the problem is still there without GUI layout :
fh = figure;
uipanel('Parent', fh, 'Position', [0 0 0.5 1], 'Title', 'Control');
uipanel('Parent', fh, 'Position', [0.5 0 0.5 1], 'Title', 'Depth');

Dani, Yannick, that doesn't sound like a GUI Layout Toolbox issue per se. Can you please confirm whether you see the same effect with two uipanels side-by-side:
fh = figure;
uipanel('Parent', h_hbox, 'Position', [0 0 0.5 1], 'Title', 'Control');
uipanel('Parent', h_hbox, 'Position', [0.5 0 0.5 1], 'Title', 'Depth');

Dani

Thanks Yannick. Works.

Dani, I had the same issue. I now use 'FontName', 'Arial' for all my GUI's.

Dani

If I run the code below then the (top) lines surrounding the panels are not aligned properly. If I change the title of the second panel to 'CDepth' then they are, i.e. it is related to the title text. Any way to fix this?

fh = figure;
h_hbox = uix.HBox('Parent', fh);
uix.Panel('Parent', h_hbox, 'Title', 'Control');
uix.Panel('Parent', h_hbox, 'Title', 'Depth');

GianCarlo

ali kermani

The class "uiextras" is undefined.
Perhaps Java is not running.

This text pops up while running a MATLAB code. How can it be solved?

lv

David Sampson

Josh, see section 6 of the GUI Layout Toolbox documentation, "Deploying GUIs using the MATLAB Compiler".

David Sampson

Grzegorz, yes you can, provided you abide by:
1. The MathWorks, Inc. software license agreement (see Help > Terms of Use)
2. The GUI Layout Toolbox license (see "View License" link above)

For more background on licensing of File Exchange submissions, see:
https://www.mathworks.com/matlabcentral/FX_transition_faq.html

Can I use GUI Layout Toolbox in commercial application? It is planned to be deployed as standalone executable.

Hello David,

I am using R2016b with version 2.3.1 of the GUI Layout Toolbox. Is there a work around to enable the GUI Layout Toolbox to work with the MATLAB compiler?

Thanks,
Josh

I am using R2016b with version 2.3.1 of the GUI Layout Toolbox.

David Sampson

Tim, if you don't need the ability to disable tabs then you should use uitab, which was added to MATLAB in R2014b. This provides a small slider to scroll if the tab titles get long.

If you do need disabling *and* long tab titles then let me know and I can lobby further to have disabling added to MATLAB.

Works like a charm :) Very intuitive.

Tim Spaeder

Hi David,
first of all: This is an amazing tool, tank you very much.

I have a Problem concerning the handling of the TabPanel. I have a GUI which creates a lot of Tabs. The fallowing MWE illustrates this:

h.mainWindow = figure('Name','Testfigure');
%mainContainer that holds all content
h.mainContainer = uiextras.VBox('Parent',h.mainWindow);
%tabPanel for various pages
h.TabBar = uiextras.TabPanel(...
'Parent', h.mainContainer,...
'TabSize',-1);
%create numerous tabs
for i=1:20
pageHandle = sprintf('Page%1.0f',i);
h.(pageHandle) = uicontrol(...
'Parent',h.TabBar,...
'Style','text',...
'String',['Content of ',pageHandle]);
end

It is obvious that the 'TabName' of every Tab is being shortened and thus unreadable. Any Idea how to fix this? I want to be able to read the full 'TabName' but I do not really care about formatting.

- I was wondering if I can somehow make the TabPanel itself scrollable and set the 'TabSize' of every Tab to say 80pts.
- Alternatively I would like to Change the height of the TabBar so the 'TabName' can span two rows
- Another alternative might be to set only a specific number of Tabs visible in the TabBar depending on which Tab is active and Change the visibility whenever another tab is being selected

Can you provide a Suggestion to this Problem?

Guojin Feng

Great toolbox! Like it! It makes the writing of GUI in Matlab more efficient. Together with the Javacomponent, one can develop really good GUI. Although the App Designer provides modern GUI design and looks really cool, its capabilities are still limited currently since it starts using the new uifigure, which is not compatible with figure component. So currently, I will use the layout toolbox to design GUI in Matlab.
One issue is the starting speed can be slow if you got quite a few components in the GUI. As discussed by other users, this is caused by the many calls to the redraw function. Hope this can be solved soon.

Hi David,

Calling the "move" method of the activeX control with the "SizeChangedFcn" of its uix parent works flawlessly.

The only pain was to find the relative position of the parent uix container wrt. the figure. I end up cascading down all the ancestors, summing up the positions, until I find the figure.

David Barry

+1 vote for the ability to disable redraws until all children have been added. This would be really useful in a GUI I am currently writing where I am creating elements in a loop and it is wasted time redrawing until I have finished the loop.

David Sampson

Boris, see my post dated 25 February 2016. Please reorder contents using the Contents property, not the Children property.

BorisPas

Hi,

I am currently building a Gui with this very helpful toolbox.
I have one question about inserting Boxes.
I want to insert a Box at a specific location between other already included ones. So far I achieve this by adding a new box and afterwards change the order in the Array.

e.g.: Box.Children([1 2]) = Box.Children([2 1]);

This way works as I wish, but it takes quite a long time especially when I get more Fields. In my case it can take up to several seconds just to insert a box like this.

Is there a better way to insert Boxes at a specific location in the stack?

Kind regards
Boris

BorisPas

Cortexlab

Thanks David. Perhaps one approach besides a user-accessible "RedrawMode" flag would be to provide a function that populates each element of a uix.Grid with an object of some type (like a uicontrol, or a uix.Box). This function could take care of disabling/enabling RedrawMode itself. Since changing the String and Style of the uicontrol is relatively very fast, this would at least solve the problem in my particular case, though probably not quite as general as a user-accessible version. In any case, let me know if you come up with something! Thanks.

David Sampson

Nick, thanks for your benchmark code. See my comment from 23 February 2016 on disabling redraws temporarily. I think this could speed up your case by ~40%. We'll take a look.

Cortexlab

Hi - thanks for making a really wonderful toolbox! It's amazing how simple it is to create sophisticated guis.

However, we're having a problem with performance. Our gui involves a uix.Grid with about 100 uicontrols in it. It takes about 3 sec to create this grid, which isn't good enough because we have to re-create versions of it frequently when users interact with the gui. From profview it looks like the vast majority of this time is in "addChild" and especially in the "setPosition" commands that it ends up calling over 5000 times (presumably re-drawing everything each time a single child is added). Do you have any suggestions for how I can improve the speed? Below is a sort of minimal example that takes nearly as much time as our entire GUI. Thanks!

Nick

tic;
f = figure;
g = uix.Grid('Parent', f);
nR = 33;
for r = 1:nR
uicontrol('Parent', g, 'Style', 'text', 'String', sprintf('text_%d',r));
uicontrol('Parent', g, 'Style', 'pushbutton', 'String', sprintf('btn1_%d',r));
uicontrol('Parent', g, 'Style', 'pushbutton', 'String', sprintf('btn2_%d',r));
end
toc % 2.5 sec to here

ch = allchild(g);
chReorder = reshape(reshape(ch(end:-1:1), 3, nR)', nR*3,1);
g.Contents = chReorder;

g.Widths = [100, 100, 100];
g.Spacing = 1;
g.Heights = 25*ones(1, nR);

toc % 2.55 sec to here

how to install this toolbox in matlab

David Sampson

Yannick, unfortunately the support for controlling the position of Active-X controls is poor. You can set the position in pixels with respect to the parent figure at the point of creation, but nothing else. Support for Java components is better.

I had a look at what it would take to synchronize the position of an Active-X control with another component, and gave up. Many ingredients exist -- getpixelposition, SizeChanged and LocationChanged events, move method -- but issues remain with keeping the control on top, forcing redraws, and handling pixel scaling.

This is a limitation in MATLAB, not GUI Layout Toolbox.

David Sampson

João, see my comment on 13 Feb 2017: "We don't provide a way to specify spanning..."

Really cool stuff. It works like a charm (I haven't encountered any issues so far). Not being force to do these layouts manually is a very useful thing. Thanks a lot :)

João Ferro

Hi David, is there an easy way to effectively merge cells within a uix.Grid object (perhaps playing with the Widths and Heights properties)? Thanks, Joao

hello all,

Has any body tried to place an ActivX control in a uix components ?

It works in theory but you can only define the ActiveX control position wrt. the figure. How do you find the exact position of your uix Panel/Box inside the figure ?

Hi,

I am even downloading .mltbx file for the first time in history. Can anyone help me please how to add this .mltbx file to my Matlab and how can I use it. I have Matlab 2016a Thanks

Jan Keller

DrewVam55

Hello David,

I guess I just needed to keep reading a few more posts to find my solution...it works great! The only thing I would suggest (I made this small modification for myself) is preventing the scrolling action in onMouseWheelScrolled if the figure has MATLAB's native zoom mode enabled. If you do not, you get a combination of the the panel scrolling and figures briefly zooming in/out as the cursor passes over them.

Thanks again,
Andrew

David Sampson

Andrew, I added the features to which you refer -- scroll while dragging, scroll with wheel -- in version 2.3.1 on 31 January. Let me know how you like them and if you have suggestions for further changes.

DrewVam55

Hello David,

How difficult would it be to modify the scrolling panel to actively move as you slide it, not just on mouse release?

I was hoping there would be a reasonable solution for controlling it with the mousewheel, but from your efforts that doesn't seem likely. In the meantime, making the GUI window update as you move the scroll bar would still go a long ways towards improving usability.

Thanks,
Andrew

João Ferro

Many thanks David, it's working now. Big thumbs up!

David Sampson

Joao, here is an example of a Grid in a ScrollingPanel. In this case it's a fixed size grid in a variable size scrolling panel.

f = figure;
s = uix.ScrollingPanel( 'Parent', f );
g = uix.Grid( 'Parent', s, 'Padding', 10, 'Spacing', 10 );
for ii = 1:16, uicontrol( 'Parent', g, 'String', ii ); end
g.Heights = [200 200 200 200]; % 4 fixed rows
s.Heights = 850;

Related, I tried but failed to add support for variable-with-minimum sizing in version 2.3.1. This would be for the case:

g.Heights = [-1 -1 -1 -1]; % 4 variable rows
s.MinimumHeights = 500; % s.Heights = -1

Fixing this is on the list for the next release.

David Sampson

Joao, on defaults:

I am suggesting, per class, a function that creates an object and set some of its properties to defaults while allowing a user to set the others.

function obj = myVBox( varargin )
obj = uix.VBox( varargin{:}, 'BackgroundColor', 'w' );
end

If you wanted a set of such functions to share the same property values then you could create a function for that.

function c = myBackgroundColor()
c = 'w';
end

If you wanted a changeable, sticky default then you could use preferences.

getpref( 'uix', 'BackgroundColor', 'w' )

João Ferro

Thanks for your reply David. In my particular application, I was looking to set the default background colour of all elements (HBox, VBox, Panel, Grid, etc) to white. Could you ellaborate on the 'factory functions' you have suggested?

On a different topic, I am also struggling to use the ScrollingPanel with something other than the axes, as shown in the documentation. What is the actual condition for the scroll bars to be shown (e.g. position(4) value of scrolling panel needs to be smaller than its child)? Would you be able to provide a couple more examples with a VBox or a Grid, for example?

David Sampson

Joao, you are looking for something like set(0,'DefaultHBoxPadding',10), or if you are feeling particularly modern, set(groot(),...).

Unfortunately the MATLAB graphics defaults system only works for graphics classes that are part of MATLAB itself. In GUI Layout Toolbox version 1 (prior to R2014b), we hacked in limited functionality for our classes, but it never worked very well, and was removed in the big rewrite for version 2 (R2014b onwards).

If you always want to create objects with certain property values, I suggest that you create a set of factory functions. Preferences (as in getpref and setpref) may also have a role to play depending on what you are trying to achieve.

João Ferro

Hi David, great toolbox! Is it possible to set a default property value for any class in the uix package, e.g. set default background colour for any VBox, HBox created? I understand this can be done on the root level for any graphics objects but I'm not sure how to do this on user defined classes. Many thanks in advance.

David Sampson

For questions on installing toolbox (.mltbx) files, you can contact MathWorks support. www.mathworks.com/support

There are several ways to confirm that a toolbox is installed:
* Launch the Add-On Manager
* Inspect the output of matlab.addons.toolbox.installedToolboxes
* If the toolbox includes documentation, launch the documentation browser, and check under "supplemental software"
* If the toolbox includes Contents.m, use ver, e.g., ver('layout')

M A

M A

Osama Abbas

I have MATLAB R2015a. When I try to install your toolbox, it appears that it is installed, but I can't find it !!. What is wrong ?

David Sampson

Yoav, we don't provide a way to specify spanning, but you can achieve what you need by nesting instead if you set the widths and heights appropriately.

Yoav Romach

Is it possible to add an option inside a grid for an item to take multiple spots?

I have a 8x5 grid, but I want the last 4 item (bottom corner) to be a single button...

Is there any way to do it currently?

Yannick, MATLAB uses column-major ordering, whereas western reading order is row-major. I didn't feel comfortable going with a default that was different to MATLAB, even though you are not the first to provide this feedback. We have toyed with providing a switch to control order, and also allowing specification of Contents as a matrix rather than a vector. We need to think some more about this point.

Hi David, I ended up overloading the tracking function just to have consistent results when loading up. Every little helps when running through the RunTime. Not sure why it takes so long though, I'm thinking it has something to do with the Proxy.

On another note, I always edit the Grid class because I need it to build up line by line instead of column by column. It would be nice to be able to choose when calling it.

David Sampson

Matthew, minimum heights and widths for scrolling panel contents are available from version 2.3.1, released today.

f = figure();
s = uix.ScrollingPanel( 'Parent', f );
h = uix.HBox( 'Parent', s, 'Padding', 10, 'Spacing', 10 );
for ii = 1:4, uicontrol( 'Parent', h, 'String', ii ); end
s.MinimumWidths = 450;

Erik, I also added wheel-based scrolling.

f = figure();
f.Position(3:4) = 450;
movegui( f, 'center' );
p = uix.ScrollingPanel( 'Parent', f );
n = 30; h = 20; s = 5;
g = uix.Grid( 'Parent', p, 'Padding', s, 'Spacing', s );
for ii = 1:n, uicontrol( 'Parent', g, 'Style', 'text', 'String', sprintf( 'Parameter #%d:', ii ), 'Enable', 'inactive' ); end
for ii = 1:n, uicontrol( 'Parent', g, 'Style', 'edit' ); end
g.Widths = [-1 -1];
g.Heights(:) = h;
p.Heights = n*h + (n+1)*s;

Unfortunately I have discovered that the two features do not work together. Wheel-based scrolling currently only works for fixed sizes, not variables sizes with minima.

David Sampson

Matthew, I agree that it would be useful to provide a way to set minimum heights and widths for scrollable panels. This doesn't conflict with the current programming model for GUI Layout Toolbox. I have captured that as an enhancement request for inclusion in an upcoming release. Thank you for the suggestion.

Afternoon David,

First off, fantastic resource. I'm having a bit of a play around with the scrolling panel and am wondering if there a solution to the following.

Say that within a gui I have a scrolling panel acting as a main wrapper. Within that I have a HBox that has flexible widths, but has a minimum width based on the minimum widths of its children. How can I force the scrolling panel to respect this when the window is resized to less than the minimum width of its children?

I would of expected a minimumWidths / minimumWidths property for the ScrollingPanel that applies to the child, but these don't exist.

Regards,

Matt

David Sampson

Correction to my last message: I meant WindowScrollWheel, not WindowMouseMotion.

David Sampson

Erik, I have looked into providing wheel-driven scrolling. This would entail hooking up a listener to the figure WindowMouseMotion event. The challenge is figuring out whether the pointer is over the ScrollingPanel, since that is the behavior that users expect.

Easiest is to check whether the HitObject in the event data is the ScrollingPanel. However that relies on the user turning off HitTest for everything in the container.

Another option would be to check whether HitObject is the ScrollingPanel or any of its children. Calling allchild in response to the pointer moving is going to be slow, and maintaining a cache of descendents is error prone.

Computing the absolute position of the ScrollingPanel, and comparing it to the absolute pointer position, is difficult for docked figures. You also have to worry about what is on top of what. Finally, you have to cache information to provide good performance.

In conclusion, I have parked this for now, but would like to revisit it in future.

David Sampson

Yannick, I wonder why performance in your environment is significantly worse than I have seen. I expect less than 0.1 s, and typically about 0.03 s, all of which is the call to urlread.

As a reminder to others:
1. The tracking is called once per MATLAB session, the first time you create a GLT object.
2. I am trying to quantify usage to build the case for development resources.

Found out I can save 1 full second when creating my gui by turning the usage tracking off :

uix.tracking('off')

Hi,
I was wondering if it is possible to use mouse scroll wheel to scroll through the uix.ScrollingPanel?
Not sure if this is related but I'm on Mac and the only way to scroll through the scrolling panel is by grabbing the slider.
Thanks!

DrewVam55, uix.ScrollingPanel, like other GLT panels, only shows one child at a time. Which child is controlled by the property Selection.

You can put subplots in a container (uicontainer or uipanel('Title','','BorderType','none')) and put the container in a scrolling panel.

f = figure;
s = uix.ScrollingPanel( 'Parent', f );
p = uipanel( 'Parent', s, 'BorderType', 'none' );
t = -10:0.01:10;
a1 = subplot( 4, 1, 1, 'Parent', p );
plot( a1, t, sin( t ) );
a2 = subplot( 4, 1, 2, 'Parent', p );
plot( a2, t, cos( t ) );
a3 = subplot( 4, 1, 3, 'Parent', p );
plot( a3, t, sign( t ) );
a4 = subplot( 4, 1, 4, 'Parent', p );
plot( a4, t, t );
s.Heights = 1000; % make this taller than the panel

(I expect that this response will trigger a bunch of follow-on questions to which I do not have satisfying answers!)

Any news on when this awesome toolbox will be compatible with the AppDesigner ?...

Thanks a lot

DrewVam55

Hello David,

Is there any plan to update this to be functional with subplot() ? I have been trying to come up with a good way to incorporate a GUI with several graphs (too many for one screen) and a combination of subplot and ScrollingPanel would be perfect. As of now, I believe subplots somehow get destroyed by the internals of the Panel when the add/remove child listener executes - only the current axes is carried over after the event callback, and the rest of the subplot axes disapper.

DrewVam55

David Sampson

For anyone having issues with installation, here are a few tips.

Make sure you download the toolbox, not the zip file.

Once you have the .mltbx file, there are several ways to install. All should work.
1. Double click on the file outside MATLAB. The file extension should be associated with MATLAB during the installation process.
2. Double click on the file in the Current Directory view inside MATLAB.
3. matlab.addons.toolbox.installToolbox (16a and later)

GUI Layout Toolbox 2.x works with MATLAB R2104b and later.

I use Matlab R2016b and can not install this toolbox no matter what I tried.

David Sampson

For the first time, GUI Layout Toolbox has reached 1000 downloads per month. Thanks everyone for your interest, support and feedback.

If you are using an older version then please download the latest version to receive enhancements and bug fixes. The toolbox is stable and we have a decent test suite that we run continuously across MATLAB versions dating back to R2014b, so updating should be no pain just gain.

If you find GUI Layout Toolbox useful then please spread the word, and please consider rating the submission on File Exchange.

Therry

Hello David,
the tool works very well! One drawback (solved): Moving the mouse over a big figure slows down the reaction time of contextmenus sometimes up to 10 s depending on movements). After including a "drawnow" in the embedded functions "onMouseMotion" in GridFlex, HBoxFlex and VBoxFlex the reaction time is fast again. Is it possible to include this in your next issue?

Steve, there should not be any particular issue with using context menus inside GLT containers. For example:

t = 0:0.1:10; % time
f = figure();
g = uix.Grid( 'Parent', f, 'Padding', 50, 'Spacing', 50 );
r = 3; c = 2; % rows and columns
for ii = 1:r*c
a = axes( 'Parent', g, 'ActivePositionProperty', 'Position' );
plot( a, t, rand( size( t ) ) );
end
g.Heights = repmat( -1, [r 1] );
c = uicontextmenu( 'Parent', f );
uimenu( 'Parent', c, 'Label', 'The' );
uimenu( 'Parent', c, 'Label', 'Math' );
uimenu( 'Parent', c, 'Label', 'Works' );
set( g.Contents, 'UIContextMenu', c )

The code that you posted does not run.

Steve Ratts

Excellent toolbox! Really great documentation that makes it easy to get started using it.

I did get stuck on one thing, though. I can't seem to add uicontextmenus to plots. I've tried following the general purpose guidance Mathworks provides, and of course their code works with ordinary figures, but when I try to do the same thing applying it to something I've plotted in an axes that's part of a grid I get an error message that says there is no Label property on the Menu class.

Here's an example of what I've tried. In this example all the objects I've created are in the gui structure, and the data for my gui is in the data structure. The GUI has a 2x3 grid of axes which are in the gui.axes array. Other than calls to uimenu, everything appears to work fine:

for n = 1:6
keyIndex = data.Index+n-1;
if keyIndex <= 256
p = plot(gui.axes(n), data.keys(keyIndex,:));
c = uicontextmenu;
p.UIContextMenu = c;
m1 = uimenu(c, 'Lable', 'Zoom In', 'Callback', @onZoomIn);
m2 = uimenu(c, 'Lable', 'Zoom Out', 'Callback', @onZoomOut);
m3 = uimenu(c, 'Lable', 'Reset', 'Callback', @onResetZoom);
ylim(gui.axes(n),YLim);
set(gui.axes(n), 'FontSize', 6);
XLim = get(gui.axes(n), 'XLim');
text(gui.axes(n), 0.02*XLim(2), 0.9*YLim(2), ...
sprintf('Key Byte = %d', keyIndex-1), ...
'FontSize', 6);
else
cla(gui.axes(n))
end
end

Steve Ratts

Christophe

David - Thanks for the example and the comments, I now understand better the use of this new panel.

David Barry

Thank you for uix.ScrollingPanel David and Ben. You have just upped the MATLAB App building game once again. I do hope that your development colleagues are seriously considering this capability for App Designer.

David Sampson

The leading use case so far is to lay out a tall list of controls in a limited vertical space.

f = figure();
f.Position(3:4) = 450;
movegui( f, 'center' );
p = uix.ScrollingPanel( 'Parent', f );
n = 30; h = 20; s = 5;
g = uix.Grid( 'Parent', p, 'Padding', s, 'Spacing', s );
for ii = 1:n
uicontrol( 'Parent', g, 'Style', 'text', 'HorizontalAlignment', ...
'right', 'String', sprintf( 'Parameter #%d:', ii ) );
end
for ii = 1:n
uicontrol( 'Parent', g, 'Style', 'edit' );
end
g.Widths = [-1 -1];
g.Heights(:) = h;
p.Heights = n*h + (n+1)*s;

Christophe

The new scrolling panel seems to work well but I do not know if I will use it because it may only help for very particular case. If you have an example putting good use of it, I am interested to see it.
Anyway new possibilities/tools are always welcomed :)

David Sampson

Putting uicontainers between the VBox and the axes appears to help, although I will still seek to understand more about why the scribe layer is removing the axes in the first place.

gui.ViewContainer1 = uicontainer( 'Parent', gui.ViewLayout );
gui.ViewAxes1 = axes('Parent', gui.ViewContainer1 );
gui.ViewContainer2 = uicontainer( 'Parent', gui.ViewLayout );
gui.ViewAxes2 = axes('Parent', gui.ViewContainer2 );

TRogers

Excellent toolbox! Thanks David

I may have found a slight bug (streamlined example below).

I have two axes displaying different images. If I click on the Data Cursor, and then click on a point in either of the images/axes, they swap positions in the GUI. Further clicks no longer swap the positions.

Any ideas? Is it something wrong in my code?

I'm using R2016a on Linux.

---- example case ----
close all; clear all;
gui = struct();

gui.Window = figure( ...
'Name', 'Image Viewer', ...
'NumberTitle', 'off', ...
'MenuBar', 'none', ...
'Toolbar', 'figure', ...
'HandleVisibility', 'off','color','w','Units','normalized','outerposition',[0,0,1,1]);

browseLayout = uiextras.HBoxFlex( 'Parent', gui.Window, 'Spacing', 3 );

gui.ViewPanel = uiextras.BoxPanel( ...
'Parent', browseLayout, ...
'Title', 'Image Viewer');

gui.ViewLayout = uiextras.VBox( 'Parent', gui.ViewPanel, ...
'Padding', 3, 'Spacing', 3 );

gui.ViewAxes1 = axes('Parent', gui.ViewLayout);
gui.ViewAxes2 = axes('Parent', gui.ViewLayout);
linkaxes([gui.ViewAxes1,gui.ViewAxes2]);

I1 = ones(700,1400);
I2 = zeros(700,1400);

imshow(I1,[],'Parent',gui.ViewAxes1)
imshow(I2,[],'Parent',gui.ViewAxes2)

David Sampson

Version 2.3 of GUI Layout Toolbox is now available. Please give the new scrolling panel a try!

David - Thanks for your help and appreciate your comments on this and agree with you to avoid addlistener against event.listener. I was unsuccessfully trying to listen to annotation deletion event followed by set(gco,'Selected''off'). Thanks so much for your solution.

David Sampson

Amit, I cannot assess whether what you are trying to do is reasonable, but I can tell you how to make a component unselectable: create a listener on the property 'Selected', and configure the listener callback to set the property value back to 'off'.

addlistener( o, findprop( o, 'Selected' ), 'PostSet', @(~,e)set(e.AffectedObject,'Selected','off') )

Normally I avoid addlistener in favour of event.listener, but in this case, the source of the original event and the reacting object are the same, so it's OK.

Here's an example that creates a number of containers, one of which -- the box panel -- is not selectable.

h = uix.HBox( 'Parent', gcf, 'Padding', 10, 'Spacing', 10 );
b = uix.BoxPanel( 'Parent', h, 'Padding', 10 );
c = uicontrol( 'Parent', b, 'String', 'Click me!' );
a = axes( 'Parent', h );
[x, y, z] = peaks();
surf( a, x, y, z )
addlistener( b, findprop( b, 'Selected' ), 'PostSet', @(~,e)set(e.AffectedObject,'Selected','off') );

David - Any comments specifically on Point 2) which is really annoying me.

Can I somehow add a listener to panel underneath so that when it get selected it triggers 'Selected' property to 'off' state?

Help on this would be appreciated.

Hi David, Thanks for your reply. I am sorry if I did not put my question properly.

I understand GLT will set Position back on next appropriate event and that's exactly one would expect.

1) But how can I disable the panel getting selected so that user is not able to move/select them? I am setting 'HitTest' property but is there any other way to prevent user to select the panels (in the first place)?

2) The panel (containing a child axes) get automatically selected when an annotation from the axes is deleted. How can I stop this behaviour?

Amit, it is possible to select GLT panels. It is also possible to resize them manually and temporarily, e.g., create and then set Position explicitly. However, GLT will set Position back on the next appropriate event, e.g., ancestor resize.

Related: Because GLT child sizes are effectively owned by parents, we don't have a way for child position sets to be constrained by their parent type and properties. I could build this -- parents listening to children positions, identifying sets not initiated by parents, and reacting -- but it would be a lot of pain for not much gain.

Hi David, In addition to Zhangjun query, like you said, 2.2.2 works as expected. But deleting an annotation (using edit plot toolbar) selects the parent panel of the axes.

I also discovered that one can move around and resize the box panels using 'EditPlot' toolbar. I can set the 'HitTest' property to 'off' to stop this. Is there any other way to stop this?

I am using 'HitTest' for the time being to disable selection of the panels (using 'EditPlot' toolbar) but parent panel containing the axes still gets selected if any annotation is deleted. How can I stop this behaviour?

Christophe, good request for default properties in the documentation. We are considering a rework of the documentation to make it look like the product documentation, but that is quite a big job.

Zhangjun, I introduced a change in version 2.2.2 enabled data cursor mode to be used without requiring an additional uicontainer.

For example:
>> h = uix.HBox( 'Parent', gcf );
>> a = axes( 'Parent', h );
>> plot( a, 1:10, rand( [1 10] ) )
Turn on data cursor mode and click on the line. Works in 2.2.2, errors (as you report) in 2.2.1.

If you are seeing an issue with the 2.2.2 then I would appreciate it if you could contact me via my FX profile and send reproduction steps.

You can select "watch this file" above to receive update notifications.

Zhangjun Yu

Christophe, you are right. Thanks very much. This problem puzzled me several weeks. In addition, my best gain is the discovery of User_guide for GUI Layout toolbox.

Christophe

Zhangjun Yu> Check the help User_guide2_3.html. I think it is the same problem than Color and legends, you have to put the axes in a uicontainer. I did not try myself but according to the comments below, it should work and will be updated later.

Zhangjun Yu

When I use the datacursor, my axes in a HBox will shrink to its half size on the horizontal direction. Here are parts of the error messages:

Warning: Error occurred while executing the listener callback for event
ChildAdded defined for class uix.ChildObserver:
No public property Units exists for class
matlab.graphics.shape.internal.AnnotationPane.

Error in uix.HBox/redraw (line 138)
child.Units = 'pixels';

Error in uix.mixin.Container/set.Dirty (line 129)
obj.redraw() % redraw now

Error in uix.mixin.Container/addChild (line 219)
obj.Dirty = true;

Error in uix.HBox/addChild (line 167)
addChild@uix.Box( obj, child )

Error in uix.mixin.Container/onChildAdded (line 159)
obj.addChild( eventData.Child )

Error in uix.mixin.Container>@(varargin)obj.onChildAdded(varargin{:}) (line 51)
childObserver, 'ChildAdded', @obj.onChildAdded );

Error in uix.ChildObserver/addChild (line 109)
notify( obj, 'ChildAdded', uix.ChildEvent( oChild ) )

Error in uix.ChildObserver/addChild (line 116)
obj.addChild( nChild, oGrandchildren(ii) )

Error in uix.ChildObserver>@(~,e)obj.addChild(nChild,e.Child) (line 96)
@(~,e)obj.addChild(nChild,e.Child) );

Error in matlab.graphics.shape.internal.ScribeStackManager/createLayer

Error in matlab.graphics.shape.internal.ScribeStackManager/getLayer

Error in matlab.graphics.shape.internal.ScribeHost>findAnnotationPane

Error in matlab.graphics.shape.internal.ScribeHost/setPeerParent

Error in matlab.graphics.shape.internal.ScribeHost

Error in matlab.graphics.shape.internal.ScribeHost>@(s,e)nDelayedReparent()
> In uix.ChildObserver/addChild (line 109)
In uix.ChildObserver/addChild (line 116)
In uix.ChildObserver>@(~,e)obj.addChild(nChild,e.Child) (line 96)
In matlab.graphics.shape.internal.ScribeStackManager/createLayer
In matlab.graphics.shape.internal.ScribeStackManager/getLayer
In matlab.graphics.shape.internal.ScribeHost>findAnnotationPane
In matlab.graphics.shape.internal.ScribeHost/setPeerParent
In matlab.graphics.shape.internal.ScribeHost/checkPeer/nDelayedReparent
In matlab.graphics.shape.internal.ScribeHost>@(s,e)nDelayedReparent()

Zhangjun Yu

Christophe

It is an excellent toolbox. I appreciate the support, the documentation and examples.

Could you add the default value for properties in the html documentation in the future update please?

David Sampson

Tobias, I think that you are right, there was at some point a property SelectionChangedCallback. I will do some digging to find out what happened. There was a lot going on in that area between GLT1 and GLT2, because of both property renaming and changes to the callback event data.

The principles to which I try to adhere are:
* GLT1 uiextras code runs with GLT2
* Minimal incompatibilities, and none undocumented, as GLT2 versions advance

Tobias

Thanks David for the reply. My bad, I meant "SelectionChangedCallback". I might have skipped a version, but in the 2.1.? Version I use, uix.TabPanel has a property "SelectionChangedCallback" and in the current version it is "SelectionChangedFcn". Don't want to nit-pick, the issue just came up.

David Sampson

Of course the search will yield a result -- this page -- after the Google crawler's next visit!

David Sampson

Tobias, no GUI Layout Toolbox TabPanel class has or had property TabSwitchCallback or TabSwitchFcn. Both have a property SelectionChangedFcn.

A Google search for TabSwitchFcn yields no results at all.

Tobias

Hi, I really like the toolbox a lot. But it seems to have low backward compatibility to previous versions. After a few minutes, I found several issues. Is there a list of commands/options that have changed? Like TabPanel.TabSwitchCallback -> TabPanel.TabSwitchFcn.
That would be very helpful.

Jason

Great tool! I'm curious to know if there are any advantages to using boxes vs grids to place UI components. Is one more efficient (cpu/memory wise) than the other? I'm planning on creating a fairly complex GUI so I'm looking to design it as efficiently as possible.

David Sampson

Ted, File Exchange ate my tabs, but you should get the idea.

David Sampson

uibuttongroup handles the selection but not the positioning. Often the position is fixed, but you might want to put the uibuttongroup inside a GLT container.

g = uibuttongroup( 'Units', 'pixels', 'Position', [20 20 200 70], ...
'SelectionChangedFcn', @onClicked );
c(1) = uicontrol( 'Parent', g, 'Style', 'radiobutton', 'String', 'Tom', ...
'Units', 'pixels', 'Position', [5 45 190 20] );
c(2) = uicontrol( 'Parent', g, 'Style', 'radiobutton', 'String', 'Dick', ...
'Units', 'pixels', 'Position', [5 25 190 20] );
c(3) = uicontrol( 'Parent', g, 'Style', 'radiobutton', 'String', 'Harry', ...
'Units', 'pixels', 'Position', [5 5 190 20] );

function onClicked( source, ~ )
% do something useful
end

uix.VButtonBox etc. handles the positioning but not the selection. However, it is not difficult to add the selection.

p = uipanel( 'Units', 'pixels', 'Position', [0 0 200 70] );
g = uix.VButtonBox( 'Parent', p, 'Padding', 5, 'ButtonSize', [200 20], ...
'HorizontalAlignment', 'left' );
c(1) = uicontrol( 'Parent', g, 'Style', 'radiobutton', 'String', 'Tom', ...
'Value', 1, 'Callback', @onClicked );
c(2) = uicontrol( 'Parent', g, 'Style', 'radiobutton', 'String', 'Dick', ...
'Value', 0, 'Callback', @onClicked );
c(3) = uicontrol( 'Parent', g, 'Style', 'radiobutton', 'String', 'Harry', ...
'Value', 0, 'Callback', @onClicked );

function onClicked( source, ~ )
source.Value = 1; % select this
set( c(c~=source), 'Value', 0 ) % unselect others
% do something useful
end

Ted Diehl

I cannot seem to get the uix.VButtonBox (or HButtonBox) to work with radiobuttons, in the sense of having the buttons linked like what occurs when using uibuttongroup. When I use the uix approach, the buttons act independently. If I place a uibuttongroup (with radiobuttons in it) inside a uicontainer which is then in a uix entity, I get the buttons to be linked, but their motion inside the uibuttongroup has the same old scaling problems with window resizing. Running 2016a.
Does Gui Layout Toolbox work with radiobuttons and if so, can someone post a simple example. All the "button" examples in the toolbox are simple unlinked (independent) pushbuttons, none that I found show linked radiobuttons. - Thanks!

Bryant

Tom Wright

kp

Please disregard my prior message. It was due to some issue in my MATLAB path.

kp

I am having a problem with both 2.1.2 and 2.2.2 under 2016a, but not 2015b. I get this error message in MATLAB:
No public property Units exists for class matlab.graphics.primitive.canvas.JavaCanvas.

As far as I remember, my code used to work under 2.1.2 in 2016a before. Could it be due to updating Java?

I think I may have found a small bug - I couldn't find anything about this in these comments yet.

This concerns the 'Title' on a uix.BoxPanel, and I can demonstrate this bug using the included demoBrowser.m.

On my 13" MacBookPro with retina display, the titles are cut off early with "...". They are: "Select a de..." and "Viewing: L...". No amount of resizing fixes this, and there is plenty of room to display the whole title.

Running the same code on a Windows desktop with a non-retina display shows the full titles correctly.

Thanks.

David Sampson

Sucheta, I don't think that this error relates to GUI Layout Toolbox. Could you please submit a technical support request including MATLAB version details and simple reproduction steps?

I am getting the following error while running GUI script file.

"Error using matlab.ui.container.Panel/set
There is no widthlimits property on the Panel class."

David Sampson

In version 2.2.2, I have added extremely basic usage tracking to GUI Layout Toolbox. Once per MATLAB session, GUI Layout Toolbox reports toolbox version, MATLAB version, and operating system. No personally identifiable information is transmitted. Tracking is optional -- you will be prompted -- but I encourage you to participate to help us to understand GUI Layout Toolbox usage and plan for ongoing development in this area.

David Sampson

Version 2.2.2 of GUI Layout Toolbox is now available. This minor release includes:
* support for axes with data cursors within all container types
* improvements to pointer management for flex containers

David Sampson

Grzegorz, currently, GUI Layout Toolbox does not support case insensitive or partial matches on property names or enumerated string property values. I will consider relaxing this.

Arti Verma

I am having issue while running a BEMacoustics toolbox which runs using this toolbox.
Here is the error message

Error using uiextras.Container (line 61)
Trying to run using double-handle MATLAB graphics against the new graphics system.
Please re-install.

Would be great if some one could guide me how to fix this issue.

Seth Kenner

Thanks David,

It works well. I was trying to be similar to the way the deploytool panels work where they minimize/maximize wherever you click in the title bar because it feels more user friendly.

I had an issue with case sensivity:
uiextras.HBox('parent', someHandle) adds the HBox to the figure children, not someHandle, without warning/error.

It took me a while to get to:
uiextras.HBox('Parent', someHandle) which works fine.

David Sampson

Abbey, a change will be included in the upcoming release so that you don't need to put axes in a container just because you want to use data cursors. You will still need to for legends and colorbars, though.

David Sampson

Seth, yes it's possible to implement this behavior.

I initiated the release process earlier in the week, so this change will not be included in the next version.

If you want to make changes locally then:
* Set TitleText Callback in set.MinimizeFcn
* Manage the Enable property of TitleText depending on whether or not MinimizeFcn is empty
* Detach and reattach TitleText in redrawButtons to ensure that it is not selected after clicking

Another question is whether people find the behavior that you propose to be intuitive.

Seth Kenner

Is there an easy way to add the minimizeFcn callback to the TitleText of a BoxPanel as well? This would make it easier to minimize and maximize a panel because the minimize button can be small and hard to hit at times.

This Toolbox is great. Just a note: the documentation mentions using uicontainer for legends and colorbars to be displayed correctly on plots; this seems to also be necessary when using datacursormode.

Juan Henao

Excuse my lack of knowledge, I've developed some quite complex guis using the guide tool but then I saw this and wow, it has awesome features. To the point: Is there any graphic version of this toolbox, like in guide, or do I have to learn the code?.
Thanks for your awesome work, keep going!.

David Sampson

Bryant, yes, but how and when are things that we (MathWorks) are working on.

Bryant

Will there be a version compatible with the new App Designer UI objects/graphics?

D. Plotnick

Excellent!

I've been using GUI Layouts for a few years now and find it a great tool. Quick question: Can I configure the compiled application to run as a Windows System-Tray background process? Any help appreciated.

Christian

In some of our code we have overloaded the redraw() method of some containers to return the current "Sizes" property of the container. Since updating our code to >R2014b, this leads to enormous amounts of output to the command line whenever such an element is redrawn. I traced this back to two lines in uix.mixin.Container (lines 129 and 149), where the redraw() method is called without a semicolon to suppress output, clearly because no output is expected.

Assuming this does not break anything else, would it be possible to simply add semicolons to the end of those lines to suppress output?

Carsten, there is a discussion of uix and uiextras in the documentation, section 2.2 "Compatibility with version 1".

If you are writing new code that only has to work in 14b and later then use uix. Otherwise use uiextras.

Carsten

Can anyone explain when to use uix and uiextras resp.?

And what is the difference?

In response to reports of installation issues, I did a quick test. I downloaded 2.2.1 from File Exchange and installed successfully in both 15b and 16a. My setup is win64 with local add-ons directory. I installed by double clicking on the mltbx file in the current folder view in the MATLAB desktop.

Ardalan

I noticed that sometimes, if I have a VBox inside a uipanel, Matlab crashes when closing the figure. I could reproduce the crash also by manually deleting the specific culprit VBox.

I could get rid of the problem by using uix.Panel instead of uipanel. I this a known problem or otherwise what was the reason to repalce uipanel with uiextras/uix.Panel?

At the moment I still have the problem of Matlab crashing. I traced the problem by deleting all child objects of my figure one-by-one. The crash occurs when deleting the very last child object, which is again a VBox having the Figure itself as its parent.

The crash manifests as an "access violation" in an "<unknown-module>". I'm using version 2.2.1 on R2014b.

Philipp

Hi David,

I tried to use the GUI Layout Toolbox in combination the uicomponent from Yair Altman and have an issue with that combination.
The following code works, which is still putting the uicomponent into a uipanel:

hf1 = figure;
hvb1 = uix.VBox('Parent',hf1);
hp1 = uipanel('Parent', hvb1);
hjl1 = uicomponent('Style','JLabel', {'no data'}, ...
'HorizontalAlignment', javax.swing.SwingConstants.CENTER, ...
'VerticalAlignment', javax.swing.SwingConstants.CENTER, ...
'Background', javax.swing.plaf.ColorUIResource(1,0,0));
set(hjl1, 'Parent',hp1, 'Units','normalized', 'Position',[0 0 1 1]);

But when I try to use the uicomponent directly with the vbox I have to resize the figure window to get the correct display:

hf2 = figure;
hvb2 = uix.VBox('Parent',hf2);
hjl2 = uicomponent('Parent',hvb2, 'Style','JLabel', {'no data'}, ...
'HorizontalAlignment', javax.swing.SwingConstants.CENTER, ...
'VerticalAlignment', javax.swing.SwingConstants.CENTER, ...
'Background', javax.swing.plaf.ColorUIResource(1,0,0));

Is there a way to get the correct behavior without having to put the uicomponent into an additional panel?

Markus

Sorry, but I think the mltbx file doesn't work under 2015b and 2016a. I double click the file "GUI Layout Toolbox 2.2.1.mltbx" and the installation sign come on top. I push the button "Install" and agree the terms. After than nothing happens...

Does anybody have the same problem?

Yair Altman

I only saw @Tanmay's comment below and @David's suggestion now. I've just uploaded a fixed version of UICOMPONENT that accepts HG2 (inc. uiextras) containers as parents, in addition to all the previously-acceptable parent types.

Ahmad Gazar

I downloaded the mltbx file, double clicked it, still no sign of installation. I typed ver layout and I received this error "Warning: No properly formatted Contents.m file was found for 'layout'." Please help, I am using matlab R2015a for ubuntu.

Please ensure that you download the mltbx file rather than the zip file.

To install the toolbox, double-click on it in the Current Folder view.

To check whether the toolbox is installed, type "ver layout" at the command prompt, or launch the Add-on Manager.

Ahmad Gazar

I am trying to install the toolbox on matlab r2015a, but no indication of the toolbox being installed. please help.

Late last year there were some reports of pointer state getting messed over flex containers. The issue was the handling of transitions between adjacent dividers in different containers. There is a fix in version 2.2.1, just released.

If you are interested in how pointer changes are now coordinated, take a look at uix.PointerManager.

It worked, David. Now that line spends 0.06s intead of 0.28s. Thanks a lot.

David Sampson

Leonardo, back to your question on performance. I'd like to remind everyone to reorder layout contents using property Contents, not property Children.

There is a discussion of the difference in the GLT documentation, but here is the brief version. Children is the vertical stacking order and is defined by MATLAB, and is irrelevant to most GLT use cases. Contents is the layout order and is defined by GLT.

If you reorder via Children, MATLAB detaches them all in turn (one redraw each), then reattaches them all in turn (one redraw each). If the children are GLT containers then each step is likely to *also* resize and therefore redraw each child too. If you are careful then you might get everything in the right layout order. Finally all this detaching and reattaching will erase your sizes, so you will have to reset those too (another redraw).

In contrast, when you reorder via Contents, you get a single redraw, and GLT permutes the sizes for you automatically.

>> b = uix.HBox( 'Parent', figure, 'Padding', 2, 'Spacing', 2 );
>> for ii = 1:30, uicontrol( 'Parent', b ); end % 30 redraws
>> b.Widths = -rand( size( b.Contents ) ); % 1 redraw
>> [~, i] = sort( rand( size( b.Contents ) ) );
>> b.Contents = b.Contents(i); % 1 redraw
>> b.Children = b.Children(i); % 60 redraws, and Widths are all -1

David Sampson

Cell spanning is not supported at this time because I feel that it overcomplicates the API. You will have to stick with nested containers.

I think it won't work, David, because each row has a different number of columns. Is there any way to do it?

David Sampson

Leonardo, I will consider this for a future release. The following changes would be made to uix.mixin.Container:
* Define a property RedrawMode to control whether or not to redraw
* In set.Dirty, add a condition to redraw only if RedrawMode is 'on'
* In set.RedrawMode, when setting to 'on', redraw if dirty (see onFigureChanged)

I see that you are using a VBox full of HBoxes. Would a Grid work for you?

Thanks for your answer, David.

Is it possible to disable these redraws?

This is the code line that is taking more time, 0.28s:

vbox10.Children = [edit_description_hbox edit_manager_hbox edit_brokerage_hbox ... edit_strategy_group_hbox ... edit_total_value_day_trade_hbox ... edit_quantity_price_hbox ...
edit_account_hbox edit_client_hbox edit_liquidity_date_hbox edit_deal_time_hbox edit_deal_date_hbox];

David Sampson

Leonardo, I think that you mean that you reorder Contents, not Children, although the two are closely related.

There is some scope for performance improvement. In your example, GLT recomputes the HBox contents sizes twice each -- once when the new item is added at the default size, and once when the new item is resized to its final size -- whereas it could be possible to compute the sizes just once. This could be achieved by having the option to temporarily disable redraws, although you would have to remember to turn them back on. Another solution would be to have a configurable default size for new items.

Note that the graphics system won't actually repaint everything twice when you change the properties in quick succession. That is generally more expensive than computing the sizes.

Out of interest, how many GLT containers do you have at each level, and how long is a redraw taking?

Hi, David,

I'm trying to make a very dinamic GUI, so i'm frequently inserting or taking out some components of a vbox. For example, many times I want to insert a hbox into a vbox when the user press a button. When I set the Parent of the hbox the vbox, the hbox is inserted as the last child, but I want it to be the third one, for example. So I use the Children property of the vbox and change the order of its components.

I realized that this process is a little slow, consuming almost 20% of the total execution time of my function. Do you have any faster way to do it or do you intend to improve the performance of this process?

Thanks and congratulations on this amazing toolbox.

David Sampson

Henri, you have uncovered a subtle bug. If the first change to ForegroundColor is to black then that change does nothing.

I will include a fix in the next release. After the first two lines of the BoxPanel constructor, please add:
obj.ForegroundColor = foregroundColor;

Henri

Many thanks for your support. The problem was, that I always tried to set the ForegroundColor property to black [0, 0, 0]. However the textcolor remained white. Today I tried [0.1, 0.1, 0.1] instead and it worked fine, even if it is rather grey than black course.

David Sampson

Henri, there is a property ForegroundColor. ForegroundColor changes the title text color. BackgroundColor controls the title background color. HighlightColor and ShadowColor control the border colors.

Henri

Hello David, thank you very much for this great toolbox!

Can you please give me hint, how to change the ForegroundColor of the title of a BoxPanel? Since version 2014b I can still set the property "TitleColor", which changes the background color of the TitleBox but not the "ForegroundColor" anymore, which used to change the textcolor of the title.

Henri

David Sampson

Alex, I am still working on the confused-pointer fix. This will be included in the next release, probably in February.

David, just updated to newest release (12 Jan 2016). I found that one mouse cursor issue, adjusting a tab "below" it, no longer occurs. However, the release did not correct the problem of mouse cursor getting "confused" about which expansion arrow to display on adjacent flex containers, and subsequently getting stuck as an expansion arrow. Was it meant to correct this? Thank you so much for this toolbox.

David, thank you very much for your help! It works perfectly now :)

Laurent

David Sampson

Ignore the third and fourth lines of code in my previous post.

David Sampson

Darya, take a look at the button box classes, HButtonBox and VButtonBox. These allow you to specify the width and height of their children and to align the children vertically and horizontally. One common use is a row of buttons at the bottom of a dialog.

In your case, put the buttons whose size you want to control explicitly into a button box each.

f = figure();
g = uix.Grid( 'Parent', f, 'Padding', 10, 'Spacing', 10 );
n = 4;
for ii = 1:10, s{ii} = deblank( evalc( 'why' ) ); end
b = uix.HButtonBox( 'Parent', g, 'ButtonSize', [100 20] );
uicontrol( 'Parent', b, 'String', 'MATLAB' );
uicontrol( 'Parent', g, 'Style', 'text', 'HorizontalAlignment', ...
'right', 'String', 'Indiana Jones:' );
uicontrol( 'Parent', g, 'Style', 'text', 'HorizontalAlignment', ...
'right', 'String', 'Three Colors:' );
b = uix.HButtonBox( 'Parent', g, 'ButtonSize', [100 20] );
uicontrol( 'Parent', b, 'String', 'Simulink' );
uicontrol( 'Parent', g, 'Style', 'listbox', 'String', ...
{'Raiders of the Lost Ark','Temple of Doom','Last Crusade'} );
uicontrol( 'Parent', g, 'Style', 'listbox', 'String', ...
{'Blue','White','Red'} );
g.Widths = [-1;-1];
g.Heights(1) = 20;

Darya, couldn't you make additional panels, like to have a button that is not so wide, you can have 3 panels in an HBox: left, middle, right. Then you can make the middle a fixed (smaller) size and put the button in there. Only problem is (I believe) only one of the three can fill up the rest of the size using -1 on the widths, so it'd be better to have two panels and have the button either on the left or right, instead of centered.

Hello David,

Thank you for your fast response. Now it's clear to me what's happening.

For the purpose of my program (which is used to post-process some data), I have a lot of components on a grid: checkboxes, textboxes and simply text - their size depends on their own content or the width of the grid columns: e.g. I have text label on the left and a corresponding textbox on the right in my grid.

Then I want to add a button and have it centered in a panel above the grid (panel and grid have the same VBox parent, e.g. width of the panel = width of all the grid columns combined). But then I don't really want to have such a wide button (because my grid is quite wide) and I can't find a way to fix it.

David Sampson

Darya, the GUI Layout Toolbox containers take control of setting the Position of their contents. So for a grid, the contents will fill the cells. Perhaps you could explain why in your specific case you need to override some of the sizes.

Hello,

I am programming a GUI using GUI layout toolbox and default Matlab components. I noticed if I use uicontrol Pushbutton or popup on a parent of a class uix.Grid or uix.Panel and set the size of Pushbutton or popup components not to be equal to the width of a Grid column or Panel (by specifying a Position property manually for these components by changing the width and height only), then when running my program it still resets to the sizes of a Grid and Panel components. If I insert a "keyboard" into the code and start debugging my code gradually, the sizes of PushButton and popup are specified correctly based on their own Position property and don't change when GUI window program runs till the end.

I am not very experienced in GUI programming in Matlab. I tried to sort the problem on my own and I don't seem to understand the source of such behaviour.

Can it be related to GUI layout toolbox components definition, that I am not aware of?

David Sampson

Alex, sorry I misunderstood your bug report because I didn't scroll down beyond the code to the screenshot. Mea culpa. The issue arises because I was checking whether the pointer is above any divider but not whether the divider is on top. Version 2.2, released yesterday, employs a new technique for detecting when the pointer is over a divider, and fixes the issue.

David, wow, that is a nifty way to keep flex containers in sync, didn't know you could listen for changes there. However, I do not care about keeping them in sync. The problem is that you can mysteriously change a flex border on one tab from *another* tab. One shouldn't be able to do that. However, it may be interaction with Gui Layout Toolbox and uitab, the latter of which I use for reasons given in my post dated 24 Jun 2015. I sent you a screen capture to your email demonstrating the problem. Please do whatever you want with the video (e.g. posting somewhere public, this site and gists do not allow posting videos, that's why I did screenshot on the gist).

David Sampson

Alex, if I understand you correctly, you have flex containers on multiple tabs and you want to keep them in sync.

Currently there is not an event on the flex containers to notify of changes to the contents sizes. As a workaround, you can react to size changes of the flex container contents. For example:

f = figure();
p = uix.TabPanel( 'Parent', f );
h1 = uix.HBoxFlex( 'Parent', p, 'Padding', 10, 'Spacing', 10 );
b1 = uicontrol( 'Parent', h1, 'String', '1' );
uicontrol( 'Parent', h1, 'String', '2' );
h2 = uix.HBoxFlex( 'Parent', p, 'Padding', 10, 'Spacing', 10 );
b2 = uicontrol( 'Parent', h2, 'String', '3' );
uicontrol( 'Parent', h2, 'String', '4' );
addprop( h1, 'ContentsSizeChangedListener' );
h1.ContentsSizeChangedListener = event.listener( h1.Contents, ...
'SizeChanged', @(~,~)set(h2,'Widths',h1.Widths) );
addprop( h2, 'ContentsSizeChangedListener' );
h2.ContentsSizeChangedListener = event.listener( h2.Contents, ...
'SizeChanged', @(~,~)set(h2,'Widths',h1.Widths) );

In similar vein to previous post about mouse expansion arrow, although looks like a separate problem: When there is an adjustable border on a tab, you can adjust this from another tab. Am I setting up the tabs incorrectly, or ... ? Please see here for code and explanation:
https://gist.github.com/alexperrone/2970592e19e3479ecba6

David, Indeed the problem falls into:
* pointer confused by transition between adjacent flex containers
When I hover near the border of an HBoxFlex and VBoxFlex, that's where the mouse cursor gets stuck as an arrow. If I change one to NOT be flex, there is no conflict of the arrow directions apparently and it doesn't get stuck. I have reproducible code and a video capture that I can send directly to you.

Alex, I have had a few issues reported in this area:
* pointer wrong in docked figure window - fix to be released soon
* pointer wrong over Java component in flex container (sporadic) - under investigation
* pointer confused by transition between adjacent flex containers - just identified

It would be helpful to know if the problems that you are seeing fall into any of the buckets above, and also whether they are pointer path dependent or speed dependent.

Whenever I hover the mouse over the adjustible border in a uix.HBoxFlex, the mouse cursor changes to the expansion arrow and stays as an arrow everywhere throughout the GUI and never returns back to the normal mouse cursor. Any ideas?

As many others, the GUI is currently quite complex, will attempt minimal reproducible example if not an easy fix or something to check. Using R2014b with June 2015 version of Gui Layout Toolbox. Thank you!

Minor improvement suggestion - would be nice if it was possible to set width of each tab separately, in case you have to mix tabs with short and long titles.

Thanks, David. Yes, you're correct with [1 1 parentPixelPos(3:4)].

I'm setting postition in pixels, rather than normalized units, to provide extra padding to content. E.g. if you try setting javacomponent with [0,0,1,1] normalized position as a child of uipanel with some title, you will notice that it is displayed on top of the title, hiding it completely. After pixel position is set, I revert the units to normalized, so resizing works pretty well. Yes, the padding size changes slightly when you resize, but that's hardly noticeable.

I'm guessing the right way would be indeed to hook up SizeChangedFcn callback as you suggest.

I do have to use Position as I use my own layout manager quite extensively, to fine-tune uicontrol layout inside panels created with uix toolbox. I will look at adding SizeChangedFcn to it. For now I've implemented a workaround that, when adding a child (uix.VBox or similar) to a TabPanel tab, switches briefly to that tab and switches back. That seems to solve the issue for me:

% panel is the parent that we just added a child (such as uix.VBox) to
if isa(panel.Parent, 'uix.TabPanel') % Workaround for the position calculation issue in GUI Layout toolbox
tabPanel = panel.Parent;
lastSelection = tabPanel.Selection;

[~, ind] = ismember(panel, tabPanel.Contents); % Note: Contents, unlike Children, has correct ordering
tabPanel.Selection = ind; % Temporarily select the tab. From now on position should be determined correctly

tabPanel.Selection = lastSelection; % Restore selection
end

David Sampson

Alexander, you touch on a number of interesting issues that I would like to address.

First, a minor point. In your code, you don't want to be setting the Position of your Java component in its container to be the Position of its container in its Parent. You probably meant javacomponent(jPanel,[1 1 parentPixelPos(3:4)],hSecondPanel). Anyway, more interestingly...

javacomponent(name,position,parent) sets the Parent and *then* sets the Position. Since the GLT containers lay out when the content is added, the subsequent set to Position clobbers the GLT Position. Indeed, we suggest you don't set Position of GLT container content yourself, but by using javacomponent, you might do so inadvertently.

Instead, you can create the Java component unparented, javacomponent(name,[0 0 1 1],[]), and then set its Parent as a second step.

It is true that we make no guarantees about the Position of unselected contents in GLT panels. Therefore there is no guarantee that getpixelposition on unselected content will return the same result after selection. Anyway it is most likely that you want your Java component to be a sensible size not just initially, but anytime its Parent resizes. For this, either put it in a GLT container (noting the points above) or hook up your own layout function using the Parent container's SizeChangedFcn.

In summary, I would replace the last 5 lines of your code with something like:
[jPanel, cPanel] = javacomponent( 'javax.swing.JPanel', [0 0 1 1], [] );
jPanel.setBorder( javax.swing.BorderFactory.createLineBorder( java.awt.Color.blue ) );
set( cPanel, 'Parent', hSecondPanel, 'Units', 'normalized', 'Position', [0 0 1 1] )

Finally, to contact me directly, it's firstname.lastname@mathworks.co.uk.

To be clear, it's not just about @getpixelposition. You'll face the same issue if you try to get position using any other method, e.g. simply: parent.Position. Apparently the only workaround that would cover all the cases is to define pre- and post-set listeners on Position property...

So in short, you cannot rely on @getpixelposition results unless that tab is currently selected. A workaround I can think of, would be traversing all ancestors before calling @getpixelposition to find all parent tab panels, select respective tab in each of them, and revert selection afterwards. This is very ugly and will cause lots of flickering in UI.

Hi David,

My issue (tab returning incorrect pixel position) is not related to how I set the position - both ways (through javacomponent and its uicontainer peer) work fine. The problem is in determining the correct position. Please find a very simplistic snippet reproducing the problem (sorry, not sure what you mean by 'File Exchange' contact form - are you referring to the 'Contact us' form to contact Mathworks?)

The snippet is below. Run the first set of commands, then switch to the second tab, then run remaining two commands. You'll see a neat blue border spanning the whole content of the tab.

And to reproduce the issue - run all the commands first, and then switch the tab. You will not see any border. Then check what parentPixelPos vector has - this is the problem.

hFig = figure();
hTabPanel = uix.TabPanel('Parent', hFig);
uicontainer('Parent', hTabPanel);
hSecondPanel = uicontainer('Parent', hTabPanel);
jPanel = javax.swing.JPanel;
jPanel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.blue));

parentPixelPos = getpixelposition(hSecondPanel);
javacomponent(jPanel, parentPixelPos, hSecondPanel);

Daniel, can you please contact me directly with full reproduction steps?

I don't use multiple monitors myself, so there may be parts of the toolbox which do not handle this well. I'd be happy to work on this, and I'd be interested in whether other users have had any issues with multiple monitors.

I am planning a release this month. The specific code that you refer to (uix.LocationObserver) has been removed. Nevertheless I would like to have your reproduction steps so that we can add a test to our test suite.

I set up some side-by-side windows in a single figure using this toolbox, and when I instantiate any new figure, it is docked by default. If I then undock the figure, send some plots to either window, and execute a "drawnow" command, I get the following java error:

Warning: Error occurred while executing callback:
Error using uix.LocationObserver/update/getFigurePixelPosition (line 239)
Java exception occurred:
java.awt.IllegalComponentStateException: component must be showing on the screen to
determine its location

at java.awt.Component.getLocationOnScreen_NoTreeLock(Unknown Source)

at java.awt.Component.getLocationOnScreen(Unknown Source)

Error in uix.LocationObserver/update (line 197)
pixel = getFigurePixelPosition( ...

Error in uix.LocationObserver/onSizeChanged (line 305)
obj.update( source )

Error in uix.LocationObserver>@(varargin)obj.onSizeChanged(varargin{:}) (line 123)
cbSizeChanged = @obj.onSizeChanged;

I am not a Java programmer. What sense should I make of this error message?

Note that undocking the figure usually causes it to appear on my right monitor; I have two. The MATLAB GUI is running on my left monitor. I am running R2014b on Windows 7 Enterprise, Service Pack 1.

Here is what I get when I type "opengl info" on the MATLAB command line:

>> opengl info
Version: '4.4.0'
Vendor: 'NVIDIA Corporation'
Renderer: 'Quadro K2100M/PCIe/SSE2'
MaxTextureSize: 16384
Visual: 'Visual 0x07, (RGBA 32 bits (8 8 8 8), Z depth ...'
Software: 'false'
SupportsGraphicsSmoothing: 1
SupportsDepthPeelTransparency: 1
SupportsAlignVertexCenters: 1
Extensions: {293x1 cell}
MaxFrameBufferSize: 16384

Alexander, a couple of comments.

"You need pixel position to use javacomponent." Actually, you don't. Instead, position by setting Parent, Units and Position of the uicontainer peer (second output argument of javacomponent). The Java widget position on screen is automatically synchronized with that of its peer container. Or just set Parent to a GUI Layout Toolbox container and let it manage its children's Units and Position.

>> t = uix.TabPanel( 'Parent', gcf, 'Padding', 10 );
>> [s, c] = javacomponent( 'javax.swing.JSpinner' );
>> c.Parent = t;

If you would like to send me reproduction steps for the case where position is different before and after selecting a tab, please do so via the File Exchange contact form, and I would be happy to provide further feedback.

I am facing a different problem now. I need to get pixel position of uix objects (you need pixel position to use @javacomponent, and in general if you want full control over how your elements are laid out inside). I'm also using uix.TabPanel. Problem is that position is not determined correctly until you switch to the tab, in which control is, at least once (!). Even drawnow does not help.

For example, this is the position I get before I switch the tab (wrong):

K>> get(parent, 'Position')
ans =
1 1 1192 795

And this is the position I get right after I switch the tab (correct):

K>> get(parent, 'Position')
ans =
1 747 1192 30

Clearly vertical position is all wrong. So I have to programmatically flick through all tabs before I can continue rendering the layout, otherwise all my controls are not even visible because they have completely wrong positions. v1 of the toolbox did not have such an issue.

David, I would be fine with either approach. For now I've hacked uix.Container (basically using similar code as in uix.Empty + extra onParentColorChanged call to initialize), but applying DefaultUicontainerBackgroundColor probably makes more sense than inheriting from parent.

Alexander, the MATLAB graphics defaults system cannot be extended to non-builtin classes, so we cannot support set(0,'DefaultHboxBackgroundColor').

However, we could decide to apply DefaultUicontainerBackgroundColor and/or DefaultUipanelBackgroundColor to new uix subtypes. What do people think?

I don't think that inferring (uix) container defaults from figure defaults is appropriate when there is a mechanism for setting (plain) container defaults.

Alexander, on the uix.Empty background color initialization, you are right: I need to call onParentColorChanged, although this should be guarded with if ~isempty(obj.Parent).

Actually, even uix.Empty has a problem. It sets the listener which handles subsequent background color changes, but it does not initialize the background properly when created. Makes sense to add onParentColorChanged(obj) call at the end to do this. But more importantly, all other uix components should do this as well.

I presume you are aware of this problem, since uix.Empty has explicit code to handle it: event listeners and corresponding onParentChanged / onParentColorChanged callbacks, which set uicontainer background to match parent. Why is it not done for any other uix objects, e.g. in uix.mixin.Container?

Firstly, thank you for the great toolbox!

I have a problem with default background color. I recently upgraded to R2015b, and also running Matlab on Windows 2008 Server. Apparently this combination somehow results in Matlab initializing all figures with a weird pink-ish background ([0.94,0.94,0.94]), while all other UI components are dark gray. I can deal with that simply by setting:

set(0,'DefaultFigureColor', [214,211,206]/255);

And that works for all figures I create. However uix objects are inherited directly from matlab.ui.container.internal.UIContainer, and this results in the same pink-ish background. So I have to set background for literally each new uix object I create. Is there a way to make it respect the global background color I set?

Thanks David, I made the suggestion to the author. I am facing an issue with uix.Grid. I am plotting 12 pie charts, and there is too much empty space in each grid, even though I set spacing to zero. Can you suggest a solution?

Thanks

Adam

Tanmay -> I usually embed uicomponents into a parent uipanel with no title or border and then parent that to the layout and then the layout will handle the panel fine.

e.g.

hSliderPanel = uipanel(...)
hSlider = uicomponent( 'Style', 'JSlider',...);
set( hSlider, 'Parent', hSliderPanel, 'Units', 'normalized', 'Position', [0 0 1 1];

I don't want to go into too much detail since this is somewhat outside of the realms of commenting on this specific toolbox, but that is the type of setup I use. I haven't worked with filechooser, but I assume you should be able to do something similar with it.

With regard to things being parented to non-figures, I actually just suppressed that warning because parenting by a panel does work, even straight up I think, but not with layouts, hence the above workaround for this.

David Sampson

Tanmay, looking into the uicomponent code further, I see:
1. The doc says that only figures are supported as Parents, but the code tries to support uicontainers, uipanels, uitabs.
2. Checking for valid Parent is by string comparison on class name, rather than by isa. That is why it rejects GLT containers, which are uicontainer subclasses.

Please ask the author to add support for HG2 uicontainer subclasses by checking isa(hParent,'matlab.ui.container.Container'). This is an undocumented class, but that should make it more not less attractive to the author!

David Sampson

Tanmay, I am not familiar with uicomponent, but I just downloaded it to run your reproduction steps. I see a warning that setting Parent of a uicomponent to a container rather than a figure is not supported:

Warning: Non-figure parent was specified - using the parent's figure as the component's parent

Adam - yes. How do you use it? set Widths in HBox does not recognize UIComponent. This doesnt work -

ImagePanel = uix.Panel('Parent', InfoTabPanel, 'Background', [1 1 1], 'Padding', 10);
ImageBox = uix.HBox('Parent', ImagePanel);
uix.Empty('Parent', ImageBox, 'Background', [1 1 1]);
uicontrol( 'Style','text','Parent',ImageBox,'String', 'GSR');
uicomponent('style','filechooser','Parent', ImageBox);
uix.Empty('Parent', ImageBox, 'Background', [1 1 1]);
set(ImageBox, 'Widths', [20 50 20 200], 'Spacing', 5 )

Because set Widths does not recognize UIComponent

Adam

David -> I will try to put together a simple example that doesn't include all the dependencies my production code has.

Tanmay -> Do you mean Yair Altman's uicomponent file exchange submission? If so then I use that in conjuction with this toolbox quite often to embed java sliders.

uicomponent is really just an expansion of uicontrol so it shouldn't be in any way incompatible with this toolbox, though there are some pitfalls with combining java components with layouts that need to be avoided.

David Sampson

Adam, can you please contact me directly with simple reproduction steps so that we can investigate.

Thanks David, I am having issue with TabPanel dividers, but it is not a real problem for me. I could not find display settings. One thing that would make this toolbox even more powerful is if you can use it in combination with UICOMPONENT toolbox. Is there any way?

Adam

An excellent toolbox that I tend to use more often than GUIDE now for a new UI.

However, I do seem to be having a recurring problem with the right-hand edge of panels not rendering in a lot of circumstances. This seems to be only when I use the -1 variable size for the panel. e.g. my current UI has 3 panels alongside each other with -1 widths all sat inside a layout. If I set the figure width to certain values it renders fine, but with most widths the right hand edge of my panels (plus panels inside these 3) does not render.

This appears to be fixable if I make the panels a fixed size rather than variable though this is quite a restriction.

Is anyone else having this problem or know what might be causing it?

Tanmay, I expect that this issue related to using Windows display settings other than 100%. (Check in Control Panel > Appearance and Personalization > Display.) Can you please confirm?

There were some changes in MATLAB in R2015b related to supporting high-DPI displays.
http://uk.mathworks.com/help/matlab/creating_guis/dpi-aware-behavior-in-matlab.html

As a result, I need to make some changes to BoxPanel and TabPanel, and hope to do so in the coming weeks. Your change will stop the error but you may notice that your TabPanel dividers don't look quite right.

Found the solution:
Change line 916 from
jData = repmat( jMask(5,:), [tabDivider.Position(4) 1] );
to
jData = repmat( jMask(5,:), [round(tabDivider.Position(4)) 1] );

Error using repmat
Replication factors must be a row vector of integers or integer scalars.

Error in uix.TabPanel/redrawTabs (line 916)
jData = repmat( jMask(5,:), [tabDivider.Position(4) 1] );

Error in uix.TabPanel/redraw (line 673)
obj.redrawTabs()

Error in uix.mixin.Container/set.Dirty (line 144)
obj.redraw() % redraw now

Error in uix.TabPanel/set.TabTitles (line 563)
obj.Dirty = true;

Error in FieldMaster (line 134)
FieldTab.TabTitles = {'Cutter', 'Bit', 'Run', 'Dull'};

This does not work for R2015b. I am getting error using repmat for some reason.

jvc

Johannes - I think the problem you are describing is due to a known MATLAB issue. For a description of the problem see the bug report at:

https://www.mathworks.com/support/bugreports/1293244

The short form fix which worked for me (assuming you are compiling for windows) is to add this line to your code and recompile:

javax.swing.UIManager.setLookAndFeel('com.sun.java.swing.plaf.windows.WindowsLookAndFeel')

Johannes

Hi, another issue came up while creating an executable. All the buttons miss their borders. The text is displayed and I can also click on them but the button itself is invisible. Am I doing something wrong here?

Johannes

David, thank you very much! That solved my problem.

David Sampson

Johannes, please take a look section 2.3 "colorbars and legends" of the GUI Layout Toolbox documentation. Please group your illustrations with their axes inside a uicontainer.

Johannes

I encountered some problems with legends in uix. I updated my software from Matlab 2014a to 2015b and therefore used uix instead of uicontrols. After some modifications it looks as beautiful as ever. However, it is not possible to display legends in a correct way. I used exactly the same code but the legend is not shown in the right plot even though the correct axes handle is provided. Instead it is shown as a separate HBox below my plots in the corresponding panel of my GUI. Any idea, what might go wrong here? Thank you for your help!

hi how do I use this to edit my GUI .fig files?

Vinh Dang

Can I create a panel containing a uitabgroup with many uitabs?

David Sampson

Alex, please review the release notes, which give a brief summary of which capabilities were added in which release.
http://www.mathworks.com/help/matlab/release-notes.html

There have been various new features and performance improvements including a new "MATLAB Execution Engine" in R2015b.

For GUI Layout Toolbox (v2), you can access all features from any release from R2014b.

I'm using the current version of toolbox with Matlab 2014b. As far as this toolbox is concerned, is there any compelling benefit to upgrading to Matlab 2015a or 2015b? e.g. speed improvements that would affect Gui Layout Toolbox in newer Matlab versions, or additional features.

Amy, your question is a graphics question rather than a GUI Layout Toolbox question. plot is convenient but it has side effects including clearing the axes ButtonDownFcn. A couple of suggestions:
1. Write a lower level callback function that doesn't use plot
2. Use the axes event Hit rather than the axes callback ButtonDownCallback

Here's an example of #1:
>> a = axes();
>> l = plot( a, 0:10, rand( 1, 11 ) );
>> a.ButtonDownFcn = @(~,~)set(l,'YData',rand(1,11));

I am trying to implement a VBox with a fixed height child (a) followed by two proportional children (b, c). For the fixed height child (a) I would like the height to be set by the maximum height required by any of children of (a). I have written a function that descends through the children and keeps track the required height via child.Extent. The only problem I have is that for the life of me I can not find a way to determine how much height a Panel will add (title + border) on top of its contents BEFORE it is rendered. I know how to use hgconvertunits to calculate this after the panel has been rendered, but not before. Any ideas?

Amy Brisben

Hello, I am enjoying overhauling our GUI using your toolbox. One question, though: is it possible to update axes without deleting the axes object and re-creating it? (That is the method in demoBrowser.m and in the comments listed below). The problem that I have is, the axis has a 'ButtonDownFcn' that I want to be able to re-use, so I don't see why I should delete the object. The code example is:

%declare object
handles.dp= uix.BoxPanel( 'Tag', 'dataPlot', 'Title', 'Data Plot', 'Parent', handles.gui.leftDataBox);
handles.plotp= uipanel('Parent',handles.dp);
handles.Data_plot = axes('Parent',handles.dp,'ButtonDownFcn',@Data_plot_ButtonDownFcn,...);

... %(create data) ; this displays correctly the first time but not subsequent times.

subplot(handles.Data_plot);
plot(data, 'LineWidth', line_thickness);

I've tried to replace the "subplot" command with the line below (based on comments I've read here), but that didn't help.

set(gcf,'CurrentAxes',handles.Data_plot);

Thank you in advance, Amy

Collin, h(1:n) = uix.HBox(...) creates a single HBox and a 1-by-n array of handles h with each element pointing to that same HBox. If you want to create multiple boxes then you need to do so in a loop.

Collin

Having difficulties with arrays of uix objects.
What I want to do;

cnt = 40;
v = uix.VBox('Parent',figure);
h(1:cnt) = uix.HBox('Parent',v);
labels(1:cnt) = uicontrol('Style','edit',.....);
values(1:cnt) = uicontrol('Style','edit',....);

for i = 1:cnt
set(labels(i),'Parent',h(i), set other properties)
set(values(i),'Parent',h(i), set other properties)
end

The contents/ children property of the VBox only has a single HBox object.
Setting the parent property of the Hboxes inside the loop does not seem to
work, while setting everthing by brute force inside the loop does. Are
there empty objects I could be pre-allocating?

Collin