use of android.graphics.Insets in project android_frameworks_base by ParanoidAndroid.
the class View method setMeasuredDimension.
/**
* <p>This method must be called by {@link #onMeasure(int, int)} to store the
* measured width and measured height. Failing to do so will trigger an
* exception at measurement time.</p>
*
* @param measuredWidth The measured width of this view. May be a complex
* bit mask as defined by {@link #MEASURED_SIZE_MASK} and
* {@link #MEASURED_STATE_TOO_SMALL}.
* @param measuredHeight The measured height of this view. May be a complex
* bit mask as defined by {@link #MEASURED_SIZE_MASK} and
* {@link #MEASURED_STATE_TOO_SMALL}.
*/
protected final void setMeasuredDimension(int measuredWidth, int measuredHeight) {
boolean optical = isLayoutModeOptical(this);
if (optical != isLayoutModeOptical(mParent)) {
Insets insets = getOpticalInsets();
int opticalWidth = insets.left + insets.right;
int opticalHeight = insets.top + insets.bottom;
measuredWidth += optical ? opticalWidth : -opticalWidth;
measuredHeight += optical ? opticalHeight : -opticalHeight;
}
mMeasuredWidth = measuredWidth;
mMeasuredHeight = measuredHeight;
mPrivateFlags |= PFLAG_MEASURED_DIMENSION_SET;
}
use of android.graphics.Insets in project android_frameworks_base by ParanoidAndroid.
the class TextView method getBoxHeight.
/////////////////////////////////////////////////////////////////////////
private int getBoxHeight(Layout l) {
Insets opticalInsets = isLayoutModeOptical(mParent) ? getOpticalInsets() : Insets.NONE;
int padding = (l == mHintLayout) ? getCompoundPaddingTop() + getCompoundPaddingBottom() : getExtendedPaddingTop() + getExtendedPaddingBottom();
return getMeasuredHeight() - padding + opticalInsets.top + opticalInsets.bottom;
}
use of android.graphics.Insets in project android_frameworks_base by AOSPA.
the class ViewGroup method computeOpticalInsets.
@Override
Insets computeOpticalInsets() {
if (isLayoutModeOptical()) {
int left = 0;
int top = 0;
int right = 0;
int bottom = 0;
for (int i = 0; i < mChildrenCount; i++) {
View child = getChildAt(i);
if (child.getVisibility() == VISIBLE) {
Insets insets = child.getOpticalInsets();
left = Math.max(left, insets.left);
top = Math.max(top, insets.top);
right = Math.max(right, insets.right);
bottom = Math.max(bottom, insets.bottom);
}
}
return Insets.of(left, top, right, bottom);
} else {
return Insets.NONE;
}
}
use of android.graphics.Insets in project android_frameworks_base by AOSPA.
the class GridLayout method onDebugDraw.
/**
* @hide
*/
@Override
protected void onDebugDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setColor(Color.argb(50, 255, 255, 255));
Insets insets = getOpticalInsets();
int top = getPaddingTop() + insets.top;
int left = getPaddingLeft() + insets.left;
int right = getWidth() - getPaddingRight() - insets.right;
int bottom = getHeight() - getPaddingBottom() - insets.bottom;
int[] xs = mHorizontalAxis.locations;
if (xs != null) {
for (int i = 0, length = xs.length; i < length; i++) {
int x = left + xs[i];
drawLine(canvas, x, top, x, bottom, paint);
}
}
int[] ys = mVerticalAxis.locations;
if (ys != null) {
for (int i = 0, length = ys.length; i < length; i++) {
int y = top + ys[i];
drawLine(canvas, left, y, right, y, paint);
}
}
super.onDebugDraw(canvas);
}
use of android.graphics.Insets in project android_frameworks_base by AOSPA.
the class Switch method onDraw.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
final Rect padding = mTempRect;
final Drawable trackDrawable = mTrackDrawable;
if (trackDrawable != null) {
trackDrawable.getPadding(padding);
} else {
padding.setEmpty();
}
final int switchTop = mSwitchTop;
final int switchBottom = mSwitchBottom;
final int switchInnerTop = switchTop + padding.top;
final int switchInnerBottom = switchBottom - padding.bottom;
final Drawable thumbDrawable = mThumbDrawable;
if (trackDrawable != null) {
if (mSplitTrack && thumbDrawable != null) {
final Insets insets = thumbDrawable.getOpticalInsets();
thumbDrawable.copyBounds(padding);
padding.left += insets.left;
padding.right -= insets.right;
final int saveCount = canvas.save();
canvas.clipRect(padding, Op.DIFFERENCE);
trackDrawable.draw(canvas);
canvas.restoreToCount(saveCount);
} else {
trackDrawable.draw(canvas);
}
}
final int saveCount = canvas.save();
if (thumbDrawable != null) {
thumbDrawable.draw(canvas);
}
final Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
if (switchText != null) {
final int[] drawableState = getDrawableState();
if (mTextColors != null) {
mTextPaint.setColor(mTextColors.getColorForState(drawableState, 0));
}
mTextPaint.drawableState = drawableState;
final int cX;
if (thumbDrawable != null) {
final Rect bounds = thumbDrawable.getBounds();
cX = bounds.left + bounds.right;
} else {
cX = getWidth();
}
final int left = cX / 2 - switchText.getWidth() / 2;
final int top = (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2;
canvas.translate(left, top);
switchText.draw(canvas);
}
canvas.restoreToCount(saveCount);
}
Aggregations