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

Side by Side Diff: ash/system/palette/palette_tray.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 | « ash/system/palette/palette_tray.h ('k') | ash/system/tray/system_tray.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ash/system/palette/palette_tray.h" 5 #include "ash/system/palette/palette_tray.h"
6 6
7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/resources/grit/ash_resources.h" 7 #include "ash/resources/grit/ash_resources.h"
9 #include "ash/resources/vector_icons/vector_icons.h" 8 #include "ash/resources/vector_icons/vector_icons.h"
10 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
11 #include "ash/session/session_controller.h" 10 #include "ash/session/session_controller.h"
12 #include "ash/shelf/shelf.h" 11 #include "ash/shelf/shelf.h"
13 #include "ash/shelf/shelf_constants.h" 12 #include "ash/shelf/shelf_constants.h"
14 #include "ash/shell.h" 13 #include "ash/shell.h"
15 #include "ash/strings/grit/ash_strings.h" 14 #include "ash/strings/grit/ash_strings.h"
16 #include "ash/system/palette/palette_tool_manager.h" 15 #include "ash/system/palette/palette_tool_manager.h"
17 #include "ash/system/palette/palette_utils.h" 16 #include "ash/system/palette/palette_utils.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 172
174 return ShowPalette(); 173 return ShowPalette();
175 } 174 }
176 175
177 bool PaletteTray::ShowPalette() { 176 bool PaletteTray::ShowPalette() {
178 if (bubble_) 177 if (bubble_)
179 return false; 178 return false;
180 179
181 DCHECK(tray_container()); 180 DCHECK(tray_container());
182 181
183 views::TrayBubbleView::InitParams init_params(GetAnchorAlignment(), 182 views::TrayBubbleView::InitParams init_params;
184 kPaletteWidth, kPaletteWidth); 183 init_params.delegate = this;
184 init_params.parent_window = GetBubbleWindowContainer();
185 init_params.anchor_view = GetBubbleAnchor();
186 init_params.anchor_alignment = GetAnchorAlignment();
187 init_params.min_width = kPaletteWidth;
188 init_params.max_width = kPaletteWidth;
185 init_params.can_activate = true; 189 init_params.can_activate = true;
186 init_params.close_on_deactivate = true; 190 init_params.close_on_deactivate = true;
187 191
188 DCHECK(tray_container());
189
190 // TODO(tdanderson): Refactor into common row layout code. 192 // TODO(tdanderson): Refactor into common row layout code.
191 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu 193 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu
192 // rows. 194 // rows.
193 195
194 // Create and customize bubble view. 196 // Create and customize bubble view.
195 views::TrayBubbleView* bubble_view = 197 views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params);
196 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params);
197 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); 198 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets());
198 bubble_view->set_margins( 199 bubble_view->set_margins(
199 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0)); 200 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0));
200 201
201 // Add title. 202 // Add title.
202 auto* title_view = new TitleView(this); 203 auto* title_view = new TitleView(this);
203 title_view->SetBorder(views::CreateEmptyBorder( 204 title_view->SetBorder(views::CreateEmptyBorder(
204 gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0))); 205 gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0)));
205 bubble_view->AddChildView(title_view); 206 bubble_view->AddChildView(title_view);
206 207
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 297 }
297 298
298 void PaletteTray::OnMouseEnteredView() {} 299 void PaletteTray::OnMouseEnteredView() {}
299 300
300 void PaletteTray::OnMouseExitedView() {} 301 void PaletteTray::OnMouseExitedView() {}
301 302
302 base::string16 PaletteTray::GetAccessibleNameForBubble() { 303 base::string16 PaletteTray::GetAccessibleNameForBubble() {
303 return GetAccessibleNameForTray(); 304 return GetAccessibleNameForTray();
304 } 305 }
305 306
306 void PaletteTray::OnBeforeBubbleWidgetInit(
307 views::Widget* anchor_widget,
308 views::Widget* bubble_widget,
309 views::Widget::InitParams* params) const {
310 // Place the bubble in the same root window as |anchor_widget|.
311 RootWindowController::ForWindow(anchor_widget->GetNativeWindow())
312 ->ConfigureWidgetInitParamsForContainer(
313 bubble_widget, kShellWindowId_SettingBubbleContainer, params);
314 }
315
316 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { 307 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) {
317 HideBubbleWithView(bubble_view); 308 HideBubbleWithView(bubble_view);
318 } 309 }
319 310
320 void PaletteTray::HidePalette() { 311 void PaletteTray::HidePalette() {
321 is_bubble_auto_opened_ = false; 312 is_bubble_auto_opened_ = false;
322 num_actions_in_bubble_ = 0; 313 num_actions_in_bubble_ = 0;
323 bubble_.reset(); 314 bubble_.reset();
324 315
325 shelf()->UpdateAutoHideState(); 316 shelf()->UpdateAutoHideState();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 UpdateIconVisibility(); 386 UpdateIconVisibility();
396 } 387 }
397 } 388 }
398 389
399 void PaletteTray::UpdateIconVisibility() { 390 void PaletteTray::UpdateIconVisibility() {
400 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && 391 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() &&
401 ShouldShowOnDisplay(this) && IsInUserSession()); 392 ShouldShowOnDisplay(this) && IsInUserSession());
402 } 393 }
403 394
404 } // namespace ash 395 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/palette/palette_tray.h ('k') | ash/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698