macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Modding Apple Sample Code
Pages: 1, 2, 3, 4

Start Making Changes in the Code

I know how useless the directive "start making changes" must sound. It's a basic truth, however, that one is either a programmer or one is not. Feel your way around the source code and make a change here or there to discover the effect, exploring how your modifications alter the program's functionality and always keeping your goals in mind.



Keep your changes small. Compile them, observe the effects, and (here's the important bit) don't hesitate to undo each change after seeing what it does. Make sure to use your modification log to record the results of your exploration so you begin to understand the bigger picture of where you can make changes and where you cannot.

These are the changes made between the standard Apple distribution and the modified version available here. Figure 3 shows the result of these changes when incorporated into the program, compiled, and run.

  • Deleted draw_blob entirely and the call to draw_blob. This got rid of the small colored circles, in which I had no interest.
  • Deleted draweditlist and the reference to it, and drawtrackthumbnails and the reference to it. This removed the two undesired rows of thumbnails, leaving just the frames with the proper decode order.
  • Removed the line between decode time stamp and display time stamp. These were used to show the differences between the media order and the decode order and were of no interest.
  • Deleted the "Y axis" calculation and removed decodeAxisY and displayAxisY as variables. These weren't used anymore.
  • Updated the frame thumbnail drawing from framesInMediaDecodeRect to framesInTrackRect (four occurrences total). This instructed the program to draw using the top row rather than the bottom row.
  • Added a constant: #define custom_multiplier 5. I used this factor to expand the size of the thumbnails as follows: multiplied the decodeWidth, displayWidth, framesInTrackRect height and the height in the frame thumbnail drawing by my multiplier.

Figure 3
Figure 3: After applying a few simple code changes including a custom multiplication factor for the thumbnail size, the updated software looks like this. The frames are far bigger and the extra rows and superfluous graphics are omitted.

Update the Interface

Interface Builder provides the key to finishing the modding process for MovieVideoChart. It allows you to achieve interface goals like removing text, setting the default value for the slider, and moving items around in the window. Here are a few key pointers to keep in mind:

  • Do not delete things. Don't remove any existent element unless you're sure you won't break the program. Instead try to edit, hide or possibly disable the element.
  • Adjust your layout when you move items. You'll want your windows to resize smoothly, with the interface elements pinned to the proper edges. Check the layout palette and make sure the settings reflect your item's new position.
  • Keep back-to-front layout in your mind. If you want to hide things, send them to the back of the layout. Bring your primary items to the front.
  • Avoid changing menu text. The program may depend on the current wording to operate properly.

Here are the steps to finish hacking MovieVideoChart, modifying its user interface in Interface Builder:

  1. Remove the text from all the text fields on the left side of the window, starting with Frames In Track and ending with Sample Flags.
  2. Select the main chart view. Bring it to the front (Layout → Bring to Front) and resize it to fit to the left of the window.
  3. Resize the ScrollBar under the ChartView to fit to the left of the window as well.
  4. Select the Use Seconds/Use Timescales pop-up and, in the Control inspector, disable and hide it.
  5. Move the frame-size slider onto the Use Seconds/Use Timescales pop-up and bring it to the front. In the Layout inspector, pin it to the top and right, but not to the bottom or left. Run the simulator to make sure this works properly. In the Attributes inspector, set the Initial value to 100.

The updated interface will look like the one shown in Figure 4. Save your changes to disk.

Figure 4
Figure 4: The modified user interface is much simpler than the original

Pages: 1, 2, 3, 4

Next Pagearrow