Commit 493a71fe authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Unified: Apply same anchor insets to volume slider

This CL applies same anchor insets to both UnifiedSystemTray bubble
and volume slider bubble. It gives 8dip padding between the shelf and
the volume slider (see the screenshot in the bug).

TEST=manual
BUG=888182

Change-Id: Idd455bb272cf58fb023a69359cd6ec68755a2b59
Reviewed-on: https://chromium-review.googlesource.com/1250461
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595712}
parent 97579817
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#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/system/unified/unified_system_tray.h" #include "ash/system/unified/unified_system_tray.h"
#include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_view.h" #include "ash/system/unified/unified_system_tray_view.h"
using chromeos::CrasAudioHandler; using chromeos::CrasAudioHandler;
...@@ -176,7 +177,7 @@ void UnifiedSliderBubbleController::ShowBubble(SliderType slider_type) { ...@@ -176,7 +177,7 @@ void UnifiedSliderBubbleController::ShowBubble(SliderType slider_type) {
bubble_view_->set_color(SK_ColorTRANSPARENT); bubble_view_->set_color(SK_ColorTRANSPARENT);
bubble_view_->layer()->SetFillsBoundsOpaquely(false); bubble_view_->layer()->SetFillsBoundsOpaquely(false);
bubble_view_->set_anchor_view_insets( bubble_view_->set_anchor_view_insets(
tray_->shelf()->GetSystemTrayAnchor()->GetBubbleAnchorInsets()); UnifiedSystemTrayBubble::GetAdjustedAnchorInsets(tray_, bubble_view_));
bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_view_); bubble_widget_ = views::BubbleDialogDelegateView::CreateBubble(bubble_view_);
......
...@@ -60,6 +60,24 @@ class ContainerView : public views::View { ...@@ -60,6 +60,24 @@ class ContainerView : public views::View {
} // namespace } // namespace
// static
gfx::Insets UnifiedSystemTrayBubble::GetAdjustedAnchorInsets(
UnifiedSystemTray* tray,
TrayBubbleView* bubble_view) {
gfx::Insets anchor_insets =
tray->shelf()->GetSystemTrayAnchor()->GetBubbleAnchorInsets();
gfx::Insets bubble_insets = bubble_view->GetBorderInsets();
if (tray->shelf()->IsHorizontalAlignment()) {
anchor_insets -=
gfx::Insets(kUnifiedMenuVerticalPadding - bubble_insets.bottom(), 0, 0,
bubble_insets.right() + anchor_insets.right());
} else {
anchor_insets -=
gfx::Insets(0, 0, bubble_insets.bottom() + anchor_insets.bottom(), 0);
}
return anchor_insets;
}
UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray, UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray,
bool show_by_click) bool show_by_click)
: controller_( : controller_(
...@@ -93,19 +111,8 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray, ...@@ -93,19 +111,8 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray,
bubble_view_->SetMaxHeight(max_height); bubble_view_->SetMaxHeight(max_height);
bubble_view_->AddChildView(new ContainerView(unified_view_)); bubble_view_->AddChildView(new ContainerView(unified_view_));
gfx::Insets anchor_insets = bubble_view_->set_anchor_view_insets(
tray->shelf()->GetSystemTrayAnchor()->GetBubbleAnchorInsets(); GetAdjustedAnchorInsets(tray, bubble_view_));
gfx::Insets bubble_insets = bubble_view_->GetBorderInsets();
if (tray_->shelf()->IsHorizontalAlignment()) {
anchor_insets -=
gfx::Insets(kUnifiedMenuVerticalPadding - bubble_insets.bottom(), 0, 0,
bubble_insets.right() + anchor_insets.right());
} else {
anchor_insets -=
gfx::Insets(0, 0, bubble_insets.bottom() + anchor_insets.bottom(), 0);
}
bubble_view_->set_anchor_view_insets(anchor_insets);
bubble_view_->set_color(SK_ColorTRANSPARENT); bubble_view_->set_color(SK_ColorTRANSPARENT);
bubble_view_->layer()->SetFillsBoundsOpaquely(false); bubble_view_->layer()->SetFillsBoundsOpaquely(false);
......
...@@ -42,6 +42,11 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase, ...@@ -42,6 +42,11 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase,
public TimeToClickRecorder::Delegate, public TimeToClickRecorder::Delegate,
public TabletModeObserver { public TabletModeObserver {
public: public:
// Return adjusted anchor insets that take into account shelf alignment and
// bubble insets.
static gfx::Insets GetAdjustedAnchorInsets(UnifiedSystemTray* tray,
TrayBubbleView* bubble_view);
explicit UnifiedSystemTrayBubble(UnifiedSystemTray* tray, bool show_by_click); explicit UnifiedSystemTrayBubble(UnifiedSystemTray* tray, bool show_by_click);
~UnifiedSystemTrayBubble() override; ~UnifiedSystemTrayBubble() 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