Commit aff95c50 authored by Eric Willigers's avatar Eric Willigers Committed by Commit Bot

Desktop PWAs: Move minimal-ui buttons closer together

The spacing around the Back and Reload buttons now matches
mocks provided by UI team.

When a profile indicator icon is present, we move the
Back and Reload icons to the right of the profile indicator.

Logic controlling the Back and Reload buttons is moved into
a new nested class WebAppFrameToolbarView::NavigationButtonContainer.

Bug: 1016663, 1028789
Change-Id: Ie404aa64a191228161e4590e430be2dfff4a5381
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1909057
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719865}
parent 73ca8856
...@@ -387,8 +387,9 @@ void BrowserNonClientFrameViewAsh::Layout() { ...@@ -387,8 +387,9 @@ void BrowserNonClientFrameViewAsh::Layout() {
if (profile_indicator_icon_) if (profile_indicator_icon_)
LayoutProfileIndicator(); LayoutProfileIndicator();
if (web_app_frame_toolbar()) { if (web_app_frame_toolbar()) {
web_app_frame_toolbar()->LayoutInContainer( web_app_frame_toolbar()->LayoutInContainer(GetToolbarLeftInset(),
0, caption_button_container_->x(), 0, painted_height); caption_button_container_->x(),
0, painted_height);
} }
BrowserNonClientFrameView::Layout(); BrowserNonClientFrameView::Layout();
...@@ -642,7 +643,16 @@ bool BrowserNonClientFrameViewAsh::ShouldShowCaptionButtons() const { ...@@ -642,7 +643,16 @@ bool BrowserNonClientFrameViewAsh::ShouldShowCaptionButtons() const {
return !IsInOverviewMode(); return !IsInOverviewMode();
} }
int BrowserNonClientFrameViewAsh::GetToolbarLeftInset() const {
// Include padding on left and right of icon.
return profile_indicator_icon_
? kProfileIndicatorPadding * 2 + profile_indicator_icon_->width()
: 0;
}
int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const { int BrowserNonClientFrameViewAsh::GetTabStripLeftInset() const {
// Include padding on left of icon.
// The tab strip has its own 'padding' to the right of the icon.
return profile_indicator_icon_ return profile_indicator_icon_
? kProfileIndicatorPadding + profile_indicator_icon_->width() ? kProfileIndicatorPadding + profile_indicator_icon_->width()
: 0; : 0;
......
...@@ -157,6 +157,10 @@ class BrowserNonClientFrameViewAsh ...@@ -157,6 +157,10 @@ class BrowserNonClientFrameViewAsh
// example, in overview mode and tablet mode. // example, in overview mode and tablet mode.
bool ShouldShowCaptionButtons() const; bool ShouldShowCaptionButtons() const;
// Distance between the edge of the NonClientFrameView and the web app frame
// toolbar.
int GetToolbarLeftInset() const;
// Distance between the edges of the NonClientFrameView and the tab strip. // Distance between the edges of the NonClientFrameView and the tab strip.
int GetTabStripLeftInset() const; int GetTabStripLeftInset() const;
int GetTabStripRightInset() const; int GetTabStripRightInset() const;
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
namespace { namespace {
constexpr int kHostedAppMenuMargin = 7;
constexpr int kFramePaddingLeft = 75; constexpr int kFramePaddingLeft = 75;
constexpr double kTitlePaddingWidthFraction = 0.1; constexpr double kTitlePaddingWidthFraction = 0.1;
...@@ -74,8 +73,7 @@ BrowserNonClientFrameViewMac::BrowserNonClientFrameViewMac( ...@@ -74,8 +73,7 @@ BrowserNonClientFrameViewMac::BrowserNonClientFrameViewMac(
AddChildView(std::make_unique<WebAppFrameToolbarView>( AddChildView(std::make_unique<WebAppFrameToolbarView>(
frame, browser_view, frame, browser_view,
GetCaptionColor(BrowserFrameActiveState::kActive), GetCaptionColor(BrowserFrameActiveState::kActive),
GetCaptionColor(BrowserFrameActiveState::kInactive), GetCaptionColor(BrowserFrameActiveState::kInactive))));
kHostedAppMenuMargin, kHostedAppMenuMargin)));
} }
DCHECK(browser_view->ShouldShowWindowTitle()); DCHECK(browser_view->ShouldShowWindowTitle());
...@@ -137,7 +135,7 @@ int BrowserNonClientFrameViewMac::GetTopInset(bool restored) const { ...@@ -137,7 +135,7 @@ int BrowserNonClientFrameViewMac::GetTopInset(bool restored) const {
if (ShouldHideTopUIForFullscreen()) if (ShouldHideTopUIForFullscreen())
return 0; return 0;
return web_app_frame_toolbar()->GetPreferredSize().height() + return web_app_frame_toolbar()->GetPreferredSize().height() +
kHostedAppMenuMargin * 2; kWebAppMenuMargin * 2;
} }
if (!browser_view()->IsTabStripVisible()) if (!browser_view()->IsTabStripVisible())
......
...@@ -12,14 +12,12 @@ ...@@ -12,14 +12,12 @@
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/command_observer.h" #include "build/build_config.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h" #include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_view.h" #include "chrome/browser/ui/views/page_action/page_action_icon_view.h"
#include "chrome/browser/ui/views/toolbar/browser_actions_container.h" #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/material_design/material_design_controller_observer.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/views/accessible_pane_view.h" #include "ui/views/accessible_pane_view.h"
...@@ -39,17 +37,18 @@ class ToolbarButton; ...@@ -39,17 +37,18 @@ class ToolbarButton;
class WebAppMenuButton; class WebAppMenuButton;
class WebAppOriginText; class WebAppOriginText;
#if defined(OS_MACOSX)
constexpr int kWebAppMenuMargin = 7;
#endif
// A container for web app buttons in the title bar. // A container for web app buttons in the title bar.
class WebAppFrameToolbarView : public views::AccessiblePaneView, class WebAppFrameToolbarView : public views::AccessiblePaneView,
public BrowserActionsContainer::Delegate, public BrowserActionsContainer::Delegate,
public CommandObserver,
public views::ButtonListener,
public ContentSettingImageView::Delegate, public ContentSettingImageView::Delegate,
public ImmersiveModeController::Observer, public ImmersiveModeController::Observer,
public PageActionIconView::Delegate, public PageActionIconView::Delegate,
public ToolbarButtonProvider, public ToolbarButtonProvider,
public views::WidgetObserver, public views::WidgetObserver {
public ui::MaterialDesignControllerObserver {
public: public:
static const char kViewClassName[]; static const char kViewClassName[];
...@@ -71,9 +70,7 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView, ...@@ -71,9 +70,7 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
WebAppFrameToolbarView(views::Widget* widget, WebAppFrameToolbarView(views::Widget* widget,
BrowserView* browser_view, BrowserView* browser_view,
SkColor active_color, SkColor active_color,
SkColor inactive_color, SkColor inactive_color);
base::Optional<int> left_margin = base::nullopt,
base::Optional<int> right_margin = base::nullopt);
~WebAppFrameToolbarView() override; ~WebAppFrameToolbarView() override;
void UpdateStatusIconsVisibility(); void UpdateStatusIconsVisibility();
...@@ -104,12 +101,6 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView, ...@@ -104,12 +101,6 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
Browser* browser, Browser* browser,
ToolbarActionsBar* main_bar) const override; ToolbarActionsBar* main_bar) const override;
// CommandObserver:
void EnabledStateChangedForCommand(int id, bool enabled) override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// ContentSettingImageView::Delegate: // ContentSettingImageView::Delegate:
SkColor GetContentSettingInkDropColor() const override; SkColor GetContentSettingInkDropColor() const override;
content::WebContents* GetContentSettingWebContents() override; content::WebContents* GetContentSettingWebContents() override;
...@@ -143,9 +134,6 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView, ...@@ -143,9 +134,6 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
// views::WidgetObserver: // views::WidgetObserver:
void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
// ui::MaterialDesignControllerObserver:
void OnTouchUiChanged() override;
static void DisableAnimationForTesting(); static void DisableAnimationForTesting();
views::View* GetRightContainerForTesting(); views::View* GetRightContainerForTesting();
views::View* GetPageActionIconContainerForTesting(); views::View* GetPageActionIconContainerForTesting();
...@@ -179,18 +167,12 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView, ...@@ -179,18 +167,12 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
SkColor GetCaptionColor() const; SkColor GetCaptionColor() const;
void UpdateChildrenColor(); void UpdateChildrenColor();
void GenerateMinimalUIButtonImages();
// Whether we're waiting for the widget to become visible. // Whether we're waiting for the widget to become visible.
bool pending_widget_visibility_ = true; bool pending_widget_visibility_ = true;
ScopedObserver<views::Widget, views::WidgetObserver> scoped_widget_observer_{ ScopedObserver<views::Widget, views::WidgetObserver> scoped_widget_observer_{
this}; this};
ScopedObserver<ui::MaterialDesignController,
ui::MaterialDesignControllerObserver>
md_observer_{this};
// Timers for synchronising their respective parts of the titlebar animation. // Timers for synchronising their respective parts of the titlebar animation.
base::OneShotTimer animation_start_delay_; base::OneShotTimer animation_start_delay_;
base::OneShotTimer icon_fade_in_delay_; base::OneShotTimer icon_fade_in_delay_;
...@@ -203,14 +185,13 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView, ...@@ -203,14 +185,13 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
SkColor active_color_; SkColor active_color_;
SkColor inactive_color_; SkColor inactive_color_;
class NavigationButtonContainer;
class ToolbarButtonContainer; class ToolbarButtonContainer;
// All remaining members are owned by the views hierarchy. // All remaining members are owned by the views hierarchy.
// These three fields are only created when the display mode is minimal-ui. // The navigation container is only created when display mode is minimal-ui.
ToolbarButtonContainer* left_container_ = nullptr; NavigationButtonContainer* left_container_ = nullptr;
ToolbarButton* back_ = nullptr;
ReloadButton* reload_ = nullptr;
// Empty container used by the parent frame to layout additional elements. // Empty container used by the parent frame to layout additional elements.
views::View* center_container_ = nullptr; views::View* center_container_ = nullptr;
......
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