OLD | NEW |
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/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
9 #include "ash/common/shelf/shelf_constants.h" | 9 #include "ash/common/shelf/shelf_constants.h" |
10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "ui/views/controls/separator.h" | 38 #include "ui/views/controls/separator.h" |
39 #include "ui/views/layout/box_layout.h" | 39 #include "ui/views/layout/box_layout.h" |
40 #include "ui/views/layout/fill_layout.h" | 40 #include "ui/views/layout/fill_layout.h" |
41 | 41 |
42 namespace ash { | 42 namespace ash { |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 // Predefined padding for the icon used in this tray. These are to be set to the | 46 // Predefined padding for the icon used in this tray. These are to be set to the |
47 // border of the icon, depending on the current |shelf_alignment()|. | 47 // border of the icon, depending on the current |shelf_alignment()|. |
48 constexpr int kHorizontalShelfHorizontalPadding = 8; | 48 const int kHorizontalShelfHorizontalPadding = 8; |
49 constexpr int kHorizontalShelfVerticalPadding = 4; | 49 const int kHorizontalShelfVerticalPadding = 4; |
50 constexpr int kVerticalShelfHorizontalPadding = 2; | 50 const int kVerticalShelfHorizontalPadding = 2; |
51 constexpr int kVerticalShelfVerticalPadding = 5; | 51 const int kVerticalShelfVerticalPadding = 5; |
52 | 52 |
53 // Width of the palette itself (dp). | 53 // Width of the palette itself (dp). |
54 constexpr int kPaletteWidth = 332; | 54 const int kPaletteWidth = 332; |
55 | 55 |
56 // Padding at the top/bottom of the palette (dp). | 56 // Padding at the top/bottom of the palette (dp). |
57 constexpr int kPalettePaddingOnTop = 4; | 57 const int kPalettePaddingOnTop = 4; |
58 constexpr int kPalettePaddingOnBottom = 2; | 58 const int kPalettePaddingOnBottom = 4; |
| 59 |
| 60 // Size of icon in the shelf (dp). |
| 61 const int kShelfIconSize = 18; |
| 62 |
| 63 // Vertical margin around the title view elements so that the title view height |
| 64 // matches kMenuButtonSize. |
| 65 const int kVerticalMarginAroundTitleView = 1; |
59 | 66 |
60 // Margins between the title view and the edges around it (dp). | 67 // Margins between the title view and the edges around it (dp). |
61 constexpr int kPaddingBetweenTitleAndLeftEdge = 12; | 68 const int kPaddingBetweenTitleAndLeftEdge = 12; |
62 constexpr int kPaddingBetweenTitleAndSeparator = 3; | 69 const int kPaddingBetweenTitleAndSeparator = 3; |
| 70 |
| 71 // The distance between the title, help, and settings button in the title (dp). |
| 72 const int kHorizontalPaddingBetweenTitleEntries = 2; |
63 | 73 |
64 // Color of the separator. | 74 // Color of the separator. |
65 constexpr SkColor kPaletteSeparatorColor = | 75 const SkColor kPaletteSeparatorColor = SkColorSetARGB(0x1E, 0x00, 0x00, 0x00); |
66 SkColorSetARGB(0x1E, 0x00, 0x00, 0x00); | |
67 | 76 |
68 // Returns true if we are in a user session that can show the stylus tools. | 77 // Returns true if we are in a user session that can show the stylus tools. |
69 bool IsInUserSession() { | 78 bool IsInUserSession() { |
70 SessionStateDelegate* session_state_delegate = | 79 SessionStateDelegate* session_state_delegate = |
71 WmShell::Get()->GetSessionStateDelegate(); | 80 WmShell::Get()->GetSessionStateDelegate(); |
72 return !session_state_delegate->IsUserSessionBlocked() && | 81 return !session_state_delegate->IsUserSessionBlocked() && |
73 session_state_delegate->GetSessionState() == | 82 session_state_delegate->GetSessionState() == |
74 session_manager::SessionState::ACTIVE && | 83 session_manager::SessionState::ACTIVE && |
75 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != | 84 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != |
76 LoginStatus::KIOSK_APP; | 85 LoginStatus::KIOSK_APP; |
77 } | 86 } |
78 | 87 |
79 class TitleView : public views::View, public views::ButtonListener { | 88 class TitleView : public views::View, public views::ButtonListener { |
80 public: | 89 public: |
81 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { | 90 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { |
82 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. | 91 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. |
83 // See crbug.com/614453. | 92 // See crbug.com/614453. |
84 auto* box_layout = | 93 auto* box_layout = new views::BoxLayout( |
85 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 94 views::BoxLayout::kHorizontal, 0, kVerticalMarginAroundTitleView, |
| 95 kHorizontalPaddingBetweenTitleEntries); |
86 SetLayoutManager(box_layout); | 96 SetLayoutManager(box_layout); |
87 | 97 |
88 title_label_ = | 98 title_label_ = |
89 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); | 99 new views::Label(l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE)); |
90 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 100 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
91 AddChildView(title_label_); | 101 AddChildView(title_label_); |
92 box_layout->SetFlexForView(title_label_, 1); | 102 box_layout->SetFlexForView(title_label_, 1); |
93 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 103 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { |
94 help_button_ = | 104 help_button_ = |
95 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, | 105 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 } else { | 424 } else { |
415 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets( | 425 icon_->SetBorder(views::CreateEmptyBorder(gfx::Insets( |
416 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); | 426 kVerticalShelfVerticalPadding, kVerticalShelfHorizontalPadding))); |
417 } | 427 } |
418 } | 428 } |
419 | 429 |
420 void PaletteTray::UpdateTrayIcon() { | 430 void PaletteTray::UpdateTrayIcon() { |
421 icon_->SetImage(CreateVectorIcon( | 431 icon_->SetImage(CreateVectorIcon( |
422 palette_tool_manager_->GetActiveTrayIcon( | 432 palette_tool_manager_->GetActiveTrayIcon( |
423 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)), | 433 palette_tool_manager_->GetActiveTool(ash::PaletteGroup::MODE)), |
424 kTrayIconSize, kShelfIconColor)); | 434 kShelfIconSize, kShelfIconColor)); |
425 } | 435 } |
426 | 436 |
427 void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) { | 437 void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) { |
428 PaletteDelegate* palette_delegate = WmShell::Get()->palette_delegate(); | 438 PaletteDelegate* palette_delegate = WmShell::Get()->palette_delegate(); |
429 | 439 |
430 // Don't do anything if the palette should not be shown or if the user has | 440 // Don't do anything if the palette should not be shown or if the user has |
431 // disabled it all-together. | 441 // disabled it all-together. |
432 if (!IsInUserSession() || !palette_delegate->ShouldShowPalette()) | 442 if (!IsInUserSession() || !palette_delegate->ShouldShowPalette()) |
433 return; | 443 return; |
434 | 444 |
(...skipping 21 matching lines...) Expand all Loading... |
456 } else { | 466 } else { |
457 UpdateIconVisibility(); | 467 UpdateIconVisibility(); |
458 } | 468 } |
459 } | 469 } |
460 | 470 |
461 void PaletteTray::UpdateIconVisibility() { | 471 void PaletteTray::UpdateIconVisibility() { |
462 SetVisible(is_palette_enabled_ && IsInUserSession()); | 472 SetVisible(is_palette_enabled_ && IsInUserSession()); |
463 } | 473 } |
464 | 474 |
465 } // namespace ash | 475 } // namespace ash |
OLD | NEW |