Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Side by Side Diff: ui/views/bubble/tray_bubble_view.cc

Issue 2901273003: chromeos: Remove TrayBubbleView::Delegate::OnBeforeBubbleWidgetInit (Closed)
Patch Set: comments, use InitParams for all parameters Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 TrayBubbleView* bubble_view_; 164 TrayBubbleView* bubble_view_;
165 165
166 DISALLOW_COPY_AND_ASSIGN(BottomAlignedBoxLayout); 166 DISALLOW_COPY_AND_ASSIGN(BottomAlignedBoxLayout);
167 }; 167 };
168 168
169 } // namespace internal 169 } // namespace internal
170 170
171 using internal::TrayBubbleContentMask; 171 using internal::TrayBubbleContentMask;
172 using internal::BottomAlignedBoxLayout; 172 using internal::BottomAlignedBoxLayout;
173 173
174 TrayBubbleView::InitParams::InitParams(AnchorAlignment anchor_alignment, 174 TrayBubbleView::InitParams::InitParams()
175 int min_width, 175 : delegate(nullptr),
msw 2017/05/30 18:36:04 optional nit: move member init to the decl?
176 int max_width) 176 parent_window(nullptr),
177 : anchor_alignment(anchor_alignment), 177 anchor_view(nullptr),
178 min_width(min_width), 178 anchor_alignment(ANCHOR_ALIGNMENT_BOTTOM),
179 max_width(max_width), 179 min_width(0),
180 max_width(0),
180 max_height(0), 181 max_height(0),
181 can_activate(false), 182 can_activate(false),
182 close_on_deactivate(true) {} 183 close_on_deactivate(true) {}
183 184
184 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; 185 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default;
185 186
186 // static 187 TrayBubbleView::TrayBubbleView(const InitParams& init_params)
187 TrayBubbleView* TrayBubbleView::Create(View* anchor, 188 : BubbleDialogDelegateView(init_params.anchor_view,
188 Delegate* delegate,
189 InitParams* init_params) {
190 return new TrayBubbleView(anchor, delegate, *init_params);
191 }
192
193 TrayBubbleView::TrayBubbleView(View* anchor,
194 Delegate* delegate,
195 const InitParams& init_params)
196 : BubbleDialogDelegateView(anchor,
197 GetArrowAlignment(init_params.anchor_alignment)), 189 GetArrowAlignment(init_params.anchor_alignment)),
198 params_(init_params), 190 params_(init_params),
199 layout_(new BottomAlignedBoxLayout(this)), 191 layout_(new BottomAlignedBoxLayout(this)),
200 delegate_(delegate), 192 delegate_(init_params.delegate),
201 preferred_width_(init_params.min_width), 193 preferred_width_(init_params.min_width),
202 bubble_border_(new BubbleBorder( 194 bubble_border_(new BubbleBorder(
203 arrow(), 195 arrow(),
204 BubbleBorder::NO_ASSETS, 196 BubbleBorder::NO_ASSETS,
205 init_params.bg_color.value_or(gfx::kPlaceholderColor))), 197 init_params.bg_color.value_or(gfx::kPlaceholderColor))),
206 owned_bubble_border_(bubble_border_), 198 owned_bubble_border_(bubble_border_),
207 is_gesture_dragging_(false), 199 is_gesture_dragging_(false),
208 mouse_actively_entered_(false) { 200 mouse_actively_entered_(false) {
201 DCHECK(delegate_);
202 DCHECK(params_.parent_window);
203 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView().
209 bubble_border_->set_use_theme_background_color(!init_params.bg_color); 204 bubble_border_->set_use_theme_background_color(!init_params.bg_color);
210 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 205 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
211 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); 206 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE);
207 set_parent_window(params_.parent_window);
212 set_can_activate(params_.can_activate); 208 set_can_activate(params_.can_activate);
213 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView().
214 set_notify_enter_exit_on_child(true); 209 set_notify_enter_exit_on_child(true);
215 set_close_on_deactivate(init_params.close_on_deactivate); 210 set_close_on_deactivate(init_params.close_on_deactivate);
216 set_margins(gfx::Insets()); 211 set_margins(gfx::Insets());
217 SetPaintToLayer(); 212 SetPaintToLayer();
218 213
219 bubble_content_mask_.reset( 214 bubble_content_mask_.reset(
220 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); 215 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius()));
221 216
222 layout_->SetDefaultFlex(1); 217 layout_->SetDefaultFlex(1);
223 SetLayoutManager(layout_); 218 SetLayoutManager(layout_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 gfx::Insets TrayBubbleView::GetBorderInsets() const { 271 gfx::Insets TrayBubbleView::GetBorderInsets() const {
277 return bubble_border_->GetInsets(); 272 return bubble_border_->GetInsets();
278 } 273 }
279 274
280 int TrayBubbleView::GetDialogButtons() const { 275 int TrayBubbleView::GetDialogButtons() const {
281 return ui::DIALOG_BUTTON_NONE; 276 return ui::DIALOG_BUTTON_NONE;
282 } 277 }
283 278
284 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, 279 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params,
285 Widget* bubble_widget) const { 280 Widget* bubble_widget) const {
286 if (delegate_)
287 delegate_->OnBeforeBubbleWidgetInit(anchor_widget(), bubble_widget, params);
288 // Apply a WM-provided shadow (see ui/wm/core/). 281 // Apply a WM-provided shadow (see ui/wm/core/).
289 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP; 282 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP;
290 params->shadow_elevation = wm::ShadowElevation::LARGE; 283 params->shadow_elevation = wm::ShadowElevation::LARGE;
291 } 284 }
292 285
293 void TrayBubbleView::OnWidgetClosing(Widget* widget) { 286 void TrayBubbleView::OnWidgetClosing(Widget* widget) {
294 BubbleDialogDelegateView::OnWidgetClosing(widget); 287 BubbleDialogDelegateView::OnWidgetClosing(widget);
295 --g_current_tray_bubble_showing_count_; 288 --g_current_tray_bubble_showing_count_;
296 DCHECK_GE(g_current_tray_bubble_showing_count_, 0); 289 DCHECK_GE(g_current_tray_bubble_showing_count_, 0);
297 } 290 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 388
396 void TrayBubbleView::ViewHierarchyChanged( 389 void TrayBubbleView::ViewHierarchyChanged(
397 const ViewHierarchyChangedDetails& details) { 390 const ViewHierarchyChangedDetails& details) {
398 if (details.is_add && details.child == this) { 391 if (details.is_add && details.child == this) {
399 details.parent->SetPaintToLayer(); 392 details.parent->SetPaintToLayer();
400 details.parent->layer()->SetMasksToBounds(true); 393 details.parent->layer()->SetMasksToBounds(true);
401 } 394 }
402 } 395 }
403 396
404 } // namespace views 397 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/tray_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698