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

Unified Diff: ash/system/fractional_view/scale_detailed_view.cc

Issue 2849953004: SV Test
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/fractional_view/scale_detailed_view.cc
diff --git a/ash/system/fractional_view/scale_detailed_view.cc b/ash/system/fractional_view/scale_detailed_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7aa3a0b3f1757c1567787296098374d521f43e70
--- /dev/null
+++ b/ash/system/fractional_view/scale_detailed_view.cc
@@ -0,0 +1,80 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/system/fractional_view/scale_detailed_view.h"
+
+#include "ash/resources/vector_icons/vector_icons.h"
+#include "ash/shell.h"
+#include "ash/system/tray/hover_highlight_view.h"
+#include "ash/system/tray/tray_popup_utils.h"
+#include "ash/system/tray/tri_view.h"
+#include "base/command_line.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/utf_string_conversions.h"
+#include "ui/display/display.h"
+#include "ui/display/display_switches.h"
+#include "ui/display/manager/display_manager.h"
+#include "ui/gfx/color_palette.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/native_theme/native_theme.h"
+#include "ui/views/controls/image_view.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/controls/scroll_view.h"
+#include "ui/views/controls/separator.h"
+
+namespace ash {
+namespace tray {
+namespace {
+
+double scales[] = {1.0f, 1.25f, 1.33f, 1.5f, 1.66f,
+ 1.75f, 1.9f, 2.0f, 2.25f, 2.5f};
+
+} // namespace
+
+ScaleDetailedView::ScaleDetailedView(SystemTrayItem* owner)
+ : TrayDetailsView(owner) {
+ CreateScrollableList();
+ UpdateScrollableList();
+ Layout();
+}
+
+ScaleDetailedView::~ScaleDetailedView() {}
+
+HoverHighlightView* ScaleDetailedView::AddScrollListItem(
+ const base::string16& text,
+ bool highlight,
+ bool checked) {
+ HoverHighlightView* container = new HoverHighlightView(this);
+
+ container->AddLabelRow(text);
+ TrayPopupUtils::InitializeAsCheckableRow(container, checked);
+
+ scroll_content()->AddChildView(container);
+ return container;
+}
+
+void ScaleDetailedView::UpdateScrollableList() {
+ scroll_content()->RemoveAllChildViews(true);
+
+ for (double scale : scales) {
+ HoverHighlightView* container = AddScrollListItem(
+ base::UTF8ToUTF16(base::DoubleToString(scale)), false /* highlight */,
+ false); /* checkmark if active */
+ view_to_scale_[container] = scale;
+ }
+}
+
+void ScaleDetailedView::HandleViewClicked(views::View* view) {
+ std::string str_value = base::DoubleToString(view_to_scale_[view]);
+ if (str_value.length() > 4)
+ str_value.erase(str_value.begin() + 4, str_value.end());
+
+ display::Display::ResetForceDeviceScaleFactorForTesting();
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kForceDeviceScaleFactor, str_value);
+ ash::Shell::Get()->display_manager()->UpdateDisplays();
+}
+
+} // namespace tray
+} // namespace ash
« 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