Previously, unless you were using a sheet alert, there was no way to set a custom dismissal handler for an alert. In Cocoa alerts are synchronous, in Cappuccino they are asynchronous, which meant that a single dismissal handler had to handle all possible non-sheet alerts.
This commit adds several methods which add two ways to specify a custom dismissal handler: via delegate/selector, and via a block (function). The new methods are:
setDidEndSelector:
runModalWithDidEndBlock:
beginSheetModalForWindow:didEndBlock:
Note that didEnd blocks are transient and take precedence over didEnd selectors.
The CPAlertTest demo was updated to fix some bugs and added the ability to run the tests using blocks.
This change brings nearly all copy and paste related into a single, self-contained class. This new class is still somewhat coupled to CPPlatformWindow+DOM.j in the sense that it's highly specific and meant to be called in a very specialised way. Despite this, it's still a significant decoupling and the new code is more readable and easier to follow.
Image copy and paste to and from the system clipboard is not available in Cappuccino today. However, the image in the collection view can be used to test internal Cappuccino copy and paste (using Edit > Copy, Edit > Paste from the Cappuccino menu).
This test makes it easy to test copy and paste both inside a Cappuccino app, and externally to and from other Cappuccino instances in other browser, or other applications, when using a text field or a collection view as the source/destination.
- CPImageInBundle() can't be used from a ThemeDescriptor. Replaced with PatternImage().
- DRY! Put clock image sizes in variables so they can be maintained in one place.
- When displayed from the theme showcase, the hand images in HandLayer -setImage: were still _CPCibCustomResources, not sure why. This condition is now explicitly handled by converting to the referenced image.
- Fixed a bug in _CPDatePickerClock -setEnabled where the sublayers would not update unless the event loop was pumped.
- Check for unchanged value in setters.
- Various code optimizations.
- Removed unnecessary method comments.
- Fixed typo in demo app.
Previously when creating a CGPath with an arc, the path was wrong. It added a line when it wasn't necessary and when it was necessary it added a line to a wrong point.
Now CGPath works like in cocoa (If the specified path already contains a subpath, Quartz implicitly adds a line connecting the subpath’s current point to the beginning of the arc. If the path is empty, Quartz creates a new subpath with a starting point set to the starting point of the arc.)
Test app in Tests/Manual/CGPath/AppController.j
Canvas supports CGContextDrawRadialGradient as in cocoa. The CGGradientDrawingOptions is not actually supported.
Test app in Tests/Manual/CGCanvasContext
- Added support for CPDateFormatter in Foundation
- Added support for CPTimeZone in Foundation
- Added support fo CPDateFormatter in nib2cib
Test app in Tests/Manual/CPDateFormatter
UnitTest in Tests/Foundation/CPTimeZoneTest.j
UnitTest in Tests/Foundation/CPDateFormatterTest.j
This commit adds notifications for focus and blur on CPTokenField.
Attached is a modified Manual CPTokenFieldTest that observes these notifications.
Fixes#1396
Previously, the enabled state of a CPComboBox could not be set in Interface Builder.
This commit allows Interface Builder to set the enabled state of a CPComboBox.
A modified test in Manual/CPComboBoxTest is included. This test simply adds a new disabled combo box to an existing window, and then checks to see if it is disabled, printing a descriptive message to the Javascript console.
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.
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
-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 _CPThemeAttribute had an ivar called _parentAttribute, which represented the attribute from the theme descriptor, as opposed to the attribute for a particular instance of a view.
This commit renames that ivar to _themeDefaultAttribute, so it is clearer where it gets its values.
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.
When a transient popover was closed by clicking, in some cases it would not detach from its parent, leaving it in the window list. This caused problems later on.
This commit ensures the popover is detached from its parent when it is ordered out.
I'm happy for those who have 27" screens, but on my poor MPB 15" screen, the CPGraphicsTest window was too tall to see everything.
I split the window into two windows so everything can be seen.
The AttachedSheet2 demo was calling runModalForWindow:, which caused the sheet to appear briefly as an application modal.
That call was removed, beginSheet: does everything.
Also:
- Wrapped _attachSheetWindow method into _attachSheet:modalDelegate: method.
- Just to be safe, in CPWindow -_sheetShouldAnimateIn:, the sheet is moved offscreen before being ordered front.
After bbfaac5, all kinds of strange behavior occurred with window sizing and moving due to overzealous constraining.
Cocoa does not constrain the frame of hidden windows. When a hidden window is ordered in, it is constrained to the usable screen content rect. A visible window has its height constrained when its frame is set. Its origin is constrained such that a minimum margin at the left, right and top is visible, and the top is constrained to be below the menu bar.
This commit fixes a number of problems related to window moving and resizing that were introduced by bbfaac5:
- Sheets are not constrained at all.
- Moving a window does not constrain its size.
In addition, when a window is moved, tracking is relative to the initial click point, which provides proper behavior when the movement is constrained and the mouse keeps moving.
Previously, when a sheet was resized, there were a number of problems:
- Sheets in Cocoa resize their width symmetrically, such that they always remain centered. This was not happening in Cappuccino.
- When a sheet is resized wider than its parent window, the shadow at the top of the sheet was growing wider than the bounds of the parent window's title bar, which makes no sense since the shadow is supposed to be cast by the title bar.
- Sheets had no top border, so when they were resized wider than the parent window, the top edge looked like it was cut off. In Cocoa, sheets have a top border that sits under the title bar of the parent window, and which is visible when the sheet is resized wider than the parent window.
This commit addresses these problems as follows:
- Sheet width is now resized symmetrically.
- Sheet resizing is pinned to the screen bounds.
- The top sheet shadow is pinned to the width of the parent window's content view.
- Sheets now have a top border.
In addition to these changes, a redundant sheet top shadow was eliminated from one of the _CPWindowView subclasses.
Fixes#1846
The popover test now added exposes a bug:
1. Click Modal Window to open a modal window.
2. Click Popover to open a popover.
3. Click on the first window.
It should not be possible to interact with this window since a modal window is open, but a bug in the modal event handling when transient popovers are open will allow the event to incorrectly pass through to the window.
AttachedSheet2 is turning into a complete window/modality/sheets/alerts/popover interaction test.