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() {
if (profile_indicator_icon_)
LayoutProfileIndicator();
if (web_app_frame_toolbar()) {
web_app_frame_toolbar()->LayoutInContainer(
0, caption_button_container_->x(), 0, painted_height);
web_app_frame_toolbar()->LayoutInContainer(GetToolbarLeftInset(),
caption_button_container_->x(),
0, painted_height);
}
BrowserNonClientFrameView::Layout();
......@@ -642,7 +643,16 @@ bool BrowserNonClientFrameViewAsh::ShouldShowCaptionButtons() const {
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 {
// Include padding on left of icon.
// The tab strip has its own 'padding' to the right of the icon.
return profile_indicator_icon_
? kProfileIndicatorPadding + profile_indicator_icon_->width()
: 0;
......
......@@ -157,6 +157,10 @@ class BrowserNonClientFrameViewAsh
// example, in overview mode and tablet mode.
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.
int GetTabStripLeftInset() const;
int GetTabStripRightInset() const;
......
......@@ -34,7 +34,6 @@
namespace {
constexpr int kHostedAppMenuMargin = 7;
constexpr int kFramePaddingLeft = 75;
constexpr double kTitlePaddingWidthFraction = 0.1;
......@@ -74,8 +73,7 @@ BrowserNonClientFrameViewMac::BrowserNonClientFrameViewMac(
AddChildView(std::make_unique<WebAppFrameToolbarView>(
frame, browser_view,
GetCaptionColor(BrowserFrameActiveState::kActive),
GetCaptionColor(BrowserFrameActiveState::kInactive),
kHostedAppMenuMargin, kHostedAppMenuMargin)));
GetCaptionColor(BrowserFrameActiveState::kInactive))));
}
DCHECK(browser_view->ShouldShowWindowTitle());
......@@ -137,7 +135,7 @@ int BrowserNonClientFrameViewMac::GetTopInset(bool restored) const {
if (ShouldHideTopUIForFullscreen())
return 0;
return web_app_frame_toolbar()->GetPreferredSize().height() +
kHostedAppMenuMargin * 2;
kWebAppMenuMargin * 2;
}
if (!browser_view()->IsTabStripVisible())
......
......@@ -12,14 +12,12 @@
#include "base/scoped_observer.h"
#include "base/time/time.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/toolbar_button_provider.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/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/geometry/rect.h"
#include "ui/views/accessible_pane_view.h"
......@@ -39,17 +37,18 @@ class ToolbarButton;
class WebAppMenuButton;
class WebAppOriginText;
#if defined(OS_MACOSX)
constexpr int kWebAppMenuMargin = 7;
#endif
// A container for web app buttons in the title bar.
class WebAppFrameToolbarView : public views::AccessiblePaneView,
public BrowserActionsContainer::Delegate,
public CommandObserver,
public views::ButtonListener,
public ContentSettingImageView::Delegate,
public ImmersiveModeController::Observer,
public PageActionIconView::Delegate,
public ToolbarButtonProvider,
public views::WidgetObserver,
public ui::MaterialDesignControllerObserver {
public views::WidgetObserver {
public:
static const char kViewClassName[];
......@@ -71,9 +70,7 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
WebAppFrameToolbarView(views::Widget* widget,
BrowserView* browser_view,
SkColor active_color,
SkColor inactive_color,
base::Optional<int> left_margin = base::nullopt,
base::Optional<int> right_margin = base::nullopt);
SkColor inactive_color);
~WebAppFrameToolbarView() override;
void UpdateStatusIconsVisibility();
......@@ -104,12 +101,6 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
Browser* browser,
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:
SkColor GetContentSettingInkDropColor() const override;
content::WebContents* GetContentSettingWebContents() override;
......@@ -143,9 +134,6 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
// views::WidgetObserver:
void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
// ui::MaterialDesignControllerObserver:
void OnTouchUiChanged() override;
static void DisableAnimationForTesting();
views::View* GetRightContainerForTesting();
views::View* GetPageActionIconContainerForTesting();
......@@ -179,18 +167,12 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
SkColor GetCaptionColor() const;
void UpdateChildrenColor();
void GenerateMinimalUIButtonImages();
// Whether we're waiting for the widget to become visible.
bool pending_widget_visibility_ = true;
ScopedObserver<views::Widget, views::WidgetObserver> scoped_widget_observer_{
this};
ScopedObserver<ui::MaterialDesignController,
ui::MaterialDesignControllerObserver>
md_observer_{this};
// Timers for synchronising their respective parts of the titlebar animation.
base::OneShotTimer animation_start_delay_;
base::OneShotTimer icon_fade_in_delay_;
......@@ -203,14 +185,13 @@ class WebAppFrameToolbarView : public views::AccessiblePaneView,
SkColor active_color_;
SkColor inactive_color_;
class NavigationButtonContainer;
class ToolbarButtonContainer;
// All remaining members are owned by the views hierarchy.
// These three fields are only created when the display mode is minimal-ui.
ToolbarButtonContainer* left_container_ = nullptr;
ToolbarButton* back_ = nullptr;
ReloadButton* reload_ = nullptr;
// The navigation container is only created when display mode is minimal-ui.
NavigationButtonContainer* left_container_ = nullptr;
// Empty container used by the parent frame to layout additional elements.
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