| 1 | /* |
|---|
| 2 | * SapphireFrontRowCompat.h |
|---|
| 3 | * Sapphire |
|---|
| 4 | * |
|---|
| 5 | * Created by Graham Booker on Oct. 29, 2007. |
|---|
| 6 | * Copyright 2007 Sapphire Development Team and/or www.nanopi.net |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * This program is free software; you can redistribute it and/or modify it under the terms of the GNU |
|---|
| 10 | * General Public License as published by the Free Software Foundation; either version 3 of the License, |
|---|
| 11 | * or (at your option) any later version. |
|---|
| 12 | * |
|---|
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even |
|---|
| 14 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
|---|
| 15 | * Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License along with this program; if not, |
|---|
| 18 | * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | /*! |
|---|
| 22 | * @brief A compatibility category for frontrow |
|---|
| 23 | * |
|---|
| 24 | * This is just here to make the compiler shut up. The sharedInstance does not exist on the ATV, but it does on frontrow. It is only called on frontrow. |
|---|
| 25 | */ |
|---|
| 26 | @interface BRRenderScene (compat) |
|---|
| 27 | /*! |
|---|
| 28 | * @brief Get the shared insntance |
|---|
| 29 | * |
|---|
| 30 | * @return The shared instance |
|---|
| 31 | */ |
|---|
| 32 | + (BRRenderScene *)sharedInstance; |
|---|
| 33 | @end |
|---|
| 34 | |
|---|
| 35 | /*! |
|---|
| 36 | * @brief A compatibility class for frontrow |
|---|
| 37 | * |
|---|
| 38 | * This class provides many compatibility functions for frontrow. This class is never instanciated since it contains no data. All of these functions could be implemented with C functions, but that looses the clarity of the exact meaning of parameters in Obj-C calls. |
|---|
| 39 | */ |
|---|
| 40 | @interface SapphireFrontRowCompat : NSObject { |
|---|
| 41 | } |
|---|
| 42 | /*! |
|---|
| 43 | * @brief Are we on frontrow? |
|---|
| 44 | * |
|---|
| 45 | * @return YES if on frotrow, NO otherwise |
|---|
| 46 | */ |
|---|
| 47 | + (BOOL)usingFrontRow; |
|---|
| 48 | |
|---|
| 49 | /*! |
|---|
| 50 | * @brief Are we on ATV Take Two? |
|---|
| 51 | * |
|---|
| 52 | * @return YES if on take two, NO otherwise |
|---|
| 53 | */ |
|---|
| 54 | + (BOOL)usingTakeTwo; |
|---|
| 55 | |
|---|
| 56 | /*! |
|---|
| 57 | * @brief Load an image at a path |
|---|
| 58 | * |
|---|
| 59 | * This returns a CGImageRef or a BRImage, depending on platform. |
|---|
| 60 | * |
|---|
| 61 | * @return The BRImage on Front Row or CGImageRef on ATV at a path |
|---|
| 62 | */ |
|---|
| 63 | + (id)imageAtPath:(NSString *)path; |
|---|
| 64 | |
|---|
| 65 | /*! |
|---|
| 66 | * @brief Load an image texture at a path |
|---|
| 67 | * |
|---|
| 68 | * This is like imageAtPath:, only it will return a BRBitmapTexture |
|---|
| 69 | * on the ATV for setting as a menu item icon. |
|---|
| 70 | * |
|---|
| 71 | * @return BRImage or BRBitmapTexture at a path |
|---|
| 72 | */ |
|---|
| 73 | + (id)imageAtPath:(NSString *)path scene:(BRRenderScene *)scene; |
|---|
| 74 | |
|---|
| 75 | /*! |
|---|
| 76 | * @brief Get a menu text menu item |
|---|
| 77 | * |
|---|
| 78 | * Menu items are of different classes on the ATV and in frontrow. |
|---|
| 79 | * |
|---|
| 80 | * @param scene The scene, if exists |
|---|
| 81 | * @param folder YES if this is a folder, NO otherwise |
|---|
| 82 | * @return The new menu item |
|---|
| 83 | */ |
|---|
| 84 | + (BRAdornedMenuItemLayer *)textMenuItemForScene:(BRRenderScene *)scene folder:(BOOL)folder; |
|---|
| 85 | |
|---|
| 86 | /*! |
|---|
| 87 | * @brief Set a menu item's title |
|---|
| 88 | * |
|---|
| 89 | * Menu items work differently in fronrow |
|---|
| 90 | * |
|---|
| 91 | * @param title The new title |
|---|
| 92 | * @param menu The menu item to set |
|---|
| 93 | */ |
|---|
| 94 | + (void)setTitle:(NSString *)title forMenu:(BRAdornedMenuItemLayer *)menu; |
|---|
| 95 | |
|---|
| 96 | /*! |
|---|
| 97 | * @brief Set a menu item's title with attributes |
|---|
| 98 | * |
|---|
| 99 | * Menu items work differently in fronrow |
|---|
| 100 | * |
|---|
| 101 | * @param title The new title |
|---|
| 102 | * @param attributes The new attributes |
|---|
| 103 | * @param menu The menu item to set |
|---|
| 104 | */ |
|---|
| 105 | + (void)setTitle:(NSString *)title withAttributes:(NSDictionary *)attributes forMenu:(BRAdornedMenuItemLayer *)menu; |
|---|
| 106 | |
|---|
| 107 | /*! |
|---|
| 108 | * @brief Get a menu item's title |
|---|
| 109 | * |
|---|
| 110 | * Menu items work differently in frontrow |
|---|
| 111 | * |
|---|
| 112 | * @param menu The menu item |
|---|
| 113 | */ |
|---|
| 114 | + (NSString *)titleForMenu:(BRAdornedMenuItemLayer *)menu; |
|---|
| 115 | |
|---|
| 116 | /*! |
|---|
| 117 | * @brief Set a menu item's right justified text |
|---|
| 118 | * |
|---|
| 119 | * Menu items work differently in fronrow |
|---|
| 120 | * |
|---|
| 121 | * @param text The new text |
|---|
| 122 | * @param menu The menu item to set |
|---|
| 123 | */ |
|---|
| 124 | + (void)setRightJustifiedText:(NSString *)text forMenu:(BRAdornedMenuItemLayer *)menu; |
|---|
| 125 | |
|---|
| 126 | /*! |
|---|
| 127 | * @brief Set a menu item's left icon |
|---|
| 128 | * |
|---|
| 129 | * Menu items work differently in fronrow |
|---|
| 130 | * |
|---|
| 131 | * @param icon The new icon |
|---|
| 132 | * @param menu The menu item to set |
|---|
| 133 | */ |
|---|
| 134 | + (void)setLeftIcon:(BRTexture *)icon forMenu:(BRAdornedMenuItemLayer *)menu; |
|---|
| 135 | |
|---|
| 136 | /*! |
|---|
| 137 | * @brief Set a menu item's right icon |
|---|
| 138 | * |
|---|
| 139 | * Menu items work differently in fronrow |
|---|
| 140 | * |
|---|
| 141 | * @param icon The new icon |
|---|
| 142 | * @param menu The menu item to set |
|---|
| 143 | */ |
|---|
| 144 | + (void)setRightIcon:(BRTexture *)icon forMenu:(BRAdornedMenuItemLayer *)menu; |
|---|
| 145 | |
|---|
| 146 | /*! |
|---|
| 147 | * @brief Get the checkmark image |
|---|
| 148 | * |
|---|
| 149 | * @param scene The secen, if exists |
|---|
| 150 | * @return The checkmark image |
|---|
| 151 | */ |
|---|
| 152 | + (id)selectedSettingImageForScene:(BRRenderScene *)scene; |
|---|
| 153 | |
|---|
| 154 | /*! |
|---|
| 155 | * @brief Get the blue unplayed dot image |
|---|
| 156 | * |
|---|
| 157 | * @param scene The scene, if it exists |
|---|
| 158 | * @return The blue unplayed dot image |
|---|
| 159 | */ |
|---|
| 160 | + (id)unplayedPodcastImageForScene:(BRRenderScene *)scene; |
|---|
| 161 | |
|---|
| 162 | /*! |
|---|
| 163 | * @brief Get the return to arrow image |
|---|
| 164 | * |
|---|
| 165 | * @param scene The scene, if it exists |
|---|
| 166 | * @return The return to arrow image |
|---|
| 167 | */ |
|---|
| 168 | + (id)returnToImageForScene:(BRRenderScene *)scene; |
|---|
| 169 | |
|---|
| 170 | /*! |
|---|
| 171 | * @brief Get a controller's frame |
|---|
| 172 | * |
|---|
| 173 | * Controllers work differently in fronrow |
|---|
| 174 | * |
|---|
| 175 | * @param controller The controller |
|---|
| 176 | * @return The frame of the controller |
|---|
| 177 | */ |
|---|
| 178 | + (NSRect)frameOfController:(id)controller; |
|---|
| 179 | |
|---|
| 180 | /*! |
|---|
| 181 | * @brief Set a controller's text |
|---|
| 182 | * |
|---|
| 183 | * Controllers work differently in fronrow |
|---|
| 184 | * |
|---|
| 185 | * @param text The new text |
|---|
| 186 | * @param attributes The new text's attributes |
|---|
| 187 | * @param control The control to set |
|---|
| 188 | */ |
|---|
| 189 | + (void)setText:(NSString *)text withAtrributes:(NSDictionary *)attributes forControl:(BRTextControl *)control; |
|---|
| 190 | |
|---|
| 191 | /*! |
|---|
| 192 | * @brief Add a divider to a menu |
|---|
| 193 | * |
|---|
| 194 | * Lists work differently in fronrow |
|---|
| 195 | * |
|---|
| 196 | * @param index The index to add the divider |
|---|
| 197 | * @param list The list to add to |
|---|
| 198 | */ |
|---|
| 199 | + (void)addDividerAtIndex:(int)index toList:(BRListControl *)list; |
|---|
| 200 | |
|---|
| 201 | /*! |
|---|
| 202 | * @brief Add a sublayer to a control |
|---|
| 203 | * |
|---|
| 204 | * Controllers work differently in fronrow |
|---|
| 205 | * |
|---|
| 206 | * @param sub The sublayer toadd |
|---|
| 207 | * @param controller The controller to add to |
|---|
| 208 | */ |
|---|
| 209 | + (void)addSublayer:(id)sub toControl:(id)controller; |
|---|
| 210 | |
|---|
| 211 | /*! |
|---|
| 212 | * @brief Insert a sublayer at a position in a control |
|---|
| 213 | * |
|---|
| 214 | * Controllers and layers are different in frontrow |
|---|
| 215 | * |
|---|
| 216 | * @param sub The sublayer to add |
|---|
| 217 | * @param controller The controller to add to |
|---|
| 218 | * @param index The index to add the sublayer at |
|---|
| 219 | */ |
|---|
| 220 | + (void)insertSublayer:(id)sub toControl:(id)controller atIndex:(long)index; |
|---|
| 221 | |
|---|
| 222 | /*! |
|---|
| 223 | * @brief Create a new header control |
|---|
| 224 | * |
|---|
| 225 | * Controllers are alloced differently in frontrow |
|---|
| 226 | * |
|---|
| 227 | * @param scene The scene, if exists. |
|---|
| 228 | */ |
|---|
| 229 | + (BRHeaderControl *)newHeaderControlWithScene:(BRRenderScene *)scene; |
|---|
| 230 | |
|---|
| 231 | /*! |
|---|
| 232 | * @brief Create a new button control |
|---|
| 233 | * |
|---|
| 234 | * Controllers are alloced differently in frontrow |
|---|
| 235 | * |
|---|
| 236 | * @param scene The scene, if exists. |
|---|
| 237 | * @param size The size of the button |
|---|
| 238 | */ |
|---|
| 239 | + (BRButtonControl *)newButtonControlWithScene:(BRRenderScene *)scene masterLayerSize:(NSSize)size; |
|---|
| 240 | |
|---|
| 241 | /*! |
|---|
| 242 | * @brief Create a new text control |
|---|
| 243 | * |
|---|
| 244 | * Controllers are alloced differently in frontrow |
|---|
| 245 | * |
|---|
| 246 | * @param scene The scene, if exists. |
|---|
| 247 | */ |
|---|
| 248 | + (BRTextControl *)newTextControlWithScene:(BRRenderScene *)scene; |
|---|
| 249 | |
|---|
| 250 | /*! |
|---|
| 251 | * @brief Get the text control's rendered size within constraints |
|---|
| 252 | * |
|---|
| 253 | * @param text The text control |
|---|
| 254 | * @param maxSize The contrained maximum size |
|---|
| 255 | * @return The rendered size |
|---|
| 256 | */ |
|---|
| 257 | + (NSSize)textControl:(BRTextControl *)text renderedSizeWithMaxSize:(NSSize)maxSize; |
|---|
| 258 | |
|---|
| 259 | /*! |
|---|
| 260 | * @brief Create a new progress bar widget |
|---|
| 261 | * |
|---|
| 262 | * Widgets are alloced differently in frontrow |
|---|
| 263 | * |
|---|
| 264 | * @param scene The scene, if exists. |
|---|
| 265 | */ |
|---|
| 266 | + (BRProgressBarWidget *)newProgressBarWidgetWithScene:(BRRenderScene *)scene; |
|---|
| 267 | |
|---|
| 268 | /*! |
|---|
| 269 | * @brief Create a new marching icon layer |
|---|
| 270 | * |
|---|
| 271 | * Layers are alloced differently in frontrow |
|---|
| 272 | * |
|---|
| 273 | * @param scene The scene, if exists. |
|---|
| 274 | */ |
|---|
| 275 | + (BRMarchingIconLayer *)newMarchingIconLayerWithScene:(BRRenderScene *)scene; |
|---|
| 276 | |
|---|
| 277 | /*! |
|---|
| 278 | * @brief Create a new image layer |
|---|
| 279 | * |
|---|
| 280 | * Layers are different in frontrow |
|---|
| 281 | * |
|---|
| 282 | * @param scene The scene, if it exists. |
|---|
| 283 | */ |
|---|
| 284 | + (BRImageLayer *)newImageLayerWithScene:(BRRenderScene *)scene; |
|---|
| 285 | |
|---|
| 286 | /*! |
|---|
| 287 | * @brief Set the image on a BRImageLayer |
|---|
| 288 | * |
|---|
| 289 | * FR uses BRImage instead of BRTexture |
|---|
| 290 | * |
|---|
| 291 | * @param image The image (BRImage on FR/BRTexture on ATV) |
|---|
| 292 | */ |
|---|
| 293 | + (void)setImage:(id)image forLayer:(BRImageLayer *)layer; |
|---|
| 294 | |
|---|
| 295 | /*! |
|---|
| 296 | * @brief Create a new image layer with an image |
|---|
| 297 | * |
|---|
| 298 | * Just a shortcut around the previous two |
|---|
| 299 | * |
|---|
| 300 | * @param image The image (BRImage on FR/BRTexture on ATV) |
|---|
| 301 | * @param scene The scene, if it exists. |
|---|
| 302 | */ |
|---|
| 303 | + (BRImageLayer *)newImageLayerWithImage:(id)image scene:(BRRenderScene *)scene; |
|---|
| 304 | |
|---|
| 305 | /*! |
|---|
| 306 | * @brief Render scene on the ATV |
|---|
| 307 | * |
|---|
| 308 | * Only does something on the ATV; frontrow has no need for this |
|---|
| 309 | * |
|---|
| 310 | * @param scene The scene to render, if exists. |
|---|
| 311 | */ |
|---|
| 312 | + (void)renderScene:(BRRenderScene *)scene; |
|---|
| 313 | |
|---|
| 314 | /*! |
|---|
| 315 | * @brief Create a new BRAlertController |
|---|
| 316 | * |
|---|
| 317 | * Scene doesn't exist on frontrow |
|---|
| 318 | * |
|---|
| 319 | * @param type The type of the alert |
|---|
| 320 | * @param titled The title of the alert |
|---|
| 321 | * @param primaryText the primary text of the alert |
|---|
| 322 | * @param secondaryText the secondary text of the alert |
|---|
| 323 | * @param scene the scene |
|---|
| 324 | */ |
|---|
| 325 | + (BRAlertController *)alertOfType:(int)type titled:(NSString *)title primaryText:(NSString *)primaryText secondaryText:(NSString *)secondaryText withScene:(BRRenderScene *)scene; |
|---|
| 326 | |
|---|
| 327 | /*! |
|---|
| 328 | * @brief Create a new BROptionDialog |
|---|
| 329 | * |
|---|
| 330 | * Scene doesn't exist in frontrow |
|---|
| 331 | * |
|---|
| 332 | * @param scene the scene |
|---|
| 333 | */ |
|---|
| 334 | + (BROptionDialog *)optionDialogWithScene:(BRRenderScene *)scene; |
|---|
| 335 | |
|---|
| 336 | /*! |
|---|
| 337 | * @brief Set the primary info text on a BROptionDialog |
|---|
| 338 | * |
|---|
| 339 | * Text/attributes are different on frontrow |
|---|
| 340 | * |
|---|
| 341 | * @param primaryInfoText the primary info text |
|---|
| 342 | * @param attributes the attributes |
|---|
| 343 | * @param dialog the BROptionDialog |
|---|
| 344 | */ |
|---|
| 345 | + (void)setOptionDialogPrimaryInfoText:(NSString *)primaryInfoText withAttributes:(NSDictionary *)attributes optionDialog:(BROptionDialog *)dialog; |
|---|
| 346 | |
|---|
| 347 | /*! |
|---|
| 348 | * @brief Create a new BRTextWithSpinnerController |
|---|
| 349 | * |
|---|
| 350 | * Method is different on frontrow |
|---|
| 351 | * |
|---|
| 352 | * @param title the title |
|---|
| 353 | * @param text the text |
|---|
| 354 | * @param networkDependent unknown |
|---|
| 355 | * @param scene the scene |
|---|
| 356 | */ |
|---|
| 357 | + (BRTextWithSpinnerController *)textWithSpinnerControllerTitled:(NSString *)title text:(NSString *)text isNetworkDependent:(BOOL)networkDependent scene:(BRRenderScene *)scene; |
|---|
| 358 | |
|---|
| 359 | /*! |
|---|
| 360 | * @brief Get the call stack addresses for an exception |
|---|
| 361 | * |
|---|
| 362 | * This function exists mostly because this method is different on Tiger and Leopard. This is not a significant differece between the ATV and Frontrow |
|---|
| 363 | * |
|---|
| 364 | * @param exception The exception to examine |
|---|
| 365 | * @return An array of call addresses if successful, nil otherwise |
|---|
| 366 | */ |
|---|
| 367 | + (NSArray *)callStackReturnAddressesForException:(NSException *)exception; |
|---|
| 368 | |
|---|
| 369 | /*! |
|---|
| 370 | * @brief Get the sharedFrontRowPreferences object. |
|---|
| 371 | * |
|---|
| 372 | * On Apple TV < 2.1, the RUIPreferences class is used for this. On 2.1, the class is renamed to BRPreferences. |
|---|
| 373 | * |
|---|
| 374 | * @return the preferences object |
|---|
| 375 | */ |
|---|
| 376 | + (RUIPreferences *)sharedFrontRowPreferences; |
|---|
| 377 | @end |
|---|
| 378 | |
|---|
| 379 | static inline void SapphireLoadFramework(NSString *frameworkPath) |
|---|
| 380 | { |
|---|
| 381 | if(NSClassFromString(@"SapphireFrontRowCompat") == nil) |
|---|
| 382 | { |
|---|
| 383 | NSString *compatPath = [frameworkPath stringByAppendingPathComponent:@"SapphireCompatClasses.framework"]; |
|---|
| 384 | NSBundle *compat = [NSBundle bundleWithPath:compatPath]; |
|---|
| 385 | if( ![compat load]){ |
|---|
| 386 | @throw [NSException exceptionWithName:@"FileNotFoundException" reason:[NSString stringWithFormat:@"SapphireCompatClasses could not be loaded from path %@", compatPath] userInfo:nil]; |
|---|
| 387 | } |
|---|
| 388 | if([SapphireFrontRowCompat usingFrontRow]) |
|---|
| 389 | { |
|---|
| 390 | compatPath = [frameworkPath stringByAppendingPathComponent:@"SapphireLeopardCompatClasses.framework"]; |
|---|
| 391 | compat = [NSBundle bundleWithPath:compatPath]; |
|---|
| 392 | if( ![compat load]){ |
|---|
| 393 | @throw [NSException exceptionWithName:@"FileNotFoundException" reason:[NSString stringWithFormat:@"SapphireLeopardCompatClasses could not be loaded from path %@", compatPath] userInfo:nil]; |
|---|
| 394 | } |
|---|
| 395 | } |
|---|
| 396 | // ATV2 |
|---|
| 397 | if(NSClassFromString(@"BRMetadataPreviewController") == nil) |
|---|
| 398 | { |
|---|
| 399 | compatPath = [frameworkPath stringByAppendingPathComponent:@"SapphireTakeTwoCompatClasses.framework"]; |
|---|
| 400 | compat = [NSBundle bundleWithPath:compatPath]; |
|---|
| 401 | if( ![compat load]){ |
|---|
| 402 | @throw [NSException exceptionWithName:@"FileNotFoundException" reason:[NSString stringWithFormat:@"SapphireTakeTwoCompatClasses could not be loaded from path %@", compatPath] userInfo:nil]; |
|---|
| 403 | } |
|---|
| 404 | } |
|---|
| 405 | } |
|---|
| 406 | } |
|---|
| 407 | |
|---|