1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
// Copyright (c) 2012 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 CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_
#define CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
#include "chrome/browser/ui/gtk/browser_window_gtk.h"
#include "chrome/browser/ui/panels/native_panel.h"
#include "ui/base/animation/animation_delegate.h"
class Panel;
class PanelBoundsAnimation;
class PanelBrowserTitlebarGtk;
class PanelDragGtk;
class NativePanelTestingGtk;
namespace gfx {
class Image;
}
class PanelBrowserWindowGtk : public BrowserWindowGtk,
public NativePanel,
public ui::AnimationDelegate {
public:
enum PaintState {
PAINT_AS_ACTIVE,
PAINT_AS_INACTIVE,
PAINT_AS_MINIMIZED,
PAINT_FOR_ATTENTION
};
PanelBrowserWindowGtk(Browser* browser, Panel* panel,
const gfx::Rect& bounds);
virtual ~PanelBrowserWindowGtk();
// BrowserWindowGtk override
virtual void Init() OVERRIDE;
// BrowserWindow overrides
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
// Overrides BrowserWindowGtk::NotificationObserver::Observe
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
bool UsingDefaultTheme() const;
Panel* panel() const { return panel_.get(); }
PaintState paint_state() const { return paint_state_; }
protected:
// BrowserWindowGtk overrides
virtual BrowserTitlebarBase* CreateBrowserTitlebar() OVERRIDE;
virtual bool GetWindowEdge(int x, int y, GdkWindowEdge* edge) OVERRIDE;
virtual GdkRegion* GetWindowShape(int width, int height) const OVERRIDE;
virtual bool HandleTitleBarLeftMousePress(
GdkEventButton* event,
guint32 last_click_time,
gfx::Point last_click_position) OVERRIDE;
virtual bool HandleWindowEdgeLeftMousePress(
GtkWindow* window,
GdkWindowEdge edge,
GdkEventButton* event) OVERRIDE;
virtual void SaveWindowPosition() OVERRIDE;
virtual void SetGeometryHints() OVERRIDE;
virtual bool UseCustomFrame() const OVERRIDE;
virtual void DrawFrame(GtkWidget* widget, GdkEventExpose* event) OVERRIDE;
virtual void OnSizeChanged(int width, int height) OVERRIDE;
virtual void ActiveWindowChanged(GdkWindow* active_window) OVERRIDE;
// Overridden from NativePanel:
virtual void ShowPanel() OVERRIDE;
virtual void ShowPanelInactive() OVERRIDE;
virtual gfx::Rect GetPanelBounds() const OVERRIDE;
virtual void SetPanelBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void SetPanelBoundsInstantly(const gfx::Rect& bounds) OVERRIDE;
virtual void ClosePanel() OVERRIDE;
virtual void ActivatePanel() OVERRIDE;
virtual void DeactivatePanel() OVERRIDE;
virtual bool IsPanelActive() const OVERRIDE;
virtual void PreventActivationByOS(bool prevent_activation) OVERRIDE;
virtual gfx::NativeWindow GetNativePanelHandle() OVERRIDE;
virtual void UpdatePanelTitleBar() OVERRIDE;
virtual void UpdatePanelLoadingAnimations(bool should_animate) OVERRIDE;
virtual void ShowTaskManagerForPanel() OVERRIDE;
virtual FindBar* CreatePanelFindBar() OVERRIDE;
virtual void NotifyPanelOnUserChangedTheme() OVERRIDE;
virtual void PanelWebContentsFocused(content::WebContents* contents) OVERRIDE;
virtual void PanelCut() OVERRIDE;
virtual void PanelCopy() OVERRIDE;
virtual void PanelPaste() OVERRIDE;
virtual void DrawAttention(bool draw_attention) OVERRIDE;
virtual bool IsDrawingAttention() const OVERRIDE;
virtual bool PreHandlePanelKeyboardEvent(
const content::NativeWebKeyboardEvent& event,
bool* is_keyboard_shortcut) OVERRIDE;
virtual void HandlePanelKeyboardEvent(
const content::NativeWebKeyboardEvent& event) OVERRIDE;
virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE;
virtual Browser* GetPanelBrowser() const OVERRIDE;
virtual void DestroyPanelBrowser() OVERRIDE;
virtual gfx::Size WindowSizeFromContentSize(
const gfx::Size& content_size) const OVERRIDE;
virtual gfx::Size ContentSizeFromWindowSize(
const gfx::Size& window_size) const OVERRIDE;
virtual int TitleOnlyHeight() const OVERRIDE;
virtual void EnsurePanelFullyVisible() OVERRIDE;
virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE;
virtual void EnableResizeByMouse(bool enable) OVERRIDE;
virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE;
virtual void PanelExpansionStateChanging(
Panel::ExpansionState old_state,
Panel::ExpansionState new_state) OVERRIDE;
private:
friend class NativePanelTestingGtk;
void StartBoundsAnimation(const gfx::Rect& from_bounds,
const gfx::Rect& to_bounds);
bool IsAnimatingBounds() const;
// Overridden from AnimationDelegate:
virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
// Creates helper for handling drags if not already created.
void EnsureDragHelperCreated();
void SetBoundsInternal(const gfx::Rect& bounds, bool animate);
PanelBrowserTitlebarGtk* GetPanelTitlebar() const;
// Returns the image to paint the frame.
const gfx::Image* GetFrameBackground() const;
const gfx::Image* GetDefaultFrameBackground() const;
const gfx::Image* GetThemedFrameBackground() const;
CHROMEGTK_CALLBACK_1(PanelBrowserWindowGtk, gboolean,
OnTitlebarButtonReleaseEvent, GdkEventButton*);
scoped_ptr<Panel> panel_;
gfx::Rect bounds_;
scoped_ptr<PanelDragGtk> drag_helper_;
// Size of window frame. Empty until the window has been allocated and sized.
gfx::Size frame_size_;
// Indicates different painting state, active, drawing attention or else.
PaintState paint_state_;
// Indicates that the panel is currently drawing attention.
bool is_drawing_attention_;
// Used to animate the bounds change.
scoped_ptr<PanelBoundsAnimation> bounds_animator_;
gfx::Rect animation_start_bounds_;
// This records the bounds set on the last animation progress notification.
// We need this for the case where a new bounds animation starts before the
// current one completes. In this case, we want to start the new animation
// from where the last one left.
gfx::Rect last_animation_progressed_bounds_;
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk);
};
#endif // CHROME_BROWSER_UI_PANELS_PANEL_BROWSER_WINDOW_GTK_H_
|