project_files/HedgewarsMobile/Classes/MGSplitViewController/MGSplitViewController.h
branchios-revival
changeset 11115 3729ac42189b
parent 8441 a00b0fa0dbd7
equal deleted inserted replaced
11114:6a0bd9c6cc82 11115:3729ac42189b
     7 //
     7 //
     8 
     8 
     9 #import <UIKit/UIKit.h>
     9 #import <UIKit/UIKit.h>
    10 
    10 
    11 typedef enum _MGSplitViewDividerStyle {
    11 typedef enum _MGSplitViewDividerStyle {
    12     // These names have been chosen to be conceptually similar to those of NSSplitView on Mac OS X.
    12 	// These names have been chosen to be conceptually similar to those of NSSplitView on Mac OS X.
    13     MGSplitViewDividerStyleThin         = 0, // Thin divider, like UISplitViewController (default).
    13 	MGSplitViewDividerStyleThin			= 0, // Thin divider, like UISplitViewController (default).
    14     MGSplitViewDividerStylePaneSplitter = 1  // Thick divider, drawn with a grey gradient and a grab-strip.
    14 	MGSplitViewDividerStylePaneSplitter	= 1  // Thick divider, drawn with a grey gradient and a grab-strip.
    15 } MGSplitViewDividerStyle;
    15 } MGSplitViewDividerStyle;
    16 
    16 
    17 @class MGSplitDividerView;
    17 @class MGSplitDividerView;
    18 @protocol MGSplitViewControllerDelegate;
    18 @protocol MGSplitViewControllerDelegate;
    19 @interface MGSplitViewController : UIViewController <UIPopoverControllerDelegate> {
    19 @interface MGSplitViewController : UIViewController <UIPopoverControllerDelegate> {
    20     BOOL _showsMasterInPortrait;
    20 	BOOL _showsMasterInPortrait;
    21     BOOL _showsMasterInLandscape;
    21 	BOOL _showsMasterInLandscape;
    22     float _splitWidth;
    22 	float _splitWidth;
    23     id _delegate;
    23 	id _delegate;
    24     BOOL _vertical;
    24 	BOOL _vertical;
    25     BOOL _masterBeforeDetail;
    25 	BOOL _masterBeforeDetail;
    26     NSMutableArray *_viewControllers;
    26 	NSMutableArray *_viewControllers;
    27     UIBarButtonItem *_barButtonItem; // To be compliant with wacky UISplitViewController behaviour.
    27 	UIBarButtonItem *_barButtonItem; // To be compliant with wacky UISplitViewController behaviour.
    28     UIPopoverController *_hiddenPopoverController; // Popover used to hold the master view if it's not always visible.
    28     UIPopoverController *_hiddenPopoverController; // Popover used to hold the master view if it's not always visible.
    29     MGSplitDividerView *_dividerView; // View that draws the divider between the master and detail views.
    29 	MGSplitDividerView *_dividerView; // View that draws the divider between the master and detail views.
    30     NSArray *_cornerViews; // Views to draw the inner rounded corners between master and detail views.
    30 	NSArray *_cornerViews; // Views to draw the inner rounded corners between master and detail views.
    31     float _splitPosition;
    31 	float _splitPosition;
    32     BOOL _reconfigurePopup;
    32 	BOOL _reconfigurePopup;
    33     MGSplitViewDividerStyle _dividerStyle; // Meta-setting which configures several aspects of appearance and behaviour.
    33 	MGSplitViewDividerStyle _dividerStyle; // Meta-setting which configures several aspects of appearance and behaviour.
       
    34 	BOOL togglesMasterPopover;
    34 }
    35 }
    35 
    36 
    36 @property (nonatomic, assign) IBOutlet id <MGSplitViewControllerDelegate> delegate;
    37 @property (nonatomic, unsafe_unretained) IBOutlet id <MGSplitViewControllerDelegate> delegate;
    37 @property (nonatomic, assign) BOOL showsMasterInPortrait; // applies to both portrait orientations (default NO)
    38 @property (nonatomic, assign) BOOL showsMasterInPortrait; // applies to both portrait orientations (default NO)
    38 @property (nonatomic, assign) BOOL showsMasterInLandscape; // applies to both landscape orientations (default YES)
    39 @property (nonatomic, assign) BOOL showsMasterInLandscape; // applies to both landscape orientations (default YES)
    39 @property (nonatomic, assign, getter=isVertical) BOOL vertical; // if NO, split is horizontal, i.e. master above detail (default YES)
    40 @property (nonatomic, assign, getter=isVertical) BOOL vertical; // if NO, split is horizontal, i.e. master above detail (default YES)
    40 @property (nonatomic, assign, getter=isMasterBeforeDetail) BOOL masterBeforeDetail; // if NO, master view is below/right of detail (default YES)
    41 @property (nonatomic, assign, getter=isMasterBeforeDetail) BOOL masterBeforeDetail; // if NO, master view is below/right of detail (default YES)
    41 @property (nonatomic, assign) float splitPosition; // starting position of split in pixels, relative to top/left (depending on .isVertical setting) if masterBeforeDetail is YES, else relative to bottom/right.
    42 @property (nonatomic, assign) float splitPosition; // starting position of split in pixels, relative to top/left (depending on .isVertical setting) if masterBeforeDetail is YES, else relative to bottom/right.
    42 @property (nonatomic, assign) float splitWidth; // width of split in pixels.
    43 @property (nonatomic, assign) float splitWidth; // width of split in pixels.
    43 @property (nonatomic, assign) BOOL allowsDraggingDivider; // whether to let the user drag the divider to alter the split position (default NO).
    44 @property (nonatomic, assign) BOOL allowsDraggingDivider; // whether to let the user drag the divider to alter the split position (default NO).
    44 
    45 
    45 @property (nonatomic, copy) NSArray *viewControllers; // array of UIViewControllers; master is at index 0, detail is at index 1.
    46 @property (nonatomic, copy) NSArray *viewControllers; // array of UIViewControllers; master is at index 0, detail is at index 1.
    46 @property (nonatomic, retain) IBOutlet UIViewController *masterViewController; // convenience.
    47 @property (nonatomic, strong) IBOutlet UIViewController *masterViewController; // convenience.
    47 @property (nonatomic, retain) IBOutlet UIViewController *detailViewController; // convenience.
    48 @property (nonatomic, strong) IBOutlet UIViewController *detailViewController; // convenience.
    48 @property (nonatomic, retain) MGSplitDividerView *dividerView; // the view which draws the divider/split between master and detail.
    49 @property (nonatomic, strong) MGSplitDividerView *dividerView; // the view which draws the divider/split between master and detail.
    49 @property (nonatomic, assign) MGSplitViewDividerStyle dividerStyle; // style (and behaviour) of the divider between master and detail.
    50 @property (nonatomic, assign) MGSplitViewDividerStyle dividerStyle; // style (and behaviour) of the divider between master and detail.
    50 
    51 
    51 @property (nonatomic, readonly, getter=isLandscape) BOOL landscape; // returns YES if this view controller is in either of the two Landscape orientations, else NO.
    52 @property (nonatomic, readonly, getter=isLandscape) BOOL landscape; // returns YES if this view controller is in either of the two Landscape orientations, else NO.
       
    53 
       
    54 @property (nonatomic, readwrite) BOOL togglesMasterPopover; // default is NO.
    52 
    55 
    53 // Actions
    56 // Actions
    54 - (IBAction)toggleSplitOrientation:(id)sender; // toggles split axis between vertical (left/right; default) and horizontal (top/bottom).
    57 - (IBAction)toggleSplitOrientation:(id)sender; // toggles split axis between vertical (left/right; default) and horizontal (top/bottom).
    55 - (IBAction)toggleMasterBeforeDetail:(id)sender; // toggles position of master view relative to detail view.
    58 - (IBAction)toggleMasterBeforeDetail:(id)sender; // toggles position of master view relative to detail view.
    56 - (IBAction)toggleMasterView:(id)sender; // toggles display of the master view in the current orientation.
    59 - (IBAction)toggleMasterView:(id)sender; // toggles display of the master view in the current orientation.
    57 - (IBAction)showMasterPopover:(id)sender; // shows the master view in a popover spawned from the provided barButtonItem, if it's currently hidden.
    60 - (IBAction)showMasterPopover:(id)sender; // shows the master view in a popover spawned from the provided barButtonItem, if it's currently hidden.
       
    61 - (IBAction)hideMasterPopover:(id)sender; // hides the master view in a popover spawned from the provided barButtonItem, if it's currently shown.
    58 - (void)notePopoverDismissed; // should rarely be needed, because you should not change the popover's delegate. If you must, then call this when it's dismissed.
    62 - (void)notePopoverDismissed; // should rarely be needed, because you should not change the popover's delegate. If you must, then call this when it's dismissed.
    59 
    63 
    60 // Conveniences for you, because I care.
    64 // Conveniences for you, because I care.
    61 - (BOOL)isShowingMaster;
    65 - (BOOL)isShowingMaster;
    62 - (void)setSplitPosition:(float)posn animated:(BOOL)animate; // Allows for animation of splitPosition changes. The property's regular setter is not animated.
    66 - (void)setSplitPosition:(float)posn animated:(BOOL)animate; // Allows for animation of splitPosition changes. The property's regular setter is not animated.
    63 /* Note:    splitPosition is the width (in a left/right split, or height in a top/bottom split) of the master view.
    67 /* Note:	splitPosition is the width (in a left/right split, or height in a top/bottom split) of the master view.
    64             It is relative to the appropriate side of the splitView, which can be any of the four sides depending on the values in isMasterBeforeDetail and isVertical:
    68 			It is relative to the appropriate side of the splitView, which can be any of the four sides depending on the values in isMasterBeforeDetail and isVertical:
    65                 isVertical = YES, isMasterBeforeDetail = YES: splitPosition is relative to the LEFT edge. (Default)
    69 				isVertical = YES, isMasterBeforeDetail = YES: splitPosition is relative to the LEFT edge. (Default)
    66                 isVertical = YES, isMasterBeforeDetail = NO: splitPosition is relative to the RIGHT edge.
    70 				isVertical = YES, isMasterBeforeDetail = NO: splitPosition is relative to the RIGHT edge.
    67                 isVertical = NO, isMasterBeforeDetail = YES: splitPosition is relative to the TOP edge.
    71  				isVertical = NO, isMasterBeforeDetail = YES: splitPosition is relative to the TOP edge.
    68                 isVertical = NO, isMasterBeforeDetail = NO: splitPosition is relative to the BOTTOM edge.
    72  				isVertical = NO, isMasterBeforeDetail = NO: splitPosition is relative to the BOTTOM edge.
    69 
    73 
    70             This implementation was chosen so you don't need to recalculate equivalent splitPositions if the user toggles masterBeforeDetail themselves.
    74 			This implementation was chosen so you don't need to recalculate equivalent splitPositions if the user toggles masterBeforeDetail themselves.
    71  */
    75  */
    72 - (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle animated:(BOOL)animate; // Allows for animation of dividerStyle changes. The property's regular setter is not animated.
    76 - (void)setDividerStyle:(MGSplitViewDividerStyle)newStyle animated:(BOOL)animate; // Allows for animation of dividerStyle changes. The property's regular setter is not animated.
    73 - (NSArray *)cornerViews;
    77 - (NSArray *)cornerViews;
    74 /*
    78 /*
    75  -cornerViews returns an NSArray of two MGSplitCornersView objects, used to draw the inner corners.
    79  -cornerViews returns an NSArray of two MGSplitCornersView objects, used to draw the inner corners.
    76  The first view is the "leading" corners (top edge of screen for left/right split, left edge of screen for top/bottom split).
    80  The first view is the "leading" corners (top edge of screen for left/right split, left edge of screen for top/bottom split).
    77  The second view is the "trailing" corners (bottom edge of screen for left/right split, right edge of screen for top/bottom split).
    81  The second view is the "trailing" corners (bottom edge of screen for left/right split, right edge of screen for top/bottom split).
    78  Do NOT modify them, except to:
    82  Do NOT modify them, except to:
    79     1. Change their .cornerBackgroundColor
    83 	1. Change their .cornerBackgroundColor
    80     2. Change their .cornerRadius
    84 	2. Change their .cornerRadius
    81  */
    85  */
    82 
    86 
    83 @end
    87 @end
    84 
    88 
    85 
    89 
    86 @protocol MGSplitViewControllerDelegate
    90 @protocol MGSplitViewControllerDelegate
    87 
    91 
    88 @optional
    92 @optional
    89 
    93 
    90 // Called when a button should be added to a toolbar for a hidden view controller.
    94 // Called when a button should be added to a toolbar for a hidden view controller.
    91 - (void)splitViewController:(MGSplitViewController*)svc
    95 - (void)splitViewController:(MGSplitViewController*)svc 
    92      willHideViewController:(UIViewController *)aViewController
    96 	 willHideViewController:(UIViewController *)aViewController 
    93           withBarButtonItem:(UIBarButtonItem*)barButtonItem
    97 		  withBarButtonItem:(UIBarButtonItem*)barButtonItem 
    94        forPopoverController: (UIPopoverController*)pc;
    98 	   forPopoverController: (UIPopoverController*)pc;
    95 
    99 
    96 // Called when the master view is shown again in the split view, invalidating the button and popover controller.
   100 // Called when the master view is shown again in the split view, invalidating the button and popover controller.
    97 - (void)splitViewController:(MGSplitViewController*)svc
   101 - (void)splitViewController:(MGSplitViewController*)svc 
    98      willShowViewController:(UIViewController *)aViewController
   102 	 willShowViewController:(UIViewController *)aViewController 
    99   invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem;
   103   invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem;
   100 
   104 
   101 // Called when the master view is shown in a popover, so the delegate can take action like hiding other popovers.
   105 // Called when the master view is shown in a popover, so the delegate can take action like hiding other popovers.
   102 - (void)splitViewController:(MGSplitViewController*)svc
   106 - (void)splitViewController:(MGSplitViewController*)svc 
   103           popoverController:(UIPopoverController*)pc
   107 		  popoverController:(UIPopoverController*)pc 
   104   willPresentViewController:(UIViewController *)aViewController;
   108   willPresentViewController:(UIViewController *)aViewController;
       
   109 
       
   110 // Called when a popover containing the master view is going to be hidden so the delegate can take action like showing other popovers.  This only happens if togglesMasterPopover is set to YES.
       
   111 - (void)splitViewController:(MGSplitViewController*)svc 
       
   112 		  popoverController:(UIPopoverController*)pc 
       
   113   willDismissViewController:(UIViewController *)aViewController;
   105 
   114 
   106 // Called when the split orientation will change (from vertical to horizontal, or vice versa).
   115 // Called when the split orientation will change (from vertical to horizontal, or vice versa).
   107 - (void)splitViewController:(MGSplitViewController*)svc willChangeSplitOrientationToVertical:(BOOL)isVertical;
   116 - (void)splitViewController:(MGSplitViewController*)svc willChangeSplitOrientationToVertical:(BOOL)isVertical;
   108 
   117 
   109 // Called when split position will change to the given pixel value (relative to left if split is vertical, or to top if horizontal).
   118 // Called when split position will change to the given pixel value (relative to left if split is vertical, or to top if horizontal).