OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_VIEWS_MENU_LOCATOR_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_VIEWS_MENU_LOCATOR_H_ | |
7 #pragma once | |
8 | |
9 #include "third_party/skia/include/core/SkScalar.h" | |
10 | |
11 namespace gfx { | |
12 class Insets; | |
13 class Point; | |
14 class Size; | |
15 } // namespace gfx | |
16 | |
17 namespace chromeos { | |
18 | |
19 class WebUIMenuWidget; | |
20 | |
21 // MenuLocator class contorls where the menu will be placed and | |
22 // which corners are rounded. | |
23 // TODO(oshima): support RTL. | |
24 class MenuLocator { | |
25 public: | |
26 enum SubmenuDirection { | |
27 DEFAULT, // default direction. | |
28 RIGHT, // submenu should grow to right. (not used now. reserved for RTL) | |
29 LEFT, // submenu should grow to left. | |
30 }; | |
31 | |
32 virtual ~MenuLocator() {} | |
33 | |
34 // Returns the direction that submenu should grow. | |
35 virtual SubmenuDirection GetSubmenuDirection() const = 0; | |
36 | |
37 // Move the widget to the right position. | |
38 virtual void Move(WebUIMenuWidget* widget) = 0; | |
39 | |
40 // Resize and move the widget to the right position. | |
41 virtual void SetBounds(WebUIMenuWidget* widget, | |
42 const gfx::Size& size) = 0; | |
43 | |
44 // Returns the 8 length array of SkScalar that represents 4 corner | |
45 // radious for each menu type. The objects are owned by the locator | |
46 // and should not be deleted. This can be null when SubMenu is | |
47 // still off screen (not visible). | |
48 virtual const SkScalar* GetCorners() const = 0; | |
49 | |
50 // Returns the insets to give space to draw rounded corners. | |
51 virtual void GetInsets(gfx::Insets* insets) const = 0; | |
52 | |
53 // Returns the menu locator for dropdown menu. The menu will | |
54 // positioned so that the top right corner is given by "point". | |
55 // Only bottom corners are rounded. | |
56 static MenuLocator* CreateDropDownMenuLocator(const gfx::Point& point); | |
57 | |
58 // Returns the menu locator for context menu. The menu will | |
59 // positioned so that the top left corner is given by "point" (in | |
60 // LTR). All 4 corners are rounded. | |
61 static MenuLocator* CreateContextMenuLocator(const gfx::Point& point); | |
62 | |
63 // Returns the menu locator for submenu menu. The menu will | |
64 // positioned at Y and on the right side of the widget, or on the | |
65 // left if there is no enough spaceon the right side. Once it changes the | |
66 // derection, all subsequent submenu should be positioned to the same | |
67 // direction given by |parent_direction|. 3 corners are | |
68 // rounded except for the corner that is attached to the widget. | |
69 static MenuLocator* CreateSubMenuLocator( | |
70 const WebUIMenuWidget* widget, | |
71 MenuLocator::SubmenuDirection parent_direction, | |
72 int y); | |
73 }; | |
74 | |
75 } // namespace chromeos | |
76 | |
77 #endif // CHROME_BROWSER_CHROMEOS_VIEWS_MENU_LOCATOR_H_ | |
OLD | NEW |