OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 VIEWS_CONTROLS_RESIZE_GRIPPER_H_ | |
6 #define VIEWS_CONTROLS_RESIZE_GRIPPER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "views/controls/image_view.h" | |
11 | |
12 namespace views { | |
13 | |
14 //////////////////////////////////////////////////////////////////////////////// | |
15 // | |
16 // A simple resize gripper (two vertical bars). | |
17 // | |
18 //////////////////////////////////////////////////////////////////////////////// | |
19 class ResizeGripper : public ImageView { | |
20 public: | |
21 ////////////////////////////////////////////////////////////////////////////// | |
22 // | |
23 // The interface needed for getting notified about the resize event. | |
24 // | |
25 ////////////////////////////////////////////////////////////////////////////// | |
26 class ResizeGripperDelegate { | |
27 public: | |
28 // OnResize is sent when resizing is detected. |resize_amount| specifies the | |
29 // number of pixels that the user wants to resize by, and can be negative or | |
30 // positive (depending on direction of dragging and flips according to | |
31 // locale directionality: dragging to the left in LTR locales gives negative | |
32 // |resize_amount| but positive amount for RTL). |done_resizing| is true if | |
33 // the user has released the mouse. | |
34 virtual void OnResize(int resize_amount, bool done_resizing) = 0; | |
35 }; | |
36 | |
37 static const char kViewClassName[]; | |
38 | |
39 explicit ResizeGripper(ResizeGripperDelegate* delegate); | |
40 virtual ~ResizeGripper(); | |
41 | |
42 // Overridden from views::View: | |
43 virtual std::string GetClassName() const; | |
44 virtual gfx::NativeCursor GetCursorForPoint(Event::EventType event_type, | |
45 const gfx::Point& p); | |
46 virtual void OnMouseEntered(const views::MouseEvent& event); | |
47 virtual void OnMouseExited(const views::MouseEvent& event); | |
48 virtual bool OnMousePressed(const views::MouseEvent& event); | |
49 virtual bool OnMouseDragged(const views::MouseEvent& event); | |
50 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); | |
51 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | |
52 | |
53 private: | |
54 // Report the amount the user resized by to the delegate, accounting for | |
55 // directionality. | |
56 void ReportResizeAmount(int resize_amount, bool last_update); | |
57 | |
58 // Changes the visibility of the gripper. | |
59 void SetGripperVisible(bool visible); | |
60 | |
61 // The delegate to notify when we have updates. | |
62 ResizeGripperDelegate* delegate_; | |
63 | |
64 // The mouse position at start (in screen coordinates). | |
65 int initial_position_; | |
66 | |
67 // Are we showing the resize gripper? We only show the resize gripper when | |
68 // the mouse is over us. | |
69 bool gripper_visible_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(ResizeGripper); | |
72 }; | |
73 | |
74 } // namespace views | |
75 | |
76 #endif // VIEWS_CONTROLS_RESIZE_GRIPPER_H_ | |
OLD | NEW |