When opening a sheet, with a double click the frame origin of the sheet changed and the parent disappeared.
This PR fix this issue.
Test app in Tests/Manual/AttachedSheet/AppController.j
Previously, if a window had an autoresizingMask and was marked as not being constrained (for example _CPMenuBarWindow), and the CPWindowConstrainToScreen was set to NO, resizing the platform window would not autoresize the window.
This commit ensures that windows that autoresize but don't care about constraining will resize with the platform window no matter what.
Fixes#1981.
Previously, addChildWindow:ordered: was setting the platform window of the child window.
This patch restore the correct behaviour, and fix a bug with _CPAutocompleteMenu. Now the autocomplete menu is opened as a child of its textfield window using the correct platform window.
Previously, addChildWindow:ordered: did not set not the child window's platform window. This could result to open them in the wrong browser window. This patch makes sure to set the parent's platform window as the child window's platform window.
Previously a fixed margin of 40px was maintained at the left/right of a window when resizing it, which was excessive.
Now the minimum size allowed during a resize is the same as the minimum margin allowed when moving a window, which is determined based on the type of window.
Previously, when the platform window was resized, windows were moved/resized to stay within the virtual screen, but if the window had a minimum size, it was not respected.
This commit ensures that if a window has a minimum size, it will always be respected.
Previously window heights were constrained to the usable screen when the platform window (virtual screen) resized, but widths were not. The code was there to constrain the width, but it wasn't being used.
This commit ensures the width constraining code is executed.
Previously, window moves were constrained such that a minimum margin of the window was visible on screen, but window resizes were not constrained, allowing the user to effectively move the window off screen.
Now resizes are constrained such that a minimum margin of the window is always visible on screen so that the window does not get "lost".
Previously, whenever the platform window (virtual screen) resized, windows were moved or resized to keep them on screen. This could not be easily overridden by the user.
Two class methods have been added:
CPWindow +setConstrainWindowsToUsableScreen:
CPWindow +constrainWindowsToUsableScreen
If +setConstrainWindowsToUsableScreen:NO is called, then resizing the platform window will not move or resize user windows.
Previously it wasn't possible to display a toolbar in a sheet window.
Now, a toobar is displayed well in a window. This PR allows every sheet window to have a toolbar, with the PR #1918 just the CPTitleWindow/HUD sheet could have a toolbar as in cocoa.
Fixes#1863
Previously when using a sheet window in a fullPlatform window, the sheet window started the animation under (the layout) the toolbar.
Now, the sheet animation starts below the toolbar as in cocoa.
It also fixed that only a CPBordelessWindow/CPTitleWindow/HUD can have a toolbar.
When added, level of child window is reset to level of the parent.
A user may change it aftewards to the level that may even break
specified relative position.
E.g. if a child window is added below the parent (Normal)
and its level is set to Floating it will be ordered above.
Whenever you change level of the parent window, levels of the child
windows are reset as well ignoring all your changes.
According to the example, if you set level of the parent to Normal+1,
child window' level will also be set to Normal+1 and its relative
order to the parent (below) will be restored.
Previously the sheet was made key at the beginning of the animation. It turns out events would not reliably make it to the sheet during animation. The other problem is that if a text field was the first responder, at the beginning of the animation it is offscreen, which means it refuses first responder and sets the first responder to nil.
Now we no longer try to make the sheet key before the animation ends, avoiding the text field problem.
Previously, if a window had a sheet, a mouse move event was passed to the sheet and then filtered. This disabled resize cursors for the parent window of a sheet.
This commit allows mouse move events to continue to the parent window so that resize cursors will work on the parent window as well.
Sheets are like child windows, they can never become main. Previously, when an attempt was made to make a sheet the main window, its parent window did not become main as it should have. Thus the title bar would remain dimmed, even though the sheet was the key window.
With this commit, when a sheet is made main, it defers to the parent window.
Previously, if an event occurred during the sheet opening animation that would close the sheet, the animation was not properly cleaned up and the subsequent closing animation would die horribly.
The animation is always cleaned up with this commit.
It is possible to resize the parent window of a sheet while it is open. Previously, the sheet's top shadow was not adjusted when the parent window was resized, which could lead to it being out of synch.
Now the sheet shadow is adjusted whenever the parent window's size changes.
Previously, sheets were only repositioned if the parent window's setFrameOrigin: method was called. This did not cover all possible cases for parent window repositioning.
Now the sheet is repositioned any time the parent window's origin changes.
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.
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.
Currently, if a window controller has a document, its title is put in menubar. I cannot remember any Cocoa application that ever did this.
This commit removes the synchronizing of the document title with the menubar title.
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, all window subclasses were constrained to the usable screen content. Unfortunately that included the menu bar window, which ended up appearing below itself!
This commit introduces an ivar that indicates whether instances of the window subclass should be constrained or not.
Previously, no bounds were placed on the placement or sizing of windows, which allowed them to extend beyond the usable screen content (the area bounded by the menu bar at the top and the platform window on the other sides).
Cocoa enforces the following restrictions:
- When a window is ordered in, it is forced within the usable screen content (below the menu bar) and its size and width are clipped to the usable screen content as well.
- If a window is already visible, any methods that move or resize the window will ensure the top and bottom of the window are within the usable screen content. The width is unchanged.
This commit implements Cocoa's restrictions in CPWindow.
Fixes#1690
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
Previously sheet animation was performed by sizing the sheet from zero to full height when animating in, and then back to zero height when animating out. This caused problems with the resize algorithms, which are not designed to deal with sizing from zero.
Analyzing Cocoa behavior revealed that sheets slide in and out with no resizing.
With this commit, a general purpose mechanism for clipping a window to a rect was added to CPDOMWindowLayer. Clipping was put in CPDOMWindowLayer because that is the class that deals with windows at the global level. CPWindow uses the clipping mechanism to slide the sheet in and out, thus avoiding all resizing problems.
Fixes#1840
Previously the attached sheet shadow (that appears below the title bar of the window a sheet is attached to) was 9x8, and it was quite dark.
With this commit the width has been reduced to 1 (to reduce the image size) and it has been lightened up.
Also changed "height-shadow" theme attribute to "shadow-height".
Previously, sheets could be resized from the top, which would destroy the illusion of being attached to the top of the parent window.
With this commit, sheets are prevented from being resized by the user from the top edge.
Without this fix, a platform window could be resized by clicking just under the menu bar and dragging downwards, even that platform windows are supposed to be the size of the browser window by definition.
Without this fix, a transient popover would close if the autocomplete menu of a token field contained in it was clicked.
This happened because the popover considered the click to be on a different window. Although not tested, it's likely the same thing would happen if the menu of a combo pop or a pop up button was clicked.
This fix makes it so that any child window of a popover can be clicked without the popover closing.
Previously, the content view of almost all window types
could overlap the frame of the window.
This is a follow on to b28429f which insets the content view
from the frame for all relevant window types.
Refs #1798
Previously, _CPStandardWindowView did not inset the content view rect
from the window frame, thus its contents could overlap the window frame.
Now the content view is correctly inset so that content view content
is clipped to the window frame, except for the corners. Because the
corners are round and the window frame is a background color, they
can still be overlapped. this will be fixed in a later commit.
Closes#1798