Commit a1297fc3 authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

CrOS Shelf: Set right margin on status area based on tablet mode

With this change, the padding between the edge of the screen and the
status area widget no longer has anything to do with the hotseat
state. This edge padding will now only ever have two possible values,
one value in tablet mode and another value in clamshell mode.

Bug: 1035716
Change-Id: I70f8ffe99ddf8e44482a3c9772f72dcf7adb9885
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1977025Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarManu Cornet <manucornet@chromium.org>
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727486}
parent a8bc3c9a
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h" #include "ash/shelf/shelf_widget.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
...@@ -86,7 +86,6 @@ StatusAreaWidgetDelegate::StatusAreaWidgetDelegate(Shelf* shelf) ...@@ -86,7 +86,6 @@ StatusAreaWidgetDelegate::StatusAreaWidgetDelegate(Shelf* shelf)
set_owned_by_client(); // Deleted by DeleteDelegate(). set_owned_by_client(); // Deleted by DeleteDelegate().
ShelfConfig::Get()->AddObserver(this); ShelfConfig::Get()->AddObserver(this);
shelf_->shelf_layout_manager()->AddObserver(this);
// Allow the launcher to surrender the focus to another window upon // Allow the launcher to surrender the focus to another window upon
// navigation completion by the user. // navigation completion by the user.
...@@ -97,7 +96,6 @@ StatusAreaWidgetDelegate::StatusAreaWidgetDelegate(Shelf* shelf) ...@@ -97,7 +96,6 @@ StatusAreaWidgetDelegate::StatusAreaWidgetDelegate(Shelf* shelf)
StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() { StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {
ShelfConfig::Get()->RemoveObserver(this); ShelfConfig::Get()->RemoveObserver(this);
shelf_->shelf_layout_manager()->RemoveObserver(this);
} }
void StatusAreaWidgetDelegate::SetFocusCyclerForTesting( void StatusAreaWidgetDelegate::SetFocusCyclerForTesting(
...@@ -180,21 +178,6 @@ void StatusAreaWidgetDelegate::OnShelfConfigUpdated() { ...@@ -180,21 +178,6 @@ void StatusAreaWidgetDelegate::OnShelfConfigUpdated() {
UpdateLayout(); UpdateLayout();
} }
void StatusAreaWidgetDelegate::OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) {
// Update the border of the last visible child so it has the right
// padding depending of the state of the shelf (See
// https://crbug.com/1025270). Don't layout as it will cause the whole
// transition to snap instead of animate (See https://crbug.com/1032770).
auto it = std::find_if(children().crbegin(), children().crend(),
[](const View* v) { return v->GetVisible(); });
if (it == children().crend())
return;
View* last_visible_child = *it;
SetBorderOnChild(last_visible_child, /*is_child_on_edge=*/true);
}
void StatusAreaWidgetDelegate::UpdateLayout() { void StatusAreaWidgetDelegate::UpdateLayout() {
// Use a grid layout so that the trays can be centered in each cell, and // Use a grid layout so that the trays can be centered in each cell, and
// so that the widget gets laid out correctly when tray sizes change. // so that the widget gets laid out correctly when tray sizes change.
...@@ -274,11 +257,13 @@ void StatusAreaWidgetDelegate::SetBorderOnChild(views::View* child, ...@@ -274,11 +257,13 @@ void StatusAreaWidgetDelegate::SetBorderOnChild(views::View* child,
// items also takes care of padding at the edge of the shelf. // items also takes care of padding at the edge of the shelf.
int right_edge = kPaddingBetweenWidgetsNewUi; int right_edge = kPaddingBetweenWidgetsNewUi;
if (is_child_on_edge && chromeos::switches::ShouldShowShelfHotseat()) { const bool tablet_mode =
right_edge = Shell::Get()->tablet_mode_controller() &&
shelf_->shelf_layout_manager()->hotseat_state() == HotseatState::kShown Shell::Get()->tablet_mode_controller()->InTabletMode();
? kPaddingBetweenWidgetAndRightScreenEdge
: 0; if (is_child_on_edge && !tablet_mode &&
chromeos::switches::ShouldShowShelfHotseat()) {
right_edge = kPaddingBetweenWidgetAndRightScreenEdge;
} }
// Swap edges if alignment is not horizontal (bottom-to-top). // Swap edges if alignment is not horizontal (bottom-to-top).
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/public/cpp/shelf_config.h" #include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_types.h" #include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf_layout_manager_observer.h"
#include "ash/system/status_area_widget.h" #include "ash/system/status_area_widget.h"
#include "base/macros.h" #include "base/macros.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
...@@ -22,8 +21,7 @@ class Shelf; ...@@ -22,8 +21,7 @@ class Shelf;
// The View for the status area widget. // The View for the status area widget.
class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView, class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView,
public views::WidgetDelegate, public views::WidgetDelegate,
public ShelfConfig::Observer, public ShelfConfig::Observer {
public ShelfLayoutManagerObserver {
public: public:
explicit StatusAreaWidgetDelegate(Shelf* shelf); explicit StatusAreaWidgetDelegate(Shelf* shelf);
~StatusAreaWidgetDelegate() override; ~StatusAreaWidgetDelegate() override;
...@@ -61,10 +59,6 @@ class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView, ...@@ -61,10 +59,6 @@ class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView,
// Overridden from ShelfConfig::Observer: // Overridden from ShelfConfig::Observer:
void OnShelfConfigUpdated() override; void OnShelfConfigUpdated() override;
// ShelfLayoutManagerObserver:
void OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) override;
void set_default_last_focusable_child(bool default_last_focusable_child) { void set_default_last_focusable_child(bool default_last_focusable_child) {
default_last_focusable_child_ = default_last_focusable_child; default_last_focusable_child_ = default_last_focusable_child;
} }
......
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