Revert of Rename isSystemLocationEnabled to isLocationEnabled. (patchset #1 id:1...
[chromium-blink-merge.git] / ash / wm / partial_screenshot_view.h
blob71e0242873373cde0b04e70884108d43c11a6513
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_
8 #include <vector>
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"
16 namespace ash {
17 class ScreenshotDelegate;
19 // The view of taking partial screenshot, i.e.: drawing region
20 // rectangles during drag, and changing the mouse cursor to indicate
21 // the current mode.
22 class ASH_EXPORT PartialScreenshotView : public views::WidgetDelegateView {
23 public:
24 // Starts the UI for taking partial screenshot; dragging to select a region.
25 // PartialScreenshotViews manage their own lifetime so caller must not delete
26 // the returned PartialScreenshotViews.
27 static std::vector<PartialScreenshotView*>
28 StartPartialScreenshot(ScreenshotDelegate* screenshot_delegate);
30 private:
31 FRIEND_TEST_ALL_PREFIXES(PartialScreenshotViewTest, BasicMouse);
32 FRIEND_TEST_ALL_PREFIXES(PartialScreenshotViewTest, BasicTouch);
34 class OverlayDelegate;
36 PartialScreenshotView(OverlayDelegate* overlay_delegate,
37 ScreenshotDelegate* screenshot_delegate);
38 ~PartialScreenshotView() override;
40 // Initializes partial screenshot UI widget for |root_window|.
41 void Init(aura::Window* root_window);
43 // Returns the currently selected region.
44 gfx::Rect GetScreenshotRect() const;
46 void OnSelectionStarted(const gfx::Point& position);
47 void OnSelectionChanged(const gfx::Point& position);
48 void OnSelectionFinished();
50 // Overridden from views::View:
51 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override;
52 void OnPaint(gfx::Canvas* canvas) override;
53 bool OnMousePressed(const ui::MouseEvent& event) override;
54 bool OnMouseDragged(const ui::MouseEvent& event) override;
55 bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
56 void OnMouseReleased(const ui::MouseEvent& event) override;
57 void OnMouseCaptureLost() override;
58 void OnGestureEvent(ui::GestureEvent* event) override;
60 bool is_dragging_;
61 gfx::Point start_position_;
62 gfx::Point current_position_;
64 // The delegate to receive Cancel. No ownership.
65 OverlayDelegate* overlay_delegate_;
67 // ScreenshotDelegate to take the actual screenshot. No ownership.
68 ScreenshotDelegate* screenshot_delegate_;
70 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotView);
73 } // namespace ash
75 #endif // #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_