OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_GTK_H_ | |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_GTK_H_ | |
7 | |
8 #include <gtk/gtk.h> | |
9 | |
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" | |
16 | |
17 class CustomDrawButton; | |
18 class GtkThemeService; | |
19 class PanelGtk; | |
20 | |
21 namespace content { | |
22 class WebContents; | |
23 } | |
24 | |
25 class PanelTitlebarGtk { | |
26 public: | |
27 explicit PanelTitlebarGtk(PanelGtk* panel_gtk); | |
28 virtual ~PanelTitlebarGtk(); | |
29 | |
30 void UpdateTextColor(); | |
31 void UpdateMinimizeRestoreButtonVisibility(); | |
32 | |
33 // When a panel appears in the same position as the one of the panel being | |
34 // closed and the cursor stays in the close button, the close button appears | |
35 // not to be clickable. This is because neither "enter-notify-event" nor | |
36 // "clicked" event for the new panel gets fired if the mouse does not move. | |
37 // This creates a bad experience when a user has multiple panels of the same | |
38 // size (which is typical) and tries closing them all by repeatedly clicking | |
39 // in the same place on the screen. | |
40 // | |
41 // Opened a gtk bug for this - | |
42 // https://bugzilla.gnome.org/show_bug.cgi?id=667841 | |
43 void SendEnterNotifyToCloseButtonIfUnderMouse(); | |
44 | |
45 void Init(); | |
46 void UpdateTitleAndIcon(); | |
47 void UpdateThrobber(content::WebContents* web_contents); | |
48 GtkWidget* widget() const; | |
49 | |
50 private: | |
51 friend class GtkNativePanelTesting; | |
52 | |
53 void BuildButtons(); | |
54 CustomDrawButton* CreateButton(panel::TitlebarButtonType button_type); | |
55 void GetButtonResources(panel::TitlebarButtonType button_type, | |
56 int* normal_image_id, | |
57 int* pressed_image_id, | |
58 int* hover_image_id, | |
59 int* tooltip_id) const; | |
60 GtkWidget* GetButtonHBox(); | |
61 | |
62 // Callback for minimize/restore/close buttons. | |
63 CHROMEGTK_CALLBACK_0(PanelTitlebarGtk, void, OnButtonClicked); | |
64 | |
65 CustomDrawButton* close_button() const { return close_button_.get(); } | |
66 CustomDrawButton* minimize_button() const { return minimize_button_.get(); } | |
67 CustomDrawButton* restore_button() const { return restore_button_.get(); } | |
68 | |
69 SkColor GetTextColor() const; | |
70 | |
71 // Pointers to the native panel window that owns us and its GtkWindow. | |
72 PanelGtk* panel_gtk_; | |
73 | |
74 // The container widget the holds the hbox which contains the whole titlebar. | |
75 GtkWidget* container_; | |
76 | |
77 // VBoxes that holds the minimize/restore/close buttons box. | |
78 GtkWidget* titlebar_right_buttons_vbox_; | |
79 | |
80 // HBoxes that contains the actual min/max/close buttons. | |
81 GtkWidget* titlebar_right_buttons_hbox_; | |
82 | |
83 // The icon and page title. | |
84 GtkWidget* icon_; | |
85 GtkWidget* title_; | |
86 | |
87 // The buttons. | |
88 scoped_ptr<CustomDrawButton> close_button_; | |
89 scoped_ptr<CustomDrawButton> minimize_button_; | |
90 scoped_ptr<CustomDrawButton> restore_button_; | |
91 | |
92 TitlebarThrobAnimation throbber_; | |
93 GtkThemeService* theme_service_; | |
94 | |
95 DISALLOW_COPY_AND_ASSIGN(PanelTitlebarGtk); | |
96 }; | |
97 | |
98 #endif // CHROME_BROWSER_UI_PANELS_PANEL_TITLEBAR_GTK_H_ | |
OLD | NEW |