128 Commits
Author SHA1 Message Date
David Richardson 1a9a42ff54 Replace #pragma mark with // MARK:
Replace objc directive with native Javascript version // MARK: to facilitate elimination of preproccsing pass.
2026-07-21 15:15:53 -06:00
daboe01 a0f9cb5183 formatting 2025-07-13 19:55:34 +02:00
daboe01 1a74b4c692 fixed: CPCollectionview displayed an erroneous offset before the first row of content 2025-07-13 19:53:33 +02:00
Martin CarlbergandGitHub 7dc77ed609 Fixed: Make sure we handle undefined when testing for nil values (#2862) 2020-01-31 13:43:58 +01:00
Kjell NilssonandMartin Carlberg 64e1a2ce4b Fixed: Protocol selector signature spell error (#2734) 2018-07-05 11:25:38 +02:00
cacaodev 5f12291ac4 Fixed: add missing import 2016-06-20 19:34:00 +02:00
cacaodev fa3647e8e5 Refactor selection with modern code.
Handle out of range errors when reflecting selection.
2016-05-03 21:50:41 +02:00
cacaodev db839f6d6d Rename _lockResizing to _inLiveResize
_inLiveResize is a CPView flag.
2016-05-03 21:50:20 +02:00
cacaodev 3a85d5b89f CPCollectionView content binding support 2016-05-03 21:50:20 +02:00
Alexandre Wilhelm a439688b3c Doc: move private variables to the top of files to not show them in the documentation 2015-05-15 09:55:17 -07:00
Antoine Mercadal f9275a70af FIXED: New warnings reveleaded by ivar type checking
This patch fixes all new warnings
2014-11-06 10:17:05 -08:00
Antoine Mercadal 4b058a8c56 Merge pull request #2150 from daboe01/fix-cpcollectionview-height
FIXED: CPCollectionView height is too low [+1]
2014-10-28 16:23:50 -07:00
daboe01 4cebfbcd13 removed collectionViewDidChangeSelection 2014-08-14 22:57:05 +02:00
daboe01 f82e52b7a2 correction of height calculation 2014-06-26 18:06:50 +02:00
daboe01 88954b9bf6 fix cpcollectionview height issue 2014-06-25 20:54:18 +02:00
Alexandre Wilhelm 8a0acedc94 Fixed: CPCollectionViewDelegate protocol does not implement CPObject protocol 2013-12-09 01:23:14 -08:00
Alexandre Wilhelm 4d266f4ad2 New: Added CPCollectionViewDelegate protocol
This PR adds the protocol CPCollectionViewDelegate.
Also, now the delegate methods are called like we are used to do it in Cappuccino.
2013-12-08 18:35:52 -08:00
Martin Carlberg e511638962 Fixed: Cleaned up return and parameter types on methods. 2013-11-24 22:21:56 +01:00
Martin Carlberg bb58a206a8 Fixed: Removed all warnings of conflicting return and parameter types caused by the new compiler 2013-08-12 16:46:14 +02:00
Andrew Hankinson 8d7e2f9ec6 Fixed: CPCollectionView range bounds exception if shift key was held for first selection
Previously, if you held down the shift key while making the first selection in a CPCollectionView it would raise an exception claiming {-1, XXX} was out of range. This was because `firstIndex` returns CPNotFound (-1) if nothing is selected.

In Cocoa, holding down the shift key while making the initial selection behaves as if you made an initial selection.

This commit catches a CPNotFound and sets the first index to the index of the item under the mouse pointer.
2013-05-31 17:19:09 -04:00
Aparajita Fishman 391ff7279d Fixed: capp_lint errors. 2013-05-16 15:02:45 -04:00
Aparajita Fishman afd5925499 Fixed: _CG and _CP macros were confusing and could degrade performance
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.
2013-03-13 12:22:10 -04:00
aparajita 96605826ba Merge pull request #1842 from stewa/empty-collectionview-keyboard-navigation-problem
Fixed: using keyboard navigation in empty CPCollectionView threw exception

Previously, if an empty CPCollectionView was first responder and keyboard navigation was used, a CPInvalidArgumentException (Range {-1, 1} is out of bounds) was thrown.

This commit checks for an empty collection, eliminating the exception.
2013-03-12 07:01:53 -07:00
aparajita da69a6e339 Merge pull request #1845 from cacaodev/CPCollectionView-doc
Docs: CPCollectionView-setItemPrototype: method documentation
2013-03-11 21:20:14 -07:00
Stefan Wallström a549c191da lint 2013-03-11 21:09:22 +01:00
cacaodev 0d168a4518 Remove //@class CPClipView 2013-03-11 17:52:21 +01:00
cacaodev 0e4f5e9203 Uncomment import 2013-03-11 17:14:00 +01:00
cacaodev a98def4326 Added doc for -setItemPrototype: explaining how to setup the item prototype when you want to use bindings for the view. 2013-03-11 16:49:19 +01:00
Stefan Wallström 2bf2442096 Fixed: Using keyboard navigation in empty CPCollectionView threw exception. 2013-03-10 17:38:08 +01:00
Alexander Ljungberg f4096b94a7 New: use @ref and @deref instead of Ref.h throughout Cappuccino. 2013-03-10 13:08:34 +00:00
Aparajita Fishman 53ce9b6588 Fixed: delegate method collectionViewDidChangeSelection: is deprecated
Previously CPCollectionView supported a delegate method collectionViewDidChangeSelection:, which is not defined in Cocoa. Since CPCollectionView is KVO-compliant for selectionIndexes, this delegate method is no longer necessary and is a needless divergence from Cocoa.

The method is now marked as deprecated, and when used will log a deprecation warning.

Closes #715
2013-02-26 08:11:42 -05:00
Aparajita Fishman a011596231 CGContext fixes/enhancements
- 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).
2013-02-23 13:53:20 -05:00
cacaodev 4791973b02 If maxNumberOfRows == 0 (the default), ignore maxNumberOfRows 2013-02-13 23:54:02 +01:00
cacaodev 21b5eade71 CPCollectionView Issue 1755:
Create the drop indicator in mouseEntered if needed. This is the case where the collection view is a drop destination but not a drag source.
In _updateDragAndDropStateWithDraggingInfo... , handle the special case where the drop destination is 0 (includes item count == 0).
Test app: add an empty collection view acting as a drop destination for the first collectionView.
2013-02-13 17:47:27 +01:00
Alexander Ljungberg 21efb90b4c Refs #1700. Fixed: setItemPrototype crash.
Setting the item prototype without first adding the collection view to a view would cause a crash, as would reloadContent.

This fix makes sure the collection view doesn't try to tile itself unless it has a frame.
2013-02-08 11:46:08 +00:00
Alexander Ljungberg 1248b1fb29 Refs #1700. Fix unknown class or global warnings. 2013-02-08 11:26:56 +00:00
Alexander Ljungberg 8ed85ede2c Refs #1700. Use more macros. 2013-02-08 11:17:45 +00:00
Alexander Ljungberg 6181b75d9f Refs #1700. Make reloadContentCachingRemovedItems: a private method. 2013-02-08 11:02:02 +00:00
Alexander Ljungberg 7b1ffb942f Refs #1700. Clean up and use macros. 2013-02-08 11:01:19 +00:00
Alexander Ljungberg 61990e764c Merge pull request #1700 from cacaodev/CPCollectionViewItem-loading
CPCollectionView -maxItemSize support, content binding, collection view item loading ... [+4]
2013-02-08 10:52:00 +00:00
Aparajita Fishman 4f377bcebe Objj2 compiler fixes
Compiled all files individually:

- Added missing imports.
- Added @class/@global declarations to break circular dependencies.
- Misc. code cleanup.

Conflicts:
	AppKit/CPWindow/_CPWindow.j
	AppKit/Platform/DOM/CPPlatformWindow+DOM.j
2013-01-23 15:48:55 +07:00
Martin Carlberg b52217e8a0 Tried to make the import mess a little better. Fixed a lot of bugs. Changed some class names in the test cases. Looks like all the tests are being run in the same space. Has to look into this….. 2012-12-17 00:40:26 +01:00
Martin Carlberg c297e926f9 Compiler now works with jake and can compiler the whole Cappuccino framework. A lot of test cases still fail 2012-12-16 17:38:47 +01:00
cacaodev 6b7b63dff4 Drop support with drop indicator.
FIXED: undefined _horizontalMargin
Test app: UI for switching uniformSubviewsResizing.
2012-12-08 23:15:41 +01:00
cacaodev dd5bd17e2b Simplify the "layout computing" method and change its name
There is not need to use that much arguments because the result is stored in ivars.
CPCollectionViewItem -copy: set properties correctly even if the collectionView overrides them.
2012-12-08 17:43:53 +01:00
cacaodev 2ab1493d27 Merge branch 'CPCollectionView-dragged-view' into CPCollectionView-dragAndDrop 2012-12-07 16:51:23 +01:00
cacaodev 9a1e75712d test app: CPSelectionIndexesBinding test 2012-12-07 16:51:11 +01:00
cacaodev 4c1ebfbdd4 -setItemPrototype:
Do not cache removed items in -reloadContent when the item prototype changes.

maxItemSize:
    Interpreted as horiz/vertic expandable when zero size and the proto view has a CPViewWidth|HeightSizable. (per cocoa but not documented).
    maxItemSize height support.

Fixed: incorrect position when num items < numberOfColumns.

Rewrote layout engine. Splitted the computation of size, columns count, rows count from the actual layout where we set the frame.
This will help when/if we support insertion/mutation of  -content or view animations.
We can also be more lazy when the computation results stay the same.

Added shared -init. Whitespace cleaning.

CPCollectionviewCibTest:
    Add ability to set the 2 kinds of prototypes, one loading its view from a cib, the other with a view outlet in the same cib.
    Loaded protoype: the bound textfield can commit its value to the model.
    UI for setting maxNumberOfColumns|Rows min|maxItemSize
2012-12-06 19:42:03 +01:00
cacaodev 34d6d0695f Freeze autoresizingMask
The mask is 0 and cannot be changed.
Cocoa allows any value but ignores them for layout.
2012-11-30 15:01:44 +01:00
cacaodev 524bd52a56 Partially rewrote layout.
it is not optimal but certainly better than the previous  version. A
collection view was unusable when resized through its scroll view.
2012-11-30 15:01:44 +01:00