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