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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_
6 #define ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_
10 #include "ash/ash_export.h"
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "ui/gfx/point.h"
14 #include "ui/views/widget/widget_delegate.h"
21 class ScreenshotDelegate
;
23 // The view of taking partial screenshot, i.e.: drawing region
24 // rectangles during drag, and changing the mouse cursor to indicate
26 class ASH_EXPORT PartialScreenshotView
: public views::WidgetDelegateView
{
28 // Starts the UI for taking partial screenshot; dragging to select a region.
29 // PartialScreenshotViews manage their own lifetime so caller must not delete
30 // the returned PartialScreenshotViews.
31 static std::vector
<PartialScreenshotView
*>
32 StartPartialScreenshot(ScreenshotDelegate
* screenshot_delegate
);
35 FRIEND_TEST_ALL_PREFIXES(PartialScreenshotViewTest
, BasicMouse
);
36 FRIEND_TEST_ALL_PREFIXES(PartialScreenshotViewTest
, BasicTouch
);
38 class OverlayDelegate
;
40 PartialScreenshotView(OverlayDelegate
* overlay_delegate
,
41 ScreenshotDelegate
* screenshot_delegate
);
42 virtual ~PartialScreenshotView();
44 // Initializes partial screenshot UI widget for |root_window|.
45 void Init(aura::RootWindow
* root_window
);
47 // Returns the currently selected region.
48 gfx::Rect
GetScreenshotRect() const;
50 void OnSelectionStarted(const gfx::Point
& position
);
51 void OnSelectionChanged(const gfx::Point
& position
);
52 void OnSelectionFinished();
54 // Overridden from views::View:
55 virtual gfx::NativeCursor
GetCursor(const ui::MouseEvent
& event
) OVERRIDE
;
56 virtual void OnPaint(gfx::Canvas
* canvas
) OVERRIDE
;
57 virtual bool OnMousePressed(const ui::MouseEvent
& event
) OVERRIDE
;
58 virtual bool OnMouseDragged(const ui::MouseEvent
& event
) OVERRIDE
;
59 virtual bool OnMouseWheel(const ui::MouseWheelEvent
& event
) OVERRIDE
;
60 virtual void OnMouseReleased(const ui::MouseEvent
& event
) OVERRIDE
;
61 virtual void OnMouseCaptureLost() OVERRIDE
;
62 virtual void OnGestureEvent(ui::GestureEvent
* event
) OVERRIDE
;
65 gfx::Point start_position_
;
66 gfx::Point current_position_
;
68 // The delegate to receive Cancel. No ownership.
69 OverlayDelegate
* overlay_delegate_
;
71 // ScreenshotDelegate to take the actual screenshot. No ownership.
72 ScreenshotDelegate
* screenshot_delegate_
;
74 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotView
);
79 #endif // #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_