Commit 817a3d76 authored by Matthew Mourgos's avatar Matthew Mourgos Committed by Commit Bot

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

This reverts commit a1297fc3.

Reason for revert: Broke test with hotseat feature enabled.

Original change's description:
> 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/+/1977025
> Reviewed-by: Tetsui Ohkubo <tetsui@chromium.org>
> Reviewed-by: Manu Cornet <manucornet@chromium.org>
> Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#727486}

TBR=tetsui@chromium.org,manucornet@chromium.org,mmourgos@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1035716
Change-Id: If730127fc7471d9a063fb45530c81b99b2abd035
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1983328Reviewed-by: default avatarMatthew Mourgos <mmourgos@chromium.org>
Commit-Queue: Matthew Mourgos <mmourgos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727623}
parent a1a4d111
......@@ -7,11 +7,11 @@
#include "ash/focus_cycler.h"
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "chromeos/constants/chromeos_switches.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
......@@ -86,6 +86,7 @@ StatusAreaWidgetDelegate::StatusAreaWidgetDelegate(Shelf* shelf)
set_owned_by_client(); // Deleted by DeleteDelegate().
ShelfConfig::Get()->AddObserver(this);
shelf_->shelf_layout_manager()->AddObserver(this);
// Allow the launcher to surrender the focus to another window upon
// navigation completion by the user.
......@@ -96,6 +97,7 @@ StatusAreaWidgetDelegate::StatusAreaWidgetDelegate(Shelf* shelf)
StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {
ShelfConfig::Get()->RemoveObserver(this);
shelf_->shelf_layout_manager()->RemoveObserver(this);
}
void StatusAreaWidgetDelegate::SetFocusCyclerForTesting(
......@@ -178,6 +180,21 @@ void StatusAreaWidgetDelegate::OnShelfConfigUpdated() {
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() {
// 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.
......@@ -257,13 +274,11 @@ void StatusAreaWidgetDelegate::SetBorderOnChild(views::View* child,
// items also takes care of padding at the edge of the shelf.
int right_edge = kPaddingBetweenWidgetsNewUi;
const bool tablet_mode =
Shell::Get()->tablet_mode_controller() &&
Shell::Get()->tablet_mode_controller()->InTabletMode();
if (is_child_on_edge && !tablet_mode &&
chromeos::switches::ShouldShowShelfHotseat()) {
right_edge = kPaddingBetweenWidgetAndRightScreenEdge;
if (is_child_on_edge && chromeos::switches::ShouldShowShelfHotseat()) {
right_edge =
shelf_->shelf_layout_manager()->hotseat_state() == HotseatState::kShown
? kPaddingBetweenWidgetAndRightScreenEdge
: 0;
}
// Swap edges if alignment is not horizontal (bottom-to-top).
......
......@@ -8,6 +8,7 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/shelf_layout_manager_observer.h"
#include "ash/system/status_area_widget.h"
#include "base/macros.h"
#include "ui/gfx/image/image_skia.h"
......@@ -21,7 +22,8 @@ class Shelf;
// The View for the status area widget.
class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView,
public views::WidgetDelegate,
public ShelfConfig::Observer {
public ShelfConfig::Observer,
public ShelfLayoutManagerObserver {
public:
explicit StatusAreaWidgetDelegate(Shelf* shelf);
~StatusAreaWidgetDelegate() override;
......@@ -59,6 +61,10 @@ class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView,
// Overridden from ShelfConfig::Observer:
void OnShelfConfigUpdated() override;
// ShelfLayoutManagerObserver:
void OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) override;
void set_default_last_focusable_child(bool 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