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