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

Side by Side Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2491033006: Adjust positioning of cros tray bubbles. (Closed)
Patch Set: rebase Created 4 years, 1 month 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/common/system/chromeos/palette/palette_tray.h ('k') | ash/common/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/common/system/chromeos/palette/palette_tray.h" 5 #include "ash/common/system/chromeos/palette/palette_tray.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_constants.h" 8 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/shelf/wm_shelf.h" 9 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/shelf/wm_shelf_util.h" 10 #include "ash/common/shelf/wm_shelf_util.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 return ShowPalette(); 206 return ShowPalette();
207 } 207 }
208 208
209 bool PaletteTray::ShowPalette() { 209 bool PaletteTray::ShowPalette() {
210 if (bubble_) 210 if (bubble_)
211 return false; 211 return false;
212 212
213 DCHECK(tray_container()); 213 DCHECK(tray_container());
214 214
215 views::TrayBubbleView::InitParams init_params( 215 views::TrayBubbleView::InitParams init_params(GetAnchorAlignment(),
216 views::TrayBubbleView::ANCHOR_TYPE_TRAY, GetAnchorAlignment(), 216 kPaletteWidth, kPaletteWidth);
217 kPaletteWidth, kPaletteWidth);
218 init_params.first_item_has_no_margin = true;
219 init_params.can_activate = true; 217 init_params.can_activate = true;
220 init_params.close_on_deactivate = true; 218 init_params.close_on_deactivate = true;
221 219
222 DCHECK(tray_container()); 220 DCHECK(tray_container());
223 221
224 // The views::TrayBubbleView ctor will cause a shelf auto hide update check. 222 // The views::TrayBubbleView ctor will cause a shelf auto hide update check.
225 // Make sure to block auto hiding before that check happens. 223 // Make sure to block auto hiding before that check happens.
226 should_block_shelf_auto_hide_ = true; 224 should_block_shelf_auto_hide_ = true;
227 225
228 // TODO(tdanderson): Refactor into common row layout code. 226 // TODO(tdanderson): Refactor into common row layout code.
229 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu 227 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu
230 // rows. 228 // rows.
231 229
232 // Create and customize bubble view. 230 // Create and customize bubble view.
233 views::TrayBubbleView* bubble_view = 231 views::TrayBubbleView* bubble_view =
234 views::TrayBubbleView::Create(tray_container(), this, &init_params); 232 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params);
235 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 233 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets());
236 bubble_view->set_margins( 234 bubble_view->set_margins(
237 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0)); 235 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0));
238 236
239 // Add title. 237 // Add title.
240 auto* title_view = new TitleView(this); 238 auto* title_view = new TitleView(this);
241 title_view->SetBorder(views::CreateEmptyBorder( 239 title_view->SetBorder(views::CreateEmptyBorder(
242 gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0))); 240 gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0)));
243 bubble_view->AddChildView(title_view); 241 bubble_view->AddChildView(title_view);
244 242
245 // Add horizontal separator. 243 // Add horizontal separator.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 302 }
305 303
306 void PaletteTray::OnMouseEnteredView() {} 304 void PaletteTray::OnMouseEnteredView() {}
307 305
308 void PaletteTray::OnMouseExitedView() {} 306 void PaletteTray::OnMouseExitedView() {}
309 307
310 base::string16 PaletteTray::GetAccessibleNameForBubble() { 308 base::string16 PaletteTray::GetAccessibleNameForBubble() {
311 return GetAccessibleNameForTray(); 309 return GetAccessibleNameForTray();
312 } 310 }
313 311
314 gfx::Rect PaletteTray::GetAnchorRect(
315 views::Widget* anchor_widget,
316 views::TrayBubbleView::AnchorType anchor_type,
317 views::TrayBubbleView::AnchorAlignment anchor_alignment) const {
318 gfx::Rect r =
319 GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment);
320
321 // Move the palette to the left so the right edge of the palette aligns with
322 // the right edge of the tray button.
323 if (IsHorizontalAlignment(shelf_alignment())) {
324 // TODO(jdufault): Figure out a more robust adjustment method that does not
325 // break in md-shelf.
326 int icon_size = tray_container()->width();
327 if (tray_container()->border())
328 icon_size -= tray_container()->border()->GetInsets().width();
329
330 r.Offset(-r.width() + icon_size + x(), 0);
331 } else {
332 // Vertical layout doesn't need the border adjustment that horizontal needs.
333 r.Offset(0, -r.height() + tray_container()->height());
334 }
335
336 return r;
337 }
338
339 void PaletteTray::OnBeforeBubbleWidgetInit( 312 void PaletteTray::OnBeforeBubbleWidgetInit(
340 views::Widget* anchor_widget, 313 views::Widget* anchor_widget,
341 views::Widget* bubble_widget, 314 views::Widget* bubble_widget,
342 views::Widget::InitParams* params) const { 315 views::Widget::InitParams* params) const {
343 // Place the bubble in the same root window as |anchor_widget|. 316 // Place the bubble in the same root window as |anchor_widget|.
344 WmLookup::Get() 317 WmLookup::Get()
345 ->GetWindowForWidget(anchor_widget) 318 ->GetWindowForWidget(anchor_widget)
346 ->GetRootWindowController() 319 ->GetRootWindowController()
347 ->ConfigureWidgetInitParamsForContainer( 320 ->ConfigureWidgetInitParamsForContainer(
348 bubble_widget, kShellWindowId_SettingBubbleContainer, params); 321 bubble_widget, kShellWindowId_SettingBubbleContainer, params);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 } else { 436 } else {
464 UpdateIconVisibility(); 437 UpdateIconVisibility();
465 } 438 }
466 } 439 }
467 440
468 void PaletteTray::UpdateIconVisibility() { 441 void PaletteTray::UpdateIconVisibility() {
469 SetVisible(IsInUserSession()); 442 SetVisible(IsInUserSession());
470 } 443 }
471 444
472 } // namespace ash 445 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tray.h ('k') | ash/common/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698