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

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

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge 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
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 // Create and customize bubble view. 232 // Create and customize bubble view.
233 views::TrayBubbleView* bubble_view = 233 views::TrayBubbleView* bubble_view =
234 views::TrayBubbleView::Create(tray_container(), this, &init_params); 234 views::TrayBubbleView::Create(tray_container(), this, &init_params);
235 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 235 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
236 bubble_view->set_margins( 236 bubble_view->set_margins(
237 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0)); 237 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0));
238 238
239 // Add title. 239 // Add title.
240 auto* title_view = new TitleView(this); 240 auto* title_view = new TitleView(this);
241 title_view->SetBorder(views::Border::CreateEmptyBorder( 241 title_view->SetBorder(views::CreateEmptyBorder(
242 gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0))); 242 gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0)));
243 bubble_view->AddChildView(title_view); 243 bubble_view->AddChildView(title_view);
244 244
245 // Add horizontal separator. 245 // Add horizontal separator.
246 views::Separator* separator = 246 views::Separator* separator =
247 new views::Separator(views::Separator::HORIZONTAL); 247 new views::Separator(views::Separator::HORIZONTAL);
248 separator->SetColor(kPaletteSeparatorColor); 248 separator->SetColor(kPaletteSeparatorColor);
249 separator->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets( 249 separator->SetBorder(views::CreateEmptyBorder(gfx::Insets(
250 kPaddingBetweenTitleAndSeparator, 0, kMenuSeparatorVerticalPadding, 0))); 250 kPaddingBetweenTitleAndSeparator, 0, kMenuSeparatorVerticalPadding, 0)));
251 bubble_view->AddChildView(separator); 251 bubble_view->AddChildView(separator);
252 252
253 // Add palette tools. 253 // Add palette tools.
254 // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design 254 // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design
255 // ripples. 255 // ripples.
256 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews(); 256 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews();
257 for (const PaletteToolView& view : views) 257 for (const PaletteToolView& view : views)
258 bubble_view->AddChildView(view.view); 258 bubble_view->AddChildView(view.view);
259 259
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 405
406 void PaletteTray::AnchorUpdated() { 406 void PaletteTray::AnchorUpdated() {
407 if (bubble_) 407 if (bubble_)
408 bubble_->bubble_view()->UpdateBubble(); 408 bubble_->bubble_view()->UpdateBubble();
409 } 409 }
410 410
411 void PaletteTray::SetIconBorderForShelfAlignment() { 411 void PaletteTray::SetIconBorderForShelfAlignment() {
412 // TODO(tdanderson): Ensure PaletteTray follows material design specs. See 412 // TODO(tdanderson): Ensure PaletteTray follows material design specs. See
413 // crbug.com/630464. 413 // crbug.com/630464.
414 if (IsHorizontalAlignment(shelf_alignment())) { 414 if (IsHorizontalAlignment(shelf_alignment())) {
415 icon_->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets( 415 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets(
416 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding))); 416 kHorizontalShelfVerticalPadding, kHorizontalShelfHorizontalPadding)));
417 } else { 417 } else {
418 icon_->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets( 418 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets(
419 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); 419 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding)));
420 } 420 }
421 } 421 }
422 422
423 void PaletteTray::UpdateTrayIcon() { 423 void PaletteTray::UpdateTrayIcon() {
424 icon_->SetImage(CreateVectorIcon( 424 icon_->SetImage(CreateVectorIcon(
425 palette_tool_manager_->GetActiveTrayIcon( 425 palette_tool_manager_->GetActiveTrayIcon(
426 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)), 426 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)),
427 kShelfIconSize, kShelfIconColor)); 427 kShelfIconSize, kShelfIconColor));
428 } 428 }
(...skipping 28 matching lines...) Expand all
457 } else { 457 } else {
458 UpdateIconVisibility(); 458 UpdateIconVisibility();
459 } 459 }
460 } 460 }
461 461
462 void PaletteTray::UpdateIconVisibility() { 462 void PaletteTray::UpdateIconVisibility() {
463 SetVisible(IsInUserSession()); 463 SetVisible(IsInUserSession());
464 } 464 }
465 465
466 } // namespace ash 466 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698