WWDC2004 Session 421

Transcript

Kind: captions Language: en thank you guys for coming out to learn about replacing your old style windows and dialogues with nip files now what are we talking about when we're talking about old style dialogues well specifically this this refers to using the dialogue manager and the resource manager to pull in your dialogues and then using api's like modal dialogue to go into a modal situation and handle all the dispatching yourself so some of the things I hope you learn today is to how to move your existing resource based user interface up to nibs by getting them into interface builder then we will talk about getting into simplifying your event handling using the new technologies that are available in the high level toolbox I want you also to start using the standard window handler if you're not already and this is so the tool box can provide standard behaviors for you and eliminate a lot of code that you need to take care of and also you learn why you'll need to adopt a chive you the steps of getting your user interface up to a modern into a nib and using the modern technologies in the toolbox are pretty simple first you need to import your dialogues into nibs and you can do this using an importer that's built into interface builder now I specifically talked about getting it in from resource files but the same techniques will apply after that regardless of how you built your interface on a using a flat flattened interface format then at runtime you'll actually need to load in that interface in display it on the screen for the user then you need to rewrite how you handle events because the old way of handling events using modal dialogues isn't going to work once you import it up to nibs and then if you're using modality because you're putting up a dialogue that needs to interact with a with a user all in a modal situation there's separate ways of there's a different way of dealing with modality that I'll talk about as well and then finally if you have custom content that's being drawn in your dialogue we're going to encourage you to start using a chive use specifically for performance if you switch into compositing mode this has to be done why would you want to convert to nim's why do you want to make this transition the single biggest reason is because we're doing a lot of work in the toolbox to improve performance give you new features like new widgets that are now available and the dialogue manager and using the resources to build your interface it just won't cut it localization is also easier if you're if you built your interface with resources generally how you ship those is by packaging the resource with the application and when you need to localize you need to build a separate version of your application to deploy using nibs in actually specifically using application bundles this is so much easier because you can localize your application in the nib and then you can deploy one binary or package across from different localization maintenance building your interface and modifying it is so much easier when you're using nibs if you're using the dialogue manager right now you're probably aware of all the problems if you need to delete an eye as an item that's in your dialogue or add an item and you have to keep the dialogue item list in sync with the numbers that your your code thinks that those dialogue items are and that can just be a nightmare also we're adding new features in the toolbox and as we do this these features will be added to interface builder and you can just use them in your interface building interface with ib is so much easier also we have aqua interface guidelines that are built in but previously when you were building your interface you would have to look at the H I guidelines figure out like exactly how many pixels the button needs to be from this other button and to the edge of the window well all of this is built into interface builder and I'll give you a demonstration of how you can do that you can also touch your interface immediately and then once you get your interface loaded and start handling events it's just so much easier i'm sure you'll agree some of the things that guy mentioned in the last session was about compositing mode now this is a huge win in terms of performance compositing mode is based on invalidation model so you're not doing unnecessary drawing and redrawing controls more often than necessary it also allows overlapping of views and if you saw the demo before the machine crashed in the last session you were able to see all these views that were rotating sudden some you could actually see through because they were translucent and it just gives it's a better experience for the user and it also gives better performance so the first step of getting up into the modern tool box is to get your inner your interface into interface builder you can do this one of two ways if you have a resource-based user interface you can import that like I mentioned in interface builder from the import menu or you could go about building your interface manually I'll talk about why you might want to do that in a moment but if you need to import your your resource based interface it's just really easy from the file menu you select to import the resource file you select which objects to import with with the dialog that pops up once you select which object to import you hit it and then interface builder will create a new nib and pull in your your interface it's also really nice because if you have controls that are embedded in your dialogues this all just be pulled in automatically by the importer alternatively you can build the interface manually and you might want to do this because your interface was like may perhaps poorly designed or maybe didn't quite follow the Aqua interface guidelines and you want to start taking advantage of the guides of their interface builder or maybe you just want to start at taking advantage in adopting new widgets that are available right now either method you choose once it's in earth in interface builder and the steps are the same you can bring up the inspector window and start editing control properties you can also take advantage of a technology called HIV layout and this means that you can set layouts in the sense of how they are bound to its a like for a view how it's bound to its pair so as you resize a window these can all be handled by reef lowing the contents of your window this can all be handled using HIV layups and you don't have to write any code to do this also in the interface you can assign a chive you IDs and that's so you can access your controls nhi command which are going to be sent when certain actions are performed in your interface also make sure once your interfaces interface builder that you have turned on the standard window handler now what this does because it allows the toolbox to take care of all of this you know the mundane stuff the stuff that everybody has to do like resizing the window or dragging the window around and it will handle a like control tracking like when the user clicks in the window it will handle what you know what controls are tracked and then lets you know that something interesting has happened then you can also test the interface and make sure that everything works out the way you want it to work so that steps is fairly easy just get it into interface builder save out that nib file now at runtime how do you actually load that interface there's just really easy steps you have to first get a reference to the nib then if you have a menu bar that's in the nib you just go ahead and you load that in and set that for your application you also extract the windows by just using a very simple API to get your window at now this will pull in all of the controls that are associated with that window and instantiate them at that time as well and finally after you get the information out of that nib you release the reference to the nib and you're done and you do this using these api to create a new reference you just call the api creates nib reference and you pass in the name of your nib minus the nib extension if you have a menu bar in there and you want to set that menu bar for your application you call the api set menu bar from lib now i want to pull into one of my windows so I call create window for nib passing on the name of my window this window is going to be pulled in from interface or from your nibs but keep in mind that for performance reasons because maybe you need to preflight the dialog you know add some information into some deals for instance the window is initially invisible so if you want it to show you have to tell show window finally when you're done just use the API disposed nib reference you don't need to cash this new preference for later use in fact it's just better when you're done using it just dispose it if you need to use it again go ahead and create another new reference to that nib so once you have your interface loaded how do I actually access the items that are in there this too is just really easy using interface builder if you select on it control or any item in your interface in interface builder you can bring up the inspector window and go look at the control segment of it and you can assign a control ID or an H I've uid to that control now control ID is a signature which is for character code and keep in mind with four character codes all lowercase is reserved for Apple use and I'll mix an uppercase you can use as much as you want and then also an ID so you can use signatures to represent all of one type of control in an ID for each individual control in that segment of your interface for instance and then at runtime programmatically you would use the API a chive you find by ID and that's so you can actually find that controlling up in your face and extinct grab a reference to the control in code this is how you do it you define an HIV ID which represent the signature and ID that you've set in interface builder you call the HIV find by ID API and it returns your control reference to you and you can just go to town do whatever you need to do with that control so let's go take a quick demo and I'll show you those initial steps of importing your interface and then loading that interface into your application before I get started I have to give you a standard disclaimer I am NOT a user interface designer at all i just sit at my computer i punch numbers in to make this stuff work so well what you see like may amaze you and astound you of how brilliant it is i really highly recommend you don't design your interface like this so let's say that i haven't I wanted to have a really fast music editing application so I just whip something up really fast in carbon and it looks something like this okay now actually I mean this is just a mock-up it doesn't really do anything I mean the only thing it does really well is not get a spinny cursor but if I want to get information about a song that I've created I go down to my song info and I bring up a dialog now this dialog is loaded in from a resource and then it's using modal dialog to actually do some information so any song info palette you know wouldn't be complete without having a really cool equalizer view in it so you can see like the equalizer so at this point I go here now this is my user interface skills like behold quick draw rectangles don't do this on your interface it's just a demo but you can choose different equalizer settings oh so beautiful so cool and because last time you blew out your dad speakers you want to be able to clip the sound at certain areas so we go track when you want to you know how loud the volume can get before it start clicking the music off I don't know if this is how real music programs work that just makes a really good demo so the interface may look simple clicking around does some things there's actually a lot of code going on behind the scenes to actually get this up and running and then your boss comes in and says I need you to create some new summary information in there like a text field that you can types as much as you want in your thinking man using the dialogue manager how am I going to do that this might be a great opportunity to start learning about nib so let's actually go look at the code see what I'm doing in here this is a big weight next event based application and I just want to prove to you that this you can do all of these steps in piecemeal you don't have to convert all of your application at once you can do one dialogue at a time so I'm going to maintain this has a big weight next event based application when I create that dialogue and you can see there's a lot of code that's being run here i'm using the resource manager to get a new dialogue i set up the dialogue and when i go do that i actually I took that area where I was doing the custom drawing that's just a user paint so I'm installing a user paying drop rocks so when the dialogue needs to repaint that area it calls my drop rocks which is where i'm doing my custom drawing then after its set up I call modal dialog now I pass in a modal filter proc because I actually want to handle behavior in that custom area as well and that was to modify that clipping thing then when modal dialog returns I'm switching off of the item that was returned in order to figure out how to modify the interface so there's a lot of code going on in here and I want to eliminate that especially since I have to add new features because my boss told me to so let's learn how to do that in interface builder we go to the file menu import import resource file we select our resource it asks which dialogues and menus do I want to pull in for this example I only have one dialogue so I only want to import that single dialogue it import creates a new nib slams that window into their let's go look at that interface now so you can see it did it did a very good job that's exactly to what the interface looked like now we have to do some triage maybe there's some things that didn't import correctly in my case when I set up the resource I had to go through some hoops actually get that pop-up button in there and interface builder displays this as a custom control so I could go in and rebuild that by creating a new pop up in here but I've already done that in a separate nib for to keep this demo kind of rolling along so I'm just going to put that in here I also decide that I want to pre-populate this stuff so I don't have to do this in code so i can do all of this with in interface builder by studying the stuff up i also encode initially when i was setting up the dialogue i'm calling set dialogue default item and set dialogue canceled item in order so the dialogue manager knows which items are the default in camp williams well i can do that with an interface builder by selecting just a button in this little interface inspector window this is going to be the cancel button I want to make sure that I have the standard handler on because this is what's going to handle all of my my low level events for me for free and then I want to start mucking around and see that you can see these interface guides like you can see that my window is probably lay out incorrectly in the first place so you can see that interface bullet presents these guys tells you how far away the controls need to be from each other some new features I want to take advantage of perhaps our to make the window resizable so I click that and if i want to make the window resizable i might as well start taking advantage of new technologies like HIV layout so in this case I decide that I want to bind be ok and cancel buttons to the right side and the bottom of that window so as the window is resized it reflows correctly so I do that again over in this inspector window by selecting layout binding to the right and and the bottom doing the same for this view the right and the bottom and like I mentioned before my boss really wanted me to add in a new text field for information so I'm going to move all of this information down pull in a textview up in the layout menu I can embed that in a scrollview to make it scrollable and just so it's not confusing i'm going to add a text field here [Music] No we can run the interface we can test the interface with an interface builder by just allowing it to run brings up a simulator you can see that there's the window I can go ahead and type now I've done no no code yet this is just interface construction when I think I recall that I want to do is these these text fields are using the old edit text control and I want to get some really cool anti-aliasing so I want to use the Edit unicode touch control this is just a check box over here and finally I decide that I want to save this this is my interface I need to save it out so I hit save give it a name where to save it and the integration between interface builder and Xcode is excellent it knows what i have a project up already and that i want to embed that nib in that project so i go ahead and add it now i need to actually write some code to drive this interface now in my main code I was pulling up that that dialogue using this guy and I want to instead write some code that's going to do it the new way now when I say new way I say new but i don't mean it's like a lot of work to do very simple i create a nib reference to my nib I extract the window from that nib I show it dispose the nib reference and we're done let's cross our fingers and make sure this builds there we go we have my same familiar interface I want to bring up my song info and boom there it is the interface works I wrote no code to actually initialize these text fields all the behavior works you know I can drag these things around you can see that my popup is here and does correct tracking and I've written no code so let's move back to the slides and move on so again import your interface into IB modify the attributes if you need to do the modification like when I took the edittext control and I made it an edit Unicode text control then you can add in new views as they become available with in interface builder make sure that the standard window handler is on that allows you to resize your window move the window around without writing any code to do that work you have any more questions about the api's that are available for interface builder go check out the IV carbon runtime header which is in the H I toolbox framework now it's not a mean it's kind of brain-dead there's only seven API is in there three of them are associated with nib management so there's only four API is getting your interface out of there so we had interface that was up and running but it didn't actually do anything interesting so it doesn't do exactly what the interface was doing when it was a dialogue manager base because I had a whole bunch of code that was behind that running it so now we need to start handling event now the old way of handling events whether using modal dialogues or wait next event is using this model you the application go sit in an event loop and start pulling events out of the queue then you figure out where that event needs to go so you start dispatching it wasn't in a window by calling find window if it was in the windows and in the control you call fine control and then you start tracking the control if you need to and then you tell finally tell the toolbox what it is that you did now this is cumbersome because you're writing a lot of boilerplate code everybody's got to do it it seems like a really nice place that this gets implemented in the toolbox and let us do the work so this is the new model of doing events and when I say new I mean like carbon event forward you tell the toolbox what events you're interested in hearing about the toolbox sits in its own event loop figures out where these things need to go and then dispatches them to you if you're interested in so it makes the model so much easier you're not doing all of this extra boilerplate code that you don't need to and you get notified only about the events that you're interested in so events are separated into different classes and kinds there's about a dozen or so different classes of types of events my control window command event and then there is split into different kinds so what type of kind what kind of event that type of her that class referred to I hope that made sense so for example in the case when you need to know to be notified when the enabled state of your control has changed you register for a key event class control cave and control enabled state changed event that's interesting but how do you actually go about doing that like I mentioned earlier you specify the events that you're interested in then you install a handler on an event target now an event target is where these events are going to be sent to and there's various targets like there's control targets a user focus window application and when I say installing a handler what you're really doing at that point is telling a toolbox I'm interested in these events call my call back when these events come in so then you go implement the handler so when your callback is called what what do you need to happen to your interface at that point and then events can go through different propagation routes so for example when commands come into your app your your handler if you don't handle that event you want it to continue out in propagating because maybe the toolbox will give you some free behavior the return value controls how that event is propagated if you return it then not handled error propagation will continue it and maybe the toolbox will handle it for you and any other value of return will terminate propagation it's as if you handled it and we're done so let's walk through an example of doing that like I mentioned an H I command is a high-level type of event to signify that some command has happened you don't care where the event came from you just want to handle this pets of event a good example is if you had a new button in your interface with in interface builder you would select the new button you'd go into the inspector window and you can assign a command to that button so when the user clicks on the button this new command is sent to your application a new is a standard H I command so you can select it from the pop-up you can also create your own types of command then encode you specify what events you're interested in you pass in an array to our api's but in this particular example I'm only interested in an H I command event so I'm interested in the class command command process event then I want to hear this on the application event target because like I mentioned the commands what can be sent to the user focus target and if that doesn't handle it'll go out to the window and if the window doesn't handle it would go out to the application so the application is kind of a catch-all for commands so I'm going to install my handler on the application event handler on the application event target excuse me and then I tell it that I'm interested in it or I want it to call my callback handler at this point so you load your interface in the users using it and then he clicks on the new button the H I command is sent the toolbox called your command event handler there's different information packed in that event and all of this is documented within the carbon event dot H header so it'll tell you as events come in what type of information is packaged in the event in this case there's an H I command so we call get event parameter to extract the H I command from the event and then we can switch what kind of event it was in this case we see that it was a new event so we go and we create our new document window now we talked about dealing with events within your user interface how do you deal with dialogue modality I'm sure your most of your dialogues have had to deal with modality basically in the old way of doing things you are calling modal dialogue and a loop and handling updates using a filter proc and for one reason or another that then we change things so that didn't work and you had to install update carbon event handlers on your non front windows in order to get the update event so you have to write determine event handlers for other ones if you're going to do that you might as well just start doing things the way we expect you and want you to do go through the steps I've pasta bought already convert your dialogue to a nib use the standard ok and cancel commands for your ok and cancel button make your interface carbon event driven by using the standard H I commands or you can even use your own event command classes that you define yourself and when you go when you need to be modal use the API run app modal loop for window this will put your window into a modal situation and that function will not return until quit at moda loot for window is called and i'll show you the example of how to do that and then eventually this is you'd start using sheets instead of going at modal you might just need to go window modal so where it's appropriate we encourage you to use sheets to get window modality so let's walk through an example of using modality in this fashion this is very similar to the previous H I command example I gave in this case again we're only going to we only will go out of the middle situation when the ok button is clicked which is sends out a command event so in this case we're doing the same thing by get registering for a command command process event and also when we install a handler for a target one of the parameters is a void star so we can pass anything we want there and then when our callback is called that void stars return to us so I'm taking advantage of that in this particular example by passing in the window as that void star parameters then I call run at moda loop for window now as I mentioned this function is not going to return until quit at moda loop for window it's called so the event system takes over start dispatching events as they come in so and then when we're in here perhaps the user clicks on the new or the ok button at that time your event handler is called and as I mentioned we passed in our window in the void star parameter so we cast that to a window because we know that's our window again we extract the event parameter we check to see that it was the ok with a standard ok command which it was and we go ahead and we call quit at moda loop for window at that point when this function returns your previous call the run at moda looper window will return and you can continue processing with drought so that's how you would deal with modality in this new world so custom content in my example I had that really cool equalizer area over there and that dialogue and how am I going to start dealing with that now using this new way of handling dialogues you need to think about two different paths here you want to remain non compositing or go compositing now the advantage of compositing are great in terms of performance your it's an invalidation model so you're not constantly redrawing when you don't need to you also can have overlapping views it doesn't look ugly but because these are the controls are racing behind themselves if you want to continue using non compositing windows and you're doing all of your drawing and user pains it's okay but we prefer that you actually start using HIVs because this is what we're focusing our energy on moving forward especially if you're using compositing or drawing directly the window you have to start taking advantage of a chive use so you'll have to write your own custom views to do this custom content and then embed that in the window I'm not going to go into any detail about how to write your own a chive you actually David's going to cover that tomorrow in session for 33 modernizing your custom controls to use a chive you so I'm not going to go any further about describing how to do that but I will use this in my example and just show you how to use a premade HIV as custom content so I like I mentioned when I was walking through my example the old way of dealing with your dialogue was during initialization if you had this custom content you would set a drawing proc and that was to deal with a drawing and then when you needed to go into the event loop and start handling events you would call modal dialog with a filter proc if you needed to handle a tracking in your custom content so at that point you'd be handling some behavior you handling the behavior of tracking and then once you return for a modal dialog you'd get this item hit and you'd start handling behavior there too so there's different areas of code and then in some cases you'd actually be installing action proc to deal with live action's too so there's different areas of your code where you're dealing with this behavior and all the behavior you're right for one dialogue you can't easily rip out and just go throw into another dialogue so like I've been saying the new way of doing things is using a chive you I mean I just can't stress enough how cool this technology's because it encapsulate the behavior and the appearance of your custom view all in one module so I don't even have to know what the module does like Joe Schmo can create one for me and I can pull it in add it to my project and it will just work because I don't care about tracking myself or anything like that so you can create the H I've you in one of two ways if you take your H I've you and you install it or register it with the H I object subclassing system during ass initialization then you can provide a class ID in interface builder so an interface ability you can pull in a custom a chive you interface builder knows nothing about this with you but you add a class ID and then when you create that window in your application it will go through and instantiate that view it's really cool to do that and alternatively you can embed it programmatically you can create one yourself and then embed it in the dialogue or window using one of the H I've you add sub view API for example now we should note here a guy mentioned this in the previous session also but I should note that you know creating your own custom views there's a lot of the same code that you have to do and there's a lot of setup associated with it so we've written something we call a chai framework which is a C++ mini framework for the toolbox and it makes the task of creating your own custom view really simple and it's provided a sample code so you can go through all of the codes see what it's doing extend it yourself add modifications if you need to so let's go back to the demo machine and we'll start plugging in the behavior and pulling in our custom area in order to get the custom content drawing so I'm going to go back to interface builder I'm going to assign standard commands to my interface I told you earlier that i want you to start taking advantage of these standard commands are available for the ok button in the inspector window i'm going down to the command pop up and i'm going to select ok because it's the ok button for the cancel button i'm going to go select cancel and then I want this dialog to be to go into a modal situation when I bring it up so let's go check out my code again I'm going to do a little hand waving by turning something off here and go looking at my new function which is really just basically the same function i had before where I create my nib reference i get my window i show the window and now since i want to make this application or this document go modal or the dialogue go modal i want to a stat install a window event handler on it to handle the ok or cancel command so I installed my way to event handler telling it to call dis call back when that event comes in then I call run at moda loop for window if this function does not return until quit amo de loop is called so it'll go around dandy you know handle events do everything on its own and then the user clicks cancel or ok my event handler is going to be called at this point I extract the H I command from it I check whether it was the standard ok or cancel command then call quit at moda loop for window and we're done so let's cross our fingers here and see this thing in action again pull up song in so I click around in the interface and I can't because this window is modal at this point because I put it into a a modal state when if I click cancel or okay the dialogue goes away so we can see that that worked hooray but there's still that custom area that we want to deal with so it's pretty obvious with I'm just using quick draw rectangles and I have no idea how to make a really cool interface so I went off and I wrote this really cool aqua interface and it's just encapsulated by itself I don't even need to know what the code itself does I just pull it into my project now and it's called eq view for equalizer the writer of this module has told me that all i need to do is register the view i don't know if you can actually see that very well you need to register the view at application initialization time so it during the initialization I would call that function and that goes through and registers the view with the H I object subclassing system and then it provides me the signature that this this view is going to be so let me walk back over to interface builder I can't use a user paint is anymore so I ditch that I bring up dis control pull over on a chive you throw that in the interface and then if you go look here in the attribute field it has a field for a class ID now that class ID was was broadcast to me in the header so I can just throw it in here and it's going to work the other thing that the the writer of this module has told me is that this view is going to respond to certain commands are sent to the window so i don't have to plug anything in its going to just handle events on its own and these are the events that is interested in handling when it when you change the equalizer settings for instance that's why i did some hand waving when i pulled out this this pop-up button i've set all this up already so when you select the classic item it's going to send out this command rock etc furthermore it's going to handle a command for clipping when you click on this check box over here to do sound clipping and also mute so we need to make sure that those controls are set up to send out that event so here I'm just going to mimic this in the interface but go ahead and save it let's build it and run go check out my interface and now we get this custom area dry night now that too I mean this is still me making it you know it's still pretty ugly but it's a lot better because when you select a different equalizer setting it just automatically schlongs it's a new equalizer setting that's just like cool and then for sound clipping if I turn this on it it responds that too and then furthermore it handles tracking on its own i didn't have to write any special code for this this is all handled by the view itself it's something i did show earlier but as I resize the window because the HIV layouts were set in the nib the ok and cancel buttons are also just refloat automatically when this was very easy code to write and get up and going so you have to adopt this is just the greatest thing ever let's go back to slides thank you so in that last step all I did was I made my interface carbon event-driven and I did that by adding command within the inspector window in interface builder then to go modal I you use the API run out lo de loop for window and this is how you would deal with modality rather than using modal dialogue in fact when you pull in a window from a nib it's not a dialogue anyway so you can't really call modal dialogues using that implement your custom content as H I've used that new view I just pulled in somebody gave this module for me I plugged it in I added a little a few features to make it respond to commands or make command sense that it's going to respond to and it just worked automatically and that custom view was written us so I'm told with a chai framework which made it just really easy to write that as well of course using dialogues in this type of modality this is just a really small case of what we would encourage you to do for your application also rather than using wait next event for your event processing we want you to get on to using run application event loop this is going to start dispatching events for you and I'll Pugh eliminate your use of weight next event I want you to start eliminating all of these old api's because we have really excellent replacements for them using the new technologies that we put in the toolbox these AP eyes are encouraging more efficient use of resources when you start using run application event loop you don't get idle time using that API so you install carbon event loop timers which will call you back so you can give fine-grained control of when you need to be called back and to make your application more efficient on the system and then we want you to use new technologies that we've created such as sheets it makes your interface just so much better so I've been talking a lot about this stuff and encouraging you to do this but you're probably thinking this transition might be really difficult for me to do for my interface and I just want to tell you that that's not the case in fact navigation services went through this transition in the Panther time frame and I'd like to bring up Brian purusha to talk about that right now thank you hurt now as Curtis mentioned then as i'm sure you all know open and save dialogues went through large amounts of changes in Panther and we added several new features including the sidebar list view and the view history forward and back buttons now we knew this is going to be a major change for navigation services and we wanted to take this as the opportunity to move forward from resources to knit and once we made that change being based on ends made it easier to adopt new features and we began the conversion we wanted to take an iterative approach the idea is to start with the simplest dialogue possible and convert it over first because it doesn't have to be done all at once convert that one dialogue over and just you know work out any kinks that there may be in the process just get used the idea and then go on to more complex dialogues we were able to very easily write a little bit of wrapper code that converted all our old dialogue item ids to control IDs so we can continue referring to all our controls as we always had in the past and continue reading them as we always have in the past minimizing code changes the next step is then taking views that we loaded manually or trades manually in our code and having interface builder do the work for us so when the window is pulled out of the mid those views are loaded automatically so the trick is we had some custom views in there like the sidebar interface bill doesn't know anything about the sidebar but that's Kurt show that's earlier we can use a custom a chive you control in interface builder add the H object classid and interface builder even though it knows nothing about our custom views could load it automatically so that was just code we didn't have to write the next step as guy alluded to in the last talks was the most fun adopting the standard event handler reason this is fun it's because we can just click a checkbox in interface builder and rip out tons of custom of that handling code for the most part navigation services we're just interested in a deep all behavior happening but in those cases where somebody clicks in the sidebar or the default button is hit something like that and then specific cases we destroyed a carbon event handler to listen to those events and can ignore everything else we let toolbox to the driving for us now the next step is adding compositing was definitely the largest step but it had the most benefits in terms of performance because navigation services handles or has also all standard controls except for the couple custom controls that we designed specifically with compositing in mind we could just go ahead and click the checkbox in interface builder and adopt compositing with two caveats the first was changed we had to make red do a little bit of special code to deal with the change in parent relative coordinate spaces so we were no longer window relative and we had a lot of embedding and navigation services in order to make sure that we're always paying attention to what our frame was relative to our parent view and not the window the second thing is that navigation services offers the ability for clients to customize the dialog so there's a custom area in the bottom of the dialog and clients had always been used to just being non compositing so we needed to maintain that behavior so we did have to add a custom compatibility area that remain non compositing now that navigation services is based on mids we can take advantage of new features in interface builder like HIV layout and going to that process we could keep the reflow the entire dialogue as its resize without having to write a whole lot of color at all now the results for the navigation services were great compositing in particular gave us a about a twenty percent speed boost loading the dialog there is so much redundant drawing going on before that's just simply eliminated by the one pass draw model of HIV the speed boosts is also apparent in resizing the dialog especially in the Sheep mode despite the fact that she spent translucent because compositing mode is the only way to get translucent sheets and really a great side benefit of moving to these next VZ technologies with that bugged and navigation services were fixed because we were removing code and adopting a better drawing model you know little visual glitches as the performance problems went away we handed all the code off to the toolbox and let it do the driving so there was less code for us to test less code for there to be bugs in and overall it was a very straightforward process actually smoother than we thought it would go there were no real strong sticking points or gotchas beyond just a couple of the compositing changes that you need to be aware of the that there that I mentioned earlier so and now that navigation service is based on mids we can go ahead and adopt new features as interface interface builder provides them so we're in a great great position going forward we really recommend that you go through this process I think you'll find it easier than you might expect and it will give you a lot of benefits in the ability to add add new features now and in the future but that like to go back to Kurt basically the reason I wanted Brian to come up and talk about the navigation services transition was because of a comment that he made to me on the side was the biggest surprise about the transition was that it wasn't that hard at all so I really encourage you to go through this transition as you add more features or when your boss says you need some new lyric dialogue in your song info panel as you need to start adopting these new technologies start converting it to the new stuff because this is where we're focusing our attention so just start getting up to nibs start handling Asia commands and your for your event dispatching make your whole interface carbon event-driven and then start using all of these api's that do always driving for you like Brian mentioned like run at moda loop for window to go modal or run out application event loop once you get your entire interface to be carbon event-driven then also keep in mind if you will have to convert your custom content to HIV use in order to take advantage of compositing in your dialogues so please check out some more information that's available something that was really useful in preparation for the demo was on how to move your project from codewarrior to xcode so because once it was in xcode the flexibility I've actually used the interface builder with that was it was pretty easy to use then also the interface builder services reference described actually how to get your interface going with in interface builder so with that I'd like to bring up that french guy over there