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

Side by Side Diff: chrome/browser/views/frame/browser_frame_win.cc

Issue 42490: Experiments with a new tabstrip + animator (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/views/frame/browser_frame_win.h" 5 #include "chrome/browser/views/frame/browser_frame_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
11 #include "app/win_util.h" 11 #include "app/win_util.h"
12 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
13 #include "chrome/browser/browser_list.h" 13 #include "chrome/browser/browser_list.h"
14 #include "chrome/browser/dock_info.h"
14 #include "chrome/browser/views/frame/browser_non_client_frame_view.h" 15 #include "chrome/browser/views/frame/browser_non_client_frame_view.h"
15 #include "chrome/browser/views/frame/browser_root_view.h" 16 #include "chrome/browser/views/frame/browser_root_view.h"
16 #include "chrome/browser/views/frame/browser_view.h" 17 #include "chrome/browser/views/frame/browser_view.h"
17 #include "chrome/browser/views/frame/glass_browser_frame_view.h" 18 #include "chrome/browser/views/frame/glass_browser_frame_view.h"
18 #include "chrome/browser/views/frame/opaque_browser_frame_view.h" 19 #include "chrome/browser/views/frame/opaque_browser_frame_view.h"
20 #include "chrome/browser/views/tabs/browser_tab_strip.h"
19 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
22 #include "views/screen.h"
20 #include "views/window/window_delegate.h" 23 #include "views/window/window_delegate.h"
21 24
22 // static 25 // static
23 static const int kClientEdgeThickness = 3; 26 static const int kClientEdgeThickness = 3;
27 static const int kTabDragWindowAlpha = 200;
24 28
25 // static (Factory method.) 29 // static (Factory method.)
26 BrowserFrame* BrowserFrame::Create(BrowserView* browser_view, 30 BrowserFrame* BrowserFrame::Create(BrowserView* browser_view,
27 Profile* profile) { 31 Profile* profile) {
28 BrowserFrameWin* frame = new BrowserFrameWin(browser_view, profile); 32 BrowserFrameWin* frame = new BrowserFrameWin(browser_view, profile);
29 frame->Init(); 33 frame->Init();
30 return frame; 34 return frame;
31 } 35 }
32 36
33 /////////////////////////////////////////////////////////////////////////////// 37 ///////////////////////////////////////////////////////////////////////////////
34 // BrowserFrame, public: 38 // BrowserFrame, public:
35 39
36 BrowserFrameWin::BrowserFrameWin(BrowserView* browser_view, Profile* profile) 40 BrowserFrameWin::BrowserFrameWin(BrowserView* browser_view, Profile* profile)
37 : WindowWin(browser_view), 41 : WindowWin(browser_view),
38 browser_view_(browser_view), 42 browser_view_(browser_view),
43 saved_window_style_(0),
44 saved_window_ex_style_(0),
45 detached_drag_mode_(false),
46 drop_tabstrip_(NULL),
39 root_view_(NULL), 47 root_view_(NULL),
40 frame_initialized_(false), 48 frame_initialized_(false),
41 profile_(profile) { 49 profile_(profile) {
42 browser_view_->set_frame(this); 50 browser_view_->set_frame(this);
43 GetNonClientView()->SetFrameView(CreateFrameViewForWindow()); 51 GetNonClientView()->SetFrameView(CreateFrameViewForWindow());
44 // Don't focus anything on creation, selecting a tab will set the focus. 52 // Don't focus anything on creation, selecting a tab will set the focus.
45 set_focus_on_creation(false); 53 set_focus_on_creation(false);
46 } 54 }
47 55
48 void BrowserFrameWin::Init() { 56 void BrowserFrameWin::Init() {
(...skipping 24 matching lines...) Expand all
73 } 81 }
74 82
75 gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(TabStrip* tabstrip) const { 83 gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(TabStrip* tabstrip) const {
76 return browser_frame_view_->GetBoundsForTabStrip(tabstrip); 84 return browser_frame_view_->GetBoundsForTabStrip(tabstrip);
77 } 85 }
78 86
79 void BrowserFrameWin::UpdateThrobber(bool running) { 87 void BrowserFrameWin::UpdateThrobber(bool running) {
80 browser_frame_view_->UpdateThrobber(running); 88 browser_frame_view_->UpdateThrobber(running);
81 } 89 }
82 90
91 void BrowserFrameWin::ContinueDraggingDetachedTab() {
92 detached_drag_mode_ = true;
93
94 // Set the frame to partially transparent.
95 UpdateWindowAlphaForTabDragging(detached_drag_mode_);
96
97 // Send the message directly, so that the window is positioned appropriately.
98 SendMessage(GetNativeWindow(), WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(0, 0));
99 }
100
83 ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const { 101 ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const {
84 // This is implemented for a different interface than GetThemeProvider is, 102 // This is implemented for a different interface than GetThemeProvider is,
85 // but they mean the same things. 103 // but they mean the same things.
86 return GetThemeProvider(); 104 return GetThemeProvider();
87 } 105 }
88 106
89 ThemeProvider* BrowserFrameWin::GetThemeProvider() const { 107 ThemeProvider* BrowserFrameWin::GetThemeProvider() const {
90 return profile_->GetThemeProvider(); 108 return profile_->GetThemeProvider();
91 } 109 }
92 110
(...skipping 11 matching lines...) Expand all
104 bool BrowserFrameWin::GetAccelerator(int cmd_id, 122 bool BrowserFrameWin::GetAccelerator(int cmd_id,
105 views::Accelerator* accelerator) { 123 views::Accelerator* accelerator) {
106 return browser_view_->GetAccelerator(cmd_id, accelerator); 124 return browser_view_->GetAccelerator(cmd_id, accelerator);
107 } 125 }
108 126
109 void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) { 127 void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) {
110 BrowserList::WindowsSessionEnding(); 128 BrowserList::WindowsSessionEnding();
111 } 129 }
112 130
113 void BrowserFrameWin::OnEnterSizeMove() { 131 void BrowserFrameWin::OnEnterSizeMove() {
132 drop_tabstrip_ = NULL;
114 browser_view_->WindowMoveOrResizeStarted(); 133 browser_view_->WindowMoveOrResizeStarted();
115 } 134 }
116 135
136 void BrowserFrameWin::OnExitSizeMove() {
137 if (TabStrip2::Enabled()) {
138 if (detached_drag_mode_) {
139 detached_drag_mode_ = false;
140 if (drop_tabstrip_) {
141 gfx::Point screen_point = views::Screen::GetCursorScreenPoint();
142 BrowserTabStrip* tabstrip = browser_view_->bts();
143 gfx::Rect tsb = tabstrip->GetDraggedTabScreenBounds(screen_point);
144 drop_tabstrip_->AttachTab(tabstrip->DetachTab(0), screen_point, tsb);
145 } else {
146 UpdateWindowAlphaForTabDragging(detached_drag_mode_);
147 browser_view_->bts()->SendDraggedTabHome();
148 }
149 }
150 }
151 WidgetWin::OnExitSizeMove();
152 }
153
117 void BrowserFrameWin::OnInitMenuPopup(HMENU menu, UINT position, 154 void BrowserFrameWin::OnInitMenuPopup(HMENU menu, UINT position,
118 BOOL is_system_menu) { 155 BOOL is_system_menu) {
119 browser_view_->PrepareToRunSystemMenu(menu); 156 browser_view_->PrepareToRunSystemMenu(menu);
120 } 157 }
121 158
122 LRESULT BrowserFrameWin::OnMouseActivate(HWND window, UINT hittest_code, 159 LRESULT BrowserFrameWin::OnMouseActivate(HWND window, UINT hittest_code,
123 UINT message) { 160 UINT message) {
124 return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT 161 return browser_view_->ActivateAppModalDialog() ? MA_NOACTIVATEANDEAT
125 : MA_ACTIVATE; 162 : MA_ACTIVATE;
126 } 163 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (GetNonClientView()->UseNativeFrame()) { 257 if (GetNonClientView()->UseNativeFrame()) {
221 LRESULT result; 258 LRESULT result;
222 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, 259 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0,
223 MAKELPARAM(pt.x, pt.y), &result)) { 260 MAKELPARAM(pt.x, pt.y), &result)) {
224 return result; 261 return result;
225 } 262 }
226 } 263 }
227 return WindowWin::OnNCHitTest(pt); 264 return WindowWin::OnNCHitTest(pt);
228 } 265 }
229 266
267 void BrowserFrameWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
268 if (TabStrip2::Enabled()) {
269 if (detached_drag_mode_) {
270 // TODO(beng): move all to BrowserTabStrip...
271
272 // We check to see if the mouse cursor is in the magnetism zone of another
273 // visible TabStrip. If so, we should dock to it.
274 std::set<HWND> ignore_windows;
275 ignore_windows.insert(GetNativeWindow());
276
277 gfx::Point screen_point = views::Screen::GetCursorScreenPoint();
278 HWND local_window =
279 DockInfo::GetLocalProcessWindowAtPoint(screen_point, ignore_windows);
280 if (local_window) {
281 drop_tabstrip_ =
282 BrowserView::GetBrowserViewForNativeWindow(local_window)->bts();
283 if (TabStrip2::IsDragRearrange(drop_tabstrip_, screen_point)) {
284 ReleaseCapture();
285 return;
286 }
287 }
288 drop_tabstrip_ = NULL;
289 }
290 }
291
292 // Let the default window procedure handle - IMPORTANT!
293 WindowWin::OnWindowPosChanged(window_pos);
294 }
295
230 /////////////////////////////////////////////////////////////////////////////// 296 ///////////////////////////////////////////////////////////////////////////////
231 // BrowserFrame, views::CustomFrameWindow overrides: 297 // BrowserFrame, views::CustomFrameWindow overrides:
232 298
233 int BrowserFrameWin::GetShowState() const { 299 int BrowserFrameWin::GetShowState() const {
234 return browser_view_->GetShowState(); 300 return browser_view_->GetShowState();
235 } 301 }
236 302
237 views::NonClientFrameView* BrowserFrameWin::CreateFrameViewForWindow() { 303 views::NonClientFrameView* BrowserFrameWin::CreateFrameViewForWindow() {
238 if (GetThemeProvider()->ShouldUseNativeFrame()) 304 if (GetThemeProvider()->ShouldUseNativeFrame())
239 browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_); 305 browser_frame_view_ = new GlassBrowserFrameView(this, browser_view_);
(...skipping 25 matching lines...) Expand all
265 // because the GDI-drawn text in the web content composited over it will 331 // because the GDI-drawn text in the web content composited over it will
266 // become semi-transparent over any glass area. 332 // become semi-transparent over any glass area.
267 MARGINS margins = { 0 }; 333 MARGINS margins = { 0 };
268 if (!IsMaximized() && !IsFullscreen()) { 334 if (!IsMaximized() && !IsFullscreen()) {
269 margins.cxLeftWidth = kClientEdgeThickness + 1; 335 margins.cxLeftWidth = kClientEdgeThickness + 1;
270 margins.cxRightWidth = kClientEdgeThickness + 1; 336 margins.cxRightWidth = kClientEdgeThickness + 1;
271 margins.cyBottomHeight = kClientEdgeThickness + 1; 337 margins.cyBottomHeight = kClientEdgeThickness + 1;
272 } 338 }
273 // In maximized mode, we only have a titlebar strip of glass, no side/bottom 339 // In maximized mode, we only have a titlebar strip of glass, no side/bottom
274 // borders. 340 // borders.
275 if (!browser_view_->IsFullscreen()) { 341 if (!browser_view_->IsFullscreen() && !TabStrip2::Enabled()) {
276 margins.cyTopHeight = 342 margins.cyTopHeight =
277 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(); 343 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom();
278 } 344 }
279 DwmExtendFrameIntoClientArea(GetNativeView(), &margins); 345 DwmExtendFrameIntoClientArea(GetNativeView(), &margins);
280 } 346 }
347
348 void BrowserFrameWin::UpdateWindowAlphaForTabDragging(bool dragging) {
349 HWND frame_hwnd = GetNativeWindow();
350 if (dragging) {
351 // Make the frame slightly transparent during the drag operation.
352 saved_window_style_ = ::GetWindowLong(frame_hwnd, GWL_STYLE);
353 saved_window_ex_style_ = ::GetWindowLong(frame_hwnd, GWL_EXSTYLE);
354 ::SetWindowLong(frame_hwnd, GWL_EXSTYLE,
355 saved_window_ex_style_ | WS_EX_LAYERED);
356 // Remove the captions tyle so the window doesn't have window controls for a
357 // more "transparent" look.
358 ::SetWindowLong(frame_hwnd, GWL_STYLE,
359 saved_window_style_ & ~WS_CAPTION);
360 SetLayeredWindowAttributes(frame_hwnd, RGB(0xFF, 0xFF, 0xFF),
361 kTabDragWindowAlpha, LWA_ALPHA);
362 } else {
363 ::SetWindowLong(frame_hwnd, GWL_STYLE, saved_window_style_);
364 ::SetWindowLong(frame_hwnd, GWL_EXSTYLE, saved_window_ex_style_);
365 }
366 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/browser_frame_win.h ('k') | chrome/browser/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698