Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 19 | import android.graphics.RecordingCanvas; |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 20 | import android.graphics.Rect; |
| 21 | |
| 22 | /** |
| 23 | * These callbacks are used to communicate window configuration changes while the user is performing |
| 24 | * window changes. |
Skuhne | 980ee47 | 2015-10-06 11:31:31 -0700 | [diff] [blame] | 25 | * Note: Note that at the time of onWindowDragResizeStart the content size isn't known. A consumer |
| 26 | * should therfore not draw anything before the additional onContentDraw call has arrived. |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 27 | * @hide |
| 28 | */ |
| 29 | public interface WindowCallbacks { |
Jorim Jaggi | c39c7b0 | 2016-03-24 10:47:07 -0700 | [diff] [blame] | 30 | |
| 31 | public static final int RESIZE_MODE_INVALID = -1; |
| 32 | public static final int RESIZE_MODE_FREEFORM = 0; |
| 33 | public static final int RESIZE_MODE_DOCKED_DIVIDER = 1; |
| 34 | |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Called by the system when the window got changed by the user, before the layouter got called. |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 37 | * It also gets called when the insets changed, or when the window switched between a fullscreen |
| 38 | * layout or a non-fullscreen layout. It can be used to perform a "quick and dirty" resize which |
| 39 | * should never take more then 4ms to complete. |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 40 | * |
| 41 | * <p>At the time the layouting has not happened yet. |
| 42 | * |
| 43 | * @param newBounds The new window frame bounds. |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 44 | * @param fullscreen Whether the window is currently drawing in fullscreen. |
| 45 | * @param systemInsets The current visible system insets for the window. |
| 46 | * @param stableInsets The stable insets for the window. |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 47 | */ |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 48 | void onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets, |
| 49 | Rect stableInsets); |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * Called when a drag resize starts. |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 53 | * |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 54 | * @param initialBounds The initial bounds where the window will be. |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 55 | * @param fullscreen Whether the window is currently drawing in fullscreen. |
| 56 | * @param systemInsets The current visible system insets for the window. |
| 57 | * @param stableInsets The stable insets for the window. |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 58 | */ |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 59 | void onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets, |
Jorim Jaggi | c39c7b0 | 2016-03-24 10:47:07 -0700 | [diff] [blame] | 60 | Rect stableInsets, int resizeMode); |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Called when a drag resize ends. |
| 64 | */ |
| 65 | void onWindowDragResizeEnd(); |
Skuhne | 980ee47 | 2015-10-06 11:31:31 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
Chong Zhang | 8dbd9ad | 2015-10-09 10:06:11 -0700 | [diff] [blame] | 68 | * The content will now be drawn to these bounds. Returns true if |
| 69 | * a draw should be requested after the next content draw. |
Skuhne | 980ee47 | 2015-10-06 11:31:31 -0700 | [diff] [blame] | 70 | */ |
Chong Zhang | 8dbd9ad | 2015-10-09 10:06:11 -0700 | [diff] [blame] | 71 | boolean onContentDrawn(int offsetX, int offsetY, int sizeX, int sizeY); |
| 72 | |
| 73 | /** |
| 74 | * Called to request the window to draw one frame. |
| 75 | * @param reportNextDraw Whether it should report when the requested draw finishes. |
| 76 | */ |
| 77 | void onRequestDraw(boolean reportNextDraw); |
Jorim Jaggi | c39c7b0 | 2016-03-24 10:47:07 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Called after all the content has drawn and the callback now has the ability to draw something |
| 81 | * on top of everything. Call {@link ViewRootImpl#requestInvalidateRootRenderNode} when this |
| 82 | * content needs to be redrawn. |
| 83 | * |
| 84 | * @param canvas The canvas to draw on. |
| 85 | */ |
John Reck | 32f140aa6 | 2018-10-04 15:08:24 -0700 | [diff] [blame] | 86 | void onPostDraw(RecordingCanvas canvas); |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 87 | } |