Commit 22cb3f63 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS][Overlay] Round the corners on the Bar, etc.

Uses the existing 9-patch image from the Bottom Sheet for the Preview Tab
Overlay Panel and Tap to Search as well.

Increases the Bar height slightly, and makes the height no longer
variable (was needed for the promo-in-the-bar).

BUG=961454

Change-Id: I9edfef49ce2c37c4ad8bfd8a5dc67f5128dae93c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1606582
Commit-Queue: Donn Denman <donnd@chromium.org>
Auto-Submit: Donn Denman <donnd@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarJinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690044}
parent c2027249
......@@ -106,6 +106,7 @@
<!-- Overlay Panel colors -->
<color name="overlay_panel_bar_background_color">@color/default_bg_color_elev_2</color>
<color name="overlay_panel_separator_line_color">@color/modern_secondary_color</color>
<!-- Contextual Search colors -->
<color name="contextual_search_promo_background_color">@color/default_bg_color_elev_0</color>
......
......@@ -137,7 +137,8 @@
<dimen name="contextual_search_bubble_y_inset">-3dp</dimen>
<!-- Overlay panel dimensions -->
<dimen name="overlay_panel_bar_height">56dp</dimen>
<dimen name="overlay_panel_bar_height_legacy">56dp</dimen>
<dimen name="overlay_panel_bar_height">60dp</dimen>
<!-- Autofill keyboard accessory dimensions -->
<dimen name="keyboard_accessory_height_with_shadow">56dp</dimen>
......
......@@ -110,15 +110,6 @@ abstract class OverlayPanelBase {
/** The height of the Toolbar in dps. */
private float mToolbarHeight;
/** The height of the Bar when the Panel is peeking, in dps. */
private final float mBarHeightPeeking;
/** The height of the Bar when the Panel is expanded, in dps. */
private final float mBarHeightExpanded;
/** The height of the Bar when the Panel is maximized, in dps. */
private final float mBarHeightMaximized;
/** The background color of the Bar. */
private final @ColorInt int mBarBackgroundColor;
......@@ -154,18 +145,14 @@ abstract class OverlayPanelBase {
mContext = context;
mPxToDp = 1.f / mContext.getResources().getDisplayMetrics().density;
mBarHeightPeeking =
mContext.getResources().getDimension(R.dimen.overlay_panel_bar_height) * mPxToDp;
mBarHeightMaximized =
mContext.getResources().getDimension(R.dimen.toolbar_height_no_shadow) * mPxToDp;
mBarHeightExpanded = Math.round((mBarHeightPeeking + mBarHeightMaximized) / 2.f);
mBarMarginSide = BAR_ICON_SIDE_PADDING_DP;
mBarMarginTop = BAR_ICON_TOP_PADDING_DP;
mProgressBarHeight = PROGRESS_BAR_HEIGHT_DP;
mBarBorderHeight = BAR_BORDER_HEIGHT_DP;
mBarHeight = mBarHeightPeeking;
int bar_height_dimen = isNewLayout() ? R.dimen.overlay_panel_bar_height
: R.dimen.overlay_panel_bar_height_legacy;
mBarHeight = mContext.getResources().getDimension(bar_height_dimen) * mPxToDp;
final Resources resources = mContext.getResources();
mBarBackgroundColor = ApiCompatibilityUtils.getColor(
......@@ -175,6 +162,8 @@ abstract class OverlayPanelBase {
ApiCompatibilityUtils.getColor(resources, R.color.drag_handlebar_color);
mButtonPaddingDps =
(int) (mPxToDp * resources.getDimension(R.dimen.overlay_panel_button_padding));
mBarShadowVisible = true;
mPanelShadowVisible = !isNewLayout();
}
// ============================================================================================
......@@ -356,20 +345,22 @@ abstract class OverlayPanelBase {
return getBarHeight();
}
/**
* @return The width of the Overlay Panel Content View in pixels.
*/
/** @return The width of the Overlay Panel Content View in pixels. */
public int getContentViewWidthPx() {
return getMaximumWidthPx();
}
/**
* @return The height of the Overlay Panel Content View in pixels.
*/
/** @return The height of the Overlay Panel Content View in pixels. */
public int getContentViewHeightPx() {
return Math.round(mMaximumHeight / mPxToDp);
}
/** @return Whether we're using the new Overlay layout feature. */
private boolean isNewLayout() {
return ChromeFeatureList.isInitialized()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT);
}
// ============================================================================================
// UI States
// ============================================================================================
......@@ -423,13 +414,13 @@ abstract class OverlayPanelBase {
// --------------------------------------------------------------------------------------------
private final float mBarMarginSide;
private final float mBarMarginTop;
private final boolean mBarShadowVisible;
private final boolean mPanelShadowVisible;
private float mBarHeight;
private boolean mIsBarBorderVisible;
private float mBarBorderHeight;
private boolean mBarShadowVisible;
private float mBarShadowOpacity;
private float mArrowIconOpacity;
private float mCloseIconOpacity;
......@@ -473,24 +464,24 @@ abstract class OverlayPanelBase {
}
/**
* @return Whether the Bar shadow is visible.
* @return Whether the Bar shadow is visible (between the Bar and content).
*/
public boolean getBarShadowVisible() {
return mBarShadowVisible;
}
/**
* @return The opacity of the Bar shadow.
* @return The background color of the Bar.
*/
public float getBarShadowOpacity() {
return mBarShadowOpacity;
public int getBarBackgroundColor() {
return mBarBackgroundColor;
}
/**
* @return The background color of the Bar.
* @return Whether the shadow for the entire Panel & Bar is visible.
*/
public int getBarBackgroundColor() {
return mBarBackgroundColor;
public boolean getPanelShadowVisible() {
return mPanelShadowVisible;
}
/**
......@@ -507,13 +498,17 @@ abstract class OverlayPanelBase {
return mDragHandlebarColor;
}
/** @return the color to use to draw the separator between the Bar and Content. */
public int getSeparatorLineColor() {
return ApiCompatibilityUtils.getColor(
mContext.getResources(), R.color.overlay_panel_separator_line_color);
}
/**
* @return The opacity of the arrow icon.
*/
public float getArrowIconOpacity() {
return ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT)
? ARROW_ICON_OPACITY_TRANSPARENT
: mArrowIconOpacity;
return isNewLayout() ? ARROW_ICON_OPACITY_TRANSPARENT : mArrowIconOpacity;
}
/**
......@@ -760,7 +755,7 @@ abstract class OverlayPanelBase {
* @return The peeked height of the panel in dps.
*/
protected float getPeekedHeight() {
return mBarHeightPeeking;
return getBarHeight();
}
/**
......@@ -821,7 +816,8 @@ abstract class OverlayPanelBase {
int nextState = PanelState.UNDEFINED;
@PanelState
int prevState = nextState;
for (@PanelState int state = 0; state < PanelState.NUM_ENTRIES; state++) {
for (@PanelState int state = PanelState.UNDEFINED; state < PanelState.NUM_ENTRIES;
state++) {
if (!isValidUiState(state)) continue;
prevState = nextState;
nextState = state;
......@@ -935,7 +931,8 @@ abstract class OverlayPanelBase {
// Iterate over all states and find the largest one which is being
// transitioned to/from.
for (@PanelState int state = 0; state < PanelState.NUM_ENTRIES; state++) {
for (@PanelState int state = PanelState.UNDEFINED; state < PanelState.NUM_ENTRIES;
state++) {
if (!isValidUiState(state)) continue;
if (panelHeight <= getPanelHeightFromState(state)) {
stateFound = state;
......@@ -986,9 +983,6 @@ abstract class OverlayPanelBase {
// Base page brightness.
mBasePageBrightness = BASE_PAGE_BRIGHTNESS_STATE_PEEKED;
// Bar height.
mBarHeight = mBarHeightPeeking;
// Bar border.
mIsBarBorderVisible = false;
......@@ -1000,9 +994,6 @@ abstract class OverlayPanelBase {
// Progress Bar.
mProgressBarOpacity = 0.f;
// Update the Bar Shadow.
updateBarShadow();
}
/**
......@@ -1028,12 +1019,6 @@ abstract class OverlayPanelBase {
BASE_PAGE_BRIGHTNESS_STATE_EXPANDED,
percentage);
// Bar height.
mBarHeight = Math.round(MathUtils.interpolate(
mBarHeightPeeking,
getBarHeightExpanded(),
percentage));
// Bar border.
mIsBarBorderVisible = true;
......@@ -1062,9 +1047,6 @@ abstract class OverlayPanelBase {
// Fades the Progress Bar the closer it gets to the bottom of the
// screen.
mProgressBarOpacity = MathUtils.interpolate(0.f, 1.f, diff / threshold);
// Update the Bar Shadow.
updateBarShadow();
}
/**
......@@ -1091,14 +1073,6 @@ abstract class OverlayPanelBase {
BASE_PAGE_BRIGHTNESS_STATE_MAXIMIZED,
percentage);
// Bar height.
float startBarHeight = supportsExpandedState
? getBarHeightExpanded() : getBarHeightPeeking();
mBarHeight = Math.round(MathUtils.interpolate(
startBarHeight,
getBarHeightMaximized(),
percentage));
// Bar border.
mIsBarBorderVisible = true;
......@@ -1110,9 +1084,6 @@ abstract class OverlayPanelBase {
// Progress Bar.
mProgressBarOpacity = 1.f;
// Update the Bar Shadow.
updateBarShadow();
}
/** Updates the Status Bar. */
......@@ -1128,43 +1099,6 @@ abstract class OverlayPanelBase {
return BASE_PAGE_BRIGHTNESS_STATE_MAXIMIZED;
}
private float getBarHeightExpanded() {
return isFullWidthSizePanel() ? mBarHeightExpanded : mBarHeightPeeking;
}
private float getBarHeightMaximized() {
return isFullWidthSizePanel() ? mBarHeightMaximized : mBarHeightPeeking;
}
/**
* @return The peeking height of the panel's bar in dp.
*/
protected float getBarHeightPeeking() {
return mBarHeightPeeking;
}
/**
* Updates the UI state for Bar Shadow.
*/
protected void updateBarShadow() {
float barShadowOpacity = calculateBarShadowOpacity();
if (barShadowOpacity > 0.f) {
mBarShadowVisible = true;
mBarShadowOpacity = barShadowOpacity;
} else {
mBarShadowVisible = false;
mBarShadowOpacity = 0.f;
}
}
/**
* @return The new opacity value for the Bar Shadow.
*/
protected float calculateBarShadowOpacity() {
return 0.f;
}
// ============================================================================================
// Base Page Offset
// ============================================================================================
......
......@@ -27,7 +27,6 @@ import org.chromium.chrome.browser.contextualsearch.ContextualSearchFieldTrial;
import org.chromium.chrome.browser.contextualsearch.ContextualSearchManagementDelegate;
import org.chromium.chrome.browser.contextualsearch.ResolvedSearchTerm.CardTag;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.util.MathUtils;
import org.chromium.chrome.browser.widget.ScrimView;
import org.chromium.chrome.browser.widget.ScrimView.ScrimParams;
import org.chromium.ui.base.LocalizationUtils;
......@@ -195,15 +194,6 @@ public class ContextualSearchPanel extends OverlayPanel {
return canDisplayContentInPanel() || state != PanelState.MAXIMIZED;
}
@Override
protected float getExpandedHeight() {
if (canDisplayContentInPanel()) {
return super.getExpandedHeight();
} else {
return getBarHeightPeeking() + getPromoHeightPx() * mPxToDp;
}
}
@Override
protected @PanelState int getProjectedState(float velocity) {
@PanelState
......@@ -374,18 +364,7 @@ public class ContextualSearchPanel extends OverlayPanel {
@Override
protected float getPeekedHeight() {
return getBarHeightPeeking() + getBarBannerControl().getHeightPeekingPx() * mPxToDp;
}
@Override
protected float calculateBarShadowOpacity() {
float barShadowOpacity = 0.f;
if (getPromoHeightPx() > 0.f) {
float threshold = 2 * mBarShadowHeightPx;
barShadowOpacity = getPromoHeightPx() > mBarShadowHeightPx ? 1.f
: MathUtils.interpolate(0.f, 1.f, getPromoHeightPx() / threshold);
}
return barShadowOpacity;
return getBarHeight() + getBarBannerControl().getHeightPeekingPx() * mPxToDp;
}
@Override
......@@ -890,6 +869,7 @@ public class ContextualSearchPanel extends OverlayPanel {
}
/**
* TODO(donnd): get rid of this promo stuff, no longer used.
* @return An implementation of {@link ContextualSearchPromoHost}.
*/
private ContextualSearchPromoHost getContextualSearchPromoHost() {
......@@ -909,9 +889,7 @@ public class ContextualSearchPanel extends OverlayPanel {
}
@Override
public void onUpdatePromoAppearance() {
ContextualSearchPanel.this.updateBarShadow();
}
public void onUpdatePromoAppearance() {}
};
}
......
......@@ -193,7 +193,7 @@ public class EphemeralTabPanel extends OverlayPanel {
@Override
protected float getPeekedHeight() {
return getBarHeightPeeking() * 1.5f;
return getBarHeight() * 1.5f;
}
@Override
......
......@@ -113,7 +113,6 @@ public class ContextualSearchSceneLayer extends SceneOverlayLayer {
float searchBarBorderHeight = panel.getBarBorderHeight();
boolean searchBarShadowVisible = panel.getBarShadowVisible();
float searchBarShadowOpacity = panel.getBarShadowOpacity();
final int iconColor = panel.getIconColor();
final int dragHandlebarColor = panel.getDragHandlebarColor();
......@@ -141,7 +140,16 @@ public class ContextualSearchSceneLayer extends SceneOverlayLayer {
WebContents panelWebContents = panel.getWebContents();
nativeUpdateContextualSearchLayer(mNativePtr, R.drawable.contextual_search_bar_background,
int roundedBarTopResourceId =
ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT)
? R.drawable.top_round
: INVALID_RESOURCE_ID;
int separatorLineColor = panel.getSeparatorLineColor();
int panelShadowResourceId = panel.getPanelShadowVisible()
? R.drawable.contextual_search_bar_background
: INVALID_RESOURCE_ID;
nativeUpdateContextualSearchLayer(mNativePtr, panelShadowResourceId,
searchBarBackgroundColor, searchContextViewId, searchTermViewId,
searchCaptionViewId, R.drawable.modern_toolbar_shadow,
R.drawable.ic_logo_googleg_24dp, quickActionIconResId, R.drawable.breadcrumb_arrow,
......@@ -161,14 +169,14 @@ public class ContextualSearchSceneLayer extends SceneOverlayLayer {
searchBarControl.getTextLayerMinHeight(), searchTermOpacity,
searchBarControl.getSearchTermCaptionSpacing(), searchCaptionAnimationPercentage,
searchCaptionVisible, searchBarBorderVisible, searchBarBorderHeight * mDpToPx,
searchBarShadowVisible, searchBarShadowOpacity, quickActionIconVisible,
thumbnailVisible, thumbnailUrl, customImageVisibilityPercentage, barImageSize,
iconColor, dragHandlebarColor, arrowIconOpacity, arrowIconRotation,
closeIconOpacity, isProgressBarVisible, progressBarHeight * mDpToPx,
progressBarOpacity, progressBarCompletion, dividerLineVisibilityPercentage,
dividerLineWidth, dividerLineHeight, dividerLineColor, dividerLineXOffset,
touchHighlightVisible, touchHighlightXOffset, touchHighlightWidth,
Profile.getLastUsedProfile());
searchBarShadowVisible, quickActionIconVisible, thumbnailVisible, thumbnailUrl,
customImageVisibilityPercentage, barImageSize, iconColor, dragHandlebarColor,
arrowIconOpacity, arrowIconRotation, closeIconOpacity, isProgressBarVisible,
progressBarHeight * mDpToPx, progressBarOpacity, progressBarCompletion,
dividerLineVisibilityPercentage, dividerLineWidth, dividerLineHeight,
dividerLineColor, dividerLineXOffset, touchHighlightVisible, touchHighlightXOffset,
touchHighlightWidth, Profile.getLastUsedProfile(), roundedBarTopResourceId,
separatorLineColor);
}
@CalledByNative
......@@ -235,13 +243,13 @@ public class ContextualSearchSceneLayer extends SceneOverlayLayer {
float searchTextLayerMinHeight, float searchTermOpacity, float searchTermCaptionSpacing,
float searchCaptionAnimationPercentage, boolean searchCaptionVisible,
boolean searchBarBorderVisible, float searchBarBorderHeight,
boolean searchBarShadowVisible, float searchBarShadowOpacity,
boolean quickActionIconVisible, boolean thumbnailVisible, String thumbnailUrl,
float customImageVisibilityPercentage, int barImageSize, int iconColor,
int dragHandlebarColor, float arrowIconOpacity, float arrowIconRotation,
float closeIconOpacity, boolean isProgressBarVisible, float progressBarHeight,
float progressBarOpacity, int progressBarCompletion,
boolean searchBarShadowVisible, boolean quickActionIconVisible,
boolean thumbnailVisible, String thumbnailUrl, float customImageVisibilityPercentage,
int barImageSize, int iconColor, int dragHandlebarColor, float arrowIconOpacity,
float arrowIconRotation, float closeIconOpacity, boolean isProgressBarVisible,
float progressBarHeight, float progressBarOpacity, int progressBarCompletion,
float dividerLineVisibilityPercentage, float dividerLineWidth, float dividerLineHeight,
int dividerLineColor, float dividerLineXOffset, boolean touchHighlightVisible,
float touchHighlightXOffset, float toucHighlightWidth, Profile profile);
float touchHighlightXOffset, float toucHighlightWidth, Profile profile,
int barBackgroundResourceId, int separatorLineColor);
}
......@@ -75,10 +75,15 @@ public class EphemeralTabSceneLayer extends SceneOverlayLayer {
int dragHandlebarId = ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT)
? R.drawable.drag_handlebar
: INVALID_RESOURCE_ID;
nativeSetResourceIds(mNativePtr, title.getViewId(),
R.drawable.contextual_search_bar_background, R.drawable.modern_toolbar_shadow,
R.drawable.infobar_chrome, dragHandlebarId, openInTabIconId,
R.drawable.btn_close);
int roundedBarTopId = ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT)
? R.drawable.top_round
: INVALID_RESOURCE_ID;
int panelShadowResourceId = panel.getPanelShadowVisible()
? R.drawable.contextual_search_bar_background
: INVALID_RESOURCE_ID;
nativeSetResourceIds(mNativePtr, title.getViewId(), panelShadowResourceId,
roundedBarTopId, R.drawable.modern_toolbar_shadow, R.drawable.infobar_chrome,
dragHandlebarId, openInTabIconId, R.drawable.btn_close);
mIsInitialized = true;
}
......@@ -95,6 +100,7 @@ public class EphemeralTabSceneLayer extends SceneOverlayLayer {
float progressBarHeight = panel.getProgressBarHeight();
float progressBarOpacity = panel.getProgressBarOpacity();
int progressBarCompletion = panel.getProgressBarCompletion();
int separatorLineColor = panel.getSeparatorLineColor();
WebContents panelWebContents = panel.getWebContents();
nativeUpdate(mNativePtr, titleViewId, captionViewId, captionAnimationPercentage,
......@@ -106,9 +112,9 @@ public class EphemeralTabSceneLayer extends SceneOverlayLayer {
panel.getBarBackgroundColor(), panel.getBarMarginSide() * mDpToPx,
panel.getBarMarginTop() * mDpToPx, panel.getBarHeight() * mDpToPx,
panel.isBarBorderVisible(), panel.getBarBorderHeight() * mDpToPx,
panel.getBarShadowVisible(), panel.getBarShadowOpacity(), panel.getIconColor(),
panel.getDragHandlebarColor(), panel.getFaviconOpacity(), isProgressBarVisible,
progressBarHeight * mDpToPx, progressBarOpacity, progressBarCompletion);
panel.getBarShadowVisible(), panel.getIconColor(), panel.getDragHandlebarColor(),
panel.getFaviconOpacity(), isProgressBarVisible, progressBarHeight * mDpToPx,
progressBarOpacity, progressBarCompletion, separatorLineColor);
}
@Override
......@@ -147,9 +153,9 @@ public class EphemeralTabSceneLayer extends SceneOverlayLayer {
long nativeEphemeralTabSceneLayer, SceneLayer contentTree);
private native void nativeHideTree(long nativeEphemeralTabSceneLayer);
private native void nativeSetResourceIds(long nativeEphemeralTabSceneLayer,
int barTextResourceId, int barBackgroundResourceId, int barShadowResourceId,
int panelIconResourceId, int dragHandlebarResourceId, int openTabIconResourceId,
int closeIconResourceId);
int barTextResourceId, int barBackgroundResourceId, int roundedBarTopResourceId,
int barShadowResourceId, int panelIconResourceId, int dragHandlebarResourceId,
int openTabIconResourceId, int closeIconResourceId);
private native void nativeUpdate(long nativeEphemeralTabSceneLayer, int titleViewId,
int captionViewId, float captionAnimationPercentage, float textLayerMinHeight,
float titleCaptionSpacing, boolean captionVisible, int progressBarBackgroundResourceId,
......@@ -157,7 +163,7 @@ public class EphemeralTabSceneLayer extends SceneOverlayLayer {
float basePageYOffset, WebContents webContents, float panelX, float panelY,
float panelWidth, float panelHeight, int barBackgroundColor, float barMarginSide,
float barMarginTop, float barHeight, boolean barBorderVisible, float barBorderHeight,
boolean barShadowVisible, float barShadowOpacity, int iconColor, int dragHandlebarColor,
float faviconOpacity, boolean isProgressBarVisible, float progressBarHeight,
float progressBarOpacity, int progressBarCompletion);
boolean barShadowVisible, int iconColor, int dragHandlebarColor, float faviconOpacity,
boolean isProgressBarVisible, float progressBarHeight, float progressBarOpacity,
int progressBarCompletion, int separatorLineColor);
}
......@@ -78,7 +78,6 @@ void ContextualSearchLayer::SetProperties(
bool search_bar_border_visible,
float search_bar_border_height,
bool search_bar_shadow_visible,
float search_bar_shadow_opacity,
bool quick_action_icon_visible,
bool thumbnail_visible,
float custom_image_visibility_percentage,
......@@ -99,7 +98,9 @@ void ContextualSearchLayer::SetProperties(
float divider_line_x_offset,
bool touch_highlight_visible,
float touch_highlight_x_offset,
float touch_highlight_width) {
float touch_highlight_width,
int rounded_bar_top_resource_id,
int separator_line_color) {
// Round values to avoid pixel gap between layers.
search_bar_height = floor(search_bar_height);
......@@ -110,9 +111,9 @@ void ContextualSearchLayer::SetProperties(
OverlayPanelLayer::SetResourceIds(
search_term_resource_id, panel_shadow_resource_id,
search_bar_shadow_resource_id, search_provider_icon_resource_id,
drag_handlebar_resource_id, open_tab_icon_resource_id,
close_icon_resource_id);
rounded_bar_top_resource_id, search_bar_shadow_resource_id,
search_provider_icon_resource_id, drag_handlebar_resource_id,
open_tab_icon_resource_id, close_icon_resource_id);
float content_view_top = search_bar_bottom + search_promo_height;
float should_render_bar_border = search_bar_border_visible
......@@ -126,9 +127,8 @@ void ContextualSearchLayer::SetProperties(
search_panel_width, search_panel_height, search_bar_background_color,
search_bar_margin_side, search_bar_margin_top, search_bar_height,
search_bar_top, search_term_opacity, should_render_bar_border,
search_bar_border_height, search_bar_shadow_visible,
search_bar_shadow_opacity, icon_color, drag_handlebar_color,
close_icon_opacity);
search_bar_border_height, search_bar_shadow_visible, icon_color,
drag_handlebar_color, close_icon_opacity, separator_line_color);
bool is_rtl = l10n_util::IsLayoutRtl();
......
......@@ -76,7 +76,6 @@ class ContextualSearchLayer : public OverlayPanelLayer {
bool search_bar_border_visible,
float search_bar_border_height,
bool search_bar_shadow_visible,
float search_bar_shadow_opacity,
bool quick_action_icon_visible,
bool thumbnail_visible,
float custom_image_visibility_percentage,
......@@ -97,7 +96,9 @@ class ContextualSearchLayer : public OverlayPanelLayer {
float divider_line_x_offset,
bool touch_highlight_visible,
float touch_highlight_x_offset,
float touch_highlight_width);
float touch_highlight_width,
int rounded_bar_top_resource_id,
int separator_line_color);
void SetThumbnail(const SkBitmap* thumbnail);
......
......@@ -77,14 +77,14 @@ void EphemeralTabLayer::SetProperties(
bool bar_border_visible,
float bar_border_height,
bool bar_shadow_visible,
float bar_shadow_opacity,
int icon_color,
int drag_handlebar_color,
jfloat favicon_opacity,
bool progress_bar_visible,
float progress_bar_height,
float progress_bar_opacity,
int progress_bar_completion) {
int progress_bar_completion,
int separator_line_color) {
if (web_contents_ != web_contents) {
web_contents_ = web_contents;
if (web_contents_) {
......@@ -107,8 +107,8 @@ void EphemeralTabLayer::SetProperties(
dp_to_px, content_layer, bar_height, panel_x, panel_y, panel_width,
panel_height, bar_background_color, bar_margin_side, bar_margin_top,
bar_height, 0.0f, title_opacity, bar_border_visible, bar_border_height,
bar_shadow_visible, bar_shadow_opacity, icon_color, drag_handlebar_color,
1.0f /* icon opacity */);
bar_shadow_visible, icon_color, drag_handlebar_color,
1.0f /* icon opacity */, separator_line_color);
SetupTextLayer(bar_top, bar_height, text_layer_min_height,
caption_view_resource_id, caption_animation_percentage,
......
......@@ -59,14 +59,14 @@ class EphemeralTabLayer : public OverlayPanelLayer,
bool bar_border_visible,
float bar_border_height,
bool bar_shadow_visible,
float bar_shadow_opacity,
int icon_color,
int drag_handlebar_color,
jfloat favicon_opacity,
bool progress_bar_visible,
float progress_bar_height,
float progress_bar_opacity,
int progress_bar_completion);
int progress_bar_completion,
int separator_line_color);
void SetupTextLayer(float bar_top,
float bar_height,
float text_layer_min_height,
......
......@@ -21,7 +21,7 @@ const float OverlayPanelLayer::kDefaultIconWidthDp = 36.0f;
const int OverlayPanelLayer::kInvalidResourceID = -1;
scoped_refptr<cc::Layer> OverlayPanelLayer::GetIconLayer() {
if (panel_icon_resource_id_ == -1)
if (panel_icon_resource_id_ == kInvalidResourceID)
return nullptr;
ui::Resource* panel_icon_resource = resource_manager_->GetResource(
ui::ANDROID_RESOURCE_TYPE_STATIC, panel_icon_resource_id_);
......@@ -38,11 +38,15 @@ scoped_refptr<cc::Layer> OverlayPanelLayer::GetIconLayer() {
}
void OverlayPanelLayer::AddBarTextLayer(scoped_refptr<cc::Layer> text_layer) {
if (text_container_->parent() != layer_)
layer_->AddChild(text_container_);
if (text_layer->parent() != text_container_)
text_container_->AddChild(text_layer);
}
void OverlayPanelLayer::SetResourceIds(int bar_text_resource_id,
int panel_shadow_resource_id,
int rounded_bar_top_resource_id,
int bar_shadow_resource_id,
int panel_icon_resource_id,
int drag_handlebar_resource_id,
......@@ -50,6 +54,7 @@ void OverlayPanelLayer::SetResourceIds(int bar_text_resource_id,
int close_icon_resource_id) {
bar_text_resource_id_ = bar_text_resource_id;
panel_shadow_resource_id_ = panel_shadow_resource_id;
rounded_bar_top_resource_id_ = rounded_bar_top_resource_id;
bar_shadow_resource_id_ = bar_shadow_resource_id;
panel_icon_resource_id_ = panel_icon_resource_id;
drag_handlebar_resource_id_ = drag_handlebar_resource_id;
......@@ -74,35 +79,36 @@ void OverlayPanelLayer::SetProperties(
bool bar_border_visible,
float bar_border_height,
bool bar_shadow_visible,
float bar_shadow_opacity,
int icon_tint,
int drag_handlebar_tint,
float icon_opacity) {
// Grabs required static resources.
ui::NinePatchResource* panel_shadow_resource =
ui::NinePatchResource::From(resource_manager_->GetResource(
ui::ANDROID_RESOURCE_TYPE_STATIC, panel_shadow_resource_id_));
DCHECK(panel_shadow_resource);
float icon_opacity,
int separator_line_color) {
// Round values to avoid pixel gap between layers.
bar_height = floor(bar_height);
float bar_top = bar_offset_y;
float bar_bottom = bar_top + bar_height;
float bar_top_y = bar_offset_y;
float bar_bottom = bar_top_y + bar_height;
bool is_rtl = l10n_util::IsLayoutRtl();
// ---------------------------------------------------------------------------
// Panel Shadow
// ---------------------------------------------------------------------------
if (panel_shadow_resource_id_ != kInvalidResourceID) {
if (panel_shadow_->parent() != layer_) {
layer_->AddChild(panel_shadow_);
}
ui::NinePatchResource* panel_shadow_resource =
ui::NinePatchResource::From(resource_manager_->GetResource(
ui::ANDROID_RESOURCE_TYPE_STATIC, panel_shadow_resource_id_));
DCHECK(panel_shadow_resource);
gfx::Size shadow_res_size = panel_shadow_resource->size();
gfx::Rect shadow_res_padding = panel_shadow_resource->padding();
gfx::Size shadow_bounds(
panel_width + shadow_res_size.width()
- shadow_res_padding.size().width(),
panel_height + shadow_res_size.height()
- shadow_res_padding.size().height());
gfx::Size shadow_bounds(panel_width + shadow_res_size.width() -
shadow_res_padding.size().width(),
panel_height + shadow_res_size.height() -
shadow_res_padding.size().height());
panel_shadow_->SetUIResourceId(panel_shadow_resource->ui_resource()->id());
panel_shadow_->SetBorder(panel_shadow_resource->Border(shadow_bounds));
panel_shadow_->SetAperture(panel_shadow_resource->aperture());
......@@ -110,13 +116,54 @@ void OverlayPanelLayer::SetProperties(
gfx::PointF shadow_position(-shadow_res_padding.origin().x(),
-shadow_res_padding.origin().y());
panel_shadow_->SetPosition(shadow_position);
}
int rounded_top_adjust = 0;
// ---------------------------------------------------------------------------
// Rounded Bar Top
// ---------------------------------------------------------------------------
if (rounded_bar_top_resource_id_ != kInvalidResourceID) {
rounded_bar_top_->SetIsDrawable(true);
ui::NinePatchResource* rounded_bar_top_resource =
ui::NinePatchResource::From(resource_manager_->GetResource(
ui::ANDROID_RESOURCE_TYPE_STATIC, rounded_bar_top_resource_id_));
DCHECK(rounded_bar_top_resource);
const gfx::Size rounded_bar_top_size(
rounded_bar_top_resource->size().width() -
rounded_bar_top_resource->padding().width(),
rounded_bar_top_resource->size().height() -
rounded_bar_top_resource->padding().height());
const int vertical_fudge_factor = 1; // gets rid of a seam.
rounded_top_adjust = rounded_bar_top_size.height() - vertical_fudge_factor;
gfx::PointF rounded_bar_top_position(
-rounded_bar_top_resource->padding().x(),
bar_top_y - rounded_top_adjust);
gfx::Size bounds(panel_width - rounded_bar_top_size.width(),
rounded_bar_top_resource->size().height());
rounded_bar_top_->SetUIResourceId(
rounded_bar_top_resource->ui_resource()->id());
rounded_bar_top_->SetBounds(bounds);
rounded_bar_top_->SetAperture(rounded_bar_top_resource->aperture());
rounded_bar_top_->SetBorder(rounded_bar_top_resource->Border(bounds));
rounded_bar_top_->SetPosition(rounded_bar_top_position);
rounded_bar_top_->SetOpacity(1.0f);
}
// ---------------------------------------------------------------------------
// Bar Background
// ---------------------------------------------------------------------------
gfx::Size background_size(panel_width, bar_height);
// If we have a rounded_bar_top then it draws the top part of the bar
// background.
gfx::Size background_size(panel_width, bar_height - rounded_top_adjust);
bar_background_->SetBounds(background_size);
bar_background_->SetPosition(gfx::PointF(0.f, bar_top));
bar_background_->SetPosition(
gfx::PointF(0.f, bar_top_y + rounded_top_adjust));
bar_background_->SetBackgroundColor(bar_background_color);
// ---------------------------------------------------------------------------
......@@ -128,7 +175,7 @@ void OverlayPanelLayer::SetProperties(
if (bar_text_resource) {
// Centers the text vertically in the Search Bar.
float bar_padding_top =
bar_top + bar_height / 2 - bar_text_resource->size().height() / 2;
bar_top_y + bar_height / 2 - bar_text_resource->size().height() / 2;
bar_text_->SetUIResourceId(bar_text_resource->ui_resource()->id());
bar_text_->SetBounds(bar_text_resource->size());
bar_text_->SetPosition(gfx::PointF(0.f, bar_padding_top));
......@@ -155,7 +202,8 @@ void OverlayPanelLayer::SetProperties(
}
// Centers the Icon vertically in the bar.
float icon_y = bar_top + bar_height / 2 - icon_layer->bounds().height() / 2;
float icon_y =
bar_top_y + bar_height / 2 - icon_layer->bounds().height() / 2;
icon_layer->SetPosition(gfx::PointF(icon_x, icon_y));
}
......@@ -163,7 +211,10 @@ void OverlayPanelLayer::SetProperties(
// ---------------------------------------------------------------------------
// Drag Handlebar
// ---------------------------------------------------------------------------
if (drag_handlebar_resource_id_ != 0 && drag_handlebar_resource_id_ != -1) {
if (drag_handlebar_resource_id_ != kInvalidResourceID) {
if (drag_handlebar_->parent() != layer_)
layer_->AddChild(drag_handlebar_);
ui::Resource* drag_handlebar_resource =
resource_manager_->GetStaticResourceWithTint(
drag_handlebar_resource_id_, drag_handlebar_tint);
......@@ -172,8 +223,8 @@ void OverlayPanelLayer::SetProperties(
drag_handlebar_->SetBounds(drag_handlebar_resource->size());
float drag_handlebar_left =
panel_width / 2 - drag_handlebar_resource->size().width() / 2;
float drag_handlebar_top =
bar_top + bar_margin_top - drag_handlebar_resource->size().height() / 2;
float drag_handlebar_top = bar_top_y + bar_margin_top -
drag_handlebar_resource->size().height() / 2;
drag_handlebar_->SetPosition(
gfx::PointF(drag_handlebar_left, drag_handlebar_top));
}
......@@ -197,7 +248,7 @@ void OverlayPanelLayer::SetProperties(
// Centers the Close Icon vertically in the bar.
float close_icon_top =
bar_top + bar_height / 2 - close_icon_resource->size().height() / 2;
bar_top_y + bar_height / 2 - close_icon_resource->size().height() / 2;
close_icon_->SetUIResourceId(close_icon_resource->ui_resource()->id());
close_icon_->SetBounds(close_icon_resource->size());
......@@ -263,7 +314,7 @@ void OverlayPanelLayer::SetProperties(
bar_shadow_->SetUIResourceId(bar_shadow_resource->ui_resource()->id());
bar_shadow_->SetBounds(shadow_size);
bar_shadow_->SetPosition(gfx::PointF(0.f, bar_bottom));
bar_shadow_->SetOpacity(bar_shadow_opacity);
bar_shadow_->SetOpacity(1.0f);
}
} else {
if (bar_shadow_.get() && bar_shadow_->parent())
......@@ -285,7 +336,8 @@ void OverlayPanelLayer::SetProperties(
bar_border_->SetBounds(bar_border_size);
bar_border_->SetPosition(
gfx::PointF(0.f, border_y));
bar_border_->SetBackgroundColor(bar_background_color);
bar_border_->SetBackgroundColor(separator_line_color);
if (bar_border_->parent() != layer_)
layer_->AddChild(bar_border_);
} else if (bar_border_.get() && bar_border_->parent()) {
bar_border_->RemoveFromParent();
......@@ -359,6 +411,7 @@ OverlayPanelLayer::OverlayPanelLayer(ui::ResourceManager* resource_manager)
: resource_manager_(resource_manager),
layer_(cc::Layer::Create()),
panel_shadow_(cc::NinePatchLayer::Create()),
rounded_bar_top_(cc::NinePatchLayer::Create()),
bar_background_(cc::SolidColorLayer::Create()),
bar_text_(cc::UIResourceLayer::Create()),
bar_shadow_(cc::UIResourceLayer::Create()),
......@@ -379,7 +432,12 @@ OverlayPanelLayer::OverlayPanelLayer(ui::ResourceManager* resource_manager)
// Panel Shadow
panel_shadow_->SetIsDrawable(true);
panel_shadow_->SetFillCenter(false);
layer_->AddChild(panel_shadow_);
// Rounded Bar Top
// Puts the layer near the bottom -- we'll decide if it's actually drawable
// later.
rounded_bar_top_->SetIsDrawable(false);
layer_->AddChild(rounded_bar_top_);
// Bar Background
bar_background_->SetIsDrawable(true);
......@@ -388,7 +446,6 @@ OverlayPanelLayer::OverlayPanelLayer(ui::ResourceManager* resource_manager)
// Bar Text
bar_text_->SetIsDrawable(true);
AddBarTextLayer(bar_text_);
layer_->AddChild(text_container_);
// Panel Icon
panel_icon_->SetIsDrawable(true);
......@@ -398,7 +455,6 @@ OverlayPanelLayer::OverlayPanelLayer(ui::ResourceManager* resource_manager)
// Drag Handlebar
drag_handlebar_->SetIsDrawable(true);
layer_->AddChild(drag_handlebar_);
// Open Tab Icon
open_tab_icon_->SetIsDrawable(true);
......
......@@ -32,6 +32,7 @@ class OverlayPanelLayer : public Layer {
void SetResourceIds(int bar_text_resource_id,
int panel_shadow_resource_id,
int rounded_bar_top_resource_id,
int bar_shadow_resource_id,
int panel_icon_resource_id,
int drag_handlebar_resource_id,
......@@ -54,10 +55,10 @@ class OverlayPanelLayer : public Layer {
bool bar_border_visible,
float bar_border_height,
bool bar_shadow_visible,
float bar_shadow_opacity,
int icon_tint,
int drag_handlebar_tint,
float icon_opacity);
float icon_opacity,
int separator_line_color);
void SetProgressBar(int progress_bar_background_resource_id,
int progress_bar_resource_id,
......@@ -81,6 +82,7 @@ class OverlayPanelLayer : public Layer {
scoped_refptr<cc::Layer> layer_;
scoped_refptr<cc::NinePatchLayer> panel_shadow_;
scoped_refptr<cc::NinePatchLayer> rounded_bar_top_;
scoped_refptr<cc::SolidColorLayer> bar_background_;
scoped_refptr<cc::UIResourceLayer> bar_text_;
scoped_refptr<cc::UIResourceLayer> bar_shadow_;
......@@ -97,6 +99,7 @@ class OverlayPanelLayer : public Layer {
int panel_icon_resource_id_;
int bar_text_resource_id_;
int panel_shadow_resource_id_;
int rounded_bar_top_resource_id_;
int bar_shadow_resource_id_;
int drag_handlebar_resource_id_;
int open_tab_icon_resource_id_;
......
......@@ -155,9 +155,12 @@ class TabLayer : public Layer {
scoped_refptr<cc::SolidColorLayer> side_padding_;
scoped_refptr<cc::SolidColorLayer> bottom_padding_;
scoped_refptr<cc::UIResourceLayer> close_button_;
scoped_refptr<cc::NinePatchLayer> front_border_;
scoped_refptr<cc::NinePatchLayer> front_border_inner_shadow_;
scoped_refptr<cc::NinePatchLayer> contour_shadow_;
scoped_refptr<cc::NinePatchLayer> shadow_;
scoped_refptr<cc::UIResourceLayer> back_logo_;
float brightness_;
......
......@@ -116,7 +116,6 @@ void ContextualSearchSceneLayer::UpdateContextualSearchLayer(
jboolean search_bar_border_visible,
jfloat search_bar_border_height,
jboolean search_bar_shadow_visible,
jfloat search_bar_shadow_opacity,
jboolean quick_action_icon_visible,
jboolean thumbnail_visible,
jstring j_thumbnail_url,
......@@ -139,7 +138,9 @@ void ContextualSearchSceneLayer::UpdateContextualSearchLayer(
jboolean touch_highlight_visible,
jfloat touch_highlight_x_offset,
jfloat touch_highlight_width,
const JavaRef<jobject>& j_profile) {
const JavaRef<jobject>& j_profile,
jint rounded_bar_top_resource_id,
jint separator_line_color) {
// Load the thumbnail if necessary.
std::string thumbnail_url =
base::android::ConvertJavaStringToUTF8(env, j_thumbnail_url);
......@@ -186,14 +187,15 @@ void ContextualSearchSceneLayer::UpdateContextualSearchLayer(
search_term_caption_spacing, search_caption_animation_percentage,
search_caption_visible, search_bar_border_visible,
search_bar_border_height, search_bar_shadow_visible,
search_bar_shadow_opacity, quick_action_icon_visible, thumbnail_visible,
quick_action_icon_visible, thumbnail_visible,
custom_image_visibility_percentage, bar_image_size, icon_color,
drag_handlebar_color, arrow_icon_opacity, arrow_icon_rotation,
close_icon_opacity, progress_bar_visible, progress_bar_height,
progress_bar_opacity, progress_bar_completion,
divider_line_visibility_percentage, divider_line_width,
divider_line_height, divider_line_color, divider_line_x_offset,
touch_highlight_visible, touch_highlight_x_offset, touch_highlight_width);
touch_highlight_visible, touch_highlight_x_offset, touch_highlight_width,
rounded_bar_top_resource_id, separator_line_color);
// Make the layer visible if it is not already.
contextual_search_layer_->layer()->SetHideLayerAndSubtree(false);
......
......@@ -88,7 +88,6 @@ class ContextualSearchSceneLayer : public SceneLayer,
jboolean search_bar_border_visible,
jfloat search_bar_border_height,
jboolean search_bar_shadow_visible,
jfloat search_bar_shadow_opacity,
jboolean quick_action_icon_visible,
jboolean thumbnail_visible,
jstring j_thumbnail_url,
......@@ -111,7 +110,9 @@ class ContextualSearchSceneLayer : public SceneLayer,
jboolean touch_highlight_visible,
jfloat touch_highlight_x_offset,
jfloat touch_highlight_width,
const base::android::JavaRef<jobject>& j_profile);
const base::android::JavaRef<jobject>& j_profile,
jint bar_background_resource_id,
jint separator_line_color);
// Inherited from BitmapFetcherDelegate
void OnFetchComplete(
......
......@@ -59,16 +59,18 @@ void EphemeralTabSceneLayer::CreateEphemeralTabLayer(
void EphemeralTabSceneLayer::SetResourceIds(JNIEnv* env,
const JavaParamRef<jobject>& object,
jint text_resource_id,
jint bar_background_resource_id,
jint panel_shadow_resource_id,
jint rounded_bar_top_resource_id,
jint bar_shadow_resource_id,
jint panel_icon_resource_id,
jint drag_handlebar_resource_id,
jint open_tab_icon_resource_id,
jint close_icon_resource_id) {
ephemeral_tab_layer_->SetResourceIds(
text_resource_id, bar_background_resource_id, bar_shadow_resource_id,
panel_icon_resource_id, drag_handlebar_resource_id,
open_tab_icon_resource_id, close_icon_resource_id);
text_resource_id, panel_shadow_resource_id, rounded_bar_top_resource_id,
bar_shadow_resource_id, panel_icon_resource_id,
drag_handlebar_resource_id, open_tab_icon_resource_id,
close_icon_resource_id);
}
void EphemeralTabSceneLayer::Update(JNIEnv* env,
......@@ -96,14 +98,14 @@ void EphemeralTabSceneLayer::Update(JNIEnv* env,
jboolean bar_border_visible,
jfloat bar_border_height,
jboolean bar_shadow_visible,
jfloat bar_shadow_opacity,
jint icon_color,
jint drag_handlebar_color,
jfloat favicon_opacity,
jboolean progress_bar_visible,
jfloat progress_bar_height,
jfloat progress_bar_opacity,
jint progress_bar_completion) {
jint progress_bar_completion,
jint separator_line_color) {
// NOTE(mdjones): It is possible to render the panel before content has been
// created. If this is the case, do not attempt to access the WebContents
// and instead pass null.
......@@ -130,10 +132,10 @@ void EphemeralTabSceneLayer::Update(JNIEnv* env,
progress_bar_background_resource_id, progress_bar_resource_id, dp_to_px,
content_layer, panel_x, panel_y, panel_width, panel_height,
bar_background_color, bar_margin_side, bar_margin_top, bar_height,
bar_border_visible, bar_border_height, bar_shadow_visible,
bar_shadow_opacity, icon_color, drag_handlebar_color, favicon_opacity,
progress_bar_visible, progress_bar_height, progress_bar_opacity,
progress_bar_completion);
bar_border_visible, bar_border_height, bar_shadow_visible, icon_color,
drag_handlebar_color, favicon_opacity, progress_bar_visible,
progress_bar_height, progress_bar_opacity, progress_bar_completion,
separator_line_color);
// Make the layer visible if it is not already.
ephemeral_tab_layer_->layer()->SetHideLayerAndSubtree(false);
}
......
......@@ -33,7 +33,8 @@ class EphemeralTabSceneLayer : public SceneLayer {
void SetResourceIds(JNIEnv* env,
const base::android::JavaParamRef<jobject>& object,
jint text_resource_id,
jint bar_background_resource_id,
jint panel_shadow_resource_id,
jint rounded_bar_top_resource_id,
jint bar_shadow_resource_id,
jint panel_icon_resource_id,
jint drag_handlebar_resource_id,
......@@ -65,14 +66,14 @@ class EphemeralTabSceneLayer : public SceneLayer {
jboolean bar_border_visible,
jfloat bar_border_height,
jboolean bar_shadow_visible,
jfloat bar_shadow_opacity,
jint icon_color,
jint drag_handlebar_color,
jfloat favicon_opacity,
jboolean progress_bar_visible,
jfloat progress_bar_height,
jfloat progress_bar_opacity,
jint progress_bar_completion);
jint progress_bar_completion,
jint separator_line_color);
void SetContentTree(
JNIEnv* env,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment