How to add minimize tool button in GUI ?

3 次查看(过去 30 天)
I have a GUI which has several charts/graphs to display. But I would like to add an GUI object whose function is to minimize /maximize or restore the graph/plot within the GUI using a button. How can I do it? I have seen the list of GUI components, none of them are relevant to what I am looking for. Is it possible to import new functionality from other development environments like Microsoft .Net /Visual Studio or JAVA to MATLAB.
  1 个评论
Jan
Jan 2018-7-8
It depends on what "minimize /maximize or restore the graph/plot" exactly means. A button, which makes an axes object and all its children invisible`? This would be easy to implement.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2018-7-8
编辑:Jan 2018-7-8
function main
Gui.FigH = figure;
Gui.AxesH = axes;
Gui.ButtonH = uicontrol('Style', 'ToggleButton', 'Value', 1, ...
'String', 'Show axes', ...
'Units', 'pixels', ...
'Position', [5, 5, 80, 25], ...
'Callback', @ButtonCB);
plot(rand(10));
Gui.ButtonH.Units = 'normalized';
Gui.ButtonPos = Gui.ButtonH.Position;
Gui.ButtonH.Units = 'pixels';
Gui.AxesPos = Gui.AxesH.Position;
guidata(Gui.FigH, Gui);
end
function ButtonCB(ButtonH, EventData)
Gui = guidata(ButtonH);
if ButtonH.Value
state = 'on';
else
state = 'off';
end
set(Gui.AxesH, 'Visible', state);
set(allchild(Gui.AxesH), 'Visible', state);
end
This is a kind of "minimizing" already and really cheap to implement. You can write a zooming or moving out of the visible area easily also. Change the callback to:
function ButtonCB(ButtonH, EventData)
Gui = guidata(ButtonH);
if ButtonH.Value
ini = Gui.ButtonPos;
fin = Gui.AxesPos;
state = 'on';
else
ini = Gui.AxesPos;
fin = Gui.ButtonPos;
state = 'off';
end
% Make axes visible and move it to or from the button position:
set(Gui.AxesH, 'Visible', 'on');
set(allchild(Gui.AxesH), 'Visible', 'on');
n = 20;
step = (fin - ini) / n;
for k = 1:n
set(Gui.AxesH, 'Position', ini + k * step);
drawnow;
end
set(Gui.AxesH, 'Visible', state);
set(allchild(Gui.AxesH), 'Visible', state);
end
In this example the axes is moved to or from the position of the button. Other effects are easy to implement also: Moving above the top of the window, shrinking inplace until they vanish, etc. Of course there are many ways to overdue the effects...

更多回答(1 个)

Image Analyst
Image Analyst 2018-7-8
The GUI already comes with controls in its title bar for minimizing, maximizing, and normalizing the whole window.
If you want to minimize just one axes on the GUI, then it might be best to just put the entire axes control into a panel control and set the visibility property of the panel on or off. There are other ways but they're more complicated because a graph has lots of handles associated with it, not just one like a panel does.
  1 个评论
VBBV
VBBV 2018-7-8
What I am interested in is to set the axes control/plotting area to appear in more interactive / dynamic way ... more like the dropdown appearance, and windup when clicked using button, or some other object component ... I see that there is no GUI object/component available in MATLAB which has that functionality which is available in MS .Net / Visual Studio environment

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by