www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@roller/private/pr_transitionon.m

    function pr_transitionon(rl)
%ROLLER/PRIVATE/PR_TRANSITIONON   Private function
%   Private rolling function for roller object

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.



% Rolling on needs to pull the on text and frame down from above
ROLLCOUNT=pr_getrolls;

% only do if object is visible
if get(rl.frame1,'UserData')
   endpos=get(rl.frame1,'Position');
   % set frame2 start pos
   onpos=[endpos(1) endpos(2)+endpos(4)-1 endpos(3) 1];
   offpos=[endpos(1) endpos(2) endpos(3) endpos(4)-1];
   set(rl.frame2,'Position',onpos,'Visible','on');
   ontxt=0;
   offtxt=1;
   amp=endpos(4)-2;
   drawnow;
   for t=0:pi/ROLLCOUNT:pi
      onpos(2)=1+endpos(2)+amp*(cos(t)+1)/2;
      onpos(4)=endpos(2)+endpos(4)-onpos(2);
      % do frames
      offpos(4)=1+amp*(cos(t)+1)/2;
      set([rl.frame1;rl.frame2],{'Position'},{offpos;onpos});
      % check for turning on ontxt and off offtxt
      if ~ontxt & onpos(4)>=3;
         set(rl.text2,'Visible','on');
         ontxt=1;
      end
      if offpos(4)<3
         set(rl.text1,'Visible','off');
         offtxt=0;
      end
      if ontxt
         set(rl.text2,'Position',[onpos(1)+1 onpos(2)+1 onpos(3)-2 onpos(4)-2]);
      end
      if offtxt
         set(rl.text1,'Position',[offpos(1)+1 offpos(2)+1 offpos(3)-2 offpos(4)-2]);
      end
      drawnow;
   end
   % finish off neatly
   set(rl.frame1,'Visible','off','Position',endpos);
   set([rl.text1;rl.text2],'Position',[endpos(1)+1 endpos(2)+1 endpos(3)-2 endpos(4)-2]);
   set(rl.frame2,'Position',endpos);
end