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_GTK_PANELS_PANEL_TITLEBAR_GTK_H_ | |
6 #define CHROME_BROWSER_UI_GTK_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 PanelGtk; | |
19 | |
20 namespace content { | |
21 class WebContents; | |
22 } | |
23 | |
24 class PanelTitlebarGtk { | |
25 public: | |
26 explicit PanelTitlebarGtk(PanelGtk* panel_gtk); | |
27 virtual ~PanelTitlebarGtk(); | |
28 | |
29 void UpdateTextColor(); | |
30 void UpdateMinimizeRestoreButtonVisibility(); | |
31 | |
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. | |
39 // | |
40 // Opened a gtk bug for this - | |
41 // https://bugzilla.gnome.org/show_bug.cgi?id=667841 | |
42 void SendEnterNotifyToCloseButtonIfUnderMouse(); | |
43 | |
44 void Init(); | |
45 void UpdateTitleAndIcon(); | |
46 void UpdateThrobber(content::WebContents* web_contents); | |
47 GtkWidget* widget() const; | |
48 | |
49 private: | |
50 friend class GtkNativePanelTesting; | |
51 | |
52 void BuildButtons(); | |
53 CustomDrawButton* CreateButton(panel::TitlebarButtonType button_type); | |
54 void GetButtonResources(panel::TitlebarButtonType button_type, | |
55 int* normal_image_id, | |
56 int* pressed_image_id, | |
57 int* hover_image_id, | |
58 int* tooltip_id) const; | |
59 GtkWidget* GetButtonHBox(); | |
60 | |
61 // Callback for minimize/restore/close buttons. | |
62 CHROMEGTK_CALLBACK_0(PanelTitlebarGtk, void, OnButtonClicked); | |
63 | |
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(); } | |
67 | |
68 SkColor GetTextColor() const; | |
69 | |
70 // Pointers to the native panel window that owns us and its GtkWindow. | |
71 PanelGtk* panel_gtk_; | |
72 | |
73 // The container widget the holds the hbox which contains the whole titlebar. | |
74 GtkWidget* container_; | |
75 | |
76 // VBoxes that holds the minimize/restore/close buttons box. | |
77 GtkWidget* titlebar_right_buttons_vbox_; | |
78 | |
79 // HBoxes that contains the actual min/max/close buttons. | |
80 GtkWidget* titlebar_right_buttons_hbox_; | |
81 | |
82 // The icon and page title. | |
83 GtkWidget* icon_; | |
84 GtkWidget* title_; | |
85 | |
86 // The buttons. | |
87 scoped_ptr<CustomDrawButton> close_button_; | |
88 scoped_ptr<CustomDrawButton> minimize_button_; | |
89 scoped_ptr<CustomDrawButton> restore_button_; | |
90 | |
91 TitlebarThrobAnimation throbber_; | |
92 | |
93 DISALLOW_COPY_AND_ASSIGN(PanelTitlebarGtk); | |
94 }; | |
95 | |
96 #endif // CHROME_BROWSER_UI_GTK_PANELS_PANEL_TITLEBAR_GTK_H_ | |
OLD | NEW |