diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 17:26:18 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 17:26:18 +0000 |
commit | 564a9026f2f0c9baf0c12b6e72a959ffc8beb985 (patch) | |
tree | f51454a79ae8aee7f0d6edc29b40ff95fa148964 /chrome/browser/wrench_menu_model.h | |
parent | 49857a356c68f5915ed73452cfc162c18576fedd (diff) | |
download | chromium_src-564a9026f2f0c9baf0c12b6e72a959ffc8beb985.zip chromium_src-564a9026f2f0c9baf0c12b6e72a959ffc8beb985.tar.gz chromium_src-564a9026f2f0c9baf0c12b6e72a959ffc8beb985.tar.bz2 |
GTK: First draft of the unified cut/copy/paste and +/-/Fullscreen menu items.
Adds special menu item types that allow shoving buttons into them, along with
tracking which button is selected. We now are halfway to the mocks that the
chrome-ui-leads sent out.
BUG=45757
TEST=none
Review URL: http://codereview.chromium.org/2800015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/wrench_menu_model.h')
-rw-r--r-- | chrome/browser/wrench_menu_model.h | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/chrome/browser/wrench_menu_model.h b/chrome/browser/wrench_menu_model.h index f86a170..5b7d2d5 100644 --- a/chrome/browser/wrench_menu_model.h +++ b/chrome/browser/wrench_menu_model.h @@ -11,14 +11,19 @@ #include "app/menus/simple_menu_model.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" class Browser; class EncodingMenuModel; +namespace menus { +class ButtonMenuItemModel; +} // namespace menus + class ToolsMenuModel : public menus::SimpleMenuModel { public: - explicit ToolsMenuModel(menus::SimpleMenuModel::Delegate* delegate, - Browser* browser); + ToolsMenuModel(menus::SimpleMenuModel::Delegate* delegate, Browser* browser); virtual ~ToolsMenuModel(); private: @@ -30,10 +35,12 @@ class ToolsMenuModel : public menus::SimpleMenuModel { }; // A menu model that builds the contents of the wrench menu. -class WrenchMenuModel : public menus::SimpleMenuModel { +class WrenchMenuModel : public menus::SimpleMenuModel, + public menus::ButtonMenuItemModel::Delegate, + public NotificationObserver { public: - explicit WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate, - Browser* browser); + WrenchMenuModel(menus::SimpleMenuModel::Delegate* delegate, + Browser* browser); virtual ~WrenchMenuModel(); // Returns true if the WrenchMenuModel is enabled. @@ -45,27 +52,48 @@ class WrenchMenuModel : public menus::SimpleMenuModel { virtual bool HasIcons() const { return true; } virtual bool GetIconAt(int index, SkBitmap* icon) const; - protected: - // Adds the cut/copy/paste items to the menu. The default implementation adds - // three real menu items, while platform specific subclasses add their own - // native monstrosities. - virtual void CreateCutCopyPaste(); + // Overridden from menus::ButtonMenuItemModel::Delegate: + virtual bool IsLabelForCommandIdDynamic(int command_id) const; + virtual string16 GetLabelForCommandId(int command_id) const; + virtual void ExecuteCommand(int command_id); - // Adds the zoom/fullscreen items to the menu. Like CreateCutCopyPaste(). - virtual void CreateZoomFullscreen(); + // Overridden from NotificationObserver: + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); private: void Build(); + // Adds custom items to the menu. Deprecated in favor of a cross platform + // model for button items. + void CreateCutCopyPaste(); + void CreateZoomFullscreen(); + + // Calculates |zoom_label_| in response to a zoom change. + void UpdateZoomControls(); + double GetZoom(bool* enable_increment, bool* enable_decrement); + string16 GetSyncMenuLabel() const; string16 GetAboutEntryMenuLabel() const; bool IsDynamicItem(int index) const; + // Models for the special menu items with buttons. + scoped_ptr<menus::ButtonMenuItemModel> edit_menu_item_model_; + scoped_ptr<menus::ButtonMenuItemModel> zoom_menu_item_model_; + + // Label of the zoom label in the zoom menu item. + string16 zoom_label_; + // Tools menu. scoped_ptr<ToolsMenuModel> tools_menu_model_; + menus::SimpleMenuModel::Delegate* delegate_; // weak + Browser* browser_; // weak + NotificationRegistrar registrar_; + DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); }; |