1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_UI_GTK_PANELS_PANEL_TITLEBAR_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_PANELS_PANEL_TITLEBAR_GTK_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/ui/gtk/titlebar_throb_animation.h"
13 #include "chrome/browser/ui/panels/panel_constants.h"
14 #include "ui/base/gtk/gtk_signal.h"
15 #include "ui/gfx/skia_util.h"
17 class CustomDrawButton
;
24 class PanelTitlebarGtk
{
26 explicit PanelTitlebarGtk(PanelGtk
* panel_gtk
);
27 virtual ~PanelTitlebarGtk();
29 void UpdateTextColor();
30 void UpdateMinimizeRestoreButtonVisibility();
32 // When a panel appears in the same position as the one of the panel being
33 // closed and the cursor stays in the close button, the close button appears
34 // not to be clickable. This is because neither "enter-notify-event" nor
35 // "clicked" event for the new panel gets fired if the mouse does not move.
36 // This creates a bad experience when a user has multiple panels of the same
37 // size (which is typical) and tries closing them all by repeatedly clicking
38 // in the same place on the screen.
40 // Opened a gtk bug for this -
41 // https://bugzilla.gnome.org/show_bug.cgi?id=667841
42 void SendEnterNotifyToCloseButtonIfUnderMouse();
45 void UpdateTitleAndIcon();
46 void UpdateThrobber(content::WebContents
* web_contents
);
47 GtkWidget
* widget() const;
50 friend class GtkNativePanelTesting
;
53 CustomDrawButton
* CreateButton(panel::TitlebarButtonType button_type
);
54 void GetButtonResources(panel::TitlebarButtonType button_type
,
56 int* pressed_image_id
,
58 int* tooltip_id
) const;
59 GtkWidget
* GetButtonHBox();
61 // Callback for minimize/restore/close buttons.
62 CHROMEGTK_CALLBACK_0(PanelTitlebarGtk
, void, OnButtonClicked
);
64 CustomDrawButton
* close_button() const { return close_button_
.get(); }
65 CustomDrawButton
* minimize_button() const { return minimize_button_
.get(); }
66 CustomDrawButton
* restore_button() const { return restore_button_
.get(); }
68 SkColor
GetTextColor() const;
70 // Pointers to the native panel window that owns us and its GtkWindow.
73 // The container widget the holds the hbox which contains the whole titlebar.
74 GtkWidget
* container_
;
76 // VBoxes that holds the minimize/restore/close buttons box.
77 GtkWidget
* titlebar_right_buttons_vbox_
;
79 // HBoxes that contains the actual min/max/close buttons.
80 GtkWidget
* titlebar_right_buttons_hbox_
;
82 // The icon and page title.
87 scoped_ptr
<CustomDrawButton
> close_button_
;
88 scoped_ptr
<CustomDrawButton
> minimize_button_
;
89 scoped_ptr
<CustomDrawButton
> restore_button_
;
91 TitlebarThrobAnimation throbber_
;
93 DISALLOW_COPY_AND_ASSIGN(PanelTitlebarGtk
);
96 #endif // CHROME_BROWSER_UI_GTK_PANELS_PANEL_TITLEBAR_GTK_H_