Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1398)

Side by Side Diff: chrome/browser/ui/panels/panel.h

Issue 11669018: Support dragging panels to stack and snap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change per feedback Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "chrome/browser/command_updater.h" 13 #include "chrome/browser/command_updater.h"
14 #include "chrome/browser/command_updater_delegate.h" 14 #include "chrome/browser/command_updater_delegate.h"
15 #include "chrome/browser/extensions/image_loading_tracker.h" 15 #include "chrome/browser/extensions/image_loading_tracker.h"
16 #include "chrome/browser/sessions/session_id.h" 16 #include "chrome/browser/sessions/session_id.h"
17 #include "chrome/browser/ui/base_window.h" 17 #include "chrome/browser/ui/base_window.h"
18 #include "chrome/browser/ui/panels/panel_constants.h" 18 #include "chrome/browser/ui/panels/panel_constants.h"
19 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
21 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
22 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
23 23
24 class GURL; 24 class GURL;
25 class NativePanel; 25 class NativePanel;
26 class PanelCollection; 26 class PanelCollection;
27 class PanelHost; 27 class PanelHost;
28 class PanelManager; 28 class PanelManager;
29 class Profile; 29 class Profile;
30 class StackedPanelCollection;
30 31
31 namespace content { 32 namespace content {
32 class WebContents; 33 class WebContents;
33 struct NativeWebKeyboardEvent; 34 struct NativeWebKeyboardEvent;
34 } 35 }
35 36
36 namespace extensions { 37 namespace extensions {
37 class Extension; 38 class Extension;
38 class WindowController; 39 class WindowController;
39 } 40 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const gfx::Image& app_icon() const { return app_icon_; } 82 const gfx::Image& app_icon() const { return app_icon_; }
82 const SessionID& session_id() const { return session_id_; } 83 const SessionID& session_id() const { return session_id_; }
83 extensions::WindowController* extension_window_controller() const { 84 extensions::WindowController* extension_window_controller() const {
84 return extension_window_controller_.get(); 85 return extension_window_controller_.get();
85 } 86 }
86 const std::string extension_id() const; 87 const std::string extension_id() const;
87 88
88 CommandUpdater* command_updater(); 89 CommandUpdater* command_updater();
89 Profile* profile() const; 90 Profile* profile() const;
90 91
92 const extensions::Extension* GetExtension() const;
93
91 // Returns web contents of the panel, if any. There may be none if web 94 // Returns web contents of the panel, if any. There may be none if web
92 // contents have not been added to the panel yet. 95 // contents have not been added to the panel yet.
93 content::WebContents* GetWebContents() const; 96 content::WebContents* GetWebContents() const;
94 97
95 void SetExpansionState(ExpansionState new_expansion_state); 98 void SetExpansionState(ExpansionState new_expansion_state);
96 99
97 bool IsDrawingAttention() const; 100 bool IsDrawingAttention() const;
98 101
99 // This function will only get called by PanelManager when full screen mode 102 // This function will only get called by PanelManager when full screen mode
100 // changes i.e it gets called when an app goes into full screen mode or when 103 // changes i.e it gets called when an app goes into full screen mode or when
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // * panel is newly created and has not been positioned yet. 172 // * panel is newly created and has not been positioned yet.
170 // * panel is being closed asynchronously. 173 // * panel is being closed asynchronously.
171 // Please use it with caution. 174 // Please use it with caution.
172 PanelCollection* collection() const { return collection_; } 175 PanelCollection* collection() const { return collection_; }
173 176
174 // Sets the current panel collection that contains this panel. 177 // Sets the current panel collection that contains this panel.
175 void set_collection(PanelCollection* new_collection) { 178 void set_collection(PanelCollection* new_collection) {
176 collection_ = new_collection; 179 collection_ = new_collection;
177 } 180 }
178 181
182 StackedPanelCollection* stack() const;
183
179 ExpansionState expansion_state() const { return expansion_state_; } 184 ExpansionState expansion_state() const { return expansion_state_; }
180 const gfx::Size& min_size() const { return min_size_; } 185 const gfx::Size& min_size() const { return min_size_; }
181 const gfx::Size& max_size() const { return max_size_; } 186 const gfx::Size& max_size() const { return max_size_; }
182 bool auto_resizable() const { return auto_resizable_; } 187 bool auto_resizable() const { return auto_resizable_; }
183 188
184 bool in_preview_mode() const { return in_preview_mode_; } 189 bool in_preview_mode() const { return in_preview_mode_; }
185 190
186 panel::Resizability CanResizeByMouse() const; 191 panel::Resizability CanResizeByMouse() const;
187 192
188 AttentionMode attention_mode() const { return attention_mode_; } 193 AttentionMode attention_mode() const { return attention_mode_; }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 293
289 // Updates the title bar to display the current title and icon. 294 // Updates the title bar to display the current title and icon.
290 void UpdateTitleBar(); 295 void UpdateTitleBar();
291 296
292 // Updates UI to reflect change in loading state. 297 // Updates UI to reflect change in loading state.
293 void LoadingStateChanged(bool is_loading); 298 void LoadingStateChanged(bool is_loading);
294 299
295 // Updates UI to reflect that the web cotents receives the focus. 300 // Updates UI to reflect that the web cotents receives the focus.
296 void WebContentsFocused(content::WebContents* contents); 301 void WebContentsFocused(content::WebContents* contents);
297 302
303 // Updates the panel stacking property due to joining or leaving a stack.
304 void UpdateStackingProperty();
305
306 // Moves the panel by delta instantly.
307 void MoveBy(const gfx::Vector2d& delta_origin);
308
298 protected: 309 protected:
299 // Panel can only be created using PanelManager::CreatePanel() or subclass. 310 // Panel can only be created using PanelManager::CreatePanel() or subclass.
300 // |app_name| is the default title for Panels when the page content does not 311 // |app_name| is the default title for Panels when the page content does not
301 // provide a title. For extensions, this is usually the application name 312 // provide a title. For extensions, this is usually the application name
302 // generated from the extension id. 313 // generated from the extension id.
303 Panel(const std::string& app_name, 314 Panel(const std::string& app_name,
304 const gfx::Size& min_size, const gfx::Size& max_size); 315 const gfx::Size& min_size, const gfx::Size& max_size);
305 316
306 private: 317 private:
307 friend class PanelManager; 318 friend class PanelManager;
(...skipping 10 matching lines...) Expand all
318 virtual void OnImageLoaded(const gfx::Image& image, 329 virtual void OnImageLoaded(const gfx::Image& image,
319 const std::string& extension_id, 330 const std::string& extension_id,
320 int index) OVERRIDE; 331 int index) OVERRIDE;
321 332
322 // Initialize state for all supported commands. 333 // Initialize state for all supported commands.
323 void InitCommandState(); 334 void InitCommandState();
324 335
325 // Configures the renderer for auto resize (if auto resize is enabled). 336 // Configures the renderer for auto resize (if auto resize is enabled).
326 void ConfigureAutoResize(content::WebContents* web_contents); 337 void ConfigureAutoResize(content::WebContents* web_contents);
327 338
328 const extensions::Extension* GetExtension() const;
329
330 // Load the app's image, firing a load state change when loaded. 339 // Load the app's image, firing a load state change when loaded.
331 void UpdateAppIcon(); 340 void UpdateAppIcon();
332 341
333 // Prepares a title string for display (removes embedded newlines, etc). 342 // Prepares a title string for display (removes embedded newlines, etc).
334 static void FormatTitleForDisplay(string16* title); 343 static void FormatTitleForDisplay(string16* title);
335 344
336 // The application name that is also the name of the window when the 345 // The application name that is also the name of the window when the
337 // page content does not provide a title. 346 // page content does not provide a title.
338 // This name should be set when the panel is created. 347 // This name should be set when the panel is created.
339 const std::string app_name_; 348 const std::string app_name_;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Used for loading app_icon_. 396 // Used for loading app_icon_.
388 scoped_ptr<ImageLoadingTracker> app_icon_loader_; 397 scoped_ptr<ImageLoadingTracker> app_icon_loader_;
389 398
390 // Icon showed in the task bar. 399 // Icon showed in the task bar.
391 gfx::Image app_icon_; 400 gfx::Image app_icon_;
392 401
393 DISALLOW_COPY_AND_ASSIGN(Panel); 402 DISALLOW_COPY_AND_ASSIGN(Panel);
394 }; 403 };
395 404
396 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_ 405 #endif // CHROME_BROWSER_UI_PANELS_PANEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698