brendand / mbtablegrid

An NSControl subclass which provides a spreadsheet-style table grid
9 stars 3 forks source link

Why does MBTableGrid.h have more than one NSScrollView? #32

Closed cognociente closed 9 years ago

cognociente commented 9 years ago

Busy reading through the code and I see that there are NSScrollViews in the TableGrid for:

1) Surely this runs the risk of these different scrollViews going out of sync? 2) That doesn't seem to be in line with NSTableView which is all wrapped in a single NSScrollView.

brendand commented 9 years ago

It's because you want the column header and row header to remain fixed at the top and left of the main content area while the main content area scrolls vertically or horizontally. But you still want the content of the column and row headers to scroll along with the main content scroll area. They won't get out of sync because as you scroll the main content area, the contentViewDidScroll notification will tell the column and row scrollers to match the scrolling of the main content area.

cognociente commented 9 years ago

I achieved the same thing by manipulating layout constraints on my row/column headers as the main content scrolled. That was one of the things that worked quite nicely.

The side effect of you are doing it is that you can scroll the headers independently of the main content view (which doesn't make sense to me in this context as they are then out-of-sync).

brendand commented 9 years ago

Yes, that's true I see. If you would like to submit a pull request to change that, that would be great.

brendand commented 9 years ago

By the way, this specific implementation detail is left over from the original author and wasn't something I added myself.

Dejal commented 9 years ago

Fixed. Also fixed a wacky scrolling behavior where the header and footer could be scrolled vertically (comment out the -adjustScroll: methods then use a trackpad to scroll vertically in the header to see it).

brendand commented 9 years ago

:+1:

brendand commented 9 years ago

Oops. Just noticed the footer view also scrolls independently and needs to be synchronized too.

Dejal commented 9 years ago

I've just added scroll syncing for the footer too. Though there are other issues with the footer, as per #39. (But this issue can be closed.)

brendand commented 9 years ago

:+1: