| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromoting; | 5 package org.chromium.chromoting; |
| 6 | 6 |
| 7 import android.graphics.Matrix; | 7 import android.graphics.Matrix; |
| 8 import android.graphics.PointF; | 8 import android.graphics.PointF; |
| 9 import android.graphics.Rect; | 9 import android.graphics.Rect; |
| 10 import android.graphics.RectF; | 10 import android.graphics.RectF; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 * @param deltaX The distance (in image coordinates) to move the cursor alon
g the x-axis. | 118 * @param deltaX The distance (in image coordinates) to move the cursor alon
g the x-axis. |
| 119 * @param deltaY The distance (in image coordinates) to move the cursor alon
g the y-axis. | 119 * @param deltaY The distance (in image coordinates) to move the cursor alon
g the y-axis. |
| 120 * @return A point representing the new cursor position. | 120 * @return A point representing the new cursor position. |
| 121 */ | 121 */ |
| 122 public PointF moveCursorPosition(float deltaX, float deltaY) { | 122 public PointF moveCursorPosition(float deltaX, float deltaY) { |
| 123 setCursorPosition(mCursorPosition.x + deltaX, mCursorPosition.y + deltaY
); | 123 setCursorPosition(mCursorPosition.x + deltaX, mCursorPosition.y + deltaY
); |
| 124 return new PointF(mCursorPosition.x, mCursorPosition.y); | 124 return new PointF(mCursorPosition.x, mCursorPosition.y); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * Sets the offset values used to calculate the space used by System UI. | 128 * Handles System UI size and visibility changes. |
| 129 * | 129 * |
| 130 * @param left The space used by System UI on the left edge of the screen. | 130 * @param parameter The set of values defining the current System UI state. |
| 131 * @param top The space used by System UI on the top edge of the screen. | |
| 132 * @param right The space used by System UI on the right edge of the screen. | |
| 133 * @param bottom The space used by System UI on the bottom edge of the scree
n. | |
| 134 */ | 131 */ |
| 135 public void setSystemUiOffsetValues(int left, int top, int right, int bottom
) { | 132 public void onSystemUiVisibilityChanged(SystemUiVisibilityChangedEventParame
ter parameter) { |
| 136 mSystemUiScreenSize.set(left, top, right, bottom); | 133 if (parameter.systemUiVisible) { |
| 134 mSystemUiScreenSize.set(parameter.left, parameter.top, |
| 135 mRenderData.screenWidth - parameter.right, |
| 136 mRenderData.screenHeight - parameter.bottom); |
| 137 | 137 |
| 138 if (mAdjustViewportForSystemUi) { | 138 if (mAdjustViewportForSystemUi) { |
| 139 // Adjust the cursor position to ensure it's visible when large Syst
em UI (defined as | 139 // Adjust the cursor position to ensure it's visible when large
System UI (1/3 or |
| 140 // 1/3 or more of the total screen size) is displayed. This is typi
cally the Soft | 140 // more of the total screen size) is displayed (typically the So
ft Keyboard). |
| 141 // Keyboard. Without this change, it is difficult for users to enter
text into edit | 141 // Without this change, it is difficult for users to enter text
into edit controls |
| 142 // controls which are located bottom of the screen and may not be ab
le to view their | 142 // which are located bottom of the screen and may not see the cu
rsor at all. |
| 143 // cursor at all. | 143 if (mSystemUiScreenSize.bottom > (mRenderData.screenHeight / 3))
{ |
| 144 if (bottom > (mRenderData.screenHeight / 3)) { | 144 // Center the cursor within the viewable area (not obscured
by System UI). |
| 145 // Center the cursor within the viewable area (not obscured by S
ystem UI). | 145 mCursorOffsetScreenY = (float) parameter.bottom / 2.0f; |
| 146 mCursorOffsetScreenY = (((float) mRenderData.screenHeight - bott
om) / 2.0f); | 146 } else { |
| 147 } else { | 147 mCursorOffsetScreenY = 0.0f; |
| 148 mCursorOffsetScreenY = 0.0f; | 148 } |
| 149 |
| 150 // Apply the cursor offset. |
| 151 setCursorPosition(mCursorPosition.x, mCursorPosition.y); |
| 149 } | 152 } |
| 150 | 153 } else { |
| 151 // Apply the cursor offset. | 154 mCursorOffsetScreenY = 0.0f; |
| 152 setCursorPosition(mCursorPosition.x, mCursorPosition.y); | 155 mSystemUiScreenSize.setEmpty(); |
| 153 } | 156 } |
| 154 } | 157 } |
| 155 | 158 |
| 156 /** Called to indicate that no System UI is visible. */ | |
| 157 public void clearSystemUiOffsets() { | |
| 158 mCursorOffsetScreenY = 0.0f; | |
| 159 mSystemUiScreenSize.setEmpty(); | |
| 160 } | |
| 161 | |
| 162 public void adjustViewportForSystemUi(boolean adjustViewportForSystemUi) { | 159 public void adjustViewportForSystemUi(boolean adjustViewportForSystemUi) { |
| 163 mAdjustViewportForSystemUi = adjustViewportForSystemUi; | 160 mAdjustViewportForSystemUi = adjustViewportForSystemUi; |
| 164 } | 161 } |
| 165 | 162 |
| 166 /** Resizes the image by zooming it such that the image is displayed without
borders. */ | 163 /** Resizes the image by zooming it such that the image is displayed without
borders. */ |
| 167 public void resizeImageToFitScreen() { | 164 public void resizeImageToFitScreen() { |
| 168 // Protect against being called before the image has been initialized. | 165 // Protect against being called before the image has been initialized. |
| 169 if (mRenderData.imageWidth == 0 || mRenderData.imageHeight == 0) { | 166 if (mRenderData.imageWidth == 0 || mRenderData.imageHeight == 0) { |
| 170 return; | 167 return; |
| 171 } | 168 } |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 PointF letterboxPadding = getLetterboxPadding(); | 371 PointF letterboxPadding = getLetterboxPadding(); |
| 375 float[] imagePoints = {0.0f, 0.0f, mRenderData.imageWidth, mRenderData.i
mageHeight}; | 372 float[] imagePoints = {0.0f, 0.0f, mRenderData.imageWidth, mRenderData.i
mageHeight}; |
| 376 mRenderData.transform.mapPoints(imagePoints); | 373 mRenderData.transform.mapPoints(imagePoints); |
| 377 | 374 |
| 378 mVisibleImagePadding.set(Math.max(imagePoints[0] - letterboxPadding.x, 0
.0f), | 375 mVisibleImagePadding.set(Math.max(imagePoints[0] - letterboxPadding.x, 0
.0f), |
| 379 Math.max(imagePoints[1] - letterboxPadding.y, 0.0f), | 376 Math.max(imagePoints[1] - letterboxPadding.y, 0.0f), |
| 380 Math.max(mRenderData.screenWidth - imagePoints[2] - letterboxPad
ding.x, 0.0f), | 377 Math.max(mRenderData.screenWidth - imagePoints[2] - letterboxPad
ding.x, 0.0f), |
| 381 Math.max(mRenderData.screenHeight - imagePoints[3] - letterboxPa
dding.y, 0.0f)); | 378 Math.max(mRenderData.screenHeight - imagePoints[3] - letterboxPa
dding.y, 0.0f)); |
| 382 } | 379 } |
| 383 } | 380 } |
| OLD | NEW |