1 // Copyright (c) 2013 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.
5 #include "ash/wm/workspace/workspace_cycler_configuration.h"
7 #include "ash/ash_switches.h"
8 #include "base/command_line.h"
9 #include "base/logging.h"
10 #include "base/values.h"
14 ListValue
* g_shallower_than_selected_y_offsets
= NULL
;
15 ListValue
* g_deeper_than_selected_y_offsets
= NULL
;
16 double g_selected_y_offset
= 40;
17 double g_selected_scale
= 1.0;
18 double g_min_scale
= 1.0;
19 double g_max_scale
= 1.0;
20 double g_min_brightness
= -0.4;
21 double g_background_opacity
= 0.8;
22 double g_desktop_workspace_brightness
= -0.4;
23 double g_distance_to_initiate_cycling
= 4.0;
24 double g_scroll_amount_to_cycle_to_next_workspace
= 4.0;
25 double g_cycler_step_animation_duration_ratio
= 4.0;
26 double g_start_cycler_animation_duration
= 100.0;
27 double g_stop_cycler_animation_duration
= 250.0;
34 bool WorkspaceCyclerConfiguration::IsCyclerEnabled() {
35 return CommandLine::ForCurrentProcess()->HasSwitch(
36 ash::switches::kAshEnableWorkspaceScrubbing
);
40 bool WorkspaceCyclerConfiguration::IsListProperty(Property property
) {
41 return (property
== SHALLOWER_THAN_SELECTED_Y_OFFSETS
||
42 property
== DEEPER_THAN_SELECTED_Y_OFFSETS
);
46 void WorkspaceCyclerConfiguration::SetListValue(Property property
,
47 const ListValue
& list_value
) {
48 DCHECK(IsListProperty(property
));
49 if (property
== SHALLOWER_THAN_SELECTED_Y_OFFSETS
)
50 g_shallower_than_selected_y_offsets
= list_value
.DeepCopy();
51 else if (property
== DEEPER_THAN_SELECTED_Y_OFFSETS
)
52 g_deeper_than_selected_y_offsets
= list_value
.DeepCopy();
56 void WorkspaceCyclerConfiguration::SetDouble(Property property
, double value
) {
58 case SHALLOWER_THAN_SELECTED_Y_OFFSETS
:
59 case DEEPER_THAN_SELECTED_Y_OFFSETS
:
62 case SELECTED_Y_OFFSET
:
63 g_selected_y_offset
= value
;
66 g_selected_scale
= value
;
75 g_min_brightness
= value
;
77 case BACKGROUND_OPACITY
:
78 g_background_opacity
= value
;
80 case DESKTOP_WORKSPACE_BRIGHTNESS
:
81 g_desktop_workspace_brightness
= value
;
83 case DISTANCE_TO_INITIATE_CYCLING
:
84 g_distance_to_initiate_cycling
= value
;
86 case SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE
:
87 g_scroll_amount_to_cycle_to_next_workspace
= value
;
89 case CYCLER_STEP_ANIMATION_DURATION_RATIO
:
90 g_cycler_step_animation_duration_ratio
= value
;
92 case START_CYCLER_ANIMATION_DURATION
:
93 g_start_cycler_animation_duration
= value
;
95 case STOP_CYCLER_ANIMATION_DURATION
:
96 g_stop_cycler_animation_duration
= value
;
102 const ListValue
& WorkspaceCyclerConfiguration::GetListValue(Property property
) {
103 DCHECK(IsListProperty(property
));
104 if (property
== SHALLOWER_THAN_SELECTED_Y_OFFSETS
) {
105 if (!g_shallower_than_selected_y_offsets
) {
106 // First time the property is accessed. Initialize it to the default
108 g_shallower_than_selected_y_offsets
= new base::ListValue();
109 g_shallower_than_selected_y_offsets
->AppendDouble(-40);
110 g_shallower_than_selected_y_offsets
->AppendDouble(-32);
111 g_shallower_than_selected_y_offsets
->AppendDouble(-20);
113 return *g_shallower_than_selected_y_offsets
;
114 } else if (property
== DEEPER_THAN_SELECTED_Y_OFFSETS
) {
115 if (!g_deeper_than_selected_y_offsets
) {
116 // First time the property is accessed. Initialize it to the default
118 g_deeper_than_selected_y_offsets
= new base::ListValue();
119 g_deeper_than_selected_y_offsets
->AppendDouble(28);
120 g_deeper_than_selected_y_offsets
->AppendDouble(20);
122 return *g_deeper_than_selected_y_offsets
;
126 CR_DEFINE_STATIC_LOCAL(base::ListValue
, default_return_value
, ());
127 return default_return_value
;
131 double WorkspaceCyclerConfiguration::GetDouble(Property property
) {
133 case SHALLOWER_THAN_SELECTED_Y_OFFSETS
:
134 case DEEPER_THAN_SELECTED_Y_OFFSETS
:
137 case SELECTED_Y_OFFSET
:
138 return g_selected_y_offset
;
140 return g_selected_scale
;
146 return g_min_brightness
;
147 case BACKGROUND_OPACITY
:
148 return g_background_opacity
;
149 case DESKTOP_WORKSPACE_BRIGHTNESS
:
150 return g_desktop_workspace_brightness
;
151 case DISTANCE_TO_INITIATE_CYCLING
:
152 return g_distance_to_initiate_cycling
;
153 case SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE
:
154 return g_scroll_amount_to_cycle_to_next_workspace
;
155 case CYCLER_STEP_ANIMATION_DURATION_RATIO
:
156 return g_cycler_step_animation_duration_ratio
;
157 case START_CYCLER_ANIMATION_DURATION
:
158 return g_start_cycler_animation_duration
;
159 case STOP_CYCLER_ANIMATION_DURATION
:
160 return g_stop_cycler_animation_duration
;