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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 using internal::BottomAlignedBoxLayout; | 168 using internal::BottomAlignedBoxLayout; |
169 | 169 |
170 TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, | 170 TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, |
171 int min_width, | 171 int min_width, |
172 int max_width) | 172 int max_width) |
173 : anchor_alignment(anchor_alignment), | 173 : anchor_alignment(anchor_alignment), |
174 min_width(min_width), | 174 min_width(min_width), |
175 max_width(max_width), | 175 max_width(max_width), |
176 max_height(0), | 176 max_height(0), |
177 can_activate(false), | 177 can_activate(false), |
178 close_on_deactivate(true), | 178 close_on_deactivate(true) {} |
179 bg_color(gfx::kPlaceholderColor) {} | |
180 | 179 |
181 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; | 180 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; |
182 | 181 |
183 // static | 182 // static |
184 TrayBubbleView* TrayBubbleView::Create(View* anchor, | 183 TrayBubbleView* TrayBubbleView::Create(View* anchor, |
185 Delegate* delegate, | 184 Delegate* delegate, |
186 InitParams* init_params) { | 185 InitParams* init_params) { |
187 return new TrayBubbleView(anchor, delegate, *init_params); | 186 return new TrayBubbleView(anchor, delegate, *init_params); |
188 } | 187 } |
189 | 188 |
190 TrayBubbleView::TrayBubbleView(View* anchor, | 189 TrayBubbleView::TrayBubbleView(View* anchor, |
191 Delegate* delegate, | 190 Delegate* delegate, |
192 const InitParams& init_params) | 191 const InitParams& init_params) |
193 : BubbleDialogDelegateView(anchor, | 192 : BubbleDialogDelegateView(anchor, |
194 GetArrowAlignment(init_params.anchor_alignment)), | 193 GetArrowAlignment(init_params.anchor_alignment)), |
195 params_(init_params), | 194 params_(init_params), |
196 layout_(new BottomAlignedBoxLayout(this)), | 195 layout_(new BottomAlignedBoxLayout(this)), |
197 delegate_(delegate), | 196 delegate_(delegate), |
198 preferred_width_(init_params.min_width), | 197 preferred_width_(init_params.min_width), |
199 bubble_border_(new BubbleBorder(arrow(), | 198 bubble_border_(new BubbleBorder( |
200 BubbleBorder::NO_ASSETS, | 199 arrow(), |
201 init_params.bg_color)), | 200 BubbleBorder::NO_ASSETS, |
| 201 init_params.bg_color.value_or(gfx::kPlaceholderColor))), |
202 owned_bubble_border_(bubble_border_), | 202 owned_bubble_border_(bubble_border_), |
203 is_gesture_dragging_(false), | 203 is_gesture_dragging_(false), |
204 mouse_actively_entered_(false) { | 204 mouse_actively_entered_(false) { |
| 205 bubble_border_->set_use_theme_background_color(!init_params.bg_color); |
205 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 206 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
206 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); | 207 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); |
207 set_can_activate(params_.can_activate); | 208 set_can_activate(params_.can_activate); |
208 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). | 209 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView(). |
209 set_notify_enter_exit_on_child(true); | 210 set_notify_enter_exit_on_child(true); |
210 set_close_on_deactivate(init_params.close_on_deactivate); | 211 set_close_on_deactivate(init_params.close_on_deactivate); |
211 set_margins(gfx::Insets()); | 212 set_margins(gfx::Insets()); |
212 SetPaintToLayer(); | 213 SetPaintToLayer(); |
213 | 214 |
214 bubble_content_mask_.reset( | 215 bubble_content_mask_.reset( |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 378 |
378 void TrayBubbleView::ViewHierarchyChanged( | 379 void TrayBubbleView::ViewHierarchyChanged( |
379 const ViewHierarchyChangedDetails& details) { | 380 const ViewHierarchyChangedDetails& details) { |
380 if (details.is_add && details.child == this) { | 381 if (details.is_add && details.child == this) { |
381 details.parent->SetPaintToLayer(); | 382 details.parent->SetPaintToLayer(); |
382 details.parent->layer()->SetMasksToBounds(true); | 383 details.parent->layer()->SetMasksToBounds(true); |
383 } | 384 } |
384 } | 385 } |
385 | 386 |
386 } // namespace views | 387 } // namespace views |
OLD | NEW |