Animating source view design advice.

  • Hi,

    I would like to create a source view like Xcode 4's project navigator view. It will have "parent" views (e.g. the project) with a twist down triangle that, when clicked, will reveal the contents (e.g. files) in an animation that slides down. Many of these parent views can exist at the top level. When one is revealed, the ones below will slide down as well.

    What is the best way to implement this? Is a table view with NSTableCellView's a reasonable approach? I'm wondering if that is the case since the items (when opened) will easily have differing heights depending on the number of children. Is an NSOutlineView more appropriate here (at least I get the sliding animation for free). One complication is that I'd like to be able to select the parent view in the same way that you can in Xcode (that brings up the project/targets inspector) to bring up a "summary" detail view.

    I don't need a full implementation (not that I'd turn it away if one is available!), but a high-level view of the best approach to do this would be greatly appreciated!

    Cheers,
    Demitri
  • Just because I hate orphaned questions (as no one answered), I thought I'd answer my own question.

    Most examples that use Core Data/bindings/array controllers use a table view as the source view, but I wanted something more flexible with my own custom view that involved a little animation. Although NSTableCellView makes this a little easier, it still felt shoehorned into a table view. I think the best answer is the realization that I don't need a table view at all to use the machinery above, and that one can simply have an array of NSViews managed by an array controller (in a scroll view). Everything else (e.g. master/detail, bindings) just falls into place after that. The most illustrative example was mmalc's "Graphics Bindings", located here:

    http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

    Although that link will only be valid for about a month before MobileMe ends. :)

    Cheers,
    Demitri
  • On May 30, 2012, at 11:37 AM, Demitri Muna <thatsanicehatyouhave...> wrote:

    > Just because I hate orphaned questions (as no one answered), I thought I'd answer my own question.
    >
    > Most examples that use Core Data/bindings/array controllers use a table view as the source view, but I wanted something more flexible with my own custom view that involved a little animation. Although NSTableCellView makes this a little easier, it still felt shoehorned into a table view.

    Really? Why? It fits quite perfectly with the view based tableview.

    > I think the best answer is the realization that I don't need a table view at all to use the machinery above,

    I think the best solution is to use a view based NSOutlineView with variable row heights and custom background drawing on the NSTableRowView.

    FWIW, Xcode uses NSOutlineView (non-view based at the current time).

    corbin

    > and that one can simply have an array of NSViews managed by an array controller (in a scroll view). Everything else (e.g. master/detail, bindings) just falls into place after that. The most illustrative example was mmalc's "Graphics Bindings", located here:
    >
    > http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
    >
    > Although that link will only be valid for about a month before MobileMe ends. :)
    >
    > Cheers,
    > Demitri
  • Hi,

    Thanks Corbin for the reply. For some reason I completely forgot that NSOutlineView was a subclass of NSTableView. Yes, of course that is the best (and should have been obvious!) solution.

    Cheers,
    Demitri

    ---

    On May 30, 2012, at 2:57 PM, Corbin Dunn wrote:

    > On May 30, 2012, at 11:37 AM, Demitri Muna <thatsanicehatyouhave...> wrote:
    >
    >> Just because I hate orphaned questions (as no one answered), I thought I'd answer my own question.
    >>
    >> Most examples that use Core Data/bindings/array controllers use a table view as the source view, but I wanted something more flexible with my own custom view that involved a little animation. Although NSTableCellView makes this a little easier, it still felt shoehorned into a table view.
    >
    > Really? Why? It fits quite perfectly with the view based tableview.
    >
    >> I think the best answer is the realization that I don't need a table view at all to use the machinery above,
    >
    > I think the best solution is to use a view based NSOutlineView with variable row heights and custom background drawing on the NSTableRowView.
    >
    > FWIW, Xcode uses NSOutlineView (non-view based at the current time).
previous month may 2012 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today