// Text of project UpInSmoke.? written on 11/21/95 at 1:33 PM
// Beginning of file UpInSmoke.t

// Before Script for "smokeItBase"
// Copyright 1993-1995 Apple Computer, Inc. All rights reserved.


smokeItBase :=
    {title: "gesture to see some smoke",
     viewBounds: {top: 0, left: 0, right: 180, bottom: 180},
     viewFormat: 328016,
     viewFlags: 1541,
     SmokeIt:
       /*
       
          This function erases an area using a poof sound and dissipating
          smoke and then forces that portion of the screen to be refreshed.
          It takes one argument, a bounds frame in global coordinates.
       
        */
       
       func(smokeBounds)
       begin
       
         local top  := smokeBounds.top;
         local left := smokeBounds.left;
       
         local bm1 := Clone(ROM_cloud1);
         local bm2 := Clone(ROM_cloud2);
         local bm3 := Clone(ROM_cloud3);
         
         //CopyBits draw bitmaps scaled to their bounds
         bm1.bounds := bm2.bounds := bm3.bounds := smokeBounds;
        
         //explained below
         local danQuayle := BuildContext({viewClass:clView,viewFlags:vFloating,viewBounds:smokeBounds,reorienttoscreen:func()nil});
       
         PlaySound(ROM_poof);
       
         GetRoot():CopyBits(bm1,left,top,modeMask);
         Sleep(2);
         GetRoot():CopyBits(bm1,left,top,modeBic);
       
         GetRoot():CopyBits(bm2,left,top,modeMask);
         Sleep(2);
         GetRoot():CopyBits(bm2,left,top,modeBic);
       
         GetRoot():CopyBits(bm3,left,top,modeMask);
         Sleep(1);
         GetRoot():CopyBits(bm3,left,top,modeBic);
       
         //force an update (ala InvalRect in the Mac ToolBox)
         danQuayle:Open();
         danQuayle:Close();
         
         //If you knew what view(s) to dirty you could just use :Dirty()
         // to force the update. This code is general purpose, so it
         // doesn't know (and GetRoot():Dirty is way slow)
       
         // In the 2.0 OS only, you could use a better technique,
         // simple call GetRoot():DirtyBox(<box>)
       end,
     viewStrokeScript:
       func(unit)
       begin
          // smoke an area slightly large than the stroke to ensure
          // it completely obscures the stroke.
       
          local strokeBox := StrokeBounds(unit);
          local qWidth := Max(10,(strokeBox.right - strokeBox.left) DIV 4);
          local qHeight := Max(10,(strokeBox.bottom - strokeBox.top) DIV 4);
          strokeBox.top := strokeBox.top - qHeight;
          strokeBox.left := strokeBox.left - qWidth;
          strokeBox.bottom := strokeBox.bottom + qHeight;
          strokeBox.right := strokeBox.right + qWidth;
       
          InkOff(unit);
         :SmokeIt(strokeBox);
       
          true;
       end,
     viewSetupDoneScript:
       func()
       begin
         :SmokeSelf()
       end,
     smokeSelf:
       func()
       begin
         local lBox := self:LocalBox();
         local gBox := self:GlobalBox();
         local hCenter := (gBox.left + gBox.right) DIV 2;
         local vCenter := (gBox.top + gBox.bottom) DIV 2;
         local width := 3*lBox.right DIV 4;
         local height := 3*lBox.bottom DIV 4;
         local smokeBounds := SetBounds(hCenter - width,vCenter - height,hCenter + width, vCenter + height);
         :SmokeIt(smokeBounds)
       end,
     viewQuitScript:
       func()
       begin
         :SmokeSelf()
       end,
     viewJustify: 80,
     ReorientToScreen: func() nil;,
     debug: "smokeItBase"
     ,
     _proto: @157
    };


constant |layout_UpInSmoke.t| := smokeItBase;
// End of file UpInSmoke.t



