Commit 3701d7b5 authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Separate browser actions from trusted area

Adds a separator to the browser-actions container that shows under the
Material refresh. This ensures that browser actions are distint from
trusted built-in toolbar buttons (like the avatar button for switching
between users).

This separator only shows when browser actions are visible and animates
in and out along with them.

Bug: chromium:822069
Change-Id: Iad7a0121088932884c4f63e8a8340e4919023957
Reviewed-on: https://chromium-review.googlesource.com/987299
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549770}
parent 24a94c5a
......@@ -26,6 +26,7 @@
namespace views {
class BubbleDialogDelegateView;
class ResizeArea;
class Separator;
}
// The BrowserActionsContainer is a container view, responsible for drawing the
......@@ -183,6 +184,10 @@ class BrowserActionsContainer : public views::View,
// the omnibox, this is probably *not* |max_width|).
int GetWidthForMaxWidth(int max_width) const;
// Sets the color for the separator if present, called after construction and
// on theme changes.
void SetSeparatorColor(SkColor color);
// Overridden from views::View:
gfx::Size CalculatePreferredSize() const override;
int GetHeightForWidth(int width) const override;
......@@ -256,6 +261,19 @@ class BrowserActionsContainer : public views::View,
// Clears the |active_bubble_|, and unregisters the container as an observer.
void ClearActiveBubble(views::Widget* widget);
// Utility functions for going from/to width and icon counts.
size_t WidthToIconCount(int width) const;
int GetWidthForIconCount(size_t num_icons) const;
int GetWidthWithAllActionsVisible() const;
// Width allocated for the resize handle, |resize_area_|. 0 when it should not
// be shown.
int GetResizeAreaWidth() const;
// Width of the separator and surrounding padding. 0 when the separator should
// not be shown.
int GetSeparatorAreaWidth() const;
const ToolbarActionsBar::PlatformSettings& platform_settings() const {
return toolbar_actions_bar_->platform_settings();
}
......@@ -279,6 +297,10 @@ class BrowserActionsContainer : public views::View,
// The resize area for the container.
views::ResizeArea* resize_area_ = nullptr;
// Separator at the end of browser actions to highlight that these actions are
// different from built-in toolbar actions.
views::Separator* separator_ = nullptr;
// The animation that happens when the container snaps to place.
std::unique_ptr<gfx::SlideAnimation> resize_animation_;
......@@ -286,8 +308,7 @@ class BrowserActionsContainer : public views::View,
bool added_to_view_ = false;
// When the container is resizing, this is the width at which it started.
// If the container is not resizing, -1.
int resize_starting_width_ = -1;
base::Optional<int> resize_starting_width_;
// This is used while the user is resizing (and when the animations are in
// progress) to know how wide the delta is between the current state and what
......
......@@ -755,6 +755,8 @@ void ToolbarView::LoadImages() {
const SkColor disabled_color =
tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE);
browser_actions_->SetSeparatorColor(normal_color);
const bool is_touch =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
// TODO(pbos): Move these constants to LayoutProvider or LayoutConstants.
......
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