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

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

Issue 2849953004: SV Test
Patch Set: 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/fractional_view/scale_detailed_view.h"
6
7 #include "ash/resources/vector_icons/vector_icons.h"
8 #include "ash/shell.h"
9 #include "ash/system/tray/hover_highlight_view.h"
10 #include "ash/system/tray/tray_popup_utils.h"
11 #include "ash/system/tray/tri_view.h"
12 #include "base/command_line.h"
13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/utf_string_conversions.h"
15 #include "ui/display/display.h"
16 #include "ui/display/display_switches.h"
17 #include "ui/display/manager/display_manager.h"
18 #include "ui/gfx/color_palette.h"
19 #include "ui/gfx/paint_vector_icon.h"
20 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/controls/image_view.h"
22 #include "ui/views/controls/label.h"
23 #include "ui/views/controls/scroll_view.h"
24 #include "ui/views/controls/separator.h"
25
26 namespace ash {
27 namespace tray {
28 namespace {
29
30 double scales[] = {1.0f, 1.25f, 1.33f, 1.5f, 1.66f,
31 1.75f, 1.9f, 2.0f, 2.25f, 2.5f};
32
33 } // namespace
34
35 ScaleDetailedView::ScaleDetailedView(SystemTrayItem* owner)
36 : TrayDetailsView(owner) {
37 CreateScrollableList();
38 UpdateScrollableList();
39 Layout();
40 }
41
42 ScaleDetailedView::~ScaleDetailedView() {}
43
44 HoverHighlightView* ScaleDetailedView::AddScrollListItem(
45 const base::string16& text,
46 bool highlight,
47 bool checked) {
48 HoverHighlightView* container = new HoverHighlightView(this);
49
50 container->AddLabelRow(text);
51 TrayPopupUtils::InitializeAsCheckableRow(container, checked);
52
53 scroll_content()->AddChildView(container);
54 return container;
55 }
56
57 void ScaleDetailedView::UpdateScrollableList() {
58 scroll_content()->RemoveAllChildViews(true);
59
60 for (double scale : scales) {
61 HoverHighlightView* container = AddScrollListItem(
62 base::UTF8ToUTF16(base::DoubleToString(scale)), false /* highlight */,
63 false); /* checkmark if active */
64 view_to_scale_[container] = scale;
65 }
66 }
67
68 void ScaleDetailedView::HandleViewClicked(views::View* view) {
69 std::string str_value = base::DoubleToString(view_to_scale_[view]);
70 if (str_value.length() > 4)
71 str_value.erase(str_value.begin() + 4, str_value.end());
72
73 display::Display::ResetForceDeviceScaleFactorForTesting();
74 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
75 switches::kForceDeviceScaleFactor, str_value);
76 ash::Shell::Get()->display_manager()->UpdateDisplays();
77 }
78
79 } // namespace tray
80 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/fractional_view/scale_detailed_view.h ('k') | ash/system/fractional_view/scale_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698