Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / menu_bar_helper.h
blobb4c0b040a4ab08cac928070b6970cd5f2443ae6c
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 // This class replicates some menubar behaviors that are tricky to get right.
6 // It is used to create a more native feel for the bookmark bar.
8 #ifndef CHROME_BROWSER_UI_GTK_MENU_BAR_HELPER_H_
9 #define CHROME_BROWSER_UI_GTK_MENU_BAR_HELPER_H_
11 #include <gtk/gtk.h>
13 #include <vector>
15 #include "base/memory/scoped_ptr.h"
16 #include "ui/base/gtk/gtk_signal.h"
18 namespace ui {
19 class GtkSignalRegistrar;
22 class MenuBarHelper {
23 public:
24 class Delegate {
25 public:
26 virtual ~Delegate() {}
28 // Called when a the menu for a button ought to be triggered.
29 virtual void PopupForButton(GtkWidget* button) = 0;
30 virtual void PopupForButtonNextTo(GtkWidget* button,
31 GtkMenuDirectionType dir) = 0;
34 // |delegate| cannot be null.
35 explicit MenuBarHelper(Delegate* delegate);
36 ~MenuBarHelper();
38 // Must be called whenever a button's menu starts showing. It triggers the
39 // MenuBarHelper to start listening for certain events.
40 void MenuStartedShowing(GtkWidget* button, GtkWidget* menu);
42 // Add |button| to the set of buttons we care about.
43 void Add(GtkWidget* button);
45 // Remove |button| from the set of buttons we care about.
46 void Remove(GtkWidget* button);
48 // Clear all buttons from the set.
49 void Clear();
51 private:
52 CHROMEGTK_CALLBACK_0(MenuBarHelper, void, OnMenuHiddenOrDestroyed);
53 CHROMEGTK_CALLBACK_1(MenuBarHelper, gboolean, OnMenuMotionNotify,
54 GdkEventMotion*);
55 CHROMEGTK_CALLBACK_1(MenuBarHelper, void, OnMenuMoveCurrent,
56 GtkMenuDirectionType);
58 // The buttons for which we pop up menus. We do not own these, or even add
59 // refs to them.
60 std::vector<GtkWidget*> buttons_;
62 // The button that is currently showing a menu, or NULL.
63 GtkWidget* button_showing_menu_;
65 // The highest level menu that is currently showing, or NULL.
66 GtkWidget* showing_menu_;
68 // All the submenus of |showing_menu_|. We connect to motion events on all
69 // of them.
70 std::vector<GtkWidget*> submenus_;
72 // Signal handlers that are attached only between the "show" and "hide" events
73 // for the menu.
74 scoped_ptr<ui::GtkSignalRegistrar> signal_handlers_;
76 Delegate* delegate_;
79 #endif // CHROME_BROWSER_UI_GTK_MENU_BAR_HELPER_H_