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

Side by Side Diff: ash/wm/gestures/long_press_affordance_handler.cc

Issue 24020002: Move GetRootWindowController() to root_window_controller.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/app_list_controller.cc ('k') | ash/wm/property_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/gestures/long_press_affordance_handler.h" 5 #include "ash/wm/gestures/long_press_affordance_handler.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
11 #include "ash/wm/property_util.h"
12 #include "third_party/skia/include/core/SkColor.h" 11 #include "third_party/skia/include/core/SkColor.h"
13 #include "third_party/skia/include/core/SkPaint.h" 12 #include "third_party/skia/include/core/SkPaint.h"
14 #include "third_party/skia/include/core/SkPath.h" 13 #include "third_party/skia/include/core/SkPath.h"
15 #include "third_party/skia/include/core/SkRect.h" 14 #include "third_party/skia/include/core/SkRect.h"
16 #include "third_party/skia/include/effects/SkGradientShader.h" 15 #include "third_party/skia/include/effects/SkGradientShader.h"
17 #include "ui/aura/client/screen_position_client.h" 16 #include "ui/aura/client/screen_position_client.h"
18 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
19 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
20 #include "ui/base/gestures/gesture_configuration.h" 19 #include "ui/base/gestures/gesture_configuration.h"
21 #include "ui/base/gestures/gesture_util.h" 20 #include "ui/base/gestures/gesture_util.h"
22 #include "ui/compositor/layer.h" 21 #include "ui/compositor/layer.h"
23 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
24 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
25 #include "ui/gfx/transform.h" 24 #include "ui/gfx/transform.h"
26 #include "ui/views/view.h" 25 #include "ui/views/view.h"
27 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
28 27
28 namespace ash {
29 namespace internal {
29 namespace { 30 namespace {
30 31
31 const int kAffordanceOuterRadius = 60; 32 const int kAffordanceOuterRadius = 60;
32 const int kAffordanceInnerRadius = 50; 33 const int kAffordanceInnerRadius = 50;
33 34
34 // Angles from x-axis at which the outer and inner circles start. 35 // Angles from x-axis at which the outer and inner circles start.
35 const int kAffordanceOuterStartAngle = -109; 36 const int kAffordanceOuterStartAngle = -109;
36 const int kAffordanceInnerStartAngle = -65; 37 const int kAffordanceInnerStartAngle = -65;
37 38
38 const int kAffordanceGlowWidth = 20; 39 const int kAffordanceGlowWidth = 20;
(...skipping 23 matching lines...) Expand all
62 views::Widget* widget = new views::Widget; 63 views::Widget* widget = new views::Widget;
63 views::Widget::InitParams params; 64 views::Widget::InitParams params;
64 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; 65 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
65 params.keep_on_top = true; 66 params.keep_on_top = true;
66 params.accept_events = false; 67 params.accept_events = false;
67 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 68 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
68 params.context = root_window; 69 params.context = root_window;
69 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 70 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
70 widget->Init(params); 71 widget->Init(params);
71 widget->SetOpacity(0xFF); 72 widget->SetOpacity(0xFF);
72 ash::GetRootWindowController(root_window)->GetContainer( 73 GetRootWindowController(root_window)->GetContainer(
73 ash::internal::kShellWindowId_OverlayContainer)->AddChild( 74 kShellWindowId_OverlayContainer)->AddChild(widget->GetNativeWindow());
74 widget->GetNativeWindow());
75 return widget; 75 return widget;
76 } 76 }
77 77
78 void PaintAffordanceArc(gfx::Canvas* canvas, 78 void PaintAffordanceArc(gfx::Canvas* canvas,
79 gfx::Point& center, 79 gfx::Point& center,
80 int radius, 80 int radius,
81 int start_angle, 81 int start_angle,
82 int end_angle) { 82 int end_angle) {
83 SkPaint paint; 83 SkPaint paint;
84 paint.setStyle(SkPaint::kStroke_Style); 84 paint.setStyle(SkPaint::kStroke_Style);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 arc_path.addArc(SkRect::MakeXYWH(center.x() - radius, 126 arc_path.addArc(SkRect::MakeXYWH(center.x() - radius,
127 center.y() - radius, 127 center.y() - radius,
128 2 * radius, 128 2 * radius,
129 2 * radius), 129 2 * radius),
130 0, 360); 130 0, 360);
131 canvas->DrawPath(arc_path, paint); 131 canvas->DrawPath(arc_path, paint);
132 } 132 }
133 133
134 } // namespace 134 } // namespace
135 135
136 namespace ash {
137 namespace internal {
138
139 // View of the LongPressAffordanceHandler. Draws the actual contents and 136 // View of the LongPressAffordanceHandler. Draws the actual contents and
140 // updates as the animation proceeds. It also maintains the views::Widget that 137 // updates as the animation proceeds. It also maintains the views::Widget that
141 // the animation is shown in. 138 // the animation is shown in.
142 class LongPressAffordanceHandler::LongPressAffordanceView 139 class LongPressAffordanceHandler::LongPressAffordanceView
143 : public views::View { 140 : public views::View {
144 public: 141 public:
145 LongPressAffordanceView(const gfx::Point& event_location, 142 LongPressAffordanceView(const gfx::Point& event_location,
146 aura::RootWindow* root_window) 143 aura::RootWindow* root_window)
147 : views::View(), 144 : views::View(),
148 widget_(CreateAffordanceWidget(root_window)), 145 widget_(CreateAffordanceWidget(root_window)),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 287 }
291 } 288 }
292 289
293 //////////////////////////////////////////////////////////////////////////////// 290 ////////////////////////////////////////////////////////////////////////////////
294 // LongPressAffordanceHandler, private 291 // LongPressAffordanceHandler, private
295 292
296 void LongPressAffordanceHandler::StartAnimation() { 293 void LongPressAffordanceHandler::StartAnimation() {
297 aura::RootWindow* root_window = NULL; 294 aura::RootWindow* root_window = NULL;
298 switch (current_animation_type_) { 295 switch (current_animation_type_) {
299 case GROW_ANIMATION: 296 case GROW_ANIMATION:
300 root_window = ash::Shell::GetInstance()->display_controller()-> 297 root_window = Shell::GetInstance()->display_controller()->
301 GetRootWindowForDisplayId(tap_down_display_id_); 298 GetRootWindowForDisplayId(tap_down_display_id_);
302 if (!root_window) { 299 if (!root_window) {
303 StopAnimation(); 300 StopAnimation();
304 return; 301 return;
305 } 302 }
306 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window)); 303 view_.reset(new LongPressAffordanceView(tap_down_location_, root_window));
307 SetDuration( 304 SetDuration(
308 ui::GestureConfiguration::long_press_time_in_seconds() * 1000 - 305 ui::GestureConfiguration::long_press_time_in_seconds() * 1000 -
309 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000 - 306 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000 -
310 kAffordanceDelayBeforeShrinkMs); 307 kAffordanceDelayBeforeShrinkMs);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 default: 365 default:
369 view_.reset(); 366 view_.reset();
370 tap_down_touch_id_ = -1; 367 tap_down_touch_id_ = -1;
371 tap_down_display_id_ = 0; 368 tap_down_display_id_ = 0;
372 break; 369 break;
373 } 370 }
374 } 371 }
375 372
376 } // namespace internal 373 } // namespace internal
377 } // namespace ash 374 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/app_list_controller.cc ('k') | ash/wm/property_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698