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

Side by Side Diff: ash/wm/partial_screenshot_view.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
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/partial_screenshot_view.h" 5 #include "ash/wm/partial_screenshot_view.h"
6 6
7 #include "ash/screenshot_delegate.h" 7 #include "ash/screenshot_delegate.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/overlay_event_filter.h" 10 #include "ash/wm/overlay_event_filter.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 widget->StackAtTop(); 52 widget->StackAtTop();
53 widget->Show(); 53 widget->Show();
54 // Captures mouse events in case that context menu already captures the 54 // Captures mouse events in case that context menu already captures the
55 // events. This will close the context menu. 55 // events. This will close the context menu.
56 widget->GetNativeView()->SetCapture(); 56 widget->GetNativeView()->SetCapture();
57 57
58 Shell::GetInstance()->overlay_filter()->Activate(view); 58 Shell::GetInstance()->overlay_filter()->Activate(view);
59 } 59 }
60 60
61 gfx::NativeCursor PartialScreenshotView::GetCursor( 61 gfx::NativeCursor PartialScreenshotView::GetCursor(
62 const views::MouseEvent& event) { 62 const ui::MouseEvent& event) {
63 // Always use "crosshair" cursor. 63 // Always use "crosshair" cursor.
64 return ui::kCursorCross; 64 return ui::kCursorCross;
65 } 65 }
66 66
67 void PartialScreenshotView::Cancel() { 67 void PartialScreenshotView::Cancel() {
68 Shell::GetInstance()->overlay_filter()->Deactivate(); 68 Shell::GetInstance()->overlay_filter()->Deactivate();
69 views::Widget* widget = GetWidget(); 69 views::Widget* widget = GetWidget();
70 if (widget) 70 if (widget)
71 widget->Close(); 71 widget->Close();
72 } 72 }
(...skipping 16 matching lines...) Expand all
89 canvas->DrawRect(screenshot_rect, SK_ColorWHITE); 89 canvas->DrawRect(screenshot_rect, SK_ColorWHITE);
90 screenshot_rect.Inset(-1, -1, -1, -1); 90 screenshot_rect.Inset(-1, -1, -1, -1);
91 canvas->DrawRect(screenshot_rect, SK_ColorBLACK); 91 canvas->DrawRect(screenshot_rect, SK_ColorBLACK);
92 } 92 }
93 } 93 }
94 94
95 void PartialScreenshotView::OnMouseCaptureLost() { 95 void PartialScreenshotView::OnMouseCaptureLost() {
96 Cancel(); 96 Cancel();
97 } 97 }
98 98
99 bool PartialScreenshotView::OnMousePressed(const views::MouseEvent& event) { 99 bool PartialScreenshotView::OnMousePressed(const ui::MouseEvent& event) {
100 start_position_ = event.location(); 100 start_position_ = event.location();
101 return true; 101 return true;
102 } 102 }
103 103
104 bool PartialScreenshotView::OnMouseDragged(const views::MouseEvent& event) { 104 bool PartialScreenshotView::OnMouseDragged(const ui::MouseEvent& event) {
105 current_position_ = event.location(); 105 current_position_ = event.location();
106 SchedulePaint(); 106 SchedulePaint();
107 is_dragging_ = true; 107 is_dragging_ = true;
108 return true; 108 return true;
109 } 109 }
110 110
111 bool PartialScreenshotView::OnMouseWheel(const views::MouseWheelEvent& event) { 111 bool PartialScreenshotView::OnMouseWheel(const views::MouseWheelEvent& event) {
112 // Do nothing but do not propagate events futhermore. 112 // Do nothing but do not propagate events futhermore.
113 return true; 113 return true;
114 } 114 }
115 115
116 void PartialScreenshotView::OnMouseReleased(const views::MouseEvent& event) { 116 void PartialScreenshotView::OnMouseReleased(const ui::MouseEvent& event) {
117 Cancel(); 117 Cancel();
118 if (!is_dragging_) 118 if (!is_dragging_)
119 return; 119 return;
120 120
121 is_dragging_ = false; 121 is_dragging_ = false;
122 if (screenshot_delegate_) { 122 if (screenshot_delegate_) {
123 aura::RootWindow *root_window = Shell::GetPrimaryRootWindow(); 123 aura::RootWindow *root_window = Shell::GetPrimaryRootWindow();
124 screenshot_delegate_->HandleTakePartialScreenshot( 124 screenshot_delegate_->HandleTakePartialScreenshot(
125 root_window, root_window->bounds().Intersect(GetScreenshotRect())); 125 root_window, root_window->bounds().Intersect(GetScreenshotRect()));
126 } 126 }
127 } 127 }
128 128
129 gfx::Rect PartialScreenshotView::GetScreenshotRect() const { 129 gfx::Rect PartialScreenshotView::GetScreenshotRect() const {
130 int left = std::min(start_position_.x(), current_position_.x()); 130 int left = std::min(start_position_.x(), current_position_.x());
131 int top = std::min(start_position_.y(), current_position_.y()); 131 int top = std::min(start_position_.y(), current_position_.y());
132 int width = ::abs(start_position_.x() - current_position_.x()); 132 int width = ::abs(start_position_.x() - current_position_.x());
133 int height = ::abs(start_position_.y() - current_position_.y()); 133 int height = ::abs(start_position_.y() - current_position_.y());
134 return gfx::Rect(left, top, width, height); 134 return gfx::Rect(left, top, width, height);
135 } 135 }
136 136
137 } // namespace ash 137 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/partial_screenshot_view.h ('k') | ash/wm/system_modal_container_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698