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