Figure window transitions (screen transitions - GUI design)

2 views (last 30 days)
Hi. My idea is building a logo image (similar to Matlab's startup one) which shows before my gui is appeared. I have the following code, which was obtained modifying the solution given by MathWorks, for it:
% create a figure1 that is not visible yet, and has minimal titlebar properties
fh = figure('Visible','off','MenuBar','none','NumberTitle','off',...
'DockControls','off');
% put an axes in it
ah = axes('Parent',fh,'Visible','on');
% put the image in it
ih = imshow('SIS.gif','Parent',ah);
% set the figure1 size to be just big enough for the image, and centered at
% the center of the screen
imxpos = get(ih,'XData');
imypos = get(ih,'YData');
set(ah,'Unit','Normalized','Position',[0,0,1,1]);
figpos = get(fh,'Position');
figpos(3:4) = [imxpos(2) imypos(2)];
set(fh,'Position',figpos);
movegui(fh,'center')
% make the figure1 visible
set(fh,'Visible','on');
pause(3);
close(fh);
I have two problems:
#1: I want the logo image's figure windows has no borders, no title and no taskbars. I have tried the WindowAPI but it does not work because I call it after the above code and because of the visibility of the window is off, then the handle of it is off too.
#2: I want that, when the logo image is disappeared, it is showed the gui window mazimized. Where is the problem? The screen transition between the logo image's window and the gui window is not smoothed. I have tried to use a lot of Matlab´s applications that I found in FEX (WindowAPI, Maxfig, Maximize, SetFigTransparency,...) without success. I realized that the problem is the visibility of my gui (I set off until all elements are created and then I change it to on). Because of the off visibility cause the handlevisibility is off too, the previous mentioned applications has no effects on the figure window that I want to maximize.
After observating the startup of Matlab, I have noticed that after the logo is showed, it appears a fullscreen image followed by the normal fullscreen of the program. So I have tried to create an maximized fullscreen windows that appears after the logo's windows is closed. However, now the problem is the transition between this last and the gui window. If I set the visibility of the gui window on and then I maximize it, during an instant it can be seen that transition that bothers me. I do not know what to do. I also think that if I could avoid that the guide window is currentfigure when I change its visibility, perhaps I would achieve it. Other solution it might be a timer that hold on the white window as currentfigure while the guide window is behind changing its visibility but I do not know how to do. Thank you for your attention.
  2 Comments
Paulo Silva
Paulo Silva on 9 Jun 2011
you have a big problem there, it's way above my experience with MATLAB so I can't help you but I'm voting on your question and looking for tips from the experts :) good luck
Julián Francisco
Julián Francisco on 9 Jun 2011
@Paulo Silva: Thank you so much for your comment. I am grateful for your help. Cheers.

Sign in to comment.

Accepted Answer

Julián Francisco
Julián Francisco on 11 Jun 2011
After a long research work, I have found a reasonable answer which was nearest to that I thought. If you type in "splash screen" in the File Exchange browser, you have some interesting applications designed specifically to it. I have chosen splash.m. With respect to the smooth transition, I have used these programs: WindowAPI and maximize. The written code looks like this:
logoh = splash('logo.jpg');% Appear the logo image
fh = figure('Visible','on','Name','MyGUI','Position',[-1000,-1000,...
1000,500],'Menu','none','Toolbar','none','NumberTitle','off');
% Put the figure window outside the screen (see Position property) because
% its visibility is on
WindowAPI(fh,'Alpha',0);% Make the figure window invisible
...
movegui(fh,'center');% Move the figure window to center
maximize(fh);% Maximize it
WindowAPI(fh,'Alpha',1); % Make the figure window visible totally
pause(2); % time during which the logo image is exposed
splash(logoh,'off');% Disappear the logo image

More Answers (2)

Jan
Jan on 9 Jun 2011
You can use WindowAPI by creating the figure with enabled visibility, but outside the screen, e.g.:
FigH = figure('Position', [-1000, -1000, 200, 200], ...
'Color', zeros(1, 3));
axes('Units', 'normalized', 'Position', [0.4, 0.4, 0.2, 0.2]);
sphere;
WindowAPI(FigH, 'Alpha', 0, uint8([0,0,0]));
WindowAPI(FigH, 'fullscreen');
WindowAPI(FigH, 'topmost');
This is not exactly "figure windows has no borders, no title and no taskbars", but you can see only the axes contents.
  1 Comment
Julián Francisco
Julián Francisco on 11 Jun 2011
@Jan Simon: Thank you for you answer. You are right but I keep the idea of creating a figure window outside the screen. Cheers.

Sign in to comment.


Robert Cumming
Robert Cumming on 9 Jun 2011

This is as close as I have got so far on this one:

screenSize = get(0,'ScreenSize');
d = dialog ( 'WindowStyle', 'normal', 'visible', 'off', ...
   'position', [0 0 screenSize(3), screenSize(4)] );
uicontrol ( 'parent', d, 'style', 'text', ...
            'string', 'myTest', 'units', 'normalized', ...
           'position', [0.4 0.4 0.1 0.1] );
drawnow()
% Start to create Your SplashScreen
img = imread('splash.png');  
jimg = im2java(img);  
frame = javax.swing.JFrame;  
frame.setUndecorated(true);  
icon = javax.swing.ImageIcon(jimg);  
label = javax.swing.JLabel(icon);  
frame.getContentPane.add(label);  
frame.pack;  
frame.setSize(screenSize(3),screenSize(4));  
frame.setLocation(screenSize(3),screenSize(4));  
frame.show;
pause(3)
frame.dispose;
set ( d, 'visible', 'on' )
pause(4);
close(d)

Mathworks support has a page about splash screens as well.

  3 Comments
Robert Cumming
Robert Cumming on 10 Jun 2011
it should show the image for 3 seconds, which then disappears and is replaced with you GUI.
You did change the filename on the line: img = imread('splash.png'); ?
Julián Francisco
Julián Francisco on 10 Jun 2011
@Robert Cumming: Yes, I did but it is only displayed the dialog window corresponding to "myTest" for 4 seconds. I notice that I have trouble with some Java commands. For example, I must write the drawnow command before the statements "jFrame = get(handle(gcf), 'JavaFrame'); jFrame.setMaximized(true);" if I want to maximize a figure window. Because of it, I have inserted a drawnow command between each two lines of your code but it still continues without working.

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!