Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1160)

Unified Diff: ui/views/controls/menu/menu_item_view.h

Issue 10532171: Added support for icon views (view used instead of icon in a menu item). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added support for icon views (view used instead of icon in a menu item). Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/menu/menu_item_view.h
diff --git a/ui/views/controls/menu/menu_item_view.h b/ui/views/controls/menu/menu_item_view.h
index 6f4b89ad6f60bfacfb1bd74faf8b2c899aa769f0..7c8397c904f60ca973d0c4a7dfc380b4ef82b4c4 100644
--- a/ui/views/controls/menu/menu_item_view.h
+++ b/ui/views/controls/menu/menu_item_view.h
@@ -239,8 +239,10 @@ class VIEWS_EXPORT MenuItemView : public View {
// Sets the icon of this menu item.
void SetIcon(const gfx::ImageSkia& icon);
- // Returns the icon.
- const gfx::ImageSkia& GetIcon() const { return icon_; }
+ // Sets the view used to render the icon. This clobbers any icon set via
+ // SetIcon(). MenuItemView takes ownership of |icon_view|.
+ void SetIconView(View* icon_view);
+ View* icon_view() { return icon_view_; }
// Sets the command id of this menu item.
void SetCommand(int command) { command_ = command; }
@@ -287,7 +289,7 @@ class VIEWS_EXPORT MenuItemView : public View {
// Sizes any child views.
virtual void Layout() OVERRIDE;
- // Returns the amount of space needed to accomodate the accelerator. The
+ // Returns the amount of space needed to accommodate the accelerator. The
// space needed for the accelerator is NOT included in the preferred width.
int GetAcceleratorTextWidth();
@@ -327,7 +329,7 @@ class VIEWS_EXPORT MenuItemView : public View {
// Calculates all sizes that we can from the OS.
//
// This is invoked prior to Running a menu.
- static void UpdateMenuPartSizes(bool has_icons);
+ void UpdateMenuPartSizes();
// Called by the two constructors to initialize this menu item.
void Init(MenuItemView* parent,
@@ -405,6 +407,9 @@ class VIEWS_EXPORT MenuItemView : public View {
// that is responsible for rendering the content.
bool IsContainer() const;
+ // Returns number if child views excluding icon_view.
+ int NonIconChildViewsCount() const;
+
// The delegate. This is only valid for the root menu item. You shouldn't
// use this directly, instead use GetDelegate() which walks the tree as
// as necessary.
@@ -435,9 +440,6 @@ class VIEWS_EXPORT MenuItemView : public View {
// Title.
string16 title_;
- // Icon.
- gfx::ImageSkia icon_;
-
// Does the title have a mnemonic? Only useful on the root menu item.
bool has_mnemonics_;
@@ -445,11 +447,19 @@ class VIEWS_EXPORT MenuItemView : public View {
// MenuConfig says mnemonics should be shown. Only used on the root menu item.
bool show_mnemonics_;
+ // Set if menu has icons or icon_views
+ // (applies to root menu item only).
bool has_icons_;
+ // Pointer to a view with a menu icon.
+ View* icon_view_;
+
// The tooltip to show on hover for this menu item.
string16 tooltip_;
+ // Width of a menu icon area.
+ static int icon_area_width_;
+
// X-coordinate of where the label starts.
static int label_start_;

Powered by Google App Engine
This is Rietveld 408576698