【问题标题】:Matlab figure window transitions (screen transitions - GUI design)Matlab图形窗口转换(屏幕转换-GUI设计)
【发布时间】:2011-06-09 09:45:29
【问题描述】:

我的想法是构建一个徽标图像(类似于 Matlab 的启动图像),它会在我的 gui 出现之前显示。我有以下代码(它是通过修改How do I make a splash screen for my MATLAB GUI application? 给出的解决方案获得的):

% 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);

我有两个问题:

  • 数字 1:我希望徽标图像的图形窗口没有边框、标题和任务栏。我尝试过WindowAPI,但它不起作用,因为我在上面的代码之后调用它并且由于窗口的可见性关闭了,所以它的句柄也关闭了。

  • 编号 2:我希望,当徽标图像消失时,它会显示 gui 窗口最大化。问题出在哪里?徽标图像窗口和 gui 窗口之间的屏幕转换不平滑。我尝试使用在 Matlab Central 的文件交换中找到的许多 Matlab 应用程序(WindowAPI、Maxfig、Maximize、SetFigTransparency...),但没有成功。我意识到问题在于我的 gui 的可见性(我开始工作,直到创建所有元素,然后将其更改为 on)。由于关闭可见性导致handlevisibility也关闭,前面提到的应用程序对我想要最大化的图形窗口没有影响。

观察Matlab的启动后,我注意到标志显示后,出现一个全屏图像,然后是程序的正常全屏。因此,我尝试创建一个最大化的全屏窗口,该窗口在徽标的窗口关闭后出现。但是,现在的问题是最后一个窗口和 gui 窗口之间的转换。如果我将 gui 窗口的可见性设置为打开,然后将其最大化,那么在瞬间可以看到困扰我的过渡。我不知道该怎么办。我还认为,如果我可以在更改其可见性时避免指南窗口是 currentfigure,也许我会实现它。其他解决方案可能是一个计时器,将白色窗口保持为 currentfigure,而引导窗口落后于更改其可见性,但我不知道该怎么做。感谢您的关注。干杯。

【问题讨论】:

    标签: user-interface matlab look-and-feel


    【解决方案1】:

    正如我在this answer 中展示的那样,派生自this MathWorks newsgroup thread,您可以使用Java 创建一个没有标题、边框等的窗口。这是我的其他答案中对代码的修改,以创建以屏幕为中心的启动窗口:

    img = imread('peppers.png');  %# A sample image to display
    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;
    imgSize = size(img);
    frame.setSize(imgSize(2),imgSize(1));
    screenSize = get(0,'ScreenSize');  %# Get the screen size from the root object
    frame.setLocation((screenSize(3)-imgSize(2))/2,...  %# Center on the screen
                      (screenSize(4)-imgSize(1))/2);
    frame.show;  %# You can hide it again with frame.hide
    

    我会尝试这个来创建您的启动画面,看看它是否也有助于解决转换到下一个 GUI 窗口的问题。

    【讨论】:

    • 感谢您的回答。给定的解决方案可用于创建启动画面。我会添加一些语句(pause(3); frame.hide;)来控制图像曝光的时间(在这种情况下为 3 秒)。干杯
    【解决方案2】:

    经过长期的研究工作,我找到了一个与我认为最接近的合理答案。如果您在File Exchange 浏览器中输入“启动画面”,您就会有一些专门为它设计的有趣应用程序。我选择了splash.m。关于平滑过渡,我使用了这些程序:WindowAPImaximize

    写出来的代码是这样的:

        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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-06
      • 2017-02-01
      • 1970-01-01
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多