OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "ash/wm/workspace/workspace_cycler_configuration.h" | |
6 | |
7 #include "ash/ash_switches.h" | |
8 #include "base/command_line.h" | |
9 #include "base/logging.h" | |
10 #include "base/values.h" | |
11 | |
12 namespace { | |
13 | |
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 = 0.95; | |
18 double g_min_scale = 0.9; | |
19 double g_max_scale = 1.0; | |
20 double g_min_brightness = -0.4; | |
21 double g_background_opacity = 0.8; | |
22 double g_distance_to_initiate_cycling = 10; | |
23 double g_scroll_amount_to_cycle_to_next_workspace = 10; | |
24 double g_cycler_step_animation_duration_ratio = 10; | |
25 double g_start_cycler_animation_duration = 100; | |
26 double g_stop_cycler_animation_duration = 100; | |
27 | |
28 } // namespace | |
29 | |
30 namespace ash { | |
31 | |
32 // static | |
33 bool WorkspaceCyclerConfiguration::IsCyclerEnabled() { | |
34 return CommandLine::ForCurrentProcess()->HasSwitch( | |
35 ash::switches::kAshEnableWorkspaceScrubbing); | |
36 } | |
37 | |
38 // static | |
39 bool WorkspaceCyclerConfiguration::IsListProperty(Property property) { | |
40 return (property == SHALLOWER_THAN_SELECTED_Y_OFFSETS || | |
41 property == DEEPER_THAN_SELECTED_Y_OFFSETS); | |
42 } | |
43 | |
44 // static | |
45 void WorkspaceCyclerConfiguration::SetListValue(Property property, | |
46 const ListValue& list_value) { | |
47 DCHECK(IsListProperty(property)); | |
48 if (property == SHALLOWER_THAN_SELECTED_Y_OFFSETS) | |
49 g_shallower_than_selected_y_offsets = list_value.DeepCopy(); | |
50 else if (property == DEEPER_THAN_SELECTED_Y_OFFSETS) | |
51 g_deeper_than_selected_y_offsets = list_value.DeepCopy(); | |
52 } | |
53 | |
54 // static | |
55 void WorkspaceCyclerConfiguration::SetDouble(Property property, double value) { | |
56 switch (property) { | |
57 case SHALLOWER_THAN_SELECTED_Y_OFFSETS: | |
58 case DEEPER_THAN_SELECTED_Y_OFFSETS: | |
59 NOTREACHED(); | |
60 break; | |
61 case SELECTED_Y_OFFSET: | |
62 g_selected_y_offset = value; | |
63 break; | |
64 case SELECTED_SCALE: | |
65 g_selected_scale = value; | |
66 break; | |
67 case MIN_SCALE: | |
68 g_min_scale = value; | |
69 break; | |
70 case MAX_SCALE: | |
71 g_max_scale = value; | |
72 break; | |
73 case MIN_BRIGHTNESS: | |
74 g_min_brightness = value; | |
75 break; | |
76 case BACKGROUND_OPACITY: | |
77 g_background_opacity = value; | |
78 break; | |
79 case DISTANCE_TO_INITIATE_CYCLING: | |
80 g_distance_to_initiate_cycling = value; | |
81 break; | |
82 case SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE: | |
83 g_scroll_amount_to_cycle_to_next_workspace = value; | |
84 break; | |
85 case CYCLER_STEP_ANIMATION_DURATION_RATIO: | |
86 g_cycler_step_animation_duration_ratio = value; | |
87 break; | |
88 case START_CYCLER_ANIMATION_DURATION: | |
89 g_start_cycler_animation_duration = value; | |
90 break; | |
91 case STOP_CYCLER_ANIMATION_DURATION: | |
92 g_stop_cycler_animation_duration = value; | |
93 break; | |
94 } | |
95 } | |
96 | |
97 // static | |
98 const ListValue& WorkspaceCyclerConfiguration::GetListValue(Property property) { | |
99 DCHECK(IsListProperty(property)); | |
100 if (property == SHALLOWER_THAN_SELECTED_Y_OFFSETS) { | |
101 if (!g_shallower_than_selected_y_offsets) { | |
102 // First time the property is accessed. Initialize it to the default | |
103 // value. | |
104 g_shallower_than_selected_y_offsets = new base::ListValue(); | |
105 g_shallower_than_selected_y_offsets->AppendDouble(-40); | |
106 g_shallower_than_selected_y_offsets->AppendDouble(-32); | |
107 g_shallower_than_selected_y_offsets->AppendDouble(-20); | |
108 } | |
109 return *g_shallower_than_selected_y_offsets; | |
110 } else if (property == DEEPER_THAN_SELECTED_Y_OFFSETS) { | |
111 if (!g_deeper_than_selected_y_offsets) { | |
112 // First time the property is accessed. Initialize it to the default | |
113 // value. | |
114 g_deeper_than_selected_y_offsets = new base::ListValue(); | |
115 g_deeper_than_selected_y_offsets->AppendDouble(28); | |
116 g_deeper_than_selected_y_offsets->AppendDouble(20); | |
117 } | |
118 return *g_deeper_than_selected_y_offsets; | |
119 } | |
120 | |
121 NOTREACHED(); | |
122 CR_DEFINE_STATIC_LOCAL(base::ListValue, default_return_value, ()); | |
123 return default_return_value; | |
124 } | |
125 | |
126 // static | |
127 double WorkspaceCyclerConfiguration::GetDouble(Property property) { | |
128 switch (property) { | |
129 case SHALLOWER_THAN_SELECTED_Y_OFFSETS: | |
130 case DEEPER_THAN_SELECTED_Y_OFFSETS: | |
131 NOTREACHED(); | |
132 return 0; | |
133 case SELECTED_Y_OFFSET: | |
134 return g_selected_y_offset; | |
135 case SELECTED_SCALE: | |
136 return g_selected_scale; | |
137 case MIN_SCALE: | |
138 return g_min_scale; | |
139 case MAX_SCALE: | |
140 return g_max_scale; | |
141 case MIN_BRIGHTNESS: | |
142 return g_min_brightness; | |
143 case BACKGROUND_OPACITY: | |
144 return g_background_opacity; | |
145 case DISTANCE_TO_INITIATE_CYCLING: | |
146 return g_distance_to_initiate_cycling; | |
147 case SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE: | |
148 return g_scroll_amount_to_cycle_to_next_workspace; | |
149 case CYCLER_STEP_ANIMATION_DURATION_RATIO: | |
150 return g_cycler_step_animation_duration_ratio; | |
151 case START_CYCLER_ANIMATION_DURATION: | |
152 return g_start_cycler_animation_duration; | |
153 case STOP_CYCLER_ANIMATION_DURATION: | |
154 return g_stop_cycler_animation_duration; | |
155 } | |
156 return 0; | |
sadrul
2013/02/12 15:59:58
NOTREACHED here too?
| |
157 } | |
158 | |
159 } // namespace ash | |
OLD | NEW |