Matlab ResizeFcn callback

조회 수: 19 (최근 30일)
Julián Francisco
Julián Francisco 2012년 2월 26일
I am worried about the look and feel of my GUI designed with Matlab. In concrete, I do not like how the figure window resizing is achieved. I have an uitabgroup (tabpanel) inside which there are three panels with border etchedin. Each time the figure is resized, it appears flickering between both positions of the panels. I hate this optical effect. So, I decided to build my own resizefcn callback to get being pleased. However, I realize Matlab first resizes the figure window and then it runs the commands inside the resizefcn callback. I would like to know if there is some solution that lets me to change this behaviour.
  댓글 수: 3
Julián Francisco
Julián Francisco 2012년 2월 27일
@Jiro Doke: Thank you for your comment. In my particular case, I was really thinking of the resizing that happens when the resize button of the figure window upper right corner is pressed. It makes sense that the figure window to be resized first though the observed optical effect becomes annoying. I have tried to change the visibility of the figure window between both states (normal and resized) but because of the resizefcn callback runs after the resizing, it does not work. I also notice that this latter function only is run when the figure increases its size but not when it is minimized (I had to make some changes to change this concrete behaviour).
Walter Roberson
Walter Roberson 2012년 2월 27일
The resize mechanism is ugly. But until such time as MATLAB comes complete with built-in layout functions for the elements ("put this part down here if there is room"), I don't know that anything can be done.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2012년 2월 27일
Sometimes the resizing looks weird: I have a uitree object on the left side of a GUI. During the resizing movement (mouse hold down, ResizeFcn is not called), the display is as expected, when I have selected the right lower corner of the figure. Then the lower left corner of the uitree keeps its absolute position in the figure, while the size is not changed - not nice, but not confusing.
But when I select the lower or left border of the figure, the uitree behaves funny, e.g. the height is reduced by the double rate than the reduction of the heigth of the figure. The optical impression is as strange as the textual description...
Of course everything is fine, when the ResizeFcn is called after lifting the mouse button. But the "look&feel" during the resizing is awkward.
2 workarounds:
  1. Close your eyes during resizing. It's time to calm down and take a break from visual impressions.
  2. Disable the resizing controlled by Matlab, but create a dedicated WindowButtonDownFcn by your own. If the mouse clicks near to the border (or in dedicated objects in the corners), the cursor changes to the appropriate shape and the WindowButtonMotionFcn can control the position of the figure.
  댓글 수: 3
Jan
Jan 2012년 2월 28일
If you disable the built-in resizing, it will not impede your own implementation: figure('Resize', 'off');
Then you can e.g. create a WindowButtonMotion function, which modifies the cursor, when the mouse is near to the edge or corners. Then the WindwoButtonDownFcn activates another WindowButtonMotionFcn, when the mouse is pressed near to the border. Then this modified WindowButtonMotionFcn is the actual ResizeFcn and it is triggered whenever the mouse changes its position - not only if it is released.
But this approach will need > 100 lines of code and it might interfer with and existing WindowButtonMotionFcn. Some improper GUI tools might overwrite the WindowButtonMotionFcn and do not restore it - as far as I remember in earlier Matlab versions the zooming was not polite enough.
Julián Francisco
Julián Francisco 2012년 2월 28일
@Jan Simon: I am not worried about the resizing made changing the figure window size with the mouse but only the one achieved pressing the resize button. So, I will try to build a WindowButtonDownFcn for my purpose.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2012년 2월 27일
You might be able to reduce the flash grunge by setting the figure visibility to 'off' during the resize process, and then to 'on' again when the resize is finished.
  댓글 수: 1
Julián Francisco
Julián Francisco 2012년 2월 27일
@Walter Roberson: Thank you for your answer. I have already tried that solution but, as I mentioned on my above comments, Matlab first resizes the figure window and then it runs the resizefcn callback.

댓글을 달려면 로그인하십시오.


Malcolm Lidierth
Malcolm Lidierth 2012년 2월 27일
If you a using the mouse to resize, the figure will always be updated multiple times because it has multiple sizes between the start and end of the mouse drag. There are any number of solutions. See http://undocumentedmatlab.com/blog/controlling-callback-re-entrancy/
  댓글 수: 1
Julián Francisco
Julián Francisco 2012년 2월 27일
@Malcolm Lidierth: Thank you for your answer. I was referring to the resizing that occurs when the resize button of the figure window upper right corner is pressed.

댓글을 달려면 로그인하십시오.

카테고리

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