| OLD | NEW |
| 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/old_frames/vista_frame.h" | 5 #include "chrome/browser/views/old_frames/vista_frame.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlapp.h> | 9 #include <atlapp.h> |
| 10 #include <atltheme.h> | 10 #include <atltheme.h> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 int height = client_rect.Height(); | 174 int height = client_rect.Height(); |
| 175 | 175 |
| 176 root_view_.SetBounds(0, 0, width, height); | 176 root_view_.SetBounds(0, 0, width, height); |
| 177 frame_view_->SetBounds(0, 0, width, height); | 177 frame_view_->SetBounds(0, 0, width, height); |
| 178 | 178 |
| 179 if (IsTabStripVisible()) { | 179 if (IsTabStripVisible()) { |
| 180 tabstrip_->SetVisible(true); | 180 tabstrip_->SetVisible(true); |
| 181 int tabstrip_x = g_bitmaps[CT_LEFT_SIDE]->width(); | 181 int tabstrip_x = g_bitmaps[CT_LEFT_SIDE]->width(); |
| 182 if (is_off_the_record_) { | 182 if (is_off_the_record_) { |
| 183 off_the_record_image_->SetVisible(true); | 183 off_the_record_image_->SetVisible(true); |
| 184 CSize otr_image_size; | 184 gfx::Size otr_image_size = off_the_record_image_->GetPreferredSize(); |
| 185 off_the_record_image_->GetPreferredSize(&otr_image_size); | 185 tabstrip_x += otr_image_size.width() + (2 * kOTRImageHorizMargin); |
| 186 tabstrip_x += otr_image_size.cx + (2 * kOTRImageHorizMargin); | |
| 187 gfx::Rect off_the_record_bounds; | 186 gfx::Rect off_the_record_bounds; |
| 188 if (IsZoomed()) { | 187 if (IsZoomed()) { |
| 189 off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(), | 188 off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(), |
| 190 kResizeBorder, | 189 kResizeBorder, |
| 191 otr_image_size.cx, | 190 otr_image_size.width(), |
| 192 tabstrip_->GetPreferredHeight() - | 191 tabstrip_->GetPreferredHeight() - |
| 193 kToolbarOverlapVertOffset + 1); | 192 kToolbarOverlapVertOffset + 1); |
| 194 } else { | 193 } else { |
| 195 off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(), | 194 off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(), |
| 196 kResizeBorder + kTitlebarHeight + | 195 kResizeBorder + kTitlebarHeight + |
| 197 tabstrip_->GetPreferredHeight() - | 196 tabstrip_->GetPreferredHeight() - |
| 198 otr_image_size.cy - | 197 otr_image_size.height() - |
| 199 kToolbarOverlapVertOffset + 1, | 198 kToolbarOverlapVertOffset + 1, |
| 200 otr_image_size.cx, | 199 otr_image_size.width(), |
| 201 otr_image_size.cy); | 200 otr_image_size.height()); |
| 202 } | 201 } |
| 203 | 202 |
| 204 if (frame_view_->UILayoutIsRightToLeft()) | 203 if (frame_view_->UILayoutIsRightToLeft()) |
| 205 off_the_record_bounds.set_x(frame_view_->MirroredLeftPointForRect( | 204 off_the_record_bounds.set_x(frame_view_->MirroredLeftPointForRect( |
| 206 off_the_record_bounds)); | 205 off_the_record_bounds)); |
| 207 off_the_record_image_->SetBounds(off_the_record_bounds.x(), | 206 off_the_record_image_->SetBounds(off_the_record_bounds.x(), |
| 208 off_the_record_bounds.y(), | 207 off_the_record_bounds.y(), |
| 209 off_the_record_bounds.width(), | 208 off_the_record_bounds.width(), |
| 210 off_the_record_bounds.height()); | 209 off_the_record_bounds.height()); |
| 211 | 210 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 226 // If we are maxmized, the tab strip will be in line with the window | 225 // If we are maxmized, the tab strip will be in line with the window |
| 227 // controls, so we need to make sure they don't overlap. | 226 // controls, so we need to make sure they don't overlap. |
| 228 int zoomed_offset = 0; | 227 int zoomed_offset = 0; |
| 229 if (distributor_logo_) { | 228 if (distributor_logo_) { |
| 230 if(IsZoomed()) { | 229 if(IsZoomed()) { |
| 231 zoomed_offset = std::max(min_offset, kWindowControlsMinOffset); | 230 zoomed_offset = std::max(min_offset, kWindowControlsMinOffset); |
| 232 | 231 |
| 233 // Hide the distributor logo if we're zoomed. | 232 // Hide the distributor logo if we're zoomed. |
| 234 distributor_logo_->SetVisible(false); | 233 distributor_logo_->SetVisible(false); |
| 235 } else { | 234 } else { |
| 236 CSize distributor_logo_size; | 235 gfx::Size distributor_logo_size = |
| 237 distributor_logo_->GetPreferredSize(&distributor_logo_size); | 236 distributor_logo_->GetPreferredSize(); |
| 238 | 237 |
| 239 int logo_x; | 238 int logo_x; |
| 240 // Because of Bug 1128173, our Window controls aren't actually flipped | 239 // Because of Bug 1128173, our Window controls aren't actually flipped |
| 241 // on Vista, yet all our math and layout presumes that they are. | 240 // on Vista, yet all our math and layout presumes that they are. |
| 242 if (frame_view_->UILayoutIsRightToLeft()) | 241 if (frame_view_->UILayoutIsRightToLeft()) |
| 243 logo_x = width - distributor_logo_size.cx; | 242 logo_x = width - distributor_logo_size.width(); |
| 244 else | 243 else |
| 245 logo_x = width - min_offset - distributor_logo_size.cx; | 244 logo_x = width - min_offset - distributor_logo_size.width(); |
| 246 | 245 |
| 247 distributor_logo_->SetVisible(true); | 246 distributor_logo_->SetVisible(true); |
| 248 distributor_logo_->SetBounds(logo_x, | 247 distributor_logo_->SetBounds(logo_x, |
| 249 kDistributorLogoVerticalOffset, | 248 kDistributorLogoVerticalOffset, |
| 250 distributor_logo_size.cx, | 249 distributor_logo_size.width(), |
| 251 distributor_logo_size.cy); | 250 distributor_logo_size.height()); |
| 252 } | 251 } |
| 253 } | 252 } |
| 254 | 253 |
| 255 gfx::Rect tabstrip_bounds(tabstrip_x, | 254 gfx::Rect tabstrip_bounds(tabstrip_x, |
| 256 kResizeBorder + (IsZoomed() ? | 255 kResizeBorder + (IsZoomed() ? |
| 257 kDwmBorderSize : kTitlebarHeight), | 256 kDwmBorderSize : kTitlebarHeight), |
| 258 width - tabstrip_x - kTabStripRightHorizOffset - | 257 width - tabstrip_x - kTabStripRightHorizOffset - |
| 259 zoomed_offset, | 258 zoomed_offset, |
| 260 tabstrip_->GetPreferredHeight()); | 259 tabstrip_->GetPreferredHeight()); |
| 261 if (frame_view_->UILayoutIsRightToLeft() && | 260 if (frame_view_->UILayoutIsRightToLeft() && |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 browser_w = width - g_bitmaps[CT_LEFT_SIDE]->width() - | 301 browser_w = width - g_bitmaps[CT_LEFT_SIDE]->width() - |
| 303 g_bitmaps[CT_RIGHT_SIDE]->width(); | 302 g_bitmaps[CT_RIGHT_SIDE]->width(); |
| 304 browser_h = height - browser_y - g_bitmaps[CT_BOTTOM_CENTER]->height(); | 303 browser_h = height - browser_y - g_bitmaps[CT_BOTTOM_CENTER]->height(); |
| 305 } else { | 304 } else { |
| 306 browser_x = 0; | 305 browser_x = 0; |
| 307 browser_y = toolbar_bottom; | 306 browser_y = toolbar_bottom; |
| 308 browser_w = width; | 307 browser_w = width; |
| 309 browser_h = height; | 308 browser_h = height; |
| 310 } | 309 } |
| 311 | 310 |
| 312 CSize preferred_size; | 311 gfx::Size preferred_size; |
| 313 if (shelf_view_) { | 312 if (shelf_view_) { |
| 314 shelf_view_->GetPreferredSize(&preferred_size); | 313 preferred_size = shelf_view_->GetPreferredSize(); |
| 315 shelf_view_->SetBounds(browser_x, | 314 shelf_view_->SetBounds(browser_x, |
| 316 height - g_bitmaps[CT_BOTTOM_CENTER]->height() - | 315 height - g_bitmaps[CT_BOTTOM_CENTER]->height() - |
| 317 preferred_size.cy, | 316 preferred_size.height(), |
| 318 browser_w, | 317 browser_w, |
| 319 preferred_size.cy); | 318 preferred_size.height()); |
| 320 browser_h -= preferred_size.cy; | 319 browser_h -= preferred_size.height(); |
| 321 } | 320 } |
| 322 | 321 |
| 323 CSize bookmark_bar_size; | 322 gfx::Size bookmark_bar_size; |
| 324 CSize info_bar_size; | 323 gfx::Size info_bar_size; |
| 325 | 324 |
| 326 if (bookmark_bar_view_.get()) | 325 if (bookmark_bar_view_.get()) |
| 327 bookmark_bar_view_->GetPreferredSize(&bookmark_bar_size); | 326 bookmark_bar_size = bookmark_bar_view_->GetPreferredSize(); |
| 328 | 327 |
| 329 if (info_bar_view_) | 328 if (info_bar_view_) |
| 330 info_bar_view_->GetPreferredSize(&info_bar_size); | 329 info_bar_size = info_bar_view_->GetPreferredSize(); |
| 331 | 330 |
| 332 // If we're showing a bookmarks bar in the new tab page style and we | 331 // If we're showing a bookmarks bar in the new tab page style and we |
| 333 // have an infobar showing, we need to flip them. | 332 // have an infobar showing, we need to flip them. |
| 334 if (info_bar_view_ && | 333 if (info_bar_view_ && |
| 335 bookmark_bar_view_.get() && | 334 bookmark_bar_view_.get() && |
| 336 bookmark_bar_view_->IsNewTabPage() && | 335 bookmark_bar_view_->IsNewTabPage() && |
| 337 !bookmark_bar_view_->IsAlwaysShown()) { | 336 !bookmark_bar_view_->IsAlwaysShown()) { |
| 338 info_bar_view_->SetBounds(browser_x, | 337 info_bar_view_->SetBounds(browser_x, |
| 339 browser_y, | 338 browser_y, |
| 340 browser_w, | 339 browser_w, |
| 341 info_bar_size.cy); | 340 info_bar_size.height()); |
| 342 browser_h -= info_bar_size.cy; | 341 browser_h -= info_bar_size.height(); |
| 343 | 342 |
| 344 browser_y += info_bar_size.cy - kSeparationLineHeight; | 343 browser_y += info_bar_size.height() - kSeparationLineHeight; |
| 345 | 344 |
| 346 bookmark_bar_view_->SetBounds(browser_x, | 345 bookmark_bar_view_->SetBounds(browser_x, |
| 347 browser_y, | 346 browser_y, |
| 348 browser_w, | 347 browser_w, |
| 349 bookmark_bar_size.cy); | 348 bookmark_bar_size.height()); |
| 350 browser_h -= bookmark_bar_size.cy - kSeparationLineHeight; | 349 browser_h -= bookmark_bar_size.height() - kSeparationLineHeight; |
| 351 browser_y += bookmark_bar_size.cy; | 350 browser_y += bookmark_bar_size.height(); |
| 352 } else { | 351 } else { |
| 353 if (bookmark_bar_view_.get()) { | 352 if (bookmark_bar_view_.get()) { |
| 354 // We want our bookmarks bar to be responsible for drawing its own | 353 // We want our bookmarks bar to be responsible for drawing its own |
| 355 // separator, so we let it overlap ours. | 354 // separator, so we let it overlap ours. |
| 356 browser_y -= kSeparationLineHeight; | 355 browser_y -= kSeparationLineHeight; |
| 357 | 356 |
| 358 bookmark_bar_view_->SetBounds(browser_x, | 357 bookmark_bar_view_->SetBounds(browser_x, |
| 359 browser_y, | 358 browser_y, |
| 360 browser_w, | 359 browser_w, |
| 361 bookmark_bar_size.cy); | 360 bookmark_bar_size.height()); |
| 362 browser_h -= bookmark_bar_size.cy - kSeparationLineHeight; | 361 browser_h -= bookmark_bar_size.height() - kSeparationLineHeight; |
| 363 browser_y += bookmark_bar_size.cy; | 362 browser_y += bookmark_bar_size.height(); |
| 364 } | 363 } |
| 365 | 364 |
| 366 if (info_bar_view_) { | 365 if (info_bar_view_) { |
| 367 info_bar_view_->SetBounds(browser_x, | 366 info_bar_view_->SetBounds(browser_x, |
| 368 browser_y, | 367 browser_y, |
| 369 browser_w, | 368 browser_w, |
| 370 info_bar_size.cy); | 369 info_bar_size.height()); |
| 371 browser_h -= info_bar_size.cy; | 370 browser_h -= info_bar_size.height(); |
| 372 browser_y += info_bar_size.cy; | 371 browser_y += info_bar_size.height(); |
| 373 } | 372 } |
| 374 } | 373 } |
| 375 | 374 |
| 376 // While our OnNCCalcSize handler does a good job of covering most of the | 375 // While our OnNCCalcSize handler does a good job of covering most of the |
| 377 // cases where we need to do this, it unfortunately doesn't cover the | 376 // cases where we need to do this, it unfortunately doesn't cover the |
| 378 // case where we're returning from maximized mode. | 377 // case where we're returning from maximized mode. |
| 379 ResetDWMFrame(); | 378 ResetDWMFrame(); |
| 380 | 379 |
| 381 tab_contents_container_->SetBounds(browser_x, | 380 tab_contents_container_->SetBounds(browser_x, |
| 382 browser_y, | 381 browser_y, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 void VistaFrame::FocusToolbar() { | 649 void VistaFrame::FocusToolbar() { |
| 651 } | 650 } |
| 652 | 651 |
| 653 bool VistaFrame::IsBookmarkBarVisible() const { | 652 bool VistaFrame::IsBookmarkBarVisible() const { |
| 654 if (!bookmark_bar_view_.get()) | 653 if (!bookmark_bar_view_.get()) |
| 655 return false; | 654 return false; |
| 656 | 655 |
| 657 if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating()) | 656 if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating()) |
| 658 return true; | 657 return true; |
| 659 | 658 |
| 660 CSize sz; | |
| 661 bookmark_bar_view_->GetPreferredSize(&sz); | |
| 662 // 1 is the minimum in GetPreferredSize for the bookmark bar. | 659 // 1 is the minimum in GetPreferredSize for the bookmark bar. |
| 663 return sz.cy > 1; | 660 return bookmark_bar_view_->GetPreferredSize().height() > 1; |
| 664 } | 661 } |
| 665 | 662 |
| 666 //////////////////////////////////////////////////////////////////////////////// | 663 //////////////////////////////////////////////////////////////////////////////// |
| 667 // | 664 // |
| 668 // Events | 665 // Events |
| 669 // | 666 // |
| 670 //////////////////////////////////////////////////////////////////////////////// | 667 //////////////////////////////////////////////////////////////////////////////// |
| 671 | 668 |
| 672 LRESULT VistaFrame::OnSettingChange(UINT u_msg, WPARAM w_param, LPARAM l_param, | 669 LRESULT VistaFrame::OnSettingChange(UINT u_msg, WPARAM w_param, LPARAM l_param, |
| 673 BOOL& handled) { | 670 BOOL& handled) { |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 tab_contents_container_->UpdateHWNDBounds(); | 1436 tab_contents_container_->UpdateHWNDBounds(); |
| 1440 } | 1437 } |
| 1441 } | 1438 } |
| 1442 | 1439 |
| 1443 bool VistaFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view, | 1440 bool VistaFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view, |
| 1444 ChromeViews::View** view) { | 1441 ChromeViews::View** view) { |
| 1445 DCHECK(view); | 1442 DCHECK(view); |
| 1446 if (*view == new_view) { | 1443 if (*view == new_view) { |
| 1447 // The views haven't changed, if the views pref changed schedule a layout. | 1444 // The views haven't changed, if the views pref changed schedule a layout. |
| 1448 if (new_view) { | 1445 if (new_view) { |
| 1449 CSize pref_size; | 1446 if (new_view->GetPreferredSize().height() != new_view->height()) |
| 1450 new_view->GetPreferredSize(&pref_size); | |
| 1451 if (pref_size.cy != new_view->height()) | |
| 1452 return true; | 1447 return true; |
| 1453 } | 1448 } |
| 1454 return false; | 1449 return false; |
| 1455 } | 1450 } |
| 1456 | 1451 |
| 1457 // The views differ, and one may be null (but not both). Remove the old | 1452 // The views differ, and one may be null (but not both). Remove the old |
| 1458 // view (if it non-null), and add the new one (if it is non-null). If the | 1453 // view (if it non-null), and add the new one (if it is non-null). If the |
| 1459 // height has changed, schedule a layout, otherwise reuse the existing | 1454 // height has changed, schedule a layout, otherwise reuse the existing |
| 1460 // bounds to avoid scheduling a layout. | 1455 // bounds to avoid scheduling a layout. |
| 1461 | 1456 |
| 1462 int current_height = 0; | 1457 int current_height = 0; |
| 1463 if (*view) { | 1458 if (*view) { |
| 1464 current_height = (*view)->height(); | 1459 current_height = (*view)->height(); |
| 1465 root_view_.RemoveChildView(*view); | 1460 root_view_.RemoveChildView(*view); |
| 1466 } | 1461 } |
| 1467 | 1462 |
| 1468 int new_height = 0; | 1463 int new_height = 0; |
| 1469 if (new_view) { | 1464 if (new_view) { |
| 1470 CSize preferred_size; | 1465 new_height = new_view->GetPreferredSize().height(); |
| 1471 new_view->GetPreferredSize(&preferred_size); | |
| 1472 new_height = preferred_size.cy; | |
| 1473 root_view_.AddChildView(new_view); | 1466 root_view_.AddChildView(new_view); |
| 1474 } | 1467 } |
| 1475 | 1468 |
| 1476 bool changed = false; | 1469 bool changed = false; |
| 1477 if (new_height != current_height) { | 1470 if (new_height != current_height) { |
| 1478 changed = true; | 1471 changed = true; |
| 1479 } else if (new_view && *view) { | 1472 } else if (new_view && *view) { |
| 1480 // The view changed, but the new view wants the same size, give it the | 1473 // The view changed, but the new view wants the same size, give it the |
| 1481 // bounds of the last view and have it repaint. | 1474 // bounds of the last view and have it repaint. |
| 1482 new_view->SetBounds((*view)->bounds().ToRECT()); | 1475 new_view->SetBounds((*view)->bounds().ToRECT()); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 &active_bookmark_bar_); | 1620 &active_bookmark_bar_); |
| 1628 | 1621 |
| 1629 // Only do a layout if the current contents is non-null. We assume that if the | 1622 // Only do a layout if the current contents is non-null. We assume that if the |
| 1630 // contents is NULL, we're either being destroyed, or ShowTabContents is going | 1623 // contents is NULL, we're either being destroyed, or ShowTabContents is going |
| 1631 // to be invoked with a non-null TabContents again so that there is no need | 1624 // to be invoked with a non-null TabContents again so that there is no need |
| 1632 // in doing a layout now (and would result in extra work/invalidation on | 1625 // in doing a layout now (and would result in extra work/invalidation on |
| 1633 // tab switches). | 1626 // tab switches). |
| 1634 if (changed && current_tab) | 1627 if (changed && current_tab) |
| 1635 Layout(); | 1628 Layout(); |
| 1636 } | 1629 } |
| OLD | NEW |