| OLD | NEW |
| 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/partial_screenshot_event_filter.h" | 10 #include "ash/wm/partial_screenshot_event_filter.h" |
| 11 #include "ui/aura/cursor.h" | |
| 12 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
| 13 #include "ui/base/cursor/cursor.h" |
| 14 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 | 18 |
| 19 namespace ash { | 19 namespace ash { |
| 20 | 20 |
| 21 PartialScreenshotView::PartialScreenshotView( | 21 PartialScreenshotView::PartialScreenshotView( |
| 22 ScreenshotDelegate* screenshot_delegate) | 22 ScreenshotDelegate* screenshot_delegate) |
| 23 : is_dragging_(false), | 23 : is_dragging_(false), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 void PartialScreenshotView::Cancel() { | 64 void PartialScreenshotView::Cancel() { |
| 65 DCHECK(window_); | 65 DCHECK(window_); |
| 66 window_->Hide(); | 66 window_->Hide(); |
| 67 Shell::GetInstance()->partial_screenshot_filter()->Deactivate(); | 67 Shell::GetInstance()->partial_screenshot_filter()->Deactivate(); |
| 68 MessageLoop::current()->DeleteSoon(FROM_HERE, window_); | 68 MessageLoop::current()->DeleteSoon(FROM_HERE, window_); |
| 69 } | 69 } |
| 70 | 70 |
| 71 gfx::NativeCursor PartialScreenshotView::GetCursor( | 71 gfx::NativeCursor PartialScreenshotView::GetCursor( |
| 72 const views::MouseEvent& event) { | 72 const views::MouseEvent& event) { |
| 73 // Always use "crosshair" cursor. | 73 // Always use "crosshair" cursor. |
| 74 return aura::kCursorCross; | 74 return ui::kCursorCross; |
| 75 } | 75 } |
| 76 | 76 |
| 77 void PartialScreenshotView::OnPaint(gfx::Canvas* canvas) { | 77 void PartialScreenshotView::OnPaint(gfx::Canvas* canvas) { |
| 78 if (is_dragging_) { | 78 if (is_dragging_) { |
| 79 // Screenshot area representation: black rectangle with white | 79 // Screenshot area representation: black rectangle with white |
| 80 // rectangle inside. | 80 // rectangle inside. |
| 81 gfx::Rect screenshot_rect = GetScreenshotRect(); | 81 gfx::Rect screenshot_rect = GetScreenshotRect(); |
| 82 canvas->DrawRect(screenshot_rect, SK_ColorBLACK); | 82 canvas->DrawRect(screenshot_rect, SK_ColorBLACK); |
| 83 screenshot_rect.Inset(1, 1, 1, 1); | 83 screenshot_rect.Inset(1, 1, 1, 1); |
| 84 canvas->DrawRect(screenshot_rect, SK_ColorWHITE); | 84 canvas->DrawRect(screenshot_rect, SK_ColorWHITE); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 114 | 114 |
| 115 gfx::Rect PartialScreenshotView::GetScreenshotRect() const { | 115 gfx::Rect PartialScreenshotView::GetScreenshotRect() const { |
| 116 int left = std::min(start_position_.x(), current_position_.x()); | 116 int left = std::min(start_position_.x(), current_position_.x()); |
| 117 int top = std::min(start_position_.y(), current_position_.y()); | 117 int top = std::min(start_position_.y(), current_position_.y()); |
| 118 int width = ::abs(start_position_.x() - current_position_.x()); | 118 int width = ::abs(start_position_.x() - current_position_.x()); |
| 119 int height = ::abs(start_position_.y() - current_position_.y()); | 119 int height = ::abs(start_position_.y() - current_position_.y()); |
| 120 return gfx::Rect(left, top, width, height); | 120 return gfx::Rect(left, top, width, height); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace ash | 123 } // namespace ash |
| OLD | NEW |