PTToolGroupManager


@interface PTToolGroupManager : NSObject <NSCoding>

The PTToolGroupManager class maintains a list of tool groups, represented by instances of the PTToolGroup class, each of which contain a set of available tools for that mode.

This class is designed to work in conjuction with the PTToolGroupToolbar class to display the tool groups and provide interactive control over the current tool.

  • Initializes a newly created PTToolGroupManager instance.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()

    Return Value

    an initialized PTToolGroupManager instance

  • Returns an object initialized from data in a given unarchiver.

    Declaration

    Objective-C

    - (nullable instancetype)initWithCoder:(nonnull NSCoder *)coder;

    Swift

    init?(coder: NSCoder)

    Parameters

    coder

    An unarchiver object

    Return Value

    self, initialized using the data in decoder, or nil if the object could not be initialized

  • Initializes a newly created PTToolGroupManager instance with the provided tool manager.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithToolManager:
        (nonnull PTToolManager *)toolManager;

    Swift

    convenience init(toolManager: PTToolManager)

    Parameters

    toolManager

    The tool manager to be used by the receiver

    Return Value

    an initialized PTToolGroupManager instance

  • The receiver uses this tool manager instance to manage the current tool and observes notifications posted by the tool manager.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) PTToolManager *toolManager;

    Swift

    var toolManager: PTToolManager? { get set }
  • The tool group manager’s delegate object.

    Declaration

    Objective-C

    @property (readwrite, nonatomic, nullable) id<PTToolGroupManagerDelegate>
        delegate;

    Swift

    weak var delegate: PTToolGroupManagerDelegate? { get set }
  • Whether this tool group manager is currently enabled. The receiver will not observe notifications posted by its toolManager when this property’s value is NO.

    The default value of this property is NO.

    Declaration

    Objective-C

    @property (getter=isEnabled, assign, readwrite, nonatomic) BOOL enabled;

    Swift

    var isEnabled: Bool { get set }
  • The list of tool groups managed by this tool group manager. Each tool group represents an “tool group”, each with their own set of available tools to be displayed.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic) NSArray<PTToolGroup *> *_Nonnull groups;

    Swift

    var groups: [PTToolGroup] { get set }
  • The currently selected tool group in groups.

    When the groups list is empty, the value of this property is nil.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) PTToolGroup *selectedGroup;

    Swift

    var selectedGroup: PTToolGroup? { get set }
  • The index of the currently selected tool group in groups.

    When the groups list is empty, the value of this property is NSNotFound.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger selectedGroupIndex;

    Swift

    var selectedGroupIndex: UInt { get set }
  • The “View” tool group.

    This group does not contain any tools.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) PTToolGroup *_Nonnull viewItemGroup;

    Swift

    var viewItemGroup: PTToolGroup { get }
  • The “Annotate” tool group.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) PTToolGroup *_Nonnull annotateItemGroup;

    Swift

    var annotateItemGroup: PTToolGroup { get }
  • The “Draw” tool group.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) PTToolGroup *_Nonnull drawItemGroup;

    Swift

    var drawItemGroup: PTToolGroup { get }
  • The “Insert” tool group.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) PTToolGroup *_Nonnull insertItemGroup;

    Swift

    var insertItemGroup: PTToolGroup { get }
  • The “Measure” tool group.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) PTToolGroup *_Nonnull measureItemGroup;

    Swift

    var measureItemGroup: PTToolGroup { get }
  • The “Pens” tool group.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) PTToolGroup *_Nonnull pensItemGroup;

    Swift

    var pensItemGroup: PTToolGroup { get }
  • The “Favorites” tool group.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) PTToolGroup *_Nonnull favoritesItemGroup;

    Swift

    var favoritesItemGroup: PTToolGroup { get }
  • Creates a new item for the specified PTTool subclass. The item is not part of any group and must be added to an existing or new group in order to be used.

    Declaration

    Objective-C

    - (nonnull UIBarButtonItem *)createItemForToolClass:(nonnull Class)toolClass;

    Swift

    func createItem(forToolClass toolClass: AnyClass) -> UIBarButtonItem

    Parameters

    toolClass

    the PTTool subclass to be associated with the created item

    Return Value

    a new item for the specified PTTool subclass

  • The undo manager currently being tracked by the tool group manager.

    When the toolManager‘s tool is a PTCreateToolBase subclass and returns YES from PTCreateToolBase.undoManagerEnabled then this property will be equal to toolManager.tool.undoManager. Otherwise, toolManager.undoManager will be returned.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSUndoManager *undoManager;

    Swift

    weak var undoManager: UndoManager? { get }
  • The undo button item.

    When activated, this item calls -undo:.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) UIBarButtonItem *_Nonnull undoButtonItem;

    Swift

    var undoButtonItem: UIBarButtonItem { get }
  • This method calls [undoManager undo] on the tool group manager’s undoManager property.

    Declaration

    Objective-C

    - (void)undo:(nonnull id)sender;

    Swift

    func undo(_ sender: Any)
  • The redo button item.

    When activated, this item calls -redo:.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) UIBarButtonItem *_Nonnull redoButtonItem;

    Swift

    var redoButtonItem: UIBarButtonItem { get }
  • This method calls [undoManager redo] on the tool group manager’s undoManager property.

    Declaration

    Objective-C

    - (void)redo:(nonnull id)sender;

    Swift

    func redo(_ sender: Any)
  • Whether editing of groups from the user interface is enabled. When enabled, the editGroupButtonItem item is displayed at the end of all tool groups, except for the favoritesItemGroup, in the user interface.

    If this property is set to NO and editing is disabled, then the editGroupButtonItem item will not be displayed in the user interface.

    The default value of this property is YES.

    Declaration

    Objective-C

    @property (getter=isEditingEnabled, assign, readwrite, nonatomic)
        BOOL editingEnabled;

    Swift

    var isEditingEnabled: Bool { get set }
  • The “Edit Items” button item. This item is to be shown at the end of all tool item groups, except for the favoritesItemGroup, when the editingEnabled property is set to YES.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic)
        UIBarButtonItem *_Nonnull editGroupButtonItem;

    Swift

    var editGroupButtonItem: UIBarButtonItem { get }
  • This method asks the tool group manager’s delegate to edit the currently selected tool group in the selectedGroup property via the -[PTToolGroupManagerDelegate toolGroupManager:editItemsForGroup:] delegate method.

    If the selectedGroup property is nil then this method does nothing.

    Declaration

    Objective-C

    - (void)editSelectedGroup:(nonnull id)sender;

    Swift

    func editSelectedGroup(_ sender: Any)
  • Save the current set of tool groups in groups and the selected group to disk at the location specified by the PTToolGroupManager.savedGroupsURL class property.

    Declaration

    Objective-C

    - (void)saveGroups;

    Swift

    func saveGroups()
  • Save the current set of tool groups in groups and the selected group to disk at the specified location.

    Declaration

    Objective-C

    - (void)saveGroupsToURL:(nonnull NSURL *)savedGroupsURL;

    Swift

    func saveGroups(to savedGroupsURL: URL)

    Parameters

    savedGroupsURL

    The URL of the location at which to save the groups

  • Restore the set of tool groups and selected group from disk at the location specified by the PTToolGroupManager.savedGroupsURL class property.

    Declaration

    Objective-C

    - (void)restoreGroups;

    Swift

    func restoreGroups()
  • Restore the set of tool groups and selected group from disk at the specified location.

    Declaration

    Objective-C

    - (void)restoreGroupsFromURL:(nonnull NSURL *)savedGroupsURL;

    Swift

    func restoreGroups(from savedGroupsURL: URL)

    Parameters

    savedGroupsURL

    The URL of the location from which to restore the groups

  • The URL of the location at which to save and restore the set of tool groups and selected group.

    The default value of this property is the URL of a .plist file inside the directory returned by PTToolsUtil.toolsResourcesDirectoryURL.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, class) NSURL *_Nonnull savedGroupsURL;

    Swift

    class var savedGroupsURL: URL { get }