Transparent NSTableView - objective-c

I want to customize my NSTableView. My overall requirements are like this:
Each row will have one image and some text; images and text could be different.
Some cells might not have an image.
Row height is dependent upon some external factor.
A cell shouldn't draw the background, it should show the NSTableView background.
So far I am able to draw transparent cells with some text. I Googled and found out I need to customize each cell. Now I have this question: should I maintain two columns or should one column be okay, having one image on the left hand side and text adjacent to that?
I also understand that I need to override two methods:
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
So for each cell, I need to draw/construct the cell -- can anyone guide me? Am I going in the right direction? Can I achieve a transparent background with dynamic height with the above approach?

Each row will have one image and some text,
So, two columns—one with an image cell, the other with a text field cell.
images and text could be different,
I should hope so.
Some cell might not have the Image,
Not a problem.
Row height is depend upon some external factor,
Be the table view's delegate, and it will ask you what the row's height should be.
Cell shouldn't draw the background,
It won't unless you set it to do so.
it should overall it should show the NSTableView background,
The table view will draw its own background anyway, which you can set in IB's Inspector. If you wanted the table view to not draw a background, you would set its background colors to the clear color.
You don't need a custom cell for any of this.

Related

tvOS tableView scroll smooth from cell to cell

In my tvOS-app I use a tableView with custom cells. If the cell is higher than the TV-screen it will show the "center-part" of the cell (top and bottom are not visible) and scrolling up or down will center the cell above or below. Is it possible and if, how, to change the "jumping" from cell to cell to a smooth scrolling like in iOS?
You should limit your cells to use a fixed height for a few lines of text and show focus. When a user selects one of the cells you can then expand / zoom / transition to show the whole text is a specific scrollable text view. This interface maintains the users understanding of content, lists and block text.
Just found the solution. Knowing what to search could be an advantage ;-)
Adding this simple line gives me the handling like in iOS:
self.tableView.panGestureRecognizer.allowedTouchTypes = #[#(UITouchTypeIndirect)];

Background color in cells in NSTableView is 1 pixel off

I am making an OSX app, and for part of it, I am using NSTableView to simulate a "timeline", by putting in a really thin column and then setting the background color. It's fine, except for whatever reason the cell seems to be 1 pixel off whenever the background color changes. Anyone got any ideas? I don't have the reputation to post an image so here's the link: http://imgur.com/PrLdjIV
Thanks for reading this!
An NSTableCellView will not necessarily fill a row from edge to edge. Likewise, an NSTextField inside such a cell view will not necessarily fill it from edge to edge.
Implement -tableView:didAddRowView:forRow: in your table view delegate and set the row view's backgroundColor.

View-based NSTableView with floating group rows

This is actually a pretty simple question: Is there any way of making a group row's view on a view-based NSTableView float without making it also transparent?
use a custom cell that draws however you like - the floating is only placing the cell inside the table.
Normally the RowView draws the bg for all cells, the default ones dont draw any own background. that is what you have to do in your cell -- have it draw a bg on its own and not rely on the TableRowView

Customizing NSTableView rows background

How could I change the background of each row of a NSTableView?
The documentation will tell you.
If you want to set the background color differently for specific rows, columns, or row-column intersections, be the table view's delegate and respond to tableView:willDisplayCell:forRow: by setting the background color of the cell.

Animating rows in an NSTableView

Is there a simple way of animating rows in an NSTableView?
I'd like to be able to do something like flash a row, or fade out a row.
Essentially - to provide a bit of visual feedback when rows are added or removed.
Edited to add:
I'd had a quick look over Google before posting this; but I wanted to know if there was some way to do this that I'd missed other than drawing and animating parts of the table view myself.
To flash a row, there are a number of ways to go. You could just grab a cell and play with it's view, such as change the color of the background or font colors. You could also just select the cell and deselect it a few times, if you don't care about removing the existing selection from another cell. Or you could superimpose another view on top of the cell's view and use blend modes...
For animating the deletion, you could do the same as above, dimming the cell, or even move the view up and out, transform it so it shrinks down and move it over to a trash can and shrink it all the way down as it enters the trash. Then after the animation is done, you delete the row.