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