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