OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 | 10 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
13 | 13 |
14 class NativePanel; | 14 class NativePanel; |
15 class PanelManager; | 15 class PanelManager; |
16 | 16 |
17 // A platform independent implementation of BrowserWindow for Panels. This | 17 // A platform independent implementation of BrowserWindow for Panels. This |
18 // class would get the first crack at all the BrowserWindow calls for Panels and | 18 // class would get the first crack at all the BrowserWindow calls for Panels and |
19 // do one or more of the following: | 19 // do one or more of the following: |
20 // - Do nothing. The function is not relevant to Panels. | 20 // - Do nothing. The function is not relevant to Panels. |
21 // - Throw an exceptions. The function shouldn't be called for Panels. | 21 // - Throw an exceptions. The function shouldn't be called for Panels. |
22 // - Do Panel specific platform independent processing and then invoke the | 22 // - Do Panel specific platform independent processing and then invoke the |
23 // function on the platform specific BrowserWindow member. For example, | 23 // function on the platform specific BrowserWindow member. For example, |
24 // Panel size is restricted to certain limits. | 24 // Panel size is restricted to certain limits. |
25 // - Invoke an appropriate PanelManager function to do stuff that might affect | 25 // - Invoke an appropriate PanelManager function to do stuff that might affect |
26 // other Panels. For example deleting a panel would rearrange other panels. | 26 // other Panels. For example deleting a panel would rearrange other panels. |
27 class Panel : public BrowserWindow { | 27 class Panel : public BrowserWindow { |
28 public: | 28 public: |
29 enum ExpansionState { | |
30 // The panel is in fully expanded with both title-bar and the client-area. | |
jennb
2011/06/30 17:33:31
s/is in/is
jianli
2011/06/30 18:22:36
Done.
| |
31 EXPANDED, | |
32 // The panel is shown with the title-bar only. | |
33 TITLE_ONLY, | |
34 // The panel is shown with 3-pxiel line. | |
35 MINIMIZED | |
36 }; | |
37 | |
29 virtual ~Panel(); | 38 virtual ~Panel(); |
30 | 39 |
31 // Returns the PanelManager associated with this panel. | 40 // Returns the PanelManager associated with this panel. |
32 PanelManager* manager() const; | 41 PanelManager* manager() const; |
33 | 42 |
34 void Minimize(); | 43 void SetExpansionState(ExpansionState expansion_state); |
35 void Restore(); | 44 |
45 bool ShouldBringUpTitleBar(int mouse_x, int mouse_y) const; | |
36 | 46 |
37 // BrowserWindow overrides. | 47 // BrowserWindow overrides. |
38 virtual void Show() OVERRIDE; | 48 virtual void Show() OVERRIDE; |
39 virtual void ShowInactive() OVERRIDE; | 49 virtual void ShowInactive() OVERRIDE; |
40 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 50 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
41 virtual void Close() OVERRIDE; | 51 virtual void Close() OVERRIDE; |
42 virtual void Activate() OVERRIDE; | 52 virtual void Activate() OVERRIDE; |
43 virtual void Deactivate() OVERRIDE; | 53 virtual void Deactivate() OVERRIDE; |
44 virtual bool IsActive() const OVERRIDE; | 54 virtual bool IsActive() const OVERRIDE; |
45 virtual void FlashFrame() OVERRIDE; | 55 virtual void FlashFrame() OVERRIDE; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 const gfx::Rect& bounds); | 147 const gfx::Rect& bounds); |
138 | 148 |
139 // Gets the extension from the browser that a panel is created from. | 149 // Gets the extension from the browser that a panel is created from. |
140 // Returns NULL if it cannot be found. | 150 // Returns NULL if it cannot be found. |
141 static const Extension* GetExtension(Browser* browser); | 151 static const Extension* GetExtension(Browser* browser); |
142 | 152 |
143 #ifdef UNIT_TEST | 153 #ifdef UNIT_TEST |
144 NativePanel* native_panel() { return native_panel_; } | 154 NativePanel* native_panel() { return native_panel_; } |
145 #endif | 155 #endif |
146 | 156 |
157 ExpansionState expansion_state() const { return expansion_state_; } | |
158 | |
147 protected: | 159 protected: |
148 virtual void DestroyBrowser() OVERRIDE; | 160 virtual void DestroyBrowser() OVERRIDE; |
149 | 161 |
150 private: | 162 private: |
151 friend class PanelManager; | 163 friend class PanelManager; |
152 | 164 |
153 // Panel can only be created using PanelManager::CreatePanel(). | 165 // Panel can only be created using PanelManager::CreatePanel(). |
154 Panel(Browser* browser, const gfx::Rect& bounds); | 166 Panel(Browser* browser, const gfx::Rect& bounds); |
155 | 167 |
156 // This is different from BrowserWindow::SetBounds(): | 168 // This is different from BrowserWindow::SetBounds(): |
157 // * SetPanelBounds() is only called by PanelManager to manage its position. | 169 // * SetPanelBounds() is only called by PanelManager to manage its position. |
158 // * SetBounds() is called by the API to try to change the bounds, which is | 170 // * SetBounds() is called by the API to try to change the bounds, which is |
159 // not allowed for Panel. | 171 // not allowed for Panel. |
160 void SetPanelBounds(const gfx::Rect& bounds); | 172 void SetPanelBounds(const gfx::Rect& bounds); |
161 | 173 |
162 // Platform specifc implementation for panels. It'd be one of | 174 // Platform specifc implementation for panels. It'd be one of |
163 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. | 175 // PanelBrowserWindowGtk/PanelBrowserView/PanelBrowserWindowCocoa. |
164 NativePanel* native_panel_; // Weak, owns us. | 176 NativePanel* native_panel_; // Weak, owns us. |
165 | 177 |
178 ExpansionState expansion_state_; | |
179 | |
166 DISALLOW_COPY_AND_ASSIGN(Panel); | 180 DISALLOW_COPY_AND_ASSIGN(Panel); |
167 }; | 181 }; |
168 | 182 |
169 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ | 183 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ |
OLD | NEW |