blob: b2dc1e91bdf7d82f633e8898b6a5564dc5abf20e [file] [log] [blame]
Skuhneb8160872015-09-22 09:51:39 -07001/*
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
17package android.view;
18
19import android.graphics.Rect;
20
21/**
22 * These callbacks are used to communicate window configuration changes while the user is performing
23 * window changes.
Skuhne980ee472015-10-06 11:31:31 -070024 * Note: Note that at the time of onWindowDragResizeStart the content size isn't known. A consumer
25 * should therfore not draw anything before the additional onContentDraw call has arrived.
Skuhneb8160872015-09-22 09:51:39 -070026 * @hide
27 */
28public interface WindowCallbacks {
Jorim Jaggic39c7b02016-03-24 10:47:07 -070029
30 public static final int RESIZE_MODE_INVALID = -1;
31 public static final int RESIZE_MODE_FREEFORM = 0;
32 public static final int RESIZE_MODE_DOCKED_DIVIDER = 1;
33
Skuhneb8160872015-09-22 09:51:39 -070034 /**
35 * Called by the system when the window got changed by the user, before the layouter got called.
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080036 * It also gets called when the insets changed, or when the window switched between a fullscreen
37 * layout or a non-fullscreen layout. It can be used to perform a "quick and dirty" resize which
38 * should never take more then 4ms to complete.
Skuhneb8160872015-09-22 09:51:39 -070039 *
40 * <p>At the time the layouting has not happened yet.
41 *
42 * @param newBounds The new window frame bounds.
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080043 * @param fullscreen Whether the window is currently drawing in fullscreen.
44 * @param systemInsets The current visible system insets for the window.
45 * @param stableInsets The stable insets for the window.
Skuhneb8160872015-09-22 09:51:39 -070046 */
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080047 void onWindowSizeIsChanging(Rect newBounds, boolean fullscreen, Rect systemInsets,
48 Rect stableInsets);
Skuhneb8160872015-09-22 09:51:39 -070049
50 /**
51 * Called when a drag resize starts.
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080052 *
Skuhneb8160872015-09-22 09:51:39 -070053 * @param initialBounds The initial bounds where the window will be.
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080054 * @param fullscreen Whether the window is currently drawing in fullscreen.
55 * @param systemInsets The current visible system insets for the window.
56 * @param stableInsets The stable insets for the window.
Skuhneb8160872015-09-22 09:51:39 -070057 */
Jorim Jaggi9511b0f2016-01-29 19:12:44 -080058 void onWindowDragResizeStart(Rect initialBounds, boolean fullscreen, Rect systemInsets,
Jorim Jaggic39c7b02016-03-24 10:47:07 -070059 Rect stableInsets, int resizeMode);
Skuhneb8160872015-09-22 09:51:39 -070060
61 /**
62 * Called when a drag resize ends.
63 */
64 void onWindowDragResizeEnd();
Skuhne980ee472015-10-06 11:31:31 -070065
66 /**
Chong Zhang8dbd9ad2015-10-09 10:06:11 -070067 * The content will now be drawn to these bounds. Returns true if
68 * a draw should be requested after the next content draw.
Skuhne980ee472015-10-06 11:31:31 -070069 */
Chong Zhang8dbd9ad2015-10-09 10:06:11 -070070 boolean onContentDrawn(int offsetX, int offsetY, int sizeX, int sizeY);
71
72 /**
73 * Called to request the window to draw one frame.
74 * @param reportNextDraw Whether it should report when the requested draw finishes.
75 */
76 void onRequestDraw(boolean reportNextDraw);
Jorim Jaggic39c7b02016-03-24 10:47:07 -070077
78 /**
79 * Called after all the content has drawn and the callback now has the ability to draw something
80 * on top of everything. Call {@link ViewRootImpl#requestInvalidateRootRenderNode} when this
81 * content needs to be redrawn.
82 *
83 * @param canvas The canvas to draw on.
84 */
85 void onPostDraw(DisplayListCanvas canvas);
Skuhneb8160872015-09-22 09:51:39 -070086}