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

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

Issue 17362: Pixel perfection on OTR icon. The tabstrip is still positioned/sized wrong r... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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
« no previous file with comments | « chrome/browser/views/frame/opaque_non_client_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/opaque_non_client_view.h" 5 #include "chrome/browser/views/frame/opaque_non_client_view.h"
6 6
7 #include "chrome/app/theme/theme_resources.h" 7 #include "chrome/app/theme/theme_resources.h"
8 #include "chrome/browser/tab_contents.h" 8 #include "chrome/browser/tab_contents.h"
9 #include "chrome/browser/views/frame/browser_view.h" 9 #include "chrome/browser/views/frame/browser_view.h"
10 #include "chrome/browser/views/tabs/tab_strip.h" 10 #include "chrome/browser/views/tabs/tab_strip.h"
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 287
288 // The distance between the top of the window and the top of the window 288 // The distance between the top of the window and the top of the window
289 // controls when the window is restored. 289 // controls when the window is restored.
290 static const int kWindowControlsTopOffset = 1; 290 static const int kWindowControlsTopOffset = 1;
291 // The distance between the right edge of the window and the right edge of the 291 // The distance between the right edge of the window and the right edge of the
292 // right-most window control when the window is restored. 292 // right-most window control when the window is restored.
293 static const int kWindowControlsRightOffset = 4; 293 static const int kWindowControlsRightOffset = 4;
294 // The distance between the top of the window and the top of the window 294 // The distance between the top of the window and the top of the window
295 // controls' images when the window is maximized. We extend the clickable area 295 // controls' images when the window is maximized. We extend the clickable area
296 // all the way to the top of the window to obey Fitts' Law. 296 // all the way to the top of the window to obey Fitts' Law.
297 static const int kWindowControlsTopZoomedExtraHeight = 5; 297 static const int kWindowControlsZoomedTopExtraHeight = 5;
298 // The distance between the right edge of the window and the right edge of the 298 // The distance between the right edge of the window and the right edge of the
299 // right-most window control when the window is maximized. 299 // right-most window control when the window is maximized.
300 static const int kWindowControlsRightZoomedOffset = 7; 300 static const int kWindowControlsZoomedRightOffset = 7;
301 // The distance between the left edge of the window and the left edge of the 301 // The distance between the left edge of the window and the left edge of the
302 // window icon when a title-bar is showing and the window is restored. 302 // window icon when a title-bar is showing and the window is restored.
303 static const int kWindowIconLeftOffset = 5; 303 static const int kWindowIconLeftOffset = 5;
304 // The distance between the left edge of the window and the left edge of the 304 // The distance between the left edge of the window and the left edge of the
305 // window icon when a title-bar is showing and the window is maximized. 305 // window icon when a title-bar is showing and the window is maximized.
306 static const int kWindowIconLeftZoomedOffset = 6; 306 static const int kWindowIconZoomedLeftOffset = 6;
307 // The distance between the top edge of the window and the top edge of the 307 // The distance between the top edge of the window and the top edge of the
308 // window icon when a title-bar is showing and the window is restored. 308 // window icon when a title-bar is showing and the window is restored.
309 static const int kWindowIconTopOffset = 6; 309 static const int kWindowIconTopOffset = 6;
310 // The distance between the top edge of the window and the top edge of the 310 // The distance between the top edge of the window and the top edge of the
311 // window icon when a title-bar is showing and the window is maximized. 311 // window icon when a title-bar is showing and the window is maximized.
312 static const int kWindowIconTopZoomedOffset = 8; 312 static const int kWindowIconZoomedTopOffset = 8;
313 // The distance between the window icon and the window title when a title-bar 313 // The distance between the window icon and the window title when a title-bar
314 // is showing. 314 // is showing.
315 static const int kWindowIconTitleSpacing = 4; 315 static const int kWindowIconTitleSpacing = 4;
316 // The distance between the top of the window and the title text when a 316 // The distance between the top of the window and the title text when a
317 // title-bar is showing. 317 // title-bar is showing and the window is restored.
318 static const int kTitleTopOffset = 6; 318 static const int kTitleTopOffset = 6;
319 // The distance between the top of the window and the title text when a 319 // The distance between the top of the window and the title text when a
320 // title-bar is showing and the window is maximized. 320 // title-bar is showing and the window is maximized.
321 static const int kTitleTopZoomedOffset = 8; 321 static const int kTitleZoomedTopOffset = 8;
322 // The distance between the right edge of the title text bounding box and the 322 // The distance between the right edge of the title text bounding box and the
323 // left edge of the distributor logo. 323 // left edge of the distributor logo.
324 static const int kTitleLogoSpacing = 5; 324 static const int kTitleLogoSpacing = 5;
325 // The distance between the bottom of the title text and the TabStrip when a 325 // The distance between the bottom of the title text and the TabStrip when a
326 // title-bar is showing. 326 // title-bar is showing.
327 static const int kTitleBottomSpacing = 6; 327 static const int kTitleBottomSpacing = 6;
328 // The distance between the top edge of the window and the TabStrip when there 328 // The distance between the top edge of the window and the TabStrip when there
329 // is no title-bar showing, and the window is restored. 329 // is no title-bar showing, and the window is restored.
330 static const int kNoTitleTopSpacing = 15; 330 static const int kNoTitleTopSpacing = 15;
331 // The distance between the top edge of the window and the TabStrip when there 331 // The distance between the top edge of the window and the TabStrip when there
(...skipping 21 matching lines...) Expand all
353 static const int kWindowBottomZoomedSpacing = 4; 353 static const int kWindowBottomZoomedSpacing = 4;
354 // The width and height of the window icon that appears at the top left of 354 // The width and height of the window icon that appears at the top left of
355 // pop-up and app windows. 355 // pop-up and app windows.
356 static const int kWindowIconSize = 16; 356 static const int kWindowIconSize = 16;
357 // The horizontal distance of the right edge of the distributor logo from the 357 // The horizontal distance of the right edge of the distributor logo from the
358 // left edge of the left-most window control. 358 // left edge of the left-most window control.
359 static const int kDistributorLogoHorizontalOffset = 7; 359 static const int kDistributorLogoHorizontalOffset = 7;
360 // The vertical distance of the top of the distributor logo from the top edge 360 // The vertical distance of the top of the distributor logo from the top edge
361 // of the window. 361 // of the window.
362 static const int kDistributorLogoVerticalOffset = 3; 362 static const int kDistributorLogoVerticalOffset = 3;
363 // The distance between the left edge of the window and the OTR avatar icon. 363 // The distance between the left edge of the window and the OTR avatar icon when
364 static const int kOTRAvatarIconMargin = 9; 364 // the window is restored.
365 // The distance between the top edge of the window and the OTR avatar icon when 365 static const int kOTRLeftOffset = 7;
366 // The distance between the left edge of the window and the OTR avatar icon when
366 // the window is maximized. 367 // the window is maximized.
367 static const int kNoTitleOTRZoomedTopSpacing = 3; 368 static const int kOTRZoomedLeftOffset = 6;
369 // The distance between the top edge of the client area and the OTR avatar icon
370 // when the window is maximized.
371 static const int kOTRZoomedTopSpacing = 2;
372 // The distance between the bottom of the OTR avatar icon and the bottom of the
373 // tabstrip.
374 static const int kOTRBottomSpacing = 2;
375 // The number of pixels to crop off the top of the OTR image when the window is
376 // maximized.
377 static const int kOTRZoomedTopCrop = 4;
368 // Horizontal distance between the right edge of the new tab icon and the left 378 // Horizontal distance between the right edge of the new tab icon and the left
369 // edge of the window minimize icon when the window is maximized. 379 // edge of the window minimize icon when the window is maximized.
370 static const int kNewTabIconWindowControlsSpacing = 10; 380 static const int kNewTabIconWindowControlsSpacing = 10;
371 381
372 /////////////////////////////////////////////////////////////////////////////// 382 ///////////////////////////////////////////////////////////////////////////////
373 // OpaqueNonClientView, public: 383 // OpaqueNonClientView, public:
374 384
375 OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame, 385 OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame,
376 BrowserView* browser_view) 386 BrowserView* browser_view)
377 : NonClientView(), 387 : NonClientView(),
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 SkIntToScalar(contents_bounds.y()), 639 SkIntToScalar(contents_bounds.y()),
630 SkIntToScalar(contents_bounds.right()), 640 SkIntToScalar(contents_bounds.right()),
631 SkIntToScalar(contents_bounds.bottom())); 641 SkIntToScalar(contents_bounds.bottom()));
632 canvas->clipRect(clip, SkRegion::kDifference_Op); 642 canvas->clipRect(clip, SkRegion::kDifference_Op);
633 643
634 // Render the remaining portions of the non-client area. 644 // Render the remaining portions of the non-client area.
635 if (frame_->IsMaximized()) 645 if (frame_->IsMaximized())
636 PaintMaximizedFrameBorder(canvas); 646 PaintMaximizedFrameBorder(canvas);
637 else 647 else
638 PaintFrameBorder(canvas); 648 PaintFrameBorder(canvas);
639 PaintOTRAvatar(canvas);
640 PaintDistributorLogo(canvas); 649 PaintDistributorLogo(canvas);
641 PaintTitleBar(canvas); 650 PaintTitleBar(canvas);
642 PaintToolbarBackground(canvas); 651 PaintToolbarBackground(canvas);
652 PaintOTRAvatar(canvas);
643 if (frame_->IsMaximized()) 653 if (frame_->IsMaximized())
644 PaintMaximizedClientEdge(canvas); 654 PaintMaximizedClientEdge(canvas);
645 else 655 else
646 PaintClientEdge(canvas); 656 PaintClientEdge(canvas);
647 } 657 }
648 658
649 void OpaqueNonClientView::Layout() { 659 void OpaqueNonClientView::Layout() {
650 LayoutWindowControls(); 660 LayoutWindowControls();
651 LayoutOTRAvatar();
652 LayoutDistributorLogo(); 661 LayoutDistributorLogo();
653 LayoutTitleBar(); 662 LayoutTitleBar();
663 LayoutOTRAvatar();
654 LayoutClientView(); 664 LayoutClientView();
655 } 665 }
656 666
657 gfx::Size OpaqueNonClientView::GetPreferredSize() { 667 gfx::Size OpaqueNonClientView::GetPreferredSize() {
658 int horizontal_border = frame_->IsMaximized() ? 668 int horizontal_border = frame_->IsMaximized() ?
659 kWindowHorizontalBorderZoomedSize : kWindowHorizontalBorderSize; 669 kWindowHorizontalBorderZoomedSize : kWindowHorizontalBorderSize;
660 gfx::Size prefsize(frame_->client_view()->GetPreferredSize()); 670 gfx::Size prefsize(frame_->client_view()->GetPreferredSize());
661 prefsize.Enlarge(2 * horizontal_border, 671 prefsize.Enlarge(2 * horizontal_border,
662 CalculateNonClientTopHeight() + kWindowVerticalBorderBottomSize); 672 CalculateNonClientTopHeight() + kWindowVerticalBorderBottomSize);
663 return prefsize; 673 return prefsize;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 canvas->TileImageInt(*top_edge, 0, kNoTitleZoomedTopSpacing, width(), 785 canvas->TileImageInt(*top_edge, 0, kNoTitleZoomedTopSpacing, width(),
776 top_edge->height()); 786 top_edge->height());
777 787
778 SkBitmap* bottom_edge = 788 SkBitmap* bottom_edge =
779 resources()->GetPartBitmap(FRAME_MAXIMIZED_BOTTOM_EDGE); 789 resources()->GetPartBitmap(FRAME_MAXIMIZED_BOTTOM_EDGE);
780 canvas->TileImageInt(*bottom_edge, 0, 790 canvas->TileImageInt(*bottom_edge, 0,
781 height() - bottom_edge->height() - kWindowBottomZoomedSpacing, width(), 791 height() - bottom_edge->height() - kWindowBottomZoomedSpacing, width(),
782 bottom_edge->height()); 792 bottom_edge->height());
783 } 793 }
784 794
785 void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
786 if (browser_view_->ShouldShowOffTheRecordAvatar()) {
787 canvas->DrawBitmapInt(browser_view_->GetOTRAvatarIcon(),
788 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y());
789 }
790 }
791
792 void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) { 795 void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) {
793 // The distributor logo is only painted when the frame is not maximized and 796 // The distributor logo is only painted when the frame is not maximized and
794 // when we actually have a logo. 797 // when we actually have a logo.
795 if (!frame_->IsMaximized() && !distributor_logo_.empty()) { 798 if (!frame_->IsMaximized() && !distributor_logo_.empty()) {
796 int logo_x = MirroredLeftPointForRect(logo_bounds_); 799 int logo_x = MirroredLeftPointForRect(logo_bounds_);
797 canvas->DrawBitmapInt(distributor_logo_, logo_x, logo_bounds_.y()); 800 canvas->DrawBitmapInt(distributor_logo_, logo_x, logo_bounds_.y());
798 } 801 }
799 } 802 }
800 803
801 void OpaqueNonClientView::PaintTitleBar(ChromeCanvas* canvas) { 804 void OpaqueNonClientView::PaintTitleBar(ChromeCanvas* canvas) {
(...skipping 24 matching lines...) Expand all
826 SkBitmap* toolbar_center = 829 SkBitmap* toolbar_center =
827 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP); 830 resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP);
828 canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(), 831 canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(), toolbar_bounds.y(),
829 toolbar_bounds.width(), toolbar_center->height()); 832 toolbar_bounds.width(), toolbar_center->height());
830 833
831 canvas->DrawBitmapInt( 834 canvas->DrawBitmapInt(
832 *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT), 835 *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT),
833 toolbar_bounds.right(), toolbar_bounds.y()); 836 toolbar_bounds.right(), toolbar_bounds.y());
834 } 837 }
835 838
839 void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
840 if (browser_view_->ShouldShowOffTheRecordAvatar()) {
841 int src_y = frame_->IsMaximized() ? kOTRZoomedTopCrop : 0;
842 canvas->DrawBitmapInt(browser_view_->GetOTRAvatarIcon(),
843 0, src_y, otr_avatar_bounds_.width(), otr_avatar_bounds_.height(),
844 MirroredLeftPointForRect(otr_avatar_bounds_), otr_avatar_bounds_.y(),
845 otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false);
846 }
847 }
848
836 void OpaqueNonClientView::PaintClientEdge(ChromeCanvas* canvas) { 849 void OpaqueNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
837 // The toolbar draws a client edge along its own bottom edge when it's 850 // The toolbar draws a client edge along its own bottom edge when it's
838 // visible. However, it only draws this for the width of the actual client 851 // visible. However, it only draws this for the width of the actual client
839 // area, leaving a gap at the left and right edges: 852 // area, leaving a gap at the left and right edges:
840 // 853 //
841 // | Toolbar | <-- part of toolbar 854 // | Toolbar | <-- part of toolbar
842 // ----- (toolbar client edge) ----- <-- gap 855 // ----- (toolbar client edge) ----- <-- gap
843 // | Client area | <-- right client edge 856 // | Client area | <-- right client edge
844 // 857 //
845 // To address this, we extend the left and right client edges up one pixel to 858 // To address this, we extend the left and right client edges up one pixel to
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 923
911 void OpaqueNonClientView::LayoutWindowControls() { 924 void OpaqueNonClientView::LayoutWindowControls() {
912 // TODO(pkasting): This function is almost identical to 925 // TODO(pkasting): This function is almost identical to
913 // DefaultNonClientView::LayoutWindowControls(), they should be combined. 926 // DefaultNonClientView::LayoutWindowControls(), they should be combined.
914 close_button_->SetImageAlignment(views::Button::ALIGN_LEFT, 927 close_button_->SetImageAlignment(views::Button::ALIGN_LEFT,
915 views::Button::ALIGN_BOTTOM); 928 views::Button::ALIGN_BOTTOM);
916 // Maximized buttons start at window top so that even if their images aren't 929 // Maximized buttons start at window top so that even if their images aren't
917 // drawn flush with the screen edge, they still obey Fitts' Law. 930 // drawn flush with the screen edge, they still obey Fitts' Law.
918 bool is_maximized = frame_->IsMaximized(); 931 bool is_maximized = frame_->IsMaximized();
919 int top_offset = is_maximized ? 0 : kWindowControlsTopOffset; 932 int top_offset = is_maximized ? 0 : kWindowControlsTopOffset;
920 int top_extra_height = is_maximized ? kWindowControlsTopZoomedExtraHeight : 0; 933 int top_extra_height = is_maximized ? kWindowControlsZoomedTopExtraHeight : 0;
921 gfx::Size close_button_size = close_button_->GetPreferredSize(); 934 gfx::Size close_button_size = close_button_->GetPreferredSize();
922 close_button_->SetBounds( 935 close_button_->SetBounds(
923 (width() - close_button_size.width() - (is_maximized ? 936 (width() - close_button_size.width() - (is_maximized ?
924 kWindowControlsRightZoomedOffset : kWindowControlsRightOffset)), 937 kWindowControlsZoomedRightOffset : kWindowControlsRightOffset)),
925 top_offset, 938 top_offset,
926 (is_maximized ? 939 (is_maximized ?
927 // We extend the maximized close button to the screen corner to obey 940 // We extend the maximized close button to the screen corner to obey
928 // Fitts' Law. 941 // Fitts' Law.
929 (close_button_size.width() + kWindowControlsRightZoomedOffset) : 942 (close_button_size.width() + kWindowControlsZoomedRightOffset) :
930 close_button_size.width()), 943 close_button_size.width()),
931 (close_button_size.height() + top_extra_height)); 944 (close_button_size.height() + top_extra_height));
932 945
933 // When the window is restored, we show a maximized button; otherwise, we show 946 // When the window is restored, we show a maximized button; otherwise, we show
934 // a restore button. 947 // a restore button.
935 bool is_restored = !is_maximized && !frame_->IsMinimized(); 948 bool is_restored = !is_maximized && !frame_->IsMinimized();
936 views::Button* invisible_button = is_restored ? 949 views::Button* invisible_button = is_restored ?
937 restore_button_ : maximize_button_; 950 restore_button_ : maximize_button_;
938 invisible_button->SetVisible(false); 951 invisible_button->SetVisible(false);
939 952
(...skipping 12 matching lines...) Expand all
952 minimize_button_->SetImageAlignment(views::Button::ALIGN_LEFT, 965 minimize_button_->SetImageAlignment(views::Button::ALIGN_LEFT,
953 views::Button::ALIGN_BOTTOM); 966 views::Button::ALIGN_BOTTOM);
954 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); 967 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize();
955 minimize_button_->SetBounds( 968 minimize_button_->SetBounds(
956 visible_button->x() - minimize_button_size.width(), 969 visible_button->x() - minimize_button_size.width(),
957 top_offset, 970 top_offset,
958 minimize_button_size.width(), 971 minimize_button_size.width(),
959 minimize_button_size.height() + top_extra_height); 972 minimize_button_size.height() + top_extra_height);
960 } 973 }
961 974
962 void OpaqueNonClientView::LayoutOTRAvatar() {
963 if (browser_view_->ShouldShowOffTheRecordAvatar()) {
964 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
965 int otr_y = browser_view_->GetTabStripHeight() - otr_avatar_icon.height() +
966 2 + (frame_->IsMaximized() ?
967 kNoTitleOTRZoomedTopSpacing : kNoTitleTopSpacing);
968 otr_avatar_bounds_.SetRect(kOTRAvatarIconMargin, otr_y,
969 otr_avatar_icon.width(), otr_avatar_icon.height());
970 } else {
971 otr_avatar_bounds_.SetRect(0, 0, 0, 0);
972 }
973 }
974
975 void OpaqueNonClientView::LayoutDistributorLogo() { 975 void OpaqueNonClientView::LayoutDistributorLogo() {
976 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_.width() - 976 logo_bounds_.SetRect(minimize_button_->x() - distributor_logo_.width() -
977 kDistributorLogoHorizontalOffset, kDistributorLogoVerticalOffset, 977 kDistributorLogoHorizontalOffset, kDistributorLogoVerticalOffset,
978 distributor_logo_.width(), distributor_logo_.height()); 978 distributor_logo_.width(), distributor_logo_.height());
979 } 979 }
980 980
981 void OpaqueNonClientView::LayoutTitleBar() { 981 void OpaqueNonClientView::LayoutTitleBar() {
982 // Size the window icon, even if it is hidden so we can size the title based 982 // Size the window icon, even if it is hidden so we can size the title based
983 // on its position. 983 // on its position.
984 int left_offset = frame_->IsMaximized() ? 984 int left_offset = frame_->IsMaximized() ?
985 kWindowIconLeftZoomedOffset : kWindowIconLeftOffset; 985 kWindowIconZoomedLeftOffset : kWindowIconLeftOffset;
986 int top_offset = frame_->IsMaximized() ? 986 int top_offset = frame_->IsMaximized() ?
987 kWindowIconTopZoomedOffset : kWindowIconTopOffset; 987 kWindowIconZoomedTopOffset : kWindowIconTopOffset;
988 views::WindowDelegate* d = frame_->window_delegate(); 988 views::WindowDelegate* d = frame_->window_delegate();
989 int icon_size = d->ShouldShowWindowIcon() ? kWindowIconSize : 0; 989 int icon_size = d->ShouldShowWindowIcon() ? kWindowIconSize : 0;
990 icon_bounds_.SetRect(left_offset, top_offset, icon_size, icon_size); 990 icon_bounds_.SetRect(left_offset, top_offset, icon_size, icon_size);
991 if (window_icon_) 991 if (window_icon_)
992 window_icon_->SetBounds(icon_bounds_); 992 window_icon_->SetBounds(icon_bounds_);
993 993
994 // Size the title, if visible. 994 // Size the title, if visible.
995 if (d->ShouldShowWindowTitle()) { 995 if (d->ShouldShowWindowTitle()) {
996 int title_right = logo_bounds_.x() - kTitleLogoSpacing; 996 int title_right = logo_bounds_.x() - kTitleLogoSpacing;
997 int icon_right = icon_bounds_.right(); 997 int icon_right = icon_bounds_.right();
998 int title_left = 998 int title_left =
999 icon_right + (d->ShouldShowWindowIcon() ? kWindowIconTitleSpacing : 0); 999 icon_right + (d->ShouldShowWindowIcon() ? kWindowIconTitleSpacing : 0);
1000 int top_offset = frame_->IsMaximized() ? 1000 int top_offset = frame_->IsMaximized() ?
1001 kTitleTopZoomedOffset : kTitleTopOffset; 1001 kTitleZoomedTopOffset : kTitleTopOffset;
1002 title_bounds_.SetRect(title_left, top_offset, 1002 title_bounds_.SetRect(title_left, top_offset,
1003 std::max(0, title_right - icon_right), title_font_.height()); 1003 std::max(0, title_right - icon_right), title_font_.height());
1004 } 1004 }
1005 } 1005 }
1006 1006
1007 void OpaqueNonClientView::LayoutOTRAvatar() {
1008 if (!browser_view_->ShouldShowOffTheRecordAvatar()) {
1009 otr_avatar_bounds_.SetRect(0, 0, 0, 0);
1010 return;
1011 }
1012
1013 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon();
1014 int non_client_height = CalculateNonClientTopHeight();
1015 int otr_bottom = non_client_height + browser_view_->GetTabStripHeight() -
1016 kOTRBottomSpacing;
1017 int otr_x, otr_y, otr_height;
1018 if (frame_->IsMaximized()) {
1019 otr_x = kOTRZoomedLeftOffset;
1020 otr_y = non_client_height + kOTRZoomedTopSpacing;
1021 otr_height = otr_bottom - otr_y;
1022 } else {
1023 otr_x = kOTRLeftOffset;
1024 otr_height = otr_avatar_icon.height();
1025 otr_y = otr_bottom - otr_height;
1026 }
1027 otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(), otr_height);
1028 }
1029
1007 void OpaqueNonClientView::LayoutClientView() { 1030 void OpaqueNonClientView::LayoutClientView() {
1008 frame_->client_view()->SetBounds(CalculateClientAreaBounds(width(), 1031 frame_->client_view()->SetBounds(CalculateClientAreaBounds(width(),
1009 height())); 1032 height()));
1010 } 1033 }
1011 1034
1012 // static 1035 // static
1013 void OpaqueNonClientView::InitClass() { 1036 void OpaqueNonClientView::InitClass() {
1014 static bool initialized = false; 1037 static bool initialized = false;
1015 if (!initialized) { 1038 if (!initialized) {
1016 active_resources_ = new ActiveWindowResources; 1039 active_resources_ = new ActiveWindowResources;
(...skipping 13 matching lines...) Expand all
1030 } 1053 }
1031 1054
1032 // static 1055 // static
1033 void OpaqueNonClientView::InitAppWindowResources() { 1056 void OpaqueNonClientView::InitAppWindowResources() {
1034 static bool initialized = false; 1057 static bool initialized = false;
1035 if (!initialized) { 1058 if (!initialized) {
1036 title_font_ = win_util::GetWindowTitleFont(); 1059 title_font_ = win_util::GetWindowTitleFont();
1037 initialized = true; 1060 initialized = true;
1038 } 1061 }
1039 } 1062 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/opaque_non_client_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698