Chromium Code Reviews| Index: chrome/browser/ui/views/exclusive_access_bubble_views.cc |
| diff --git a/chrome/browser/ui/views/exclusive_access_bubble_views.cc b/chrome/browser/ui/views/exclusive_access_bubble_views.cc |
| index f8d5fe5ab87b49753b97943c201b0493de1f8198..46a38c9e44316b20cb3fd5ed04bed5ba8280c5fe 100644 |
| --- a/chrome/browser/ui/views/exclusive_access_bubble_views.cc |
| +++ b/chrome/browser/ui/views/exclusive_access_bubble_views.cc |
| @@ -44,9 +44,8 @@ namespace { |
| // Space between the site info label and the buttons / link. |
| const int kMiddlePaddingPx = 30; |
| -// Gets the opacity of the bubble when not animating. |
| -int GetMaximumOpacity() { |
| - return ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 180 : 255; |
| +float GetBackgroundOpacity() { |
| + return ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() ? 0.7 : 1.0; |
| } |
| class ButtonView : public views::View { |
| @@ -109,11 +108,20 @@ class ExclusiveAccessBubbleViews::ExclusiveAccessView |
| // views::LinkListener |
| void LinkClicked(views::Link* source, int event_flags) override; |
| + // views::View |
| + gfx::Size GetPreferredSize() const override; |
| + void Layout() override; |
| + |
| void UpdateContent(const GURL& url, ExclusiveAccessBubbleType bubble_type); |
| private: |
| ExclusiveAccessBubbleViews* bubble_; |
| + // Background and border (semi-transparent). |
| + views::View* background_; |
|
msw
2015/10/22 22:03:44
Why do we need new container views to set the opac
Matt Giuca
2015/10/26 03:10:38
O_o why didn't I think of that?
Thanks, fixed.
A
|
| + // Container for all text, button and link views. |
| + views::View* contents_; |
| + |
| // Clickable hint text for exiting fullscreen mode. |
| views::Link* link_; |
| // Instruction for exiting mouse lock. |
| @@ -152,25 +160,31 @@ ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( |
| ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() |
| ? SK_ColorBLACK |
| : theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); |
| + SkColor label_background_color = |
| + ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() |
| + ? SK_ColorTRANSPARENT |
| + : background_color; |
| SkColor foreground_color = |
| ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() |
| ? SK_ColorWHITE |
| : theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor); |
| - scoped_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder( |
| - views::BubbleBorder::NONE, shadow_type, background_color)); |
| - set_background(new views::BubbleBackground(bubble_border.get())); |
| - SetBorder(bubble_border.Pass()); |
| SetFocusable(false); |
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| const gfx::FontList& medium_font_list = |
| rb.GetFontList(ui::ResourceBundle::MediumFont); |
| + background_ = new views::View(); |
| + scoped_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder( |
| + views::BubbleBorder::NONE, shadow_type, background_color)); |
| + background_->set_background(new views::BubbleBackground(bubble_border.get())); |
| + background_->SetBorder(bubble_border.Pass()); |
| + |
| if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
| message_label_ = new views::Label(base::string16(), medium_font_list); |
| message_label_->SetEnabledColor(foreground_color); |
| - message_label_->SetBackgroundColor(background_color); |
| + message_label_->SetBackgroundColor(label_background_color); |
| } |
| mouse_lock_exit_instruction_ = |
| @@ -178,7 +192,7 @@ ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( |
| mouse_lock_exit_instruction_->set_collapse_when_hidden(true); |
| mouse_lock_exit_instruction_->SetEnabledColor(foreground_color); |
| - mouse_lock_exit_instruction_->SetBackgroundColor(background_color); |
| + mouse_lock_exit_instruction_->SetBackgroundColor(label_background_color); |
| link_ = new views::Link(); |
| link_->set_collapse_when_hidden(true); |
| @@ -191,12 +205,13 @@ ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( |
| link_->SetFontList(medium_font_list); |
| link_->SetPressedColor(foreground_color); |
| link_->SetEnabledColor(foreground_color); |
| - link_->SetBackgroundColor(background_color); |
| + link_->SetBackgroundColor(label_background_color); |
| link_->SetVisible(false); |
| button_view_ = new ButtonView(this, kPaddingPx); |
| - views::GridLayout* layout = new views::GridLayout(this); |
| + contents_ = new views::View(); |
| + views::GridLayout* layout = new views::GridLayout(contents_); |
| views::ColumnSet* columns = layout->AddColumnSet(0); |
| if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
| // In the simplified UI, do not show the message label, only the exit |
| @@ -224,7 +239,15 @@ ExclusiveAccessBubbleViews::ExclusiveAccessView::ExclusiveAccessView( |
| gfx::Insets padding(kPaddingPx, kPaddingPx, kPaddingPx, kPaddingPx); |
| padding += GetInsets(); |
| layout->SetInsets(padding); |
| - SetLayoutManager(layout); |
| + contents_->SetLayoutManager(layout); |
| + |
| + background_->SetPaintToLayer(true); |
|
msw
2015/10/22 22:03:44
Shouldn't these values be contingent on the new UI
Matt Giuca
2015/10/26 03:10:39
N/A
|
| + background_->SetFillsBoundsOpaquely(false); |
| + background_->layer()->SetOpacity(GetBackgroundOpacity()); |
| + contents_->SetPaintToLayer(true); |
| + contents_->SetFillsBoundsOpaquely(false); |
| + AddChildView(background_); |
| + AddChildView(contents_); |
| UpdateContent(url, bubble_type); |
| } |
| @@ -247,6 +270,20 @@ void ExclusiveAccessBubbleViews::ExclusiveAccessView::LinkClicked( |
| bubble_->ExitExclusiveAccess(); |
| } |
| +gfx::Size ExclusiveAccessBubbleViews::ExclusiveAccessView::GetPreferredSize() |
| + const { |
| + return contents_->GetPreferredSize(); |
| +} |
| + |
| +void ExclusiveAccessBubbleViews::ExclusiveAccessView::Layout() { |
| + // The background's bounds rect must extend out beyond its parent's bounds, to |
| + // account for the border. |
| + gfx::Rect background_rect(GetContentsBounds()); |
| + background_rect.Inset(-background_->GetInsets()); |
| + background_->SetBoundsRect(background_rect); |
| + contents_->SetBoundsRect(GetContentsBounds()); |
| +} |
| + |
| void ExclusiveAccessBubbleViews::ExclusiveAccessView::UpdateContent( |
| const GURL& url, |
| ExclusiveAccessBubbleType bubble_type) { |
| @@ -341,7 +378,6 @@ ExclusiveAccessBubbleViews::ExclusiveAccessBubbleViews( |
| popup_->SetContentsView(view_); |
| gfx::Size size = GetPopupRect(true).size(); |
| popup_->SetBounds(GetPopupRect(false)); |
| - popup_->SetOpacity(GetMaximumOpacity()); |
| // We set layout manager to nullptr to prevent the widget from sizing its |
| // contents to the same size as itself. This prevents the widget contents from |
| // shrinking while we animate the height of the popup to give the impression |
| @@ -445,7 +481,7 @@ void ExclusiveAccessBubbleViews::UpdateForImmersiveState() { |
| // assumes |popup_| has the opacity when it is fully shown and the opacity |
| // animation assumes |popup_| has the bounds when |popup_| is fully shown. |
| if (animated_attribute_ == ANIMATED_ATTRIBUTE_BOUNDS) |
| - popup_->SetOpacity(GetMaximumOpacity()); |
| + popup_->SetOpacity(255); |
| else |
| UpdateBounds(); |
| } |
| @@ -468,7 +504,7 @@ views::View* ExclusiveAccessBubbleViews::GetBrowserRootView() const { |
| void ExclusiveAccessBubbleViews::AnimationProgressed( |
| const gfx::Animation* animation) { |
| if (animated_attribute_ == ANIMATED_ATTRIBUTE_OPACITY) { |
| - int opacity = animation_->CurrentValueBetween(0, GetMaximumOpacity()); |
| + int opacity = animation_->CurrentValueBetween(0, 255); |
| if (opacity == 0) { |
| popup_->Hide(); |
| } else { |
| @@ -517,8 +553,8 @@ gfx::Rect ExclusiveAccessBubbleViews::GetPopupRect( |
| top_container_bottom = |
| bubble_view_context_->GetTopContainerBoundsInScreen().bottom(); |
| } |
| - // |desired_top| is the top of the bubble area including the shadow. |
| - int desired_top = kPopupTopPx - view_->border()->GetInsets().top(); |
| + // |desired_top| is the top of the bubble area excluding the shadow. |
| + int desired_top = kPopupTopPx; |
| int y = top_container_bottom + desired_top; |
| if (!ignore_animation_state && |