Coder Social home page Coder Social logo

bccollectionview's Introduction

BCCollectionView

BCCollectionView is intended as a replacement for NSCollectionView (and possibly IKImageBrowserView). It is designed to work with a lot of items and only loads the views that it actually needs.

Unlike NSCollectionView, BCCollectionView smoothly displays 300.000+ items. Every 'cell' in an BCCollectionView is an NSViewController. At the moment these are only uniform; every cell is supposed to be the same NSViewController subclass.

High-level concept overview of BCCollectionView

The delegate provides empty NSViewControllers for the BCCollectionView that will be reused as often as needed; you can already style the view in it to a creation degree but the delegate doesn't know yet which item it will be displaying later.

- (NSViewController *)reusableViewControllerForIconView:(BCCollectionView *)iconView

Before BCCollectionView shows them, it asks the delegate to populate an NSViewController with an item from its contentArray; this is the time to set labels or images that are dependent on the item its supposed to represent

- (void)iconView:(BCCollectionView *)iconView willShowViewController:(NSViewController *)viewController forItem:(id)anItem

When the user scrolls the view, some views will become invisible. BCCollectionView removes them from view and stores them for later use. The delegate has a chance to unload any item-specific resources the item, possibly to save memory for example or do other kinds of cleanup

- (void)iconView:(BCCollectionView *)iconView viewControllerBecameInvisible:(NSViewController *)viewController

If the categories on BCCollectionView are included too, the users can use either mouse or keyboard to select items. By default, BCCollectionView will (for now) just draw a rather ugly bezel under a view if it is selected. The delegate can customise this behaviour by return NO in:

- (BOOL)iconViewShouldDrawSelections:(BCCollectionView *)iconView

If the delegate also overrides the following two methods it can customise its view to determine how to show a selected item instead:

- (void)iconView:(BCCollectionView *)iconView updateViewControllerAsSelected:(NSViewController *)viewController forItem:(id)item;
- (void)iconView:(BCCollectionView *)iconView updateViewControllerAsDeselected:(NSViewController *)viewController forItem:(id)item;

Note. Do not use the following methods to style viewControllers. They are intended to inform the delegates of changes in the selection. Using these methods to style the viewControllers might break when the views are being reused at a later point.

- (BOOL)iconView:(BCCollectionView *)iconView shouldSelectItem:(id)anItem withViewController:(NSViewController *)viewController;
- (void)iconView:(BCCollectionView *)iconView didSelectItem:(id)anItem withViewController:(NSViewController *)viewController;
- (void)iconView:(BCCollectionView *)iconView didDeselectItem:(id)anItem withViewController:(NSViewController *)viewController;

Groups

The latest addition to BCCollectionView has to with groups. Just like IKImageBrowserView, we can now divide the items into groups. A group is simply a range with a title, and the delegate can supply a custom NSViewController to represent the header. Groups can be set using the default way to load the BCCollectionView:

- (void)reloadDataWithItems:(NSArray *)newContent groups:(NSArray *)newGroups emptyCaches:(BOOL)shouldEmptyCaches;

License

BCCollectionView is licensed under the BSD license

bccollectionview's People

Contributors

aaronbrethorst avatar apparentsoft avatar bewebste avatar glebd avatar indragie avatar jelledelaender avatar kgn avatar pieteromvlee avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.