Following my post two weeks ago about disabling an entire Matlab figure window, and my article last week about setting the transparency of a figure window, I would like to combine these two functionalities into a blurred-window effect for a disabled window.
The basic idea
The basic idea, as reader Mory pointed out in a comment, is to overlay a semi-transparent empty figure window, having just the right size and position, on top of the main (disabled) figure window:



Main (unblurred) window + semi-transparent window = blurred window effect
In addition to ensuring the correct figure size and position, there are several other things we should care for: We need to synchronize the figure/blurring color, menubar/toolbar, and title. We also need to handle docking, resizing and figure movement. Finally we need to connect the two figures so that whenever one is closed then so is the other.
blurFigure
My blurFigure utility on the Matlab File Exchange attempts to handle all these setups for the user. The utility is quite simple to use:
blurFigure(hFig) blurs figure hFig and prevents interaction with it. The only interaction possible is with user-created controls on the blurring panel (see below).
hFigBlur = blurFigure(hFig) returns the overlaid blurred figure pane. This is useful to present a progress bar or other GUI controls, for user interaction during the blur phase (see the demo below).
blurFigure(hFig,STATE) sets the blur status of figure hFig to STATE, where state is ‘on’,'off’,true or false (default=’on’/true). blurFigure(hFig,’on’) or blurFigure(hFig,true) is the same as: blurFigure(hFig); blurFigure(hFig,’off’) or blurFigure(hFig,false) is the same as: close(hFigBlur).
blurFigure(‘demo’) displays a simple demo of the blurring. In fact, this runs the following simple code:
% Create the main (blurred) figure window hFigMain = figure; % Display some GUI controls in the main window try oldWarn = warning('off','MATLAB:uitree:MigratingFunction'); catch, end hTree = uitree('root','c:\'); drawnow; try hTree.getTree.expandRow(0); catch, end try warning(oldWarn); catch, end uicontrol('string','click me!', 'units','pixel', 'pos',[300,50,100,20]); axes('parent',gcf, 'units','pixel', 'pos',[230,100,300,300]); surf(peaks); set(gcf,'ToolBar','figure'); % restore the toolbar that was removed by the uicontrol() call above % Call blurFigure() to add a semi-transparent overlaid window hFigBlurTemp = blurFigure(hFigMain); % Add some non-blurred controls on top of the blur uicontrol('parent',hFigBlurTemp, 'style','text', 'units','pixel', 'pos',[130,85,390,80], ... 'string','Processing - please wait...', 'FontSize',12, 'FontWeight','bold','Fore','red','Back','yellow'); jProgressBar = javacomponent('javax.swing.JProgressBar', [180,115,310,20], hFigBlurTemp); jProgressBar.setValue(67); uicontrol('parent',hFigBlurTemp, 'string','Cancel', 'pos',[280,90,100,20], 'Callback','close(gcbf)');

Non-blurred controls displayed over a blurred figure window
Do you have some other interesting uses for window transparency in Matlab? If so, please share your thought in a comment.
Related posts:
- Transparent Matlab figure window Matlab figure windows can be made fully or partially transparent/translucent or blurred - this article explains how...
- Enable/disable entire figure window Disabling/enabling an entire figure window is impossible with pure Matlab, but is very simple using the underlying Java. This article explains how....
- Minimize/maximize figure window Matlab figure windows can easily be maximized, minimized and restored using a bit of undocumented magic powder...
- Customizing figure toolbar background Setting the figure toolbar's background color can easily be done using just a tiny bit of Java magic powder. This article explains how. ...