| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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. | |
| 4 | |
| 5 #ifndef ASH_UTILITY_PARTIAL_SCREENSHOT_CONTROLLER_H_ | |
| 6 #define ASH_UTILITY_PARTIAL_SCREENSHOT_CONTROLLER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <map> | |
| 11 #include <memory> | |
| 12 | |
| 13 #include "ash/ash_export.h" | |
| 14 #include "ash/shell_observer.h" | |
| 15 #include "base/macros.h" | |
| 16 #include "ui/display/display_observer.h" | |
| 17 #include "ui/events/event_handler.h" | |
| 18 #include "ui/gfx/geometry/point.h" | |
| 19 | |
| 20 namespace aura { | |
| 21 class Window; | |
| 22 } | |
| 23 | |
| 24 namespace ui { | |
| 25 class LocatedEvent; | |
| 26 } | |
| 27 | |
| 28 namespace ash { | |
| 29 class ScreenshotDelegate; | |
| 30 | |
| 31 // This class controls a session of taking partial screenshot, i.e.: drawing | |
| 32 // region rectangles during drag, and changing the mouse cursor to indicate | |
| 33 // the current mode. | |
| 34 // This class does not use aura::Window / views::Widget intentionally to avoid | |
| 35 // the conflicts of window manager features like mouse captures or window focus. | |
| 36 class ASH_EXPORT PartialScreenshotController : public ui::EventHandler, | |
| 37 public display::DisplayObserver { | |
| 38 public: | |
| 39 PartialScreenshotController(); | |
| 40 ~PartialScreenshotController() override; | |
| 41 | |
| 42 // Starts the UI for taking partial screenshot; dragging to select a region. | |
| 43 // PartialScreenshotController manage their own lifetime so caller must not | |
| 44 // delete the returned values. | |
| 45 void StartPartialScreenshotSession(ScreenshotDelegate* screenshot_delegate); | |
| 46 | |
| 47 private: | |
| 48 friend class PartialScreenshotControllerTest; | |
| 49 | |
| 50 class ScopedCursorSetter; | |
| 51 class PartialScreenshotLayer; | |
| 52 | |
| 53 // Starts, ends, cancels, or updates the region selection. | |
| 54 void MaybeStart(const ui::LocatedEvent& event); | |
| 55 void Complete(); | |
| 56 void Cancel(); | |
| 57 void Update(const ui::LocatedEvent& event); | |
| 58 | |
| 59 // ui::EventHandler: | |
| 60 void OnKeyEvent(ui::KeyEvent* event) override; | |
| 61 void OnMouseEvent(ui::MouseEvent* event) override; | |
| 62 void OnTouchEvent(ui::TouchEvent* event) override; | |
| 63 | |
| 64 // display::DisplayObserver: | |
| 65 void OnDisplayAdded(const display::Display& new_display) override; | |
| 66 void OnDisplayRemoved(const display::Display& old_display) override; | |
| 67 void OnDisplayMetricsChanged(const display::Display& display, | |
| 68 uint32_t changed_metrics) override; | |
| 69 | |
| 70 // The data to build the screenshot region. | |
| 71 gfx::Point start_position_; | |
| 72 aura::Window* root_window_; | |
| 73 | |
| 74 // Layers to create the visual effect of region selection. | |
| 75 std::map<aura::Window*, PartialScreenshotLayer*> layers_; | |
| 76 | |
| 77 // The object to specify the crosshair cursor. | |
| 78 std::unique_ptr<ScopedCursorSetter> cursor_setter_; | |
| 79 | |
| 80 // ScreenshotDelegate to take the actual screenshot. No ownership. | |
| 81 ScreenshotDelegate* screenshot_delegate_; | |
| 82 | |
| 83 DISALLOW_COPY_AND_ASSIGN(PartialScreenshotController); | |
| 84 }; | |
| 85 | |
| 86 } // namespace ash | |
| 87 | |
| 88 #endif // #ifndef ASH_WM_PARTIAL_SCREENSHOT_VIEW_H_ | |
| OLD | NEW |