Commit 35c5e6ff authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS sys tray: fix padding to better match spec

A few changes here:

* Specify padding on both ends of the whole tray separately (instead
  of using space around some tray items to build it up)
* Override the size function for the battery to better match its
  actual visual footprint.
* Specify padding between items with one single number, used at the
  layout level.

This all allows for simpler code while better matching the specs.

Bug: 901989
Change-Id: Ia75dcfc7b355b114e6492c26ee4ce6372af92f71
Reviewed-on: https://chromium-review.googlesource.com/c/1328042
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609183}
parent cc47325f
...@@ -220,8 +220,7 @@ void TimeView::UpdateClockLayout(ClockLayout clock_layout) { ...@@ -220,8 +220,7 @@ void TimeView::UpdateClockLayout(ClockLayout clock_layout) {
layout->AddView(vertical_label_hours_.get()); layout->AddView(vertical_label_hours_.get());
layout->StartRow(0, kColumnId); layout->StartRow(0, kColumnId);
layout->AddView(vertical_label_minutes_.get()); layout->AddView(vertical_label_minutes_.get());
layout->AddPaddingRow( layout->AddPaddingRow(0, kVerticalClockMinutesTopOffset);
0, kTrayImageItemPadding + kVerticalClockMinutesTopOffset);
} }
Layout(); Layout();
} }
......
...@@ -51,6 +51,15 @@ PowerTrayView::~PowerTrayView() { ...@@ -51,6 +51,15 @@ PowerTrayView::~PowerTrayView() {
PowerStatus::Get()->RemoveObserver(this); PowerStatus::Get()->RemoveObserver(this);
} }
gfx::Size PowerTrayView::CalculatePreferredSize() const {
// The battery icon is a lot thinner than other icons, hence the special
// logic.
gfx::Size standard_size = TrayItemView::CalculatePreferredSize();
if (IsHorizontalAlignment())
return gfx::Size(kUnifiedTrayBatteryWidth, standard_size.height());
return standard_size;
}
void PowerTrayView::GetAccessibleNodeData(ui::AXNodeData* node_data) { void PowerTrayView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->SetName(accessible_name_); node_data->SetName(accessible_name_);
node_data->role = ax::mojom::Role::kButton; node_data->role = ax::mojom::Role::kButton;
......
...@@ -25,6 +25,7 @@ class PowerTrayView : public TrayItemView, ...@@ -25,6 +25,7 @@ class PowerTrayView : public TrayItemView,
~PowerTrayView() override; ~PowerTrayView() override;
// views::View: // views::View:
gfx::Size CalculatePreferredSize() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override; views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
bool GetTooltipText(const gfx::Point& p, bool GetTooltipText(const gfx::Point& p,
......
...@@ -173,9 +173,10 @@ constexpr gfx::Insets kUnifiedSliderPadding(0, 16); ...@@ -173,9 +173,10 @@ constexpr gfx::Insets kUnifiedSliderPadding(0, 16);
constexpr int kUnifiedMenuVerticalPadding = 8; constexpr int kUnifiedMenuVerticalPadding = 8;
constexpr int kUnifiedNotificationCenterSpacing = 16; constexpr int kUnifiedNotificationCenterSpacing = 16;
constexpr int kUnifiedTrayIconSize = 20; constexpr int kUnifiedTrayIconSize = 20;
constexpr int kUnifiedTraySpacingBetweenIcons = 2; constexpr int kUnifiedTraySpacingBetweenIcons = 6;
constexpr int kUnifiedTrayBatteryWidth = 10;
constexpr int kUnifiedTrayCornerRadius = 20; constexpr int kUnifiedTrayCornerRadius = 20;
constexpr int kUnifiedTrayContentPadding = 5; constexpr int kUnifiedTrayContentPadding = 8;
constexpr int kUnifiedTopShortcutSpacing = 16; constexpr int kUnifiedTopShortcutSpacing = 16;
constexpr int kUnifiedNotificationHiddenLineHeight = 20; constexpr int kUnifiedNotificationHiddenLineHeight = 20;
constexpr gfx::Insets kUnifiedTopShortcutPadding(0, 16); constexpr gfx::Insets kUnifiedTopShortcutPadding(0, 16);
......
...@@ -68,14 +68,8 @@ void TrayContainer::UpdateLayout() { ...@@ -68,14 +68,8 @@ void TrayContainer::UpdateLayout() {
is_horizontal ? views::BoxLayout::kHorizontal is_horizontal ? views::BoxLayout::kHorizontal
: views::BoxLayout::kVertical; : views::BoxLayout::kVertical;
const int hit_region_with_separator = gfx::Insets insets(is_horizontal ? gfx::Insets(0, kHitRegionPadding)
kHitRegionPadding + TrayConstants::separator_width(); : gfx::Insets(kHitRegionPadding, 0));
gfx::Insets insets(
is_horizontal
? gfx::Insets(0, kHitRegionPadding, 0, hit_region_with_separator)
: gfx::Insets(kHitRegionPadding, 0, hit_region_with_separator, 0));
if (base::i18n::IsRTL())
insets.Set(insets.top(), insets.right(), insets.bottom(), insets.left());
SetBorder(views::CreateEmptyBorder(insets)); SetBorder(views::CreateEmptyBorder(insets));
int horizontal_margin = main_axis_margin_; int horizontal_margin = main_axis_margin_;
......
...@@ -83,17 +83,17 @@ int TrayItemView::GetAnimationDurationMS() { ...@@ -83,17 +83,17 @@ int TrayItemView::GetAnimationDurationMS() {
return kTrayItemAnimationDurationMS; return kTrayItemAnimationDurationMS;
} }
bool TrayItemView::IsHorizontalAlignment() const {
return shelf_->IsHorizontalAlignment();
}
gfx::Size TrayItemView::CalculatePreferredSize() const { gfx::Size TrayItemView::CalculatePreferredSize() const {
DCHECK_EQ(1, child_count()); DCHECK_EQ(1, child_count());
gfx::Size inner_size = views::View::CalculatePreferredSize(); gfx::Size size = views::View::CalculatePreferredSize();
if (image_view_) { if (image_view_) {
inner_size = gfx::Size(TrayConstants::GetTrayIconSize(), size = gfx::Size(kUnifiedTrayIconSize, kUnifiedTrayIconSize);
TrayConstants::GetTrayIconSize());
} }
gfx::Rect rect(inner_size);
if (label_)
rect.Inset(gfx::Insets(-kTrayImageItemPadding));
gfx::Size size = rect.size();
if (!animation_.get() || !animation_->is_animating()) if (!animation_.get() || !animation_->is_animating())
return size; return size;
if (shelf_->IsHorizontalAlignment()) { if (shelf_->IsHorizontalAlignment()) {
......
...@@ -24,7 +24,7 @@ class ImageView; ...@@ -24,7 +24,7 @@ class ImageView;
namespace ash { namespace ash {
class Shelf; class Shelf;
// Lable view which can be given a different data from the visible label. // Label view which can be given a different data from the visible label.
// IME icons like "US" (US keyboard) or "あ(Google Japanese Input)" are // IME icons like "US" (US keyboard) or "あ(Google Japanese Input)" are
// rendered as a label, but reading such text literally will not always be // rendered as a label, but reading such text literally will not always be
// understandable. // understandable.
...@@ -67,6 +67,9 @@ class ASH_EXPORT TrayItemView : public views::View, ...@@ -67,6 +67,9 @@ class ASH_EXPORT TrayItemView : public views::View,
// The default animation duration is 200ms. But each view can customize this. // The default animation duration is 200ms. But each view can customize this.
virtual int GetAnimationDurationMS(); virtual int GetAnimationDurationMS();
// Returns whether the shelf is horizontal.
bool IsHorizontalAlignment() const;
private: private:
// Overridden from views::View. // Overridden from views::View.
void ChildPreferredSizeChanged(View* child) override; void ChildPreferredSizeChanged(View* child) override;
......
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