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

Side by Side Diff: ash/system/display_scale/scale_detailed_view.cc

Issue 2855143004: Implements a display scale tray setting behind a chrome switch (Closed)
Patch Set: Sync with ToT 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/system/display_scale/scale_detailed_view.h"
6
7 #include "ash/shell.h"
8 #include "ash/strings/grit/ash_strings.h"
9 #include "ash/system/tray/hover_highlight_view.h"
10 #include "ash/system/tray/tray_popup_utils.h"
11 #include "base/command_line.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "ui/display/display.h"
15 #include "ui/display/display_switches.h"
16 #include "ui/display/manager/display_manager.h"
17 #include "ui/views/controls/scroll_view.h"
18
19 namespace ash {
20 namespace tray {
21 namespace {
22
23 double scales[] = {1.0f, 1.25f, 1.33f, 1.5f, 1.66f,
24 1.75f, 1.9f, 2.0f, 2.25f, 2.5f};
25 double kEpsilon = 0.005;
26
27 } // namespace
28
29 ScaleDetailedView::ScaleDetailedView(SystemTrayItem* owner)
30 : TrayDetailsView(owner) {
31 CreateScrollableList();
32 CreateTitleRow(IDS_ASH_STATUS_TRAY_SCALE);
33 UpdateScrollableList();
34 Layout();
35 }
36
37 ScaleDetailedView::~ScaleDetailedView() {}
38
39 HoverHighlightView* ScaleDetailedView::AddScrollListItem(
40 const base::string16& text,
41 bool highlight,
42 bool checked) {
43 HoverHighlightView* container = new HoverHighlightView(this);
44
45 container->AddLabelRow(text);
46 TrayPopupUtils::InitializeAsCheckableRow(container, checked);
47
48 scroll_content()->AddChildView(container);
49 return container;
50 }
51
52 void ScaleDetailedView::UpdateScrollableList() {
53 scroll_content()->RemoveAllChildViews(true);
54 view_to_scale_.clear();
55
56 for (double scale : scales) {
57 HoverHighlightView* container = AddScrollListItem(
58 base::UTF8ToUTF16(base::DoubleToString(scale)), false /* highlight */,
59 std::abs(display::Display::GetForcedDeviceScaleFactor() - scale) <
60 kEpsilon /* checkmark icon */);
61 view_to_scale_[container] = scale;
oshima 2017/05/06 19:50:22 optional: or you can parse it from the view.
malaykeshav 2017/05/08 19:18:06 Ack
62 }
63 }
64
65 void ScaleDetailedView::HandleViewClicked(views::View* view) {
66 display::Display::SetForceDeviceScaleFactor(view_to_scale_[view]);
67 ash::Shell::Get()->display_manager()->UpdateDisplays();
68 UpdateScrollableList();
69 Layout();
70 }
71
72 } // namespace tray
73 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698