• This repository has been archived on 16/Sep/2019
  • Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    Objective-C
  • Created almost 12 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CNSplitView is an feature enhanced derivative of NSSplitView. It has support for sticky top or bottom toolbars for each of its subviews.

Flattr this git repo Travis Status

Overview

CNSplitView is an feature enhanced derivative of NSSplitView. It has support for sticky top or bottom toolbars for each of its subviews. You can configure CNSplitView to add toolbars with buttons and/or drag handles, you can define the orientation of each button inside the toolbar or center it all.

Here are two shots of the included example application:

CNSplitView Example - Vertical SplitView

CNSplitView Example - Horizontal SplitView

Graphics & Icons

The icon used to show in the example application (green leaf) was taken from IconFinder. It is published under the CC License Attribution-Noncommercial 3.0 and was created by Bruno Maia, IconTexto.

Installation

Via CocoaPods

Just add pod 'CNSplitView' to your podfile.

Via Git SubModule

cd into your project directory and execute git submodule add https://github.com/phranck/CNSplitView.git $DIR_WHERE_YOUR_SUBMODULES_ARE_PLACED

You have to replace the $DIR_WHERE_YOUR_SUBMODULES_ARE_PLACED with the real path where your submodules are placed.

Manually

Download the entire project from Github via git clone https://github.com/phranck/CNSplitView.git, cd into the CNSplitView directory and drag the underyling CNSplitView directory to your Xcode project.

How to run the example

To run the example application you have to complete this project by opening a terminal and cd into the directory where your CNSplitView Example.xcodeproj is. Here you will find a Podfile. Type pod install (or pod update if you have done it before) to install (or update) all dependencies. CNSplitView needs another component CNBaseView.

After the creation of CNSplitView Example.xcworkspace you're done. Now you only have to use the workspace file!

Usage

The usage of CNSplitView is quite simple. In Interfacebuilder just create a new window, grab a NSSplitView from the objects palette and drop it onto the content view of your window. Select the the size inspector and let it fill the container both horizontally and vertically. Then you select the identity inspector and set the class of this NSSplitView to CNSplitView. In Interfacebuilder you're done for that moment.

On the code side you keep going that easy way. The code of the example application looks like this:

NSMenu *contextMenu = [[NSMenu alloc] init];
[contextMenu addItemWithTitle:@"Add new Item" action:@selector(contextMenuItemSelection:) keyEquivalent:@""];
[contextMenu addItemWithTitle:@"Add new Group" action:@selector(contextMenuItemSelection:) keyEquivalent:@""];
CNSplitViewToolbarButton *button1 = [[CNSplitViewToolbarButton alloc] initWithContextMenu:contextMenu];
button1.imageTemplate = CNSplitViewToolbarButtonImageTemplateAdd;

CNSplitViewToolbarButton *button2 = [[CNSplitViewToolbarButton alloc] init];
button2.imageTemplate = CNSplitViewToolbarButtonImageTemplateRemove;

CNSplitViewToolbarButton *button3 = [[CNSplitViewToolbarButton alloc] init];
button3.imageTemplate = CNSplitViewToolbarButtonImageTemplateLockUnlocked;
button3.imagePosition = NSImageRight;
button3.title = @"Lock";

CNSplitViewToolbarButton *button4 = [[CNSplitViewToolbarButton alloc] init];
button4.imageTemplate = CNSplitViewToolbarButtonImageTemplateRefresh;
button4.title = @"Refresh";

NSTextField *textField = [[NSTextField alloc] init];
[textField setBezeled:YES];
[textField setBezeled:NSTextFieldRoundedBezel];
[textField setToolbarItemWidth:120.0];

NSPopUpButton *popupButton = [[NSPopUpButton alloc] init];
[popupButton setToolbarItemWidth:120];
[popupButton addItemsWithTitles:@[@"Chelsea Manning...", @"Edward Snowden...", @"Aaron Swartz..."]];
[[popupButton cell] setControlSize:NSSmallControlSize];

NSSlider *slider = [[NSSlider alloc] init];
[slider setToolbarItemWidth:120.0];
[[slider cell] setControlSize:NSSmallControlSize];


[toolbar addItem:button1 align:CNSplitViewToolbarItemAlignLeft];
[toolbar addItem:button2 align:CNSplitViewToolbarItemAlignLeft];
[toolbar addItem:button3 align:CNSplitViewToolbarItemAlignRight];
[toolbar addItem:button4 align:CNSplitViewToolbarItemAlignRight];
//[toolbar addItem:popupButton align:CNSplitViewToolbarItemAlignLeft];

self.splitView.delegate = self;
self.splitView.toolbarDelegate = self;
[self.splitView attachToolbar:toolbar toSubViewAtIndex:attachedSubViewIndex onEdge:CNSplitViewToolbarEdgeBottom];

Requirements

CNSplitView was written using ARC and should run on 10.7 and above. You have to add the QuartzCore Framework to your project.

Contribution

The code is provided as-is, and it is far off being complete or free of bugs. If you like this component feel free to support it. Make changes related to your needs, extend it or just use it in your own project. Pull-Requests and Feedbacks are very welcome. Just contact me at [[email protected]](mailto:[email protected]?Subject=[CNSplitView] Your component on Github) or send me a ping on Twitter @TheCocoaNaut.

Documentation

The complete documentation you will find on CocoaDocs.

License

This software is published under the MIT License.

Software that uses CNSplitView

If you like this component and if you're using it in your own software so please let me know. I'll give you a mention and set a link to your website (or the Mac App Store, if it exists).

CNSplitView is used by this software:

  • BezierCode - BezierCode is an intuitive vector drawing that generate Objective C code.

More Repositories

1

CCNStatusItem

CCNStatusItem is a subclass of NSObject to act as a custom view for NSStatusItem. It supports a customizable statusItemWindow handling any viewController for presenting the content.
Objective-C
222
star
2

CNGridView

CNGridView is a (wanna be) replacement for NSCollectionView. It has full delegate and dataSource support with method calls like known from NSTableView/UITableView.
Objective-C
150
star
3

CCNPreferencesWindowController

CCNPreferencesWindowController is an Objective-C subclass of NSWindowController that automatically manages your custom view controllers for handling app preferences.
Objective-C
108
star
4

CNUserNotification

CNUserNotification is a kind of proxy to give OS X Lion 10.7 β€žthe sameβ€Ÿ support for user notifications like OS X Mountain Lion 10.8 does. Benefits are also a bit more flexibility since you are able to define a custom banner image or variable dismiss delay times.
Objective-C
93
star
5

CCNNavigationController

An Mac OS X Navigation Controller that acts mostly like the counter part on iOS - UINavigationController.
Objective-C
61
star
6

CCNLaunchAtLoginItem

An Objective-C class that encapsulates the functionality for launching a Mac application automatic on login, presented in a very simple interface.
Objective-C
16
star
7

Cooking-Recipes

Lose Sammlung veganer Rezepte
14
star
8

Xcode-Coordinator-Template

An Xcode File Template that creates an Objective-C Coordinator class.
Shell
7
star
9

Xcode-CodeSnippets

A set of Xcode CodeSnippets I use
7
star
10

CCNXML

Simple basic handling of XML files for both reading and manual creation in Objective-C.
Objective-C
4
star
11

CCNTreeNode

An easy way to build a tree of nested objects.
Objective-C
3
star
12

RadioTimeKit

The Swift SDK for TuneIn
Swift
2
star
13

Xcode-File-Templates

Shell
1
star