Thursday, April 1, 2010

Programming filters with Xcode +...

Hi,

I've figured out how to make a working PC Photoshop plugin and am now figuring out the Mac side. What is a reasonable method for creating/altering the GUI... e.g. altering the Dissolve filter example's GUI or creating my GUI from scratch?



I looked through the Dissolve filter example and it's not clear how to alter the GUI... the documentation talks about the example being a Xcode project but the .r file doesn't open in interface builder. Perhaps one is to use Metrowerks Codewarrior...? (But I don't have that program and it doesn't look available.) So basically I am thinking I have to figure out how to get the filter working with Xcode/interface builder/carbon. It would be helpful if there was example code for that.



2- I am on the Mactel platform (Macbook Pro).



Any help would be greatly appreciated! Thanks.
Programming filters with Xcode +...
Ok so I've figured out part of the puzzle. You can make Carbon windows normally, with the complication of the plugin finding the NIB properly.%26lt;br /%26gt;%26lt;br /%26gt;I needed to add the following two lines to info.plist (choose whatever identifier you want)%26lt;br /%26gt;%26lt;br /%26gt; %26lt;key%26gt;CFBundleIdentifier%26lt;/key%26gt;%26lt;br /%26gt; %26lt;string%26gt;Whatever identifier you want goes here%26lt;/string%26gt;%26lt;br /%26gt;%26lt;br /%26gt;And then in your DissolveMacUI.cpp you might do something like:%26lt;br /%26gt;%26lt;br /%26gt; IBNibRef theNib;%26lt;br /%26gt; CFBundleRef bundleRef;%26lt;br /%26gt; bundleRef = CFBundleGetBundleWithIdentifier (CFSTR (''Whatever identifier you want goes here''));%26lt;br /%26gt; %26lt;br /%26gt; err = CreateNibReferenceWithCFBundle(bundleRef, CFSTR(''Name of your NIB file here''), %26amp;theNib);%26lt;br /%26gt;%26lt;br /%26gt;I'm trying to figure out how to display a proxy in the resulting window. Does anyone have any insights here?Programming filters with Xcode +...
%26gt; I'm trying to figure out how to display a proxy in the resulting

%26gt; window. Does anyone have any insights here?



Use the Channel Ports suite to get your pixel data out of Photoshop; use the DisplayPixels callback (either from the UI Hooks suite, or from the filter record) to write pixel data to your dialog.

Hi Matthew,



Thanks for the reply. Right now I'm trying to figure out how the DisplayPixels callback works and how to integrate that into my GUI. I thought that you can just use the example code and cast the WindowRefs to DialogRefs (and other Window equivalents to their Dialog equivalent), but this is a dead end path (the WindowRefs need to be made with Dialog manager for that to work it seems).



So it looks like I need to figure out how to use Quickdraw (not Quartz) with Windows, not Dialogs.



Could you point me towards the right documentation to read to figure this out?

Hmm there is an example in ''Handling Carbon Windows and Controls''--%26gt; Control Implementation Examples (in the documentation that comes with Xcode). I think that might be what I was looking for.

Since i'm also developing a Plugin with a fairly complicated user interface, i would like to know if You've made any progress with the NIB based dialog. Thank You.

It's working for me. You need to use Quickdraw and you need to set the ports correctly.



Make sure you:

//Set the graphics port before calling displayPixels

GrafPtr oldPort;

GetPort(%26amp;oldPort);

SetPortWindowPort(theWindow);



//[...]



/* Display the data. */



if (gFilterRecord-%26gt;displayPixels != NULL)

{

OSErr err;

err = (*(gFilterRecord-%26gt;displayPixels)) (%26amp;outMap, %26amp;srcRect, dstRow, dstCol, gFilterRecord-%26gt;platformData);

}



//Set the port back.

SetPort(oldPort);



//Make the watch stop spinning

OSErr err;

err = PISetWatchSuspension(999); //%26lt;--not sure about this line, but do something like that.

InitCursor(); //This seems to fix a bug where the watch cursor needs to be refreshed.

Just to make sure i understand (because this is my first Mac OS project ever):



You've written a Plugin for Photoshop in XCode, using Carbon and Interface Builder and You display pixel data from the current photoshop document in the Window created by IB ? Because that's exactly what i need to do :-)



Thank You.

Yes.



I think there may have been some other gotchas that I forgot about... because I did not use Dialog Manager (Interface Builder won't do it, but the example code uses it). It's something like that; my memory is hazy. So I used the Window manager, and you sometimes need to create the equivalent functions to what the Dialog Manager is doing. And you can't convert Windows into Dialogs. You need to convert from Dialog Manager to Window manager.

Ok, now my dialog (by IB) is displaying and is handling events and i can draw into it. Next problem: I need the pixels from the current photoshop document for a preview. Where do You get the ''gFilterRecord-%26gt;displayPixels'' from ?

Did you take a look at the Dissolve example code? I would start from there and convert that code into Window manager.



My last message was assuming you were working off of the Dissolve sample code.

Christof: I have code for previewing. See http://www.telegraphics.com.au/svn/filterfoundry/trunk/preview.c (GPL).

Hi

Can u please send me the code for how to work with POP UP and buttons and how to handle events on varios events like when u select something from pop up and when u click on button.

and how to open a new window when user clicks on the buttons.

I've found that it's a hell of a lot easier to just do a Carbon NIB-based user interface than to try to deal with all of that antiquated crap that's in the sample code. I have quite a sophisticated UI working now in my filter, including a preview control, and it didn't take me any more effort than it would have if I were coding it in an application. Even the debugger works, as well as Xcode/GDB ever works (which isn't saying much).



The only trick is that you have to load the NIB file manually. Here's the code to put up your dialog:



IBNibRef dialogNibRef = NULL;

WindowRef windowRef = NULL;

CFBundleRef bundle = CFBundleGetBundleWithIdentifier(kMyBundleIdentifier);

CreateNibReferenceWithCFBundle(bundle, kMyNIBName, %26amp;dialogNibRef);

CreateWindowFromNib(dialogNibRef, kMyWindowName, %26amp;windowRef);

DisposeNibReference(dialogNibRef);



Having done this, you can show the window using RunAppModalLoopForWindow.



Hope this helps,

Aaron

Hello,



I currently have several Photoshop plugins available under Windows which are created using Visual Studios 2005 and I am trying to find an example plugin in the Photoshop CS4 SDK environment which I could practice on. My goal is to edit the dialogs/UI of the plugin and finally just add connect existing functionality.



The ultimate goal is to implement existing PC Photoshop plugins under Mac OS Systems using the Adoble Dialog Manager and API architecture. A cross platform solution for both PC and Mac is desired.



Could someone please direct me to a simple example in the Photoshop CS4 SDK environment or a good tutorial, as I am a working student with little C++ programming knowledge.



Thank you in advance,

Andreas

ADM has long been deprecated. Some developers are using Qt for x-platform UI, see other recent threads.

%26gt;The only trick is that you have to load the NIB file manually. Here's the code to put up your %26gt;dialog:

%26gt;

%26gt;IBNibRef dialogNibRef = NULL;

%26gt;WindowRef windowRef = NULL;

%26gt;CFBundleRef bundle = CFBundleGetBundleWithIdentifier(kMyBundleIdentifier);

%26gt;CreateNibReferenceWithCFBundle(bundle, kMyNIBName, %26amp;dialogNibRef);

%26gt;CreateWindowFromNib(dialogNibRef, kMyWindowName, %26amp;windowRef);

%26gt;DisposeNibReference(dialogNibRef);

%26gt;

%26gt;Having done this, you can show the window using RunAppModalLoopForWindow.



Could you please explain these steps more in detail Aaron. I've setup a UI using the Interface Builder and have put the above mentioned code into DissolveUIMac.cpp but i am getting the following errors:



error: 'kMyBundleIdentifier' was not declared in this scope

error: expected constructor, destructor, or type conversion before '(' token

error: expected constructor, destructor, or type conversion before '(' token

error: expected constructor, destructor, or type conversion before '(' token

No comments:

Post a Comment