summaryrefslogtreecommitdiffstats
path: root/app/menus/button_menu_item_model.h
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 21:34:04 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 21:34:04 +0000
commit9c8f1501112092eba0e1c411c2c196487eb61b00 (patch)
tree38a5b7452b7bb9d9a5334eb3740f4cdc1fe8da51 /app/menus/button_menu_item_model.h
parent66761b95332549f825999e482c17c94675275f49 (diff)
downloadchromium_src-9c8f1501112092eba0e1c411c2c196487eb61b00.zip
chromium_src-9c8f1501112092eba0e1c411c2c196487eb61b00.tar.gz
chromium_src-9c8f1501112092eba0e1c411c2c196487eb61b00.tar.bz2
Reapply r50859 with chromeos fixes.
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. Review URL: http://codereview.chromium.org/2800015 BUG=45757 TEST=none Review URL: http://codereview.chromium.org/2879002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/menus/button_menu_item_model.h')
-rw-r--r--app/menus/button_menu_item_model.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/app/menus/button_menu_item_model.h b/app/menus/button_menu_item_model.h
new file mode 100644
index 0000000..b8418d1
--- /dev/null
+++ b/app/menus/button_menu_item_model.h
@@ -0,0 +1,103 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
+#define APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_
+
+#include <vector>
+
+#include "base/string16.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+namespace menus {
+
+// A model representing the rows of buttons that should be inserted in a button
+// containing menu item.
+//
+// TODO(erg): There are still two major pieces missing from this model. It
+// needs to be able to group buttons together so they all have the same
+// width. ButtonSides needs to be used to communicate how buttons are squashed
+// together.
+class ButtonMenuItemModel {
+ public:
+ // Types of buttons.
+ enum ButtonType {
+ TYPE_SPACE,
+ TYPE_BUTTON
+ };
+
+ // Which sides of the button are visible.
+ enum ButtonSides {
+ SIDE_NONE = 0,
+ SIDE_LEFT = 1 << 0,
+ SIDE_RIGHT = 1 << 1,
+ SIDE_BOTH = SIDE_LEFT | SIDE_RIGHT
+ };
+
+ class Delegate {
+ public:
+ // Some command ids have labels that change over time.
+ virtual bool IsLabelForCommandIdDynamic(int command_id) const {
+ return false;
+ }
+ virtual string16 GetLabelForCommandId(int command_id) const {
+ return string16();
+ }
+
+ // Performs the action associated with the specified command id.
+ virtual void ExecuteCommand(int command_id) = 0;
+ };
+
+ ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate);
+
+ // Adds a button that will emit |command_id|.
+ void AddItemWithStringId(int command_id, int string_id);
+
+ // Adds a button that has an icon instead of a label.
+ void AddItemWithImage(int command_id, int icon_idr);
+
+ // Adds a small horizontal space.
+ void AddSpace();
+
+ // Returns the number of items for iteration.
+ int GetItemCount() const;
+
+ // Returns what kind of item is at |index|.
+ ButtonType GetTypeAt(int index) const;
+
+ // Changes a position into a command ID.
+ int GetCommandIdAt(int index) const;
+
+ const string16& GetLabelAt(int index) const;
+
+ // If the button at |index| should have an icon instead, returns true and
+ // sets the IDR |icon|.
+ bool GetIconAt(int index, int* icon) const;
+
+ // Called from implementations.
+ void ActivatedCommand(int command_id);
+
+ const string16& label() const { return item_label_; }
+
+ private:
+ // The non-clickable label to the left of the buttons.
+ string16 item_label_;
+
+ struct Item {
+ int command_id;
+ ButtonType type;
+ string16 label;
+ int sides;
+ int icon_idr;
+ };
+ std::vector<Item> items_;
+
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(ButtonMenuItemModel);
+};
+
+} // namespace menus
+
+#endif // APP_MENUS_BUTTON_MENU_ITEM_MODEL_H_