Commit a36b318a authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Adjust bubble size in response to screen configuration change.

As a known issue, this doesn't respond to turning on/off the docked
magnifier.

Test: manually verified by rotating screen and zooming by ctrl-shift-+.
Bug: 862575
Change-Id: I7e74b4ce701c017b77df59cce00a30b0c3ebc821
Reviewed-on: https://chromium-review.googlesource.com/1134633Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575944}
parent 33b43734
...@@ -81,17 +81,10 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray, ...@@ -81,17 +81,10 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray,
bubble_view_ = new views::TrayBubbleView(init_params); bubble_view_ = new views::TrayBubbleView(init_params);
// TODO(yamaguchi): Reconsider this formula. The y-position of the top edge
// still differes by few pixels between the horizontal and vertical shelf
// modes.
int free_space_height_above_anchor =
tray->shelf()->GetSystemTrayAnchor()->GetBoundsInScreen().y() -
tray->shelf()->GetUserWorkAreaBounds().y();
int max_height = free_space_height_above_anchor - kPaddingFromScreenTop -
bubble_view_->GetBorderInsets().height();
unified_view_ = controller_->CreateView(); unified_view_ = controller_->CreateView();
time_to_click_recorder_ = time_to_click_recorder_ =
std::make_unique<TimeToClickRecorder>(this, unified_view_); std::make_unique<TimeToClickRecorder>(this, unified_view_);
int max_height = CalculateMaxHeight();
unified_view_->SetMaxHeight(max_height); unified_view_->SetMaxHeight(max_height);
bubble_view_->SetMaxHeight(max_height); bubble_view_->SetMaxHeight(max_height);
bubble_view_->AddChildView(new ContainerView(unified_view_)); bubble_view_->AddChildView(new ContainerView(unified_view_));
...@@ -214,6 +207,21 @@ views::Widget* UnifiedSystemTrayBubble::GetBubbleWidget() const { ...@@ -214,6 +207,21 @@ views::Widget* UnifiedSystemTrayBubble::GetBubbleWidget() const {
return bubble_widget_; return bubble_widget_;
} }
int UnifiedSystemTrayBubble::CalculateMaxHeight() const {
// TODO(yamaguchi): Reconsider this formula. The y-position of the top edge
// still differes by few pixels between the horizontal and vertical shelf
// modes.
int free_space_height_above_anchor =
tray_->shelf()->GetSystemTrayAnchor()->GetBoundsInScreen().y() -
tray_->shelf()->GetUserWorkAreaBounds().y();
return free_space_height_above_anchor - kPaddingFromScreenTop -
bubble_view_->GetBorderInsets().height();
}
void UnifiedSystemTrayBubble::OnDisplayConfigurationChanged() {
UpdateBubbleBounds();
}
void UnifiedSystemTrayBubble::OnWidgetDestroying(views::Widget* widget) { void UnifiedSystemTrayBubble::OnWidgetDestroying(views::Widget* widget) {
CHECK_EQ(bubble_widget_, widget); CHECK_EQ(bubble_widget_, widget);
bubble_widget_->RemoveObserver(this); bubble_widget_->RemoveObserver(this);
...@@ -241,6 +249,9 @@ void UnifiedSystemTrayBubble::OnTabletModeEnded() { ...@@ -241,6 +249,9 @@ void UnifiedSystemTrayBubble::OnTabletModeEnded() {
} }
void UnifiedSystemTrayBubble::UpdateBubbleBounds() { void UnifiedSystemTrayBubble::UpdateBubbleBounds() {
int max_height = CalculateMaxHeight();
unified_view_->SetMaxHeight(max_height);
bubble_view_->SetMaxHeight(max_height);
// If the bubble is open while switching to and from tablet mode, change the // If the bubble is open while switching to and from tablet mode, change the
// bubble anchor if needed. The new anchor view may also have a translation // bubble anchor if needed. The new anchor view may also have a translation
// applied to it so shift the bubble bounds so that it appears in the correct // applied to it so shift the bubble bounds so that it appears in the correct
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include "ash/system/screen_layout_observer.h"
#include "ash/system/tray/time_to_click_recorder.h" #include "ash/system/tray/time_to_click_recorder.h"
#include "ash/system/tray/tray_bubble_base.h" #include "ash/system/tray/tray_bubble_base.h"
#include "ash/wm/tablet_mode/tablet_mode_observer.h" #include "ash/wm/tablet_mode/tablet_mode_observer.h"
...@@ -35,6 +36,7 @@ class UnifiedSystemTrayView; ...@@ -35,6 +36,7 @@ class UnifiedSystemTrayView;
// case, this class calls UnifiedSystemTray::CloseBubble() to delete itself. // case, this class calls UnifiedSystemTray::CloseBubble() to delete itself.
class UnifiedSystemTrayBubble : public TrayBubbleBase, class UnifiedSystemTrayBubble : public TrayBubbleBase,
public views::WidgetObserver, public views::WidgetObserver,
public ash::ScreenLayoutObserver,
public TimeToClickRecorder::Delegate, public TimeToClickRecorder::Delegate,
public TabletModeObserver { public TabletModeObserver {
public: public:
...@@ -67,6 +69,9 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase, ...@@ -67,6 +69,9 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase,
views::TrayBubbleView* GetBubbleView() const override; views::TrayBubbleView* GetBubbleView() const override;
views::Widget* GetBubbleWidget() const override; views::Widget* GetBubbleWidget() const override;
// ash::ScreenLayoutObserver:
void OnDisplayConfigurationChanged() override;
// views::WidgetObserver: // views::WidgetObserver:
void OnWidgetDestroying(views::Widget* widget) override; void OnWidgetDestroying(views::Widget* widget) override;
...@@ -117,6 +122,9 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase, ...@@ -117,6 +122,9 @@ class UnifiedSystemTrayBubble : public TrayBubbleBase,
views::TrayBubbleView* bubble_view_ = nullptr; views::TrayBubbleView* bubble_view_ = nullptr;
UnifiedSystemTrayView* unified_view_ = nullptr; UnifiedSystemTrayView* unified_view_ = nullptr;
private:
int CalculateMaxHeight() const;
DISALLOW_COPY_AND_ASSIGN(UnifiedSystemTrayBubble); DISALLOW_COPY_AND_ASSIGN(UnifiedSystemTrayBubble);
}; };
......
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