From 6457e1668fbeeff2af228137fa90bb0e37adc326 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 3 Jun 2018 21:39:49 -0400 Subject: [PATCH] Rewrote uiTableModelRowChanged() to properly update rows. We can do this now that we have the setup for row updates and reuse, but this is better than calling reloadData anyway (and reloadData doesn't update the row view, but we (almost) do, so...)... --- darwin/table.m | 33 +++++++++++++++++---------------- darwin/tablecolumn.m | 4 ++-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/darwin/table.m b/darwin/table.m index ac2aef63..70b11c3e 100644 --- a/darwin/table.m +++ b/darwin/table.m @@ -26,7 +26,7 @@ - (NSView *)tableView:(NSTableView *)tv viewForTableColumn:(NSTableColumn *)cc row:(NSInteger)row { uiprivTableColumn *c = (uiprivTableColumn *) cc; - xx TODO consider renaming this type to uiprivTableCellView + // TODO consider renaming this type to uiprivTableCellView uiprivColumnCellView *cv; cv = (uiprivColumnCellView *) [tv makeViewWithIdentifier:[c identifier] owner:self]; @@ -43,24 +43,17 @@ @end -=================== TODOTODO - uiTableModel *uiNewTableModel(uiTableModelHandler *mh) { uiTableModel *m; m = uiprivNew(uiTableModel); m->mh = mh; - m->m = [[tableModel alloc] initWithModel:m]; + m->m = [[uiprivTableModel alloc] initWithModel:m]; m->tables = [NSMutableArray new]; return m; } -void *uiTableModelGiveColor(double r, double g, double b, double a) -{ - return [[NSColor colorWithSRGBRed:r green:g blue:b alpha:a] retain]; -} - void uiFreeTableModel(uiTableModel *m) { if ([m->tables count] != 0) @@ -84,16 +77,22 @@ void uiTableModelRowInserted(uiTableModel *m, int newIndex) void uiTableModelRowChanged(uiTableModel *m, int index) { NSTableView *tv; - NSIndexSet *set, *cols; + NSTableRowView *rv; + NSUInteger i, n; + uiprivTableColumnView *cv; - set = [NSIndexSet indexSetWithIndex:index]; for (tv in m->tables) { - cols = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(0, [[tv tableColumns] count])]; - [tv reloadDataForRowIndexes:set columnIndexes:cols]; - // TODO this isn't enough - [cols release]; + rv = [tv rowViewForRow:index makeIfNecessary:NO]; + if (rv != nil) { + xx TODO update colors + } + n = [[tv tableColumns] count]; + for (i = 0; i < n; i++) { + cv = (uiprivTableCellView *) [tv viewForColumn:i row:index makeIfNecessary:NO]; + if (cv != nil) + [cv uiprivUpdate:index]; + } } - // set is autoreleased } void uiTableModelRowDeleted(uiTableModel *m, int oldIndex) @@ -107,6 +106,8 @@ void uiTableModelRowDeleted(uiTableModel *m, int oldIndex) // set is autoreleased } +=================== TODOTODO + void uiTableColumnAppendTextPart(uiTableColumn *c, int modelColumn, int expand) { tablePart *part; diff --git a/darwin/tablecolumn.m b/darwin/tablecolumn.m index e01fb546..01ff5b27 100644 --- a/darwin/tablecolumn.m +++ b/darwin/tablecolumn.m @@ -259,12 +259,12 @@ struct textColumnCreateParams { data = (*(self->m->mh->CellValue))(self->m->mh, self->m, row, self->textParams.ColorModelColumn); uiTableDataColor(data, &r, &g, &b, &a); uiFreeTableData(data); - // TODO + color = [NSColor colorWithSRGBRed:r green:g blue:b alpha:a]; } if (color == nil) color = [NSColor controlTextColor]; [self->tf setColor:color]; - // TODO release color + // we don't own color in ether case; don't release } if (self->iv != nil) { uiImage *img;