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 19 import android.graphics.RecordingCanvas; 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. 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. 27 * @hide 28 */ 29 public interface WindowCallbacks { 30 31 int RESIZE_MODE_INVALID = -1; 32 33 /** 34 * The window is being resized by dragging one of the window corners, 35 * in this case the surface would be fullscreen-sized. The client should 36 * render to the actual frame location (instead of (0,curScrollY)). 37 */ 38 int RESIZE_MODE_FREEFORM = 0; 39 40 /** 41 * The window is being resized by dragging on the docked divider. The client should render 42 * at (0, 0) and extend its background to the background frame passed into 43 * {@link IWindow#resized}. 44 */ 45 int RESIZE_MODE_DOCKED_DIVIDER = 1; 46 47 /** 48 * Called by the system when the window got changed by the user, before the layouter got called. 49 * It also gets called when the insets changed, or when the window switched between a fullscreen 50 * layout or a non-fullscreen layout. It can be used to perform a "quick and dirty" resize which 51 * should never take more then 4ms to complete. 52 * 53 * <p>At the time the layouting has not happened yet. 54 * 55 * @param newBounds The new window frame bounds. 56 * @param fullscreen Whether the window is currently drawing in fullscreen. 57 * @param systemInsets The current visible system insets for the window. 58 * @param stableInsets The stable insets for the window. 59 */ onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets, Rect stableInsets)60 void onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets, 61 Rect stableInsets); 62 63 /** 64 * Called when a drag resize starts. 65 * 66 * @param initialBounds The initial bounds where the window will be. 67 * @param fullscreen Whether the window is currently drawing in fullscreen. 68 * @param systemInsets The current visible system insets for the window. 69 * @param stableInsets The stable insets for the window. 70 */ onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets, Rect stableInsets, int resizeMode)71 void onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets, 72 Rect stableInsets, int resizeMode); 73 74 /** 75 * Called when a drag resize ends. 76 */ onWindowDragResizeEnd()77 void onWindowDragResizeEnd(); 78 79 /** 80 * The content will now be drawn to these bounds. Returns true if 81 * a draw should be requested after the next content draw. 82 */ onContentDrawn(int offsetX, int offsetY, int sizeX, int sizeY)83 boolean onContentDrawn(int offsetX, int offsetY, int sizeX, int sizeY); 84 85 /** 86 * Called to request the window to draw one frame. 87 * @param reportNextDraw Whether it should report when the requested draw finishes. 88 */ onRequestDraw(boolean reportNextDraw)89 void onRequestDraw(boolean reportNextDraw); 90 91 /** 92 * Called after all the content has drawn and the callback now has the ability to draw something 93 * on top of everything. Call {@link ViewRootImpl#requestInvalidateRootRenderNode} when this 94 * content needs to be redrawn. 95 * 96 * @param canvas The canvas to draw on. 97 */ onPostDraw(RecordingCanvas canvas)98 void onPostDraw(RecordingCanvas canvas); 99 } 100