OLD | NEW |
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 #include "chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h" | 5 #include "chrome/browser/ui/views/ash/browser_non_client_frame_view_ash.h" |
6 | 6 |
7 #include "ash/wm/frame_painter.h" | 7 #include "ash/wm/frame_painter.h" |
8 #include "ash/wm/workspace/frame_maximize_button.h" | 8 #include "ash/wm/workspace/frame_maximize_button.h" |
9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 AddObserver(this); | 184 AddObserver(this); |
185 } | 185 } |
186 | 186 |
187 /////////////////////////////////////////////////////////////////////////////// | 187 /////////////////////////////////////////////////////////////////////////////// |
188 // BrowserNonClientFrameView overrides: | 188 // BrowserNonClientFrameView overrides: |
189 | 189 |
190 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip( | 190 gfx::Rect BrowserNonClientFrameViewAsh::GetBoundsForTabStrip( |
191 views::View* tabstrip) const { | 191 views::View* tabstrip) const { |
192 if (!tabstrip) | 192 if (!tabstrip) |
193 return gfx::Rect(); | 193 return gfx::Rect(); |
194 int tabstrip_x = | 194 TabStripInsets insets(GetTabStripInsets(false)); |
195 avatar_button() ? | 195 return gfx::Rect(insets.left, insets.top, |
196 (avatar_button()->bounds().right() + kAvatarSideSpacing) : | 196 std::max(0, width() - insets.left - insets.right), |
197 kTabstripLeftSpacing; | |
198 int tabstrip_width = | |
199 size_button_->x() - kTabstripRightSpacing - tabstrip_x; | |
200 return gfx::Rect(tabstrip_x, | |
201 GetHorizontalTabStripVerticalOffset(false), | |
202 std::max(0, tabstrip_width), | |
203 tabstrip->GetPreferredSize().height()); | 197 tabstrip->GetPreferredSize().height()); |
204 } | 198 } |
205 | 199 |
206 int BrowserNonClientFrameViewAsh::GetHorizontalTabStripVerticalOffset( | 200 BrowserNonClientFrameView::TabStripInsets |
207 bool force_restored) const { | 201 BrowserNonClientFrameViewAsh::GetTabStripInsets(bool force_restored) const { |
208 return NonClientTopBorderHeight(force_restored); | 202 int left = avatar_button() ? kAvatarSideSpacing + |
| 203 browser_view()->GetOTRAvatarIcon().width() + kAvatarSideSpacing : |
| 204 kTabstripLeftSpacing; |
| 205 int right = frame_painter_->GetRightInset() + kTabstripRightSpacing; |
| 206 return TabStripInsets(NonClientTopBorderHeight(force_restored), left, right); |
209 } | 207 } |
210 | 208 |
211 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { | 209 void BrowserNonClientFrameViewAsh::UpdateThrobber(bool running) { |
212 if (window_icon_) | 210 if (window_icon_) |
213 window_icon_->Update(); | 211 window_icon_->Update(); |
214 } | 212 } |
215 | 213 |
216 /////////////////////////////////////////////////////////////////////////////// | 214 /////////////////////////////////////////////////////////////////////////////// |
217 // views::NonClientFrameView overrides: | 215 // views::NonClientFrameView overrides: |
218 | 216 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 PaintToolbarBackground(canvas, mode.mode); | 311 PaintToolbarBackground(canvas, mode.mode); |
314 // If we're fading in and have saved canvas, restore it now. | 312 // If we're fading in and have saved canvas, restore it now. |
315 if (fading_in) | 313 if (fading_in) |
316 canvas->Restore(); | 314 canvas->Restore(); |
317 } else { | 315 } else { |
318 PaintContentEdge(canvas); | 316 PaintContentEdge(canvas); |
319 } | 317 } |
320 } | 318 } |
321 | 319 |
322 void BrowserNonClientFrameViewAsh::Layout() { | 320 void BrowserNonClientFrameViewAsh::Layout() { |
323 bool maximized_layout = UseShortHeader(); | 321 frame_painter_->LayoutHeader(this, UseShortHeader()); |
324 frame_painter_->LayoutHeader(this, maximized_layout); | |
325 if (avatar_button()) | 322 if (avatar_button()) |
326 LayoutAvatar(); | 323 LayoutAvatar(); |
327 BrowserNonClientFrameView::Layout(); | 324 BrowserNonClientFrameView::Layout(); |
328 } | 325 } |
329 | 326 |
330 std::string BrowserNonClientFrameViewAsh::GetClassName() const { | 327 std::string BrowserNonClientFrameViewAsh::GetClassName() const { |
331 return kViewClassName; | 328 return kViewClassName; |
332 } | 329 } |
333 | 330 |
334 bool BrowserNonClientFrameViewAsh::HitTest(const gfx::Point& l) const { | 331 bool BrowserNonClientFrameViewAsh::HitTest(const gfx::Point& l) const { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 default: | 464 default: |
468 NOTREACHED(); | 465 NOTREACHED(); |
469 return false; | 466 return false; |
470 } | 467 } |
471 } | 468 } |
472 | 469 |
473 void BrowserNonClientFrameViewAsh::LayoutAvatar() { | 470 void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
474 DCHECK(avatar_button()); | 471 DCHECK(avatar_button()); |
475 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); | 472 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
476 | 473 |
477 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + | 474 int avatar_bottom = GetTabStripInsets(false).top + |
478 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; | 475 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; |
479 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 476 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
480 int avatar_y = frame()->IsMaximized() ? | 477 int avatar_y = frame()->IsMaximized() ? |
481 NonClientTopBorderHeight(false) + kContentShadowHeight: | 478 NonClientTopBorderHeight(false) + kContentShadowHeight: |
482 avatar_restored_y; | 479 avatar_restored_y; |
483 gfx::Rect avatar_bounds(kAvatarSideSpacing, | 480 gfx::Rect avatar_bounds(kAvatarSideSpacing, |
484 avatar_y, | 481 avatar_y, |
485 incognito_icon.width(), | 482 incognito_icon.width(), |
486 avatar_bottom - avatar_y); | 483 avatar_bottom - avatar_y); |
487 avatar_button()->SetBoundsRect(avatar_bounds); | 484 avatar_button()->SetBoundsRect(avatar_bounds); |
(...skipping 29 matching lines...) Expand all Loading... |
517 | 514 |
518 // Paint the main toolbar image. Since this image is also used to draw the | 515 // Paint the main toolbar image. Since this image is also used to draw the |
519 // tab background, we must use the tab strip offset to compute the image | 516 // tab background, we must use the tab strip offset to compute the image |
520 // source y position. If you have to debug this code use an image editor | 517 // source y position. If you have to debug this code use an image editor |
521 // to paint a diagonal line through the toolbar image and ensure it lines up | 518 // to paint a diagonal line through the toolbar image and ensure it lines up |
522 // across the tab and toolbar. | 519 // across the tab and toolbar. |
523 gfx::ImageSkia* theme_toolbar = | 520 gfx::ImageSkia* theme_toolbar = |
524 browser_view()->GetToolbarBackgroundImage(mode); | 521 browser_view()->GetToolbarBackgroundImage(mode); |
525 canvas->TileImageInt( | 522 canvas->TileImageInt( |
526 *theme_toolbar, | 523 *theme_toolbar, |
527 x, bottom_y - GetHorizontalTabStripVerticalOffset(false), | 524 x, bottom_y - GetTabStripInsets(false).top, |
528 x, bottom_y, | 525 x, bottom_y, |
529 w, theme_toolbar->height()); | 526 w, theme_toolbar->height()); |
530 | 527 |
531 // The content area line has a shadow that extends a couple of pixels above | 528 // The content area line has a shadow that extends a couple of pixels above |
532 // the toolbar bounds. | 529 // the toolbar bounds. |
533 const int kContentShadowHeight = 2; | 530 const int kContentShadowHeight = 2; |
534 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed( | 531 gfx::ImageSkia* toolbar_top = tp->GetImageSkiaNamed( |
535 chrome::search::IsInstantExtendedAPIEnabled( | 532 chrome::search::IsInstantExtendedAPIEnabled( |
536 browser_view()->browser()->profile()) ? | 533 browser_view()->browser()->profile()) ? |
537 IDR_TOOLBAR_SHADE_TOP_SEARCH : IDR_TOOLBAR_SHADE_TOP); | 534 IDR_TOOLBAR_SHADE_TOP_SEARCH : IDR_TOOLBAR_SHADE_TOP); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const { | 599 BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImage() const { |
603 ui::ThemeProvider* tp = GetThemeProvider(); | 600 ui::ThemeProvider* tp = GetThemeProvider(); |
604 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 601 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
605 browser_view()->IsBrowserTypeNormal() && | 602 browser_view()->IsBrowserTypeNormal() && |
606 !browser_view()->IsOffTheRecord()) { | 603 !browser_view()->IsOffTheRecord()) { |
607 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? | 604 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ? |
608 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); | 605 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE); |
609 } | 606 } |
610 return NULL; | 607 return NULL; |
611 } | 608 } |
OLD | NEW |