When reloading the table view, the actual loading (-load) is defered
until layout is needed (generally in the next run loop). This is an
advantage because it minimize reloads but in some case it is necessary
to force a reload, for example when we need to access data views, or
manually edit a view, or when we explicitely ask for a reload.
This commit adds _reloadDataViewsImmediately and make use of it when
necessary.
Tests: AppKit/CPTableViewTest -> -testEditCell
Cell-based table views with no identifier set for the table column:
Before this commit, the caching system was asking for a view identified
by the tableColumn UID. If the table column data view was changed
externaly, the previoulsy cached data views were loaded instead of the
new ones. The views are now identified by the -dataview UID.
Test: AppKit/TableTest -testLayout were a custom data view is set.
Fixed: Starting a column drag is now faster.
Fixed: When dragging a selected column, selection is now drawn on the dragging view and the cursor is the closed hand.
Fixed: When dragging a table column, underlying columns were sliding according to the tracking location instead of the column lateral edges.
Fixed: In CPTableView, the drop indicator for rows could appear when dragging a column.
This commit creates directly the dragging column instead of relying on
built-in drag&drop. Also fixes a bug where the drop indicator would appear when
dragging a column if some rows were previously drag&dropped.
Fixed: An edited view no longer send its action (view-based) or commit its object value (cell-based) when unexposed.
Fixed: Cell based tables support for editing any control, not just textfield and buttons.
This commit reverts #1478. It appears it is a bad idea to enqueue
visible views. The views generally stay in the cache forever and they
are repeatedly asked to be removed from the table at each load, causing
a performance penalty.
Fixed: Column dragging performance, content binding performance.
After this commit, -reloadDataForRowsIndexes:columnIndexes: reloads the data and the data only.
The -reloadData method no longer tries to reuse the views, instead it just reloads the data for visible views.
To flush and reload the views cache for visible rows, use _reloadDataViews.
To internaly layout the views geometry, use _layouViewsForRowIndexes:columnIndexes:
In CPTableView dragging column code, relayout the views whose frame changed instead of reloading everything.
New: preparedViewAtColumn:row:
These methods allow to enumerate visible data views or data views in specified columns and rows.
-enumerateAvailableViewsUsingBlock: is the counterpart of cocoa's -enumerateAvailableRowViewsUsingBlock: except that it enumerates data views instead of CPTableRowView and the block has an additional column parameter.
This commit reverses the way views are stored and accessed in the table view: rows>columns instead of columns>rows.
Applied the second method where it is relevant, making the code more compact and readable.
This bug appears only if a table view have been added to the window.
CPTableView observes first responder changes and moves up in the view
hierarchy to determine the edited data view. If for some reason, a
superview in the hierarchy was nil, we entered an infinite loop.
This commit adds guards to the recursive method that searches the data
view. Also added an early return when the fr changes to a view outside
the table.
Fixes#1875
Previously CPTableView -_init was trying to reference a theme value, but that doesn't work because the theme creates a CPTableView and during that _init the theme value is not yet defined.
This commit uses lazy instantiation to avoid this problem.
Also, column selection was added to the CPDictionaryControllerTest to better visualize unfocused selection highlight colors.
Previously, the colors used for unfocused selection highlighting were hard coded. In Cocoa, they seem to be desaturations of the focused selection highlight colors.
This commit calculates the unfocused highlight colors from the focused colors.
It also removes some dangling commas.
Previously, CPTableView was unconditionally setting the selected theme state for selected data views. When the selection highlight style is CPTableViewSelectionHighlightStyleNone, there is no row selection highlighting done. Since the default theme specifies white text for selected data views, we ended up with white text on a non-highlighted background, which was invisible on non-alternate rows and almost invisible on alternate rows.
This commit unsets the selected theme state flag for any redrawn data views when the selection highlight style is CPTableViewSelectionHighlightStyleNone, thus the text color does change at all when selected.
Fixes#1847
Previously, when a table cell was edited, the table thought it had lost focus and displayed the cell's row highlight in an unfocused state.
This fix updates the _isFocused test to include tests for cell editing in both cell-based and view-based tables.
Previously the gradient in an unfocused selection highlight in CPTableViewSelectionHighlightStyleSourceList style was darker at the top and brighter at the bottom, which is the opposite direction of the gradient when focused.
This commit makes all of the unfocused highlight colors a strict 5% desaturation of the focused colors.
Refs #1839
CPTableView has no focus ring, and currently gives no visual feedback of its firstResponder status. In Cocoa when the table view resigns firstResponder or its window loses key status, the selection color turns gray.
This commit sets the selection color to gray when a table view resign firstResponder or its window loses key status. A second window and a couple of textfields were added to the CPDictionaryControllerTest to demonstrate the changes.
Fixes#1839
Previously the selection highlight update loop created two selectors and called an extra method for every row being updated.
The selectors are now calculated beforehand, and the method call has been eliminated.
Previously in CPTableView, after clicking a sortable column, data views of the sorted column ended up in a selected state and a row was selected instead of the sorted column. As a result, the text of the rows would turn white as if they were selected, but there was no highlight, so the text was basically invisible.
This commit fixes that by reversing the order of operations when clicking a column. First the sort is done, then the selection.
Fixes#1337, #1688, #1779.
-tableView:dataViewForTableColumn:row: and -outlineView:dataViewForTableColumn:item: are deprecated in favor of ...viewForTableColumn:...
Using the previous delegate API and not caching the view with an identifier was degrading performance. With this change, developers are encouraged to use the new caching system and the CPTableView method -makeViewWithIdentifier:owner: to get the view.
Also fixed a condition where a view-based outline view was not always asking for the view from its delegate. In some circumstances, an outline view could be considered as view-based instead of cell-based.
Test for deprecated delegate methods in CPOutlineViewViewBasedCib and TableTest/ViewBased examples.
Fixes#1823
Previously in CPTableTView, a view being edited was not cached when unloaded, for example when made invisible after scrolling or when calling -reloadData.
This situation was causing a duplicated view to be added at the same place when the data view was loaded again.
After this commit, edited data views are cached and resign their first responder status just before they are added to the queue because they can be reused at another place.
Test: Added a "reload data" button in ViewBasedCib example.
Previously, Cappuccino was using preprocessor macros internally for the CGPoint/Size/Rect/Inset/Affine functions, as well as for CPRange. These macros had the same name as the corresponding function, but began with _. The functions were actually defined using the macros.
The motivation behind using macros was to increase performance by reducing function calls. However, there were a number of problems with this approach:
- There was an artificial dichotomy between _CG macros and the corresponding CG functions. We never completely replaced CG function calls with _CG macros. In fact, they were often mixed up in the same file. There was an extra burden on the programmer to remember to use the macro instead of the function.
- If a method call was passed as an argument to a macro, performance could actually be significantly *worse* than a function call. For example, _CGGetRectMakeCopy([view frame]) would expand to `{ origin:{ x:[view frame].origin.x, y:[view frame].origin.y }, size:{ width:[view frame].size.width, height:[view frame].size.height } }`. So instead of a single objj_msgSend and a single simple function call, we ended up with 4 objj_msgSend calls, which are way more expensive than simple function calls.
- Because of this expansion problem, to use macros efficiently required us to remember to use variables for all macro parameters. This didn't happen, and shouldn't have to happen.
- Finally, with modern Javascript engines, function call overhead is so small that it really isn't worth using the macros.
This commit eliminates the _CGGeometry, CGAffineTransformation and CPRange macros and replaces them with function calls.
BREAKING CHANGE:
The macros are no longer available. They could only be used with compiled code, but if there is any user code that used them, they will have to be replaced with the corresponding functions.
Added documentation for tableView:dataViewForTableColum:row: delegate method. Document other cases, when we expect the data view to have a CPViewNotSizable mask.
ViewBasedCib example: added variable row heights.
- NEW: Retrieve the underlying Image element from a CPImage with -image.
- NEW: You can now render any arbitrary drawing to a pattern context and use that as a fill or stroke pattern. See CGContextCreatePatternContext, CGContextSetFillPattern and CGContextSetStrokePattern. Works in all canvas-enabled browsers, including IE 9+.
- NEW: An example of using a custom rendered pattern is in Tests/Manual/PatternFillTest.
- NEW: Test if a CPImage is a single image (vs. three/nine part) with -isSingleImage.
- FIXED: With canvas, we have to track ourselves whether the context has a path or not.
- FIXED: All shapes except rects may not be added to a path with no context. If you attempt to do so, an error is logged.
- FIXED: CGPath was not setting the start and current point correctly in some cases.
- FIXED: CGContextAddPath was not moving to the path's start point at the beginning.
- FIXED: Removed superfluous CGContextClosePath commands, fixed some drawing sequences.
- FIXED: Misc. formatting.
Sorry, these changes are canvas only (including IE 9+)! I am not going to spend the time to port these fixes to VML (IE 8).