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(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(); |
| 53 } |
| 54 |
| 55 // static |
| 56 void WorkspaceCyclerConfiguration::SetDouble(Property property, double value) { |
| 57 switch (property) { |
| 58 case SHALLOWER_THAN_SELECTED_Y_OFFSETS: |
| 59 case DEEPER_THAN_SELECTED_Y_OFFSETS: |
| 60 NOTREACHED(); |
| 61 break; |
| 62 case SELECTED_Y_OFFSET: |
| 63 g_selected_y_offset = value; |
| 64 break; |
| 65 case SELECTED_SCALE: |
| 66 g_selected_scale = value; |
| 67 break; |
| 68 case MIN_SCALE: |
| 69 g_min_scale = value; |
| 70 break; |
| 71 case MAX_SCALE: |
| 72 g_max_scale = value; |
| 73 break; |
| 74 case MIN_BRIGHTNESS: |
| 75 g_min_brightness = value; |
| 76 break; |
| 77 case BACKGROUND_OPACITY: |
| 78 g_background_opacity = value; |
| 79 break; |
| 80 case DISTANCE_TO_INITIATE_CYCLING: |
| 81 g_distance_to_initiate_cycling = value; |
| 82 break; |
| 83 case SCROLL_DISTANCE_TO_CYCLE_TO_NEXT_WORKSPACE: |
| 84 g_scroll_amount_to_cycle_to_next_workspace = value; |
| 85 break; |
| 86 case CYCLER_STEP_ANIMATION_DURATION_RATIO: |
| 87 g_cycler_step_animation_duration_ratio = value; |
| 88 break; |
| 89 case START_CYCLER_ANIMATION_DURATION: |
| 90 g_start_cycler_animation_duration = value; |
| 91 break; |
| 92 case STOP_CYCLER_ANIMATION_DURATION: |
| 93 g_stop_cycler_animation_duration = value; |
| 94 break; |
| 95 } |
| 96 } |
| 97 |
| 98 // static |
| 99 const ListValue* WorkspaceCyclerConfiguration::GetListValue(Property property) { |
| 100 DCHECK(IsListProperty(property)); |
| 101 if (property == SHALLOWER_THAN_SELECTED_Y_OFFSETS) { |
| 102 if (!g_shallower_than_selected_y_offsets) { |
| 103 // First time the property is accessed. Initialize it to the default |
| 104 // value. |
| 105 g_shallower_than_selected_y_offsets = new base::ListValue(); |
| 106 g_shallower_than_selected_y_offsets->AppendDouble(-40); |
| 107 g_shallower_than_selected_y_offsets->AppendDouble(-32); |
| 108 g_shallower_than_selected_y_offsets->AppendDouble(-20); |
| 109 } |
| 110 return g_shallower_than_selected_y_offsets; |
| 111 } else if (property == DEEPER_THAN_SELECTED_Y_OFFSETS) { |
| 112 if (!g_deeper_than_selected_y_offsets) { |
| 113 // First time the property is accessed. Initialize it to the default |
| 114 // value. |
| 115 g_deeper_than_selected_y_offsets = new base::ListValue(); |
| 116 g_deeper_than_selected_y_offsets->AppendDouble(28); |
| 117 g_deeper_than_selected_y_offsets->AppendDouble(20); |
| 118 } |
| 119 return g_deeper_than_selected_y_offsets; |
| 120 } |
| 121 |
| 122 NOTREACHED(); |
| 123 return NULL; |
| 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 } |
| 157 |
| 158 } // namespace ash |
OLD | NEW |