WWDC2003 Session 409

Transcript

Kind: captions Language: en my name is xavier Lugo and engineers are working developer relations and like to welcome year-to-date position 409 the new h I to debug last year if you remember correctly not in the same room but you know to be more self we introduce a chai view which is a new drawing composited model for Latinos during controls on Mac OS then we got a lot of feedback from you guys and we're very happy to present you what we've been doing in the last year you have to understand that if you're doing carbon development and if your CC posters developed on a platform these technology is very very important for you and at one point over of your development cycle you have to look at what we're doing which have you and what we're doing the involute h-hi toolbox because this is really the future of C and C++ development on Mac OS 10 we have a station full of new things and very cool demos and in order to talk about that we're going to go directly into the content i'd like to introduce guys return who is known as well as be who's going to be actually talking about the brand new atractivo that we have for you guys yep thank you thank you save you get him back come on Xavier so you have to forgive me a little bit i've been told that there's a krispy kreme donut waiting for me back there after i finish the presentation so i might go a little quickly here i really really like doughnut oh can we get the front monitors on so i can see the slides without turning around if not I'll just stand back here and I can see the screen so I'm sure some of you are sitting here wondering nu H I tool box why'd they call the session the new h I toolbox I mean it's not like the control manager api's have changed fundamentally since 1984 you can still call many manager routines the same way you've always been been able to call them and the contents of mac windows H is almost the same as it has been you know back in nineteen eighty-four so why are we calling the session the new h I toolbox well the reason is that over the past couple years we've completely rewritten the foundations of H I toolbox in Jaguar we introduce a chai object which is our standard tool box object model and every object model of course made some kind of messaging model and carbon events is that messaging model and carbon events has been around even longer than H I object and of course if you've got objects you need base handlers and base functionality and of course we have that in the form of the standard window handler and the base handlers for controls and applications and menus and things like that so with this foundation in place what we were able to do is completely rewrite the control manager so that the control system is now a chive you and HIV us are now a full-featured view system that supports a one-pass efficient composited drawing model so in short the reason we call this the new hol box is because it's built on a completely modern foundation now there's a famous saying to stand still is to regress and what this means to us on the tool box is it the world moves kind of fast around it there's a lot of other things going on and if we don't at least keep up and if not move faster than the rest of everybody we're falling behind and so that's actually the reason why we rewrote the foundations of a tie toolbox now that we have this modern foundation in place we can innovate much more quickly than we were able to before and that's fine for us you know let's have put new features out there but you might be wondering you know why do we care an application that was written back in nineteen eighty-four that underwent the powerpc transition and then ported to carbon still runs about the same on mac OS 10 as it did in nineteen eighty-four sure it's got a new user interface and stuff but your code can just work the same if you wanted to so what does it really matter we have a new a check tool box well the reason is that the new foundation forms the basis of all of our new functionality from here on out we have things like the toolbar which were introduced in Jaguar and you can't really use the toolbar unless you understand how H I objects and HIV works and in fact you can't even customize the toolbar unless you know how to make a custom HIV you similarly if you want to put sheets in your application to be you know truly aqua compliant you need to understand how carbon events work so you really need to understand how this foundation works and you need to start adopting this as soon as you can so you can bring your applications forward another real benefit of this new foundation is it offers much much better performance compositing view systems are an awful lot faster more efficient and even more predictable than the old-school sorts of view system on Mac OS but the best point is that sticking with a chai toolbox is a very easy easy iterative adoption path that allows you to keep using the same often cross platform C and C plus Co that you're already used to so in short the new age I toolbox is what allows you to take your applications to the next level on Mac OS 10 so with this new foundation in place we actually did tons more stuff for Panther nhi toolbox than we were able to for Jaguar for previous system releases and I'm going to talk about an awful lot of stuff so the real reason I'm going to talk fast is I got to get all this stuff fit in an into an hour wouldn't surprise me if we go a little bit over but before I start going into the new features I want to talk about something else when we were implementing Panther one of our mantras was performance we really had to look hard at ways we could make the toolbox faster performance as a main goal of Panther you know has talked about in other sessions so we took a good hard look at a number of different facets of the toolbox and and did some intelligent things to make it as fast and then perform as efficiently as it possibly could for instance you know we send a lot of carbon events on the system but if you sample your application you're not going to see a lot of time spent in carbon event routines right the bulk of the time is spent in your app but still we know the number of carbon events were sending out we know that over the course of a run of an application there's going to be thousands and thousands of carbon events getting sent to various objects all over your application so we need to make sure carbon emitter is lightweight as possible so we rethought some of the algorithms rethought some of the data structures and we put some speed boost in there the best of which is that event event construction is now twice as fast on Panther as it was on Jaguar now we took a similar look at HIV you in the compositing view system we found some ways we could do in validation of views a little bit better we found ways of speeding other things up like doing our vision calculations in a deferred manner and things like that and the net result is that now live resize for a fairly typical compositing window that you probably has a toolbar and a couple complex views that's now about thirty to forty percent faster on Panther than it was on Jaguar and it doesn't just affect compositing windows see even though your windows may not yet be compositing we still draw the wind frame and the title bar wages and all that with compositing so these performance improvements we did just at the compositing path even helps your non compositing windows now it's hard to say exactly how much it helps out non compositing windows because it depends greatly on what exactly you draw and how you draw on those windows but with our test apps we're seeing up to about a ten percent performance improvement in library size during for non capacity windows and of course these same changes speed up just about anything having to do with a chive use any API you would call that might invalidate of you is now a little bit faster as a result and of course it was mentioned in other sessions but we need to make text absolutely fast on Mac OS gets most of your interfaces text so we spent some time in there we made our theme text layers thin as possible and set it directly on top of Atsui put some smarter caching even smarter than we had in Jaguar in place and now theme text drawing is now about twice as fast on Panther as it was on Jaguar we looked at the menu manager you see a lot of applications enable and disable items you know in which is in response to every key press and whatnot and sure that's not an ideal solution there may be better ways to enable and disable your items but we still wanted to make that experience faster for the user so we tweaked some menu Mannion's manager algorithms and now you know typical menu item manipulation is about thirty to forty percent faster on Panther as it was on Jaguar and of course we've had a lot of people feedback about data browser and some of the complaints is that it's slow in a few areas so we concentrated on certain algorithms that people were complaining about and we made data browser item addition I think it was about thirty percent faster on Panther and data browser item removal and selection ten times faster on Panther than it was on Jaguar well I know you're not here to listen to me Pat myself on the back or anything so let's just jump into the features and I'd like to start off with a chai text view we've got mentioned in other sessions but a chai text view is a very full-featured compositing text editing view based around em LTE the multi multi lingual text engine it's compositing mode only so this is another reason why you need to start switching your windows over to compositing mode so you can add optical feature like this the reason why we based it on em LTE is because M LTE already had a lot of functionality it already supports mixed style runs full unicode support so it supports all the language that oculus 10 supports its kind of advanced typographic features and things like that and it already integrates with certain standard systems on the on the system like the Edit and services menu and right now we're working on support for the font panel it's not there in the WWDC seed but it will be there by the time we ship Panther GM so M LTE already has this really rich API you know can already do things like insert text into it associate an ml to eat instance with a file set up style you know do complex manipulations and whatnot so that allowed us to make the H I text view API very very small there's basically two api's in the H I text view API the first allows you to create a text view the second allows you to get the M LTE objects out of that text view so you can do manipulations on it so the intended design Mar the intended usage model is you create your view you get out the MLP object and you know you call em LTE api's on it but the main thing you need to realize is that some M LTE api's do not work with these M LTE objects that are bound to a view and the reason for that is because the MLT api is so huge and it predates a chive you actually that it does some things that don't make sense in the world of HIV for instance there's an M LTE API which allows you to change the bounds of an M LTE object well we'd much prefer you use the HIV you api's to change the bound of bounds of a given view so we actually disabled the MLT EAP is that do those things just for these m LTE objects that are bound to HIV so as you're perusing the ml 2 e api's and you see something you'll make sure there's not an HIV you attend equivalent HIV you APR instead make sure to call that a chive you instead HIV API instead now another way that we leverage existing technology to make our text view a lot quicker or to implement our text feel a lot quicker I would through the use of H I scrollview the scrollview was something we implemented in Jaguar it's an H I've you that can manage the scrolling for any arbitrary scrollable canvas it could be a picture who knows what it could be a list it could be text and it already does a whole bunch of work for us it manages the scrollbars it'll hide and show the scrollbars appropriately according to the Aqua human interface guidelines you know it'll it'll keep the canvas size at the right amount and all that and it's got a carbon in that protocol that communicates with the canvas itself so we built the h i text for you to understand that protocol and to communicate via that protocol with the scrollview so that all you need to do is you take a textview embedded in the scroll view and now you've got a scrollable text field so here's a very quick example of a chai text view creation pretty much exactly what you would expect you create a text view by calling a chai text we create it's an HIV you creation API like the ones we introduced in Jaguar so it'll look real familiar to you you can pass a frame to it in this particular example I did not need to pass a criminal get to that in a second you support some option bits right now there are no option bits that are specific to the H I TechSoup and gives us future expandability but more importantly is the fact you can pass em LTE option bits into our creation function that's the TX and frame options parameter so this TX and frame options parameter allows you to configure the ml 2 e object with certain creation data turn on certain behaviors and whatnot these are all in the normal ms eat em LTE headers but in this particular example we didn't evening options and after you call this routine of course you get back your text view the next thing you need to do is make it visible because by default and HIV was created invisibly and then the next step is we just take our text you and embed it in the scrolls view that we've already created and then our text just working the more likely than not you're going to actually need to manipulate your text view in some way via M LTE so here's a very brief example of how to do that we've already got our text be created so we call a chai text view get txn object to extract the M LTE object from it and let's say we want to associate that M LTE object with a file so it will display the contents of the file and support revert functionality and things like that so we build a URL for that file using you know the normal API and then we call the techs tension routine to associate that file with the texts mention object or sorry with the M LTE object and that's it very very straightforward now of course you can build it in code if you want but better yet you can go into IB and build it there because the IB the interface builder in Panther now supports a bunch of the new HIV use they implemented the ones we introduced in Jaguar and even for a moment is most of the ones we've introduced and Panther and we're continuing to work with them to make the carbon experience in interface builder a lot richer so this is a good way to go as well so another new view that was talked about at the earlier sessions is a chai search field search fields are a big part of the Aqua user interface on Panther they're really convenient for the users and offer a lot of functionality and our H I search field supports all the standard behaviors you know it's editable text field it's got the rounded frame which indicates that it's the search field we've got an optional cancel button it's got an optional popup menu completely customizable menu and it has an optional descriptive label which is the little great out text you can see that's in the text field right now it kind of indicates what you're going to be searching so here's a very quick example of how you might create one I'm going to assume you've already created a menu ref in fact I'm going to assume you already know how to handle carbon events on the menu rep because this is something you've been able to do for the past couple years it's very straightforward you build up a menu you put H I commands in it you put the gay event command process handler on the menu and then you can react to commands as they get sent out so we'll assume that's already been done the next step is to just create our search field give it its bounding rectangle you can set up the attributes right now the only attribute is whether or not you want to cancel button in this case we do want the cancel button and you had it your menu and you give it the descriptive text you want blade and receive back the search field now we also offer API so that you can set the attribute and the menu and the descriptive text on the fly later if you need to now what you've set it up you're going to want to handle events for two things you want to react to clicks on the cancel widget of course you're going to want to react to the text as the user types it and hits return so you can actually do the search to carbon events you need to handle to deal with those two things the first is k event text accepted and the second is k event search field canceled clicked the install a handler the way i'm sure you guys already know how to install and the handler might look something like this if you receive the text accepted event you get your search field you ask for the text out of the search field you do your search you update your interface the way you would you would normally do that and if the cancel buttons click you just undo that search you remove whatever filtering you did and restore your list to its normal to its normal state so the next few I want to talk about is the segment view or as it was called in other sessions I think that switcher thingy but we prefer the segment view so I'm sure everybody's used the segment view in the finder right it's a view switcher control it's like a group of radio buttons now you can choose between icon list and column view and it's there each of those choices are mutually exclusive so of course our segment ISA ports that but some other uses of a segment view have a more momentary behavior best example are the back and forward buttons that you see in Safari and the back and forward buttons you see in the new open and save panel that's essentially a segment view just got two segments but each of those two segments is a push button that does back and forward functionality so of course the segment view supports that segment view also supports sticky behavior you can think of that as a checkbox right you click it it stays pressed until you click it again at which point it pops back up now the cool thing is that every segment in a segment view is configurable you can set the number of segments and you can set each one up differently so you could have for instance think of like a DVD player control you could have a play/pause record fast forward reverse each of those with a different type of button behavior and of course you can customize each of the button contents differently as well we support icon services icon refs cg image reps which is sort of the preferred format and text of course for those applications that need text-based segment is 0 the last point is that unfortunately we did not get the segment view API is publicized in time for the WTC build but we are currently actually using the implementation inside the new nav services so it is there it does exist it is it's fully functional it's just the API didn't look quite the way we wanted to for the seed so we pulled it back but the API will definitely be in place by the time Panther ships we've got a lot of feedback about data browser over the years this actually it had quite a long life span it's been around since before Mac OS 10 because it shipped in carbon lib and so we wanted to implement some of the feature requests you've asked for now in Jaguar our big push was for HIV you you know we wanted everybody to get out there and use a chive you and it's this really exciting cool functionality so I'm sure everybody raced out tried it and then hit a brick wall and went oh data browser doesn't support it I guess I can't use it I guess I can't use compositing mode and yeah that's true it is unfortunate if that's one of the things we really really wanted to fix Panther so I'm happy to say that now it works in compositing mode it's pretty darn cool and compositing mode it's actually a lot faster because because of the way compositing modes and validation system works I have to redraw a lot less than data browser when things happen to it then I had to a non compositing mode in fact this normal data browser API usage got a little bit faster because there were some data browser api's that would immediately redraw and so if he did sort of a multi-state change on the data browser you might get three or four redraws whereas now in compositing mode those four state changes will only be accompanied by one redraw but data browser is a really huge API right I got it working in my test tools we got it working enough for the new nav services and find her in a few places but I know we didn't quite cover all the bases so I need your feedback so those of you who hit the brick wall for adopting compositing in Jaguar please go try it out don't go let us know if you see any problems in compositing mode with you know various data types and whatnot I'd like to have this thing rock solid for panther but I need your help to do it so write up any bugs you see so the other thing we add is for one thing we added for Jaguar actually was type selection in column view and we can actually do type selection for free in column view because there's only one column that sort of focused at a time if you will enlist view however if you've got multiple columns the data browser doesn't know which column to apply the type selecting to write in finder it would need to be the name column but you know we could make that guess we can find the first column that does text but that's you know a little fishy it might not work for every application so what we decided to do was make it an adoption passing which actually gives us a benefit in a second but I'll talk about when you set up your call on a tray list view you can specify a new property this K data browser list view type select column property which is in control definition CH associate that with one of your columns and that's the column will apply type selection to now the benefit we got actually for making this an adoption path thing is it prevented us from breaking your existing applications we know there are some applications out there that filter the incoming text before it hits the data browser and you can filter it at sort of the weight next event level up until now data browser wasn't particularly compartment savvy and so you know you can get away with taking an event out of weight next event filtering it and then calling data browser with only those key presses you wanted to give the data browser well when type selections turned on in order to do proper Unicode matching with the contents of the types of left column we need to handle our text input via the K event text input carbon event so that is a difference when you turn on type select text input will be grabbed by data browser in a different way so if you need to do filtering make sure you filter using the K event text input carbon events or some other similar mechanism in fact there are some new events put out by the tech services manager that make text filtering in general a lot easier take a look in carbon events H for that kind of stuff so the appearance manager was introduced in Mac OS 8 i'm sure most of you are familiar with it i'm sure some of you have even used it and it worked great on mac OS 8 was really fast but on mac OS 10 it didn't perform particularly well and the reason for that is that the appearance manager was entirely quick-draw base it assumed it was drawing into the current port that's basically the main quick draw basis that it had now Mac OS 10 is very coarse paste we want to use core graphics all over the place and in fact the internals of the appearance manager on Mac OS 10 draw in court so we had this weird sandwich effect going on in the appearance manager where okay somebody would call the appearance manager they would have set up their port properly but before we call our internal stuff we needed to convert the port information to cg contacts and make sure to synchronize the clip of the CG context with the quick-draw clip and that's terrifically expensive now sometimes after we were done doing our drawing we needed to call your code back to do label drawing and stuff like that and that is yet another sort of mode switch where we had to shore up the data structures and make sure everything was right and quick draw world to match the way we set it up in the core graphics world so you had the sandwich of quick draw core graphics in the middle and quick draw on the other side and that just slowed everything down so what we did is we took just that center portion just that courts portion and we exported it as I seen drawing primitives now of course this is going to give you massive performance increases in general we see about a two-time speed boost for an HIV may pee I on Panther compared to the equivalent appearance API on Jaguar so if you can adopt this stuff conditionally in your code for Panther you're going to see really big speed benefits for those of you who are using appearance manager now the best thing is that these AP of the HIV api's will look really really familiar it's virtually an identical usage model so should be extraordinarily easy to adopt and the number one request for the appearance manager is give us a way to draw posting push buttons please so you can do that to the HIV api's now now another reason H I theme is so important is because this is the API set that will allow you to draw all the new aqua widgets right you need to use H I theme if you want to draw that new tab look and the segment views and things like that so you need to get familiar with this and understand how to use it if you need your own drawing primitives and lastly the HIC API is actually lay the foundation for the toolbox and its ability to print what it doesn't it doesn't print quite yet but this lays enough groundwork so that we can actually print whereas the appearance manager API simply cannot print by virtue of the way we have the manual manufacture a context to match the quick report so like I said it's a very very familiar usage model but there are some differences first obviously is that the HIV may pis are completely court savvy so no longer will you be able to assume oh I can set up the current court with a background color and the appearance manager is going to raise to it a race to it now you have to do your race beforehand if that's something you need to do and then call the H I theme API and in fact the HIC may pee I requires that you pass in a core graphics context so you manufacture one of these core graphics context and you can call multiple thi theme api's as you need to the second major difference is the fact that the H I theme api's use H I point and H I rectangle parameters and there's two reasons for this the first is that since H I theme is entirely core graphics based and since core graphics has a floating point based coordinate system quickdraw coordinate field quick-draw coordinates which we're not floating point don't really work well in the context of CG right then did they don't allow maximum flexibility and so that made it natural to use a chai point in H Iraq the second reason is that the HIPAA p is were literally designed so that we could implement our system HIV use like the push button and whatnot and since they are a chive use they also use a chai point H I rectangle parameters so it was just a perfectly natural fit now you guys are all used to drawing with the top left-hand origin I think that's more comfortable I'm sure all of you do too so of course the HIC maybe I support that model but if you're doing more PDF compatible compatible drawing or if you're trying to do something primitive drawing from a cocoa application HIC and supports the bottom left origin as well so you can use it from just about anywhere so we introduced HIV you and Jaguar and it has a lot of cooling functionality but we wanted to add something really key to it in Panther and so we've got something that's kind of exciting and it's called a chai view layout but rather than explain it I want to give you a brief demo because I think that'll do a better job showing you what it's all about so if we could go to the demo machine yeah I'm being told I need to talk faster something tells me that's not the case okay so this is rebounder this is our test tool for the HIV layout stuff but it's also we're also going to sort of polish it up and put it out a sample code after the show but it needs a little bit of work I mean for one we're stretching a push button well beyond the bounds of good taste anyway so this is basically just a normal window with a push button in it you can click and track on it but we put some carbon event handlers on the push button so that we can put it in this sort of edit mode right you can see these little handles get associated with it and you know i can rearrange the push button we've showed demos like this before but that's not the point of this application the point of this application is it lets us test out all of the HIV you layout stuff now layouts simply speaking are just a way to make a view resize or move when a window resizes you can think of it that way so for instance I've got this view a I can set up a binding which is the first type of a layout that we support and I can associate that me with the right hand side of the window and when I grow the window view stays in place just like you'd expect and you know you're not limited to just want to edge of course I can bind it to the bottom of the window you know let's say it's like an ok button you know and it's going to stay in the right place it's all automatic I just set up some data structures call an API and the toolbox we'll take care of the rest now another cool thing is that you can do sort of arbitrary relationships I've associated this view a with its parent the window but you're not limited to just parent relationships I can create another view of you be let's move it down here next to view a because I like it there to make it a little bit smaller so I'm at least somewhat close to the Aqua human interface guidelines and I'm going to bind that view I'm going to bind it's right edge to the left edge of you a and now when I resize the window you get this sort of cascade of automatic risa our automatic repositioning now of course i can find view be to view a top as well you know and so now you've got a really easy way to keep your ok and cancel buttons down on the bottom of the window [Applause] okay so but bindings are just one of the layouts we support one of the types of relationships we support another thing we support is positioning and you can think of positioning sort of as alignment and it's an alternative way to do something we've already done in this demo so I'm going to go ahead and position a horizontally such that it is now right aligned with the window so it immediately snaps over there and it's going to stay over there just like you'd expect but positionings also support offsets so I think the Aqua human interface guidelines say that the right offset from the edge of the window is 13 pixels so let me apply an offset to the positioning I've set up and it'll say 13 pixels from the edge of the window of course I can do the same thing to the bottom but before I do that when we actually turn off the binding do the same thing position that 13 pixels up from the bottom of the window and a is going to stay in the right place just the way we want and B is still moving as well because it still bounds a Age movement but one other cool aspect is that the relationships are one way so I can actually move be someplace else and it'll still maintain these relative offset from a so it's kind of powerful in that way you can move your views around and change the layouts and things still behave the way you'd expect okay so another cool thing you can do with positionings is centering let me clear the offsets and I can Center a so a is going to stay in the center of course be still bound to it he's going to stay right where we wanted to be and if I clear the centering I can show you the third type of layout we support and that's scaling I can say all right let's let's say for some strange reason I always want view a to be fifty percent of the width of the window I can set that up and let's say for some of the strange reason I want it to be twenty-five percent the height of the window that works as well so now whenever the windows height changes and with changes a size changes along with it now probably the coolest part about layout is you can mix and match them income item so I'm going to leave aids bindings all set up so that he's staying proportion of the window size but now i'm also going to say all right center and two and both of those bindings are respected so this is really really powerful we switch the new navigation services over to using this stuff got rid of a ton of code in nav and and it not only live resizes faster but it just makes the code so much easier to maintain so if we can go back to the slides now that'd be great so obviously layouts are cool but there's some other technical reasons why you might want to use these it's a very rich descriptive language for associating views together for one you know you can do peer relationships like I showed a to be you can do parent relationships a to the window but you can even do strange relative relationships you could do a to its second cousin if you wanted to we took advantage of this and navigation services as well and it made some of the relay out of the dialogue that we needed to do to support you know various optional pop-ups and whatnot made that super simple and the other main benefit is that if you let us do the layout for you not only do you have less code you need to maintain but we can make sure that our layout code is as efficient as possible so you don't have to spend time optimizing it and we can also make sure we do it at the most optimal time so that we invalidate as little as possible and causes a little of a redraw as possible this without all I'm going to talk about in terms of HIV layouts but sessions for 25 is going to go into quite a bit more detail so go check that one out so the Aqua human interface guidelines gets sort of the the desired look for simple about boxes and yeah it's really simple but we figured well if we can do that for you why not so we added the H I about box API to the toolbox for Panther to do simple about boxes and of course it's going to support everything you're looking for in one of these simple about boxes it gives you the right look it's you know it's going to display your applications name and version and copyright information and it does that by looking at your applications bundle which probably already has that information so we'll just fetch it from there and display it appropriately but if you want to customize it there's two different ways you can customize it you can either give us a CF dictionary full of strings with well-known keys and say you know please use this string for the name please use this string for the version and whatnot and that might actually be useful for plugins that want to display in about box right you wouldn't want the plug-in to displaying about bucks at points at the apps bundle so you know you supply your own strings alternatively for supplying a dictionary you can point the H I about box API at a strings file and we'll pull the strings out of there so it makes it easier to localize and whatnot now if you use run application event loop to drive your event loop the about box will display automatically whenever the default application object receives the H I command about command so all you need to do to get one of these wired into your app is just associate that command ID with your about menu item will put it up automatically but if you need to display it manually like in the case of a plug-in graph or for a white next event based application you can call the H I about box command directly if you need to now the about box is a moat modeless window in the document layer of your application and so you know the user is going to expect to click between it so you need to be prepared to deal with that we need to be sort of prepared for this other window when though you may not have created to be in your document list and the other thing users going to need to be able to do is close it well the about box already handles a bunch of carbon events on itself it's a standard handler base so it's going to automatically close if the user clicks on the closed box but the users of course going to want to close it by choosing the appropriate commands from the file menu and the easiest way to do that is to put the eh I command clothes command ID in your close window command in your file menu that I fleet command enough I think so anyway you get the point toolbar was another technology we added in Jaguar and family need to add a few things to that as well the toolbar is set up such that it can automatically save its configuration to your preferences and that's really powerful it means you have to write less code and the user gets the desired experience but there was a small hole in that plan having to do with custom toolbar items there are some custom toolbar items you may have added to your toolbar and those items may have had their own internal state and there may be times when that internal state changes without the user doing something explicit and if that happened there was no way for your toolbar items to communicate back to the toolbar and say hey I'm dirty now you need to save me at the next possible chance so it was possible that our automatic saving of configuration data would kind of would lose some configuration every now and again so we added an API to deal with that which is a chai toolbar item config data changed so anytime your internal state changes in a custom item just call this the toolbar will automatically save your configuration a lot of people that use toolbars build them up programmatically not everybody can use our sort of automatic regeneration from prep technique but what we found in fact finder was one of those clients they built it up manually from their own preferences store and what we found is it's actually quite slow because the previous AP is only allowed you to programmatically add toolbar items to a toolbar one at a time and every time you add a toolbar item to a toolbar there's a bunch of carbon events that gets sent out so that all the toolbar views in the various windows that use that tool bar no to update and then each of those toolbar views is oh I've got a new view of me I think I need to relay stuff out you know ship stuff around that's a lot of work for every single tool bar item you multiply that times n items and things start slowing down a lot so we added the H I toolbar set items with identifies API to allow you to add a whole batch of toolbar items at once to a tool bar toolbar so if you are doing this custom tool our creation programmatically make sure to conditionally use this API on Panther and later because it's going to speed up your window creation possibly dramatically depending on how many toolbar items are in it so I'm running out of good segue so I'm just going to say let's talk about the carbon event manager we added a few API the first is kind of an edge case usage thing a chai mau maus tracking get parameters is an API that allows you to ask us how we do our sticky menu tracking in sort of an abstract way there's some applications out there that want to replicate our sticky menu tracking you know perhaps you're doing something men you like or you know you're doing your own custom and your implementation something and you need to behave the same this API allows you to make sure you're behaving the same with respect to all the things the users configured on the system and all of that user's preferences the next API we added is copy event add in the carbon event manager we we transform events as they cascade through the system right a ROM ass down becomes a window content click the window content click might spawn a que event control click the control click will spawn a control track and so on and so on and so on and our model generally dictates that an event on from another event should have pretty much all the same parameters as the event that spawned it and if you're trying to replicate that in your own code or if you're trying to do some trigger some functionality and the standard window handlers and want to make sure you're passing the right kind of event to the standard window handler the copy event as function you might find useful it allows you to take any given event of a certain class and kind and create another event of a different class in kind while still maintaining all the same parameters that the original event had now another API we added fields all fills a hole and fixes of performance bug at the same time you know we're pushing everybody to adopt carbon events as much as possible and we've pretty much got all the bases covered but we found out that some people still need to use a vent avail and still down in their applications for various reasons we just didn't have a sort of carbon event savvy version of those and that's fine I mean generally those two api's give you the information you need but the real problem was that there were kind of performance hogs not only does events avail tell you whether or not one of these types of events but it also calls the run loop which might fire timers and it may also flush your windows that are dirty which means that any given call to event avail may take a lot more time than you want it to considering most people use event avail in a fairly tight loop so what we did is we implemented a choir first matching event in queue which is kind of like a carbon event savvy version of events avail without all the horrendously expensive stuff underneath it it just synchronizes RT with the windows servers to you and tells you real quick hey yeah this event is in the queue here it is have fun does not do any flushing or anything like that so you need to look at your code find all places where you're using a vent avail and spill down and see if you can switch over to require first matching event event in q4 Panther additionally so the lake things an awful lot faster one sort of important thing to note is that you can't do a direct one-to-one replacement from still down to acquire first matching event in q you're probably still going to want to check button because you know that's generally the semantics used that's generally the semantics you desire when you still down so we had some requests from accessibility developers for a way to look at other applications events you know they for whatever reason need to watch the key key downs and key eps and mouse ups and mouth bound sort of other similar events as they happen in other applications generally for accessibility purposes so we invented get event monitor target which returns a carbon event event target ref that you can put handlers on for these sort of low-level user events and it only receives the low-level ones it's not like we're going to give you you know k event window activated events and whatnot it's just a low-level layer so you can install handlers for the events you want to see in other applications and your handler and your application will see those events the first important note is that there are times when the system puts itself in sort of a secure event mode the password fields are the best example right i mean if the users typing in a password field you don't want other applications to see those keyboard input see a keyboard input so we will not send you those events the other important thing to realize is that get event monitor target and flow the system down in general so you only want to use it when you need to and those of you who need to use it already know who you are this is not something for general applications out there and the reason why it slows things down is because normally as the user types and clicks and stuff the windows server just sends events to one process well we'd get event monitor target if another application installed handlers for PFC towns amounts of smell sounds the windows servers send in two copies out and not only are there two copies going out but that means your application that's in the background normally being quiet not consuming any resources is suddenly consuming resources taking away the user's ability to use the program in the front so don't use this unless you need to very specialized jump right into the menu managers the first menu manager API we added these cancel menu tracking does just what you'd expect cancels the menu tracking so if you have some kind of need where you want to programmatically stop the user from tracking the menus I don't know maybe you want to put up an alert or do some other UI you can now do so programmatically and we also send out a pair of carbon events whenever the menu bar is shown in hidden this would allow you to you know certain certain pieces of three interface may want to show or hide appropriately like your pallets and whatnot whenever the menu bar showing so you just install handlers for these pair of events on the application eventtarget listen to it modify your interface appropriately but probably the best feature we add it to the menu manager was support for HIV based menus of coming into Panther we'd already HIV 05 most of the system right H I've use our control so that was already done the window manager got changed so that now window frames and whatnot are drawn with compositing view so that was all in place but the big missing piece was a menu manager and the menu manager was kind of this weird environment where you had a quick report that didn't really point to anything besides some buffer of bits that the menu manager managed and online it would look those to the screen but on 10 you know we got some other functionality for free and em deaths were confusing i guess at best and hard to do and therefore you didn't see a whole lot of custom menus well HIV based menus changes all that makes menu customization super super easy but you just need to know a few fundamental principles and for those of you who understand HIV already this is going to be really straightforward so if you've got a chive use you need compositing windows and that means every menu is now drawn in a compositing window just like you'd expect it has with a normal view hierarchy of a compositing window you know there's sort of a structure of you and there's a content view but there's a few special nuances of a menu vee system that you need to be aware of and the first is the notion of the menu content view the menu content view lives inside the windows normal content view and the menu content views responsibility is to draw all of the menu items of course we have a standard menu content view for our menus and that's what draws I context command key and whatnot now the windows normal content view is where the menu background gets drawn in the case of our standard one we draw those aqualine and if you're going to write one of these custom menus you need to be able to find out you need to be able to go back and forth between views and menus so we've got two api's would facilitate that functionality a chai menu get content view says alright given this menu ref give me the content view that's going to render it and there's the inverse as well H I menu view get menu which is really useful for inside your custom menu view right you need to know which menu to render so you can ask for it with that API now there's not a lot of custom menus out there because it's hard but let me give you a little advice on why you might want to make a custom menu and show you a couple examples basically you'd want to do a custom menu to get functionality that isn't already provided by our system menu that is to get a menu that's not just you know text command keys good example of that would be something like the finder in Panther the file menu now has a menu item that allows you to change the label of any given finder item and that's actually done by a custom HIV that's inserted in that menu implemented by finder another example that we've shown up here in the center is something like we call an XY menu would be great for like a color sort of palette like which oh there or maybe some kind of tool palette and lastly some menus in our system really aren't menus right if you look at the volume menu in the right hand side of your menu bar it's got a slider in it it's not much of a menu but it displays like one so if you want to do some functionality like that you would do it with the custom menu making one is very straightforward if you already understand the architecture we introduced a chai object in Jaguar it's the object model you can derive from base classes and we provide the base menu content view class as khi menu view class ID so you derive from that using the H object mechanism now that you have your object class you can associate that view class with any given menu and then that one that menu drawers it's going to display with your it'll actually create what an instance of your custom view and then draw with that custom view and since it's a normal a chive you in a normal compositing window you can embed other views inside your custom view as you need to and after you've done that you just want to have the five fairly straightforward carbon events and in fact they're very familiar of carbon events that we've already had on the system for a year or so but the important thing to understand is the protocol the menu manager uses with respect to part codes so the control manager and a chive you often talk in terms of part codes right what part of the control was hit what part of a control is the mouse over but the menu manager always talks in terms of menu items and it wants to know the same piece of information so the protocol with respect to many content views is that part codes correspond directly to the menuitem if you receive an HIV event that's asking for information about part foot five given information about menu item five the first event you want to handle is k event control draw and in fact you wouldn't necessarily even need to handle this if all of your drawing was done by just embedding other H I've use the responsibility for K event control draw or for your content view when it receives this event is to draw your menu items really straight forward forward draw however you need to draw them but as the user is tracking the mouse over a menu the menu manager wants one of those items highlighted of course so you need to draw that highlighted the way you find out which item is highlighted is by looking at the focused part of your menu content view so you can call a chive you get focus part that'll tell you the menu items that's currently highlighted so you draw that in the inverted manner or whatever is appropriate for your pesto menu now the second event you want to handle is k event control hit test the menu manager will send this event to your custom menu whenever it needs to find out which item is under the mouse so all you need to do is look at the coordinate in the event it's a view relative coordinate figure out which menu item that corresponds to and pass that back in the carbon event and similarly the cave and control get part region carbon event will be sent whenever the menu manager needs to know the total area that that menu item occupies visually in the menu so you look at the incoming part you build up a region that represents the bounding rectangle for that item pass it back in the event the fourth event is k event control get optimal bounds the menu manager will send this to you sort of early at menu time when it needs to figure out how big your menu would ideally be right this is assuming you've got infinite screen real estate so if you've got an eight thousand item menu make sure you return a really big rectangle but the one thing note is that your menu maybe size smaller to fit on a screen just like you'd expect so you need to be prepared to deal with that and the way the menu manager does scrolling most of it is actually handle automatically for you but the way it Scrolls you is by offsetting your content views bounds origin appropriately so in your draw handler what you can do is look at your bounds origin and constrain drawing a pro really to cover only those items that are visible on the screen which will speed up your menu a lot right if you've got a lot of menu items that aren't displayed there's no point drawing though so there's one last carbon event you need to handle and that's to facilitate scrolling it's Kevin scrollable get info and we introduce that in Jaguar as part of the H I scrollview carbon event protocol what we're leveraging it here there's about I think four or five pieces of data that you need to provide in this event to the menu manager take a look in carbon events that H actually now I think that one is an HIV dot H to see what those parameters are but they describe things like how much of you is visible how much total of you there is how much you want to have scrolled every time the you know the user or it's sort of in every scroll increment right that kind of information it's really straightforward and the rest of the functionality is all going to be taken care of for you by the base menu handling right so if you just implement those five carbon events you're going to have a custom menu up and running but there's a few more events you might want to handle for various other regions if you need to do further customization or change sort of the default behaviors so the first of those is k event menu create frame view this event is sent to your menu content view when it needs when the menu manager wants to know what the window frame you should look like this is the thing that actually draws the menu background by default the base handler will create a frame view that will draw the normal aqualine background but if you want a custom background picture or something you can handle this event and create your own view and do whatever drawing you need to the second event is k event menu get frame bounds this event is sent to the content view to determine where that content where the total menu area should be displayed globally on screen you know generally they're going to pop down from the menu bar but you might have a pop-up button or something and you know it needs to position appropriately relative to the item that the caller called pop-up menu select with and so there's a whole bunch of data that gets passed into the get frame bounds karbonn event so you can decide or customize how exactly you want to taste efficient on screen then finally there's a key event then you become scrollable carbon wind with carbon events is sent to your content view whenever your content view is a candidate bowling and this will happen whenever your whenever your content view represents the sort of leaf node menu right of a series of menus because that's the one the user can type selected so you'll receive this event and you can either block the default scrolling behavior if you don't want any scrolling for some reason or you can do your own scrolling behavior if you've got really unique need you know maybe you need to scroll horizontally through a menu or something who knows and so it comes with a lot of info you can look at generally you want to when you receive this event you're going to want to install a bunch of event handlers on the menus window so that you can receive other input and whatnot and then when your menu is no longer a candidate for scrolling we send the key event menu cease to be scrollable carbon event to you and that's where you tear down all the handlers you set up when you became trouble so that's just sort of one technique sort of a comprehensive technique for creating a custom menu but it's certainly not the only technique right if you've got a composited window you can do just about anything with that thing there's all kinds of carbon lets you can hook can do to create views and you can use existing views on the system and it's all carpet event handlers to handle user interaction and all that stuff so there's lots of other techniques we've got a piece of sample code out there it went on the website earlier this week so I suggest you go check that out it shows I think about four different custom menus in fact that will be app I use to take the screenshots a few slide back with those custom any so it'll show you how to do all three of those custom menus plus one additional one which puts a menu bar sorry a picture as a menu background it's really really good sample code let's jump right into the window manager the first API we added there is a chai window change class now this is really cool because it allows you to sort of polymorphic ly change a window from say document a floating and back so you can do some really interesting you I there you can sort of promote things to float or you know change them around a little bit so that's really need the next API we added is both sort of a technology thing and a convenience thing right now if you need to programmatically flush a window to the screen the only way to do that was with a quick draw API and if we're really moving towards court it doesn't make sense to keep you guys using a quick draw API to do the flushing so now a chai window wash allows you to do a flush on just a window rack you can you know completely ignore the implementation details of the fact that the support there the other benefit is that flush time now in the toolbox is more than just painting the bits to the screen right we do other interesting things in the compositing view system like right at flush time we look to see which of your views are dirty and we tell them to repaint right now and then we can flush that to the screen and similarly window shadows often need to get recalculated right at flush time so this h i went to flush the api is this one-stop shopping api to just say hey look this window the way it needs to be bulleted now with the evidence of sheets you know more more applications or adopting them and probably the number one piece of feedback we've heard about sheets is that you've got a document window an error happens you put up a sheet that document window is still sort of modeless with respect to the rest of the windows in your app and you might get into a situation where you need to display another sheet on that same document window but the Aqua human interface guidelines say now you shouldn't do that and unfortunately there's no really good way to find out if you've already got a sheet on your document window so H I window is document modal target is designed to solve that problem tell is it easy and easily in just a one-stop shopping API for whether or not there's a sheet here we know we also have a detached sheet window API which will allow you to create a sheet display it and then recycle it for display at a later time as opposed to just disposing it and then creating a new sheet later right so this will buy you a little bit in terms of efficiency if you're constantly we're using a particular type of sheet we also send out a couple new carbon events having to do with Windows we've got a you can because this is a carbon event hook k event app active window changed gets sent out whenever the app the active window in your application gets changed so if you need to maintain state or update some UI based on whatever the active window is you can just install a handler for this event on the application target and you'll be notified whenever that happens now the window manager will automatically take care of rearranging windows on the screen whenever the monitor configuration changes or whenever like the documents from the bottom over to the side so the window manager will already do that and it sends events to your application I think they're k event window constrain events to each window so each mundo can deal with it itself but if you need a global way to hook into that and replace the window management window managers entire batch of functionality you can now install a handler 4k event app available window bounds changed on the application target and then completely replace the window managers functionality if you need to so we also enrich the existing window transition API the coolest part now as you can see is we now support a genie transition effect so you can Genie whatever you need to whenever you need to it's not just for coming in and out of the dock and it will give you the standard UI for it so you're going to match the rest of the system now we also came up with a new API called transition window with options it's going to look very familiar because it's based off the existing transition window API but from the options it allows you to customize it has to do with durations you can make say a window fade transition as fast or as slow as you want you can speed up or slow down the genie effect as you need to and it also supports asynchronous transitions so that you can just call transition with window with options it'll return immediately and the transition will happen sort of behind your back without you having a block so you can continue processing now of course if you're using asynchronous transitions you probably want to know when the transition is finished so we have a pair of carbon events to help you out with that we have a key event window transition started event it's sent to the window right when the transition starts so you can set up any state you need to maintain and then a cabin window transition completed carbon event when the transition is finished now performance is not all just about super duper fat code that SuperDuper fast code helps of course but you know it's not the end all be all some of it has to do with perceived performance how fast is your apps seem and one way we facilitate that on Panther is through asynchronous window dragging so traditionally on Mac OS when you want to drag a window sorry there's no Michael attend when you want to drag a window you click on the title bar the windows server has to send the click event to your application your application catches that event and either you call drag window or the toolbox calls drag window for you and then the user starts mouthing or you know starts moving the window around and there is a slight lag there right there's a cross process message that has to be sent if we can actually allow window dragging at the windows server level that process is going to be we're going to eliminate the cross process message and the drag is going to start virtually instantaneously it's much much faster perceived performance the secondary benefit is that if your app is busy you've got the spinning cursor of death or after doing some you know intense computation you can't serve as events very often the user will still be able to click their window even if your app is not generally responsive of course the best part is that it's really easy to turn on we've got a new window attribute k window async drag attribute you can specify that after we either in create new window or change window attributes later if you need to but there's one very very important caveat because the window server is handling your window dragging you are not going to receive a steady stream of K event window bounds changing events as the windows dragged around you will get them occasionally but there will be sort of like a hiccup effect you'll get them every now and again sort of disease or pauses so if you were relying on K event window bounds changing to do some sort of custom window drag gridding you know you want it to snap to various locations or snap tool bars together and whatnot it's not going to work real well with a sink window dragging so you've got a couple options there the first is just don't use async window dragging right you don't have to use it for all the windows in your application if your interface is better served by that gridding you know keep doing that gridding don't turn on anything for those windows that's fine alternatively we do send out a cabin window drag completed carbon event whenever a window drag is finished so one thing you could do is install a handler for that event instead of the balance changing event and then let the user drag the window all around the screen wherever don't do the sort of live snapping and then when the drags finished you'll get the dry completed event and you can snap the window to the correct location then we've got a couple options there the other real important thing to realize about a synchronous window dragon is that if you turn this on you don't want to call drag window when you finally receive the mouth now because you will receive that mouth then in your application and if you turn on a cig dragging receive the mouse down and then call drag window yourself you're going to get a really weird effect as the window sort of jumps around between two different locations so make sure to take out your pulses Ragueneau similar API so I've talked about an awful lot of stuff and that's not even in I mean we have a couple other sessions for a chai toolbox where we talk about entirely other pieces of functionality that we've added but that shouldn't stop you from going and implementing some of the stuff now there's a lot of quick and easy things you can do you can conditional eyes some of your code for Panther such that it uses vhi theme api's instead of the appearance manager you're going to get a lot of performance boost from that you can use the replacement for event avail and skill down you can start adopting the new aqua widgets right you start using that search field start using the segment view when it's when it's finally available but even more important than that is if you haven't started looking at the new technologies and our underlying foundational technology you got to start looking at that now more and more of our stuff is only going to work under this new model you need to start learning about compositing try turning on the standard window Handler and some of your windows you know you're going to run through some issues there is a little bit of a code Brescia needs to happen but it's not a very big coat brush so go turn those things on and start iterative iteratively making these improvements to your application so you'll be completely flexible as we a sort of throwing technologies out there for you to use now this is something we actually did for the new navigation services for Panther the old map was completely dialogue based it did all the event handling self except for a few edge cases and therefore now was a really big binary did a lot of work so as part of the new UI we actually switched navigation services over to using the standard handlers over to using compositing and you know sure it took us a little bit of time but the end result was great we gave much better performance we got to adopt all the new widgets you know we got these with segments to you and whatnot we got to use data browser and compositing mode but the best thing is that we got rid of a lot of code out an app I mean the nav binary even though navigation services does more now in Panthers than it did in Jaguar is still ten percent smaller than it wasn't Jaguar you know so for your applications that's going to mean quicker download times you know let's paging that needs to happen when your application as loaded and things like that so you got to get out there start adopting these new technologies and move your applications to the future Mac os10 so now I would like to bring back up saviers so you take us through the roadmap and some QA [Applause] alright we have a couple of things that are very important to understand and hopefully between make sense for you guys on what we've been trying to achieve this year with the station for carbon developers very important the data exchange option for carbon application with brand new services form to the pit board the new type which is the UTI the uniform type identifier but we're going to be talking about critical go and see that because you have to use that in danger prepare if you need more information about HIV you if you have Kristen controls and you like to take advantage of co graphics and the new completed view model that we have please go to position 4 to 5 carbon will we took reading details about HIV and how your application can take advantage of this technology to very important stations this year we have something specific fault amazing performance for carbon applications where we're going to be able actually taking you guys to a bunch of steps from networking file i/o what you should do with carbon essence what type of composite you should use when on what windows we're going to talk about things like a PRS that maybe you should start moving out of you know that you should not be using anymore a very very good session and we have session 3 07 that's going to be specifically for carbon development and your Xcode the new to be released the tools team has made major effort to actually have the tools integrates very well with what carbon developers are doing and with HIV of course and you so little bit of like that to interface builder but X collect some pretty cool built-in support for the building carbon applications as well can I had one thing he David what's your session number 43 there is one station that is not there with decisions for two or three very cool station a lot of people winery like you know are in my case which is you know we all have applications for mac OS 9 but are using power plant and we have all these different technologies in carbon to use and were wondering well why should I start but session is going to be specifically on how to build a modern C C++ application on Mac OS theorem so you can think of it kind of as fresher course if you need to kind of get reminded of what the right way to do things are you know to use run application event loop instead of wait next event things like that you know it'll give you the right pointers toward using the modern API it's what makes you a murderer and keep the first application fee of typical application on my question what should you use we'd go through a carbon event a chive you we have like a bunch of things for that I encourage you to justice to that station I got them back sugar should you need any question you can contact me exhibit apple com there is always my manager in case i don't answer and I mean Tahiti or something like that and jungle and is also a really good guy if you have aqua questions jungle entities actually or user experience technology evangelist you