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 #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_ | 5 #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_ |
6 #define ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_ | 6 #define ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/wm/overlay_event_filter.h" |
9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
10 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
11 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
12 | 13 |
13 namespace ash { | 14 namespace ash { |
14 class ScreenshotDelegate; | 15 class ScreenshotDelegate; |
15 | 16 |
16 // The view of taking partial screenshot, i.e.: drawing region | 17 // The view of taking partial screenshot, i.e.: drawing region |
17 // rectangles during drag, and changing the mouse cursor to indicate | 18 // rectangles during drag, and changing the mouse cursor to indicate |
18 // the current mode. | 19 // the current mode. |
19 class ASH_EXPORT PartialScreenshotView : public views::WidgetDelegateView { | 20 class ASH_EXPORT PartialScreenshotView |
| 21 : public views::WidgetDelegateView, |
| 22 public internal::OverlayEventFilter::Delegate { |
20 public: | 23 public: |
21 PartialScreenshotView(ScreenshotDelegate* screenshot_delegate); | 24 PartialScreenshotView(ScreenshotDelegate* screenshot_delegate); |
22 virtual ~PartialScreenshotView(); | 25 virtual ~PartialScreenshotView(); |
23 | 26 |
24 // Starts the UI for taking partial screenshot; dragging to select a region. | 27 // Starts the UI for taking partial screenshot; dragging to select a region. |
25 static void StartPartialScreenshot(ScreenshotDelegate* screenshot_delegate); | 28 static void StartPartialScreenshot(ScreenshotDelegate* screenshot_delegate); |
26 | 29 |
27 // Cancels the current screenshot UI. | |
28 void Cancel(); | |
29 | |
30 // Overriddden from View: | 30 // Overriddden from View: |
31 virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE; | 31 virtual gfx::NativeCursor GetCursor(const views::MouseEvent& event) OVERRIDE; |
32 | 32 |
| 33 // Overridden from internal::OverlayEventFilter::Delegate: |
| 34 virtual void Cancel() OVERRIDE; |
| 35 virtual bool IsCancelingKeyEvent(aura::KeyEvent* event) OVERRIDE; |
| 36 virtual aura::Window* GetWindow() OVERRIDE; |
| 37 |
33 private: | 38 private: |
34 gfx::Rect GetScreenshotRect() const; | 39 gfx::Rect GetScreenshotRect() const; |
35 | 40 |
36 // Overridden from View: | 41 // Overridden from View: |
37 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 42 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
38 virtual void OnMouseCaptureLost() OVERRIDE; | 43 virtual void OnMouseCaptureLost() OVERRIDE; |
39 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | 44 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; |
40 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; | 45 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE; |
41 virtual bool OnMouseWheel(const views::MouseWheelEvent& event) OVERRIDE; | 46 virtual bool OnMouseWheel(const views::MouseWheelEvent& event) OVERRIDE; |
42 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | 47 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; |
43 | 48 |
44 bool is_dragging_; | 49 bool is_dragging_; |
45 gfx::Point start_position_; | 50 gfx::Point start_position_; |
46 gfx::Point current_position_; | 51 gfx::Point current_position_; |
47 ScreenshotDelegate* screenshot_delegate_; | 52 ScreenshotDelegate* screenshot_delegate_; |
48 | 53 |
49 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotView); | 54 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotView); |
50 }; | 55 }; |
51 | 56 |
52 } // namespace ash | 57 } // namespace ash |
53 | 58 |
54 #endif // #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_ | 59 #endif // #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_ |
OLD | NEW |