OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/bubble/tray_bubble_view.h" | 5 #include "ui/views/bubble/tray_bubble_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "cc/paint/paint_flags.h" | 10 #include "cc/paint/paint_flags.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 using internal::BottomAlignedBoxLayout; | 172 using internal::BottomAlignedBoxLayout; |
173 | 173 |
174 TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, | 174 TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, |
175 int min_width, | 175 int min_width, |
176 int max_width) | 176 int max_width) |
177 : anchor_alignment(anchor_alignment), | 177 : anchor_alignment(anchor_alignment), |
178 min_width(min_width), | 178 min_width(min_width), |
179 max_width(max_width), | 179 max_width(max_width), |
180 max_height(0), | 180 max_height(0), |
181 can_activate(false), | 181 can_activate(false), |
182 close_on_deactivate(true), | 182 close_on_deactivate(true) {} |
183 bg_color(gfx::kPlaceholderColor) {} | |
184 | 183 |
185 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; | 184 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; |
186 | 185 |
187 // static | 186 // static |
188 TrayBubbleView* TrayBubbleView::Create(View* anchor, | 187 TrayBubbleView* TrayBubbleView::Create(View* anchor, |
189 Delegate* delegate, | 188 Delegate* delegate, |
190 InitParams* init_params) { | 189 InitParams* init_params) { |
191 return new TrayBubbleView(anchor, delegate, *init_params); | 190 return new TrayBubbleView(anchor, delegate, *init_params); |
192 } | 191 } |
193 | 192 |
194 TrayBubbleView::TrayBubbleView(View* anchor, | 193 TrayBubbleView::TrayBubbleView(View* anchor, |
195 Delegate* delegate, | 194 Delegate* delegate, |
196 const InitParams& init_params) | 195 const InitParams& init_params) |
197 : BubbleDialogDelegateView(anchor, | 196 : BubbleDialogDelegateView(anchor, |
198 GetArrowAlignment(init_params.anchor_alignment)), | 197 GetArrowAlignment(init_params.anchor_alignment)), |
199 params_(init_params), | 198 params_(init_params), |
200 layout_(new BottomAlignedBoxLayout(this)), | 199 layout_(new BottomAlignedBoxLayout(this)), |
201 delegate_(delegate), | 200 delegate_(delegate), |
202 preferred_width_(init_params.min_width), | 201 preferred_width_(init_params.min_width), |
203 bubble_border_(new BubbleBorder(arrow(), | 202 bubble_border_(new BubbleBorder( |
204 BubbleBorder::NO_ASSETS, | 203 arrow(), |
205 init_params.bg_color)), | 204 BubbleBorder::NO_ASSETS, |
| 205 init_params.bg_color.value_or(gfx::kPlaceholderColor))), |
206 owned_bubble_border_(bubble_border_), | 206 owned_bubble_border_(bubble_border_), |
207 is_gesture_dragging_(false), | 207 is_gesture_dragging_(false), |
208 mouse_actively_entered_(false) { | 208 mouse_actively_entered_(false) { |
| 209 bubble_border_->set_use_theme_background_color(!init_params.bg_color); |
209 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 210 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
210 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); | 211 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); |
211 set_can_activate(params_.can_activate); | 212 set_can_activate(params_.can_activate); |
212 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). | 213 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). |
213 set_notify_enter_exit_on_child(true); | 214 set_notify_enter_exit_on_child(true); |
214 set_close_on_deactivate(init_params.close_on_deactivate); | 215 set_close_on_deactivate(init_params.close_on_deactivate); |
215 set_margins(gfx::Insets()); | 216 set_margins(gfx::Insets()); |
216 SetPaintToLayer(); | 217 SetPaintToLayer(); |
217 | 218 |
218 bubble_content_mask_.reset( | 219 bubble_content_mask_.reset( |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 395 |
395 void TrayBubbleView::ViewHierarchyChanged( | 396 void TrayBubbleView::ViewHierarchyChanged( |
396 const ViewHierarchyChangedDetails& details) { | 397 const ViewHierarchyChangedDetails& details) { |
397 if (details.is_add && details.child == this) { | 398 if (details.is_add && details.child == this) { |
398 details.parent->SetPaintToLayer(); | 399 details.parent->SetPaintToLayer(); |
399 details.parent->layer()->SetMasksToBounds(true); | 400 details.parent->layer()->SetMasksToBounds(true); |
400 } | 401 } |
401 } | 402 } |
402 | 403 |
403 } // namespace views | 404 } // namespace views |
OLD | NEW |