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

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

Issue 2901273003: chromeos: Remove TrayBubbleView::Delegate::OnBeforeBubbleWidgetInit (Closed)
Patch Set: nit 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() = default;
175 int min_width,
176 int max_width)
177 : anchor_alignment(anchor_alignment),
178 min_width(min_width),
179 max_width(max_width),
180 max_height(0),
181 can_activate(false),
182 close_on_deactivate(true) {}
183 175
184 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default; 176 TrayBubbleView::InitParams::InitParams(const InitParams& other) = default;
185 177
186 // static 178 TrayBubbleView::TrayBubbleView(const InitParams& init_params)
187 TrayBubbleView* TrayBubbleView::Create(View* anchor, 179 : 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)), 180 GetArrowAlignment(init_params.anchor_alignment)),
198 params_(init_params), 181 params_(init_params),
199 layout_(new BottomAlignedBoxLayout(this)), 182 layout_(new BottomAlignedBoxLayout(this)),
200 delegate_(delegate), 183 delegate_(init_params.delegate),
201 preferred_width_(init_params.min_width), 184 preferred_width_(init_params.min_width),
202 bubble_border_(new BubbleBorder( 185 bubble_border_(new BubbleBorder(
203 arrow(), 186 arrow(),
204 BubbleBorder::NO_ASSETS, 187 BubbleBorder::NO_ASSETS,
205 init_params.bg_color.value_or(gfx::kPlaceholderColor))), 188 init_params.bg_color.value_or(gfx::kPlaceholderColor))),
206 owned_bubble_border_(bubble_border_), 189 owned_bubble_border_(bubble_border_),
207 is_gesture_dragging_(false), 190 is_gesture_dragging_(false),
208 mouse_actively_entered_(false) { 191 mouse_actively_entered_(false) {
192 DCHECK(delegate_);
193 DCHECK(params_.parent_window);
194 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView().
209 bubble_border_->set_use_theme_background_color(!init_params.bg_color); 195 bubble_border_->set_use_theme_background_color(!init_params.bg_color);
210 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 196 bubble_border_->set_alignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
211 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE); 197 bubble_border_->set_paint_arrow(BubbleBorder::PAINT_NONE);
198 set_parent_window(params_.parent_window);
212 set_can_activate(params_.can_activate); 199 set_can_activate(params_.can_activate);
213 DCHECK(anchor_widget()); // Computed by BubbleDialogDelegateView().
214 set_notify_enter_exit_on_child(true); 200 set_notify_enter_exit_on_child(true);
215 set_close_on_deactivate(init_params.close_on_deactivate); 201 set_close_on_deactivate(init_params.close_on_deactivate);
216 set_margins(gfx::Insets()); 202 set_margins(gfx::Insets());
217 SetPaintToLayer(); 203 SetPaintToLayer();
218 204
219 bubble_content_mask_.reset( 205 bubble_content_mask_.reset(
220 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius())); 206 new TrayBubbleContentMask(bubble_border_->GetBorderCornerRadius()));
221 207
222 layout_->SetDefaultFlex(1); 208 layout_->SetDefaultFlex(1);
223 SetLayoutManager(layout_); 209 SetLayoutManager(layout_);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 gfx::Insets TrayBubbleView::GetBorderInsets() const { 262 gfx::Insets TrayBubbleView::GetBorderInsets() const {
277 return bubble_border_->GetInsets(); 263 return bubble_border_->GetInsets();
278 } 264 }
279 265
280 int TrayBubbleView::GetDialogButtons() const { 266 int TrayBubbleView::GetDialogButtons() const {
281 return ui::DIALOG_BUTTON_NONE; 267 return ui::DIALOG_BUTTON_NONE;
282 } 268 }
283 269
284 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params, 270 void TrayBubbleView::OnBeforeBubbleWidgetInit(Widget::InitParams* params,
285 Widget* bubble_widget) const { 271 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/). 272 // Apply a WM-provided shadow (see ui/wm/core/).
289 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP; 273 params->shadow_type = Widget::InitParams::SHADOW_TYPE_DROP;
290 params->shadow_elevation = wm::ShadowElevation::LARGE; 274 params->shadow_elevation = wm::ShadowElevation::LARGE;
291 } 275 }
292 276
293 void TrayBubbleView::OnWidgetClosing(Widget* widget) { 277 void TrayBubbleView::OnWidgetClosing(Widget* widget) {
294 BubbleDialogDelegateView::OnWidgetClosing(widget); 278 BubbleDialogDelegateView::OnWidgetClosing(widget);
295 --g_current_tray_bubble_showing_count_; 279 --g_current_tray_bubble_showing_count_;
296 DCHECK_GE(g_current_tray_bubble_showing_count_, 0); 280 DCHECK_GE(g_current_tray_bubble_showing_count_, 0);
297 } 281 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 379
396 void TrayBubbleView::ViewHierarchyChanged( 380 void TrayBubbleView::ViewHierarchyChanged(
397 const ViewHierarchyChangedDetails& details) { 381 const ViewHierarchyChangedDetails& details) {
398 if (details.is_add && details.child == this) { 382 if (details.is_add && details.child == this) {
399 details.parent->SetPaintToLayer(); 383 details.parent->SetPaintToLayer();
400 details.parent->layer()->SetMasksToBounds(true); 384 details.parent->layer()->SetMasksToBounds(true);
401 } 385 }
402 } 386 }
403 387
404 } // namespace views 388 } // 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