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

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

Issue 2825383003: Fix stylus tools palette. (Closed)
Patch Set: Fix nits. Created 3 years, 7 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/palette/palette_utils.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" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/resources/grit/ash_resources.h" 8 #include "ash/resources/grit/ash_resources.h"
9 #include "ash/resources/vector_icons/vector_icons.h" 9 #include "ash/resources/vector_icons/vector_icons.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/session/session_controller.h" 11 #include "ash/session/session_controller.h"
12 #include "ash/shelf/shelf_constants.h" 12 #include "ash/shelf/shelf_constants.h"
13 #include "ash/shelf/wm_shelf.h" 13 #include "ash/shelf/wm_shelf.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/strings/grit/ash_strings.h" 15 #include "ash/strings/grit/ash_strings.h"
16 #include "ash/system/palette/palette_tool_manager.h" 16 #include "ash/system/palette/palette_tool_manager.h"
17 #include "ash/system/palette/palette_utils.h" 17 #include "ash/system/palette/palette_utils.h"
18 #include "ash/system/tray/system_menu_button.h" 18 #include "ash/system/tray/system_menu_button.h"
19 #include "ash/system/tray/system_tray_controller.h" 19 #include "ash/system/tray/system_tray_controller.h"
20 #include "ash/system/tray/system_tray_delegate.h" 20 #include "ash/system/tray/system_tray_delegate.h"
21 #include "ash/system/tray/tray_bubble_wrapper.h" 21 #include "ash/system/tray/tray_bubble_wrapper.h"
22 #include "ash/system/tray/tray_constants.h" 22 #include "ash/system/tray/tray_constants.h"
23 #include "ash/system/tray/tray_container.h" 23 #include "ash/system/tray/tray_container.h"
24 #include "ash/system/tray/tray_popup_header_button.h" 24 #include "ash/system/tray/tray_popup_header_button.h"
25 #include "ash/system/tray/tray_popup_item_style.h" 25 #include "ash/system/tray/tray_popup_item_style.h"
26 #include "ash/wm_window.h" 26 #include "ash/wm_window.h"
27 #include "base/metrics/histogram_macros.h" 27 #include "base/metrics/histogram_macros.h"
28 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/display/display.h"
30 #include "ui/events/devices/input_device_manager.h" 31 #include "ui/events/devices/input_device_manager.h"
31 #include "ui/events/devices/stylus_state.h" 32 #include "ui/events/devices/stylus_state.h"
32 #include "ui/gfx/color_palette.h" 33 #include "ui/gfx/color_palette.h"
33 #include "ui/gfx/paint_vector_icon.h" 34 #include "ui/gfx/paint_vector_icon.h"
34 #include "ui/views/controls/image_view.h" 35 #include "ui/views/controls/image_view.h"
35 #include "ui/views/controls/label.h" 36 #include "ui/views/controls/label.h"
36 #include "ui/views/controls/separator.h" 37 #include "ui/views/controls/separator.h"
37 #include "ui/views/layout/box_layout.h" 38 #include "ui/views/layout/box_layout.h"
38 #include "ui/views/layout/fill_layout.h" 39 #include "ui/views/layout/fill_layout.h"
39 40
(...skipping 22 matching lines...) Expand all
62 // Returns true if we are in a user session that can show the stylus tools. 63 // Returns true if we are in a user session that can show the stylus tools.
63 bool IsInUserSession() { 64 bool IsInUserSession() {
64 SessionController* session_controller = Shell::Get()->session_controller(); 65 SessionController* session_controller = Shell::Get()->session_controller();
65 return !session_controller->IsUserSessionBlocked() && 66 return !session_controller->IsUserSessionBlocked() &&
66 session_controller->GetSessionState() == 67 session_controller->GetSessionState() ==
67 session_manager::SessionState::ACTIVE && 68 session_manager::SessionState::ACTIVE &&
68 Shell::Get()->system_tray_delegate()->GetUserLoginStatus() != 69 Shell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
69 LoginStatus::KIOSK_APP; 70 LoginStatus::KIOSK_APP;
70 } 71 }
71 72
73 // Returns true if the |palette_tray| is on an internal display or on every
74 // display if requested from the command line.
75 bool ShouldShowOnDisplay(PaletteTray* palette_tray) {
76 const display::Display& display =
77 WmWindow::Get(palette_tray->GetWidget()->GetNativeWindow())
78 ->GetDisplayNearestWindow();
79 return display.IsInternal() ||
80 palette_utils::IsPaletteEnabledOnEveryDisplay();
81 }
82
72 class TitleView : public views::View, public views::ButtonListener { 83 class TitleView : public views::View, public views::ButtonListener {
73 public: 84 public:
74 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) { 85 explicit TitleView(PaletteTray* palette_tray) : palette_tray_(palette_tray) {
75 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title. 86 // TODO(tdanderson|jdufault): Use TriView to handle the layout of the title.
76 // See crbug.com/614453. 87 // See crbug.com/614453.
77 auto* box_layout = 88 auto* box_layout =
78 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 89 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
79 SetLayoutManager(box_layout); 90 SetLayoutManager(box_layout);
80 91
81 auto* title_label = 92 auto* title_label =
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 if (!enabled) { 394 if (!enabled) {
384 SetVisible(false); 395 SetVisible(false);
385 palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE); 396 palette_tool_manager_->DisableActiveTool(PaletteGroup::MODE);
386 } else { 397 } else {
387 UpdateIconVisibility(); 398 UpdateIconVisibility();
388 } 399 }
389 } 400 }
390 401
391 void PaletteTray::UpdateIconVisibility() { 402 void PaletteTray::UpdateIconVisibility() {
392 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && 403 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() &&
393 IsInUserSession()); 404 ShouldShowOnDisplay(this) && IsInUserSession());
394 } 405 }
395 406
396 } // namespace ash 407 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/palette/palette_tray.h ('k') | ash/system/palette/palette_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698