Subversion Repositories filter_foundry

Rev

Rev 526 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.     This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop
  3.     Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.net
  4.     Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 2 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19. */
  20.  
  21. #include "preview.h"
  22. #include "ui.h"
  23.  
  24. extern CursHandle handcursor; // provided and initialised by ui_mac.c
  25.  
  26. pascal void preview_item(DialogRef dp,DialogItemIndex item);
  27. pascal Boolean previewfilter(DialogRef dialog,EventRecord *event,short *item);
  28.  
  29. pascal void preview_item(DialogRef dp,DialogItemIndex item){
  30.         GrafPtr port;
  31.  
  32.         ENTERCALLBACK();
  33.  
  34.         GetPort(&port);
  35.         SetPortDialogPort(dp);
  36.  
  37.         drawpreview(dp,0,PILOCKHANDLE(preview_handle,false));
  38.         PIUNLOCKHANDLE(preview_handle);
  39.  
  40.         FrameRect(&preview_rect);
  41.  
  42.         SetPort(port);
  43.  
  44.         EXITCALLBACK();
  45. }
  46.  
  47. // The following code is not actually used by Filter Foundry;
  48. // it implements an event filter for plugins that need
  49. // only preview functionality (without sliders).
  50.  
  51. pascal Boolean previewfilter(DialogRef dialog,EventRecord *event,short *item){
  52.         int i;
  53.         Point pt,origscroll,newscroll;
  54.         Boolean result = false,f;
  55.         EventRecord ev;
  56.         GrafPtr oldport;
  57.  
  58.         ENTERCALLBACK();
  59.  
  60.         GetPort(&oldport);
  61.         SetPortDialogPort(dialog);
  62.  
  63.         if( !event->what || (event->what == updateEvt
  64.                                                  && (WindowRef)event->message != GetDialogWindow(dialog)) )
  65.         {       // pass null events and update events to Photoshop
  66.                 gpb->processEvent(event);
  67.         }
  68.         else if(event->what == mouseDown){
  69.                 pt = event->where;
  70.                 GlobalToLocal(&pt);
  71.  
  72.                 i = FindDialogItem(dialog,pt)+1;
  73.                 if(i == PREVIEWITEM){
  74.                         SetCursor(*handcursor);
  75.                         origscroll = preview_scroll;
  76.                         do{
  77.                                 f = WaitNextEvent(mUpMask,&ev,5,NULL);
  78.                                 newscroll.h = origscroll.h - zoomfactor*(ev.where.h - event->where.h);
  79.                                 newscroll.v = origscroll.v - zoomfactor*(ev.where.v - event->where.v);
  80.                                 if(!EqualPt(newscroll,preview_scroll)){
  81.                                         preview_scroll = newscroll;
  82.                                         recalc_preview(gpb,dialog);
  83.                                 }
  84.                         }while(!f);
  85.  
  86.                         *item = i;
  87.                         result = true;
  88.                 }
  89.         }
  90.         else
  91.                 result = StdFilterProc(dialog,event,item);
  92.  
  93.         SetPort(oldport);
  94.  
  95.         EXITCALLBACK();
  96.  
  97.         return result;
  98. }
  99.