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

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

Issue 7344: Convert GetPreferredSize from:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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) 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/views/frame/browser_view2.h" 8 #include "chrome/browser/views/frame/browser_view2.h"
9 #include "chrome/browser/views/tabs/tab_strip.h" 9 #include "chrome/browser/views/tabs/tab_strip.h"
10 #include "chrome/common/gfx/chrome_font.h" 10 #include "chrome/common/gfx/chrome_font.h"
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 } 619 }
620 620
621 void OpaqueNonClientView::Layout() { 621 void OpaqueNonClientView::Layout() {
622 LayoutWindowControls(); 622 LayoutWindowControls();
623 LayoutOTRAvatar(); 623 LayoutOTRAvatar();
624 LayoutDistributorLogo(); 624 LayoutDistributorLogo();
625 LayoutTitleBar(); 625 LayoutTitleBar();
626 LayoutClientView(); 626 LayoutClientView();
627 } 627 }
628 628
629 void OpaqueNonClientView::GetPreferredSize(CSize* out) { 629 gfx::Size OpaqueNonClientView::GetPreferredSize() {
630 DCHECK(out); 630 gfx::Size prefsize = frame_->client_view()->GetPreferredSize();
631 frame_->client_view()->GetPreferredSize(out); 631 prefsize.Enlarge(2 * kWindowHorizontalBorderSize,
632 out->cx += 2 * kWindowHorizontalBorderSize; 632 CalculateNonClientTopHeight() +
633 out->cy += CalculateNonClientTopHeight() + kWindowVerticalBorderBottomSize; 633 kWindowVerticalBorderBottomSize);
634 return prefsize;
634 } 635 }
635 636
636 ChromeViews::View* OpaqueNonClientView::GetViewForPoint( 637 ChromeViews::View* OpaqueNonClientView::GetViewForPoint(
637 const gfx::Point& point, 638 const gfx::Point& point,
638 bool can_create_floating) { 639 bool can_create_floating) {
639 // We override this function because the ClientView can overlap the non - 640 // We override this function because the ClientView can overlap the non -
640 // client view, making it impossible to click on the window controls. We need 641 // client view, making it impossible to click on the window controls. We need
641 // to ensure the window controls are checked _first_. 642 // to ensure the window controls are checked _first_.
642 ChromeViews::View* views[] = { close_button_, restore_button_, 643 ChromeViews::View* views[] = { close_button_, restore_button_,
643 maximize_button_, minimize_button_ }; 644 maximize_button_, minimize_button_ };
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 canvas->TileImageInt(app_top_center_, client_area_bounds.x(), 869 canvas->TileImageInt(app_top_center_, client_area_bounds.x(),
869 client_area_bounds.y() - app_top_center_.height(), 870 client_area_bounds.y() - app_top_center_.height(),
870 client_area_bounds.width(), app_top_center_.height()); 871 client_area_bounds.width(), app_top_center_.height());
871 canvas->DrawBitmapInt(app_top_right_, client_area_bounds.right(), 872 canvas->DrawBitmapInt(app_top_right_, client_area_bounds.right(),
872 client_area_bounds.y() - app_top_right_.height() + 873 client_area_bounds.y() - app_top_right_.height() +
873 fudge); 874 fudge);
874 } 875 }
875 } 876 }
876 877
877 void OpaqueNonClientView::LayoutWindowControls() { 878 void OpaqueNonClientView::LayoutWindowControls() {
878 CSize ps; 879 gfx::Size ps;
879 if (frame_->IsMaximized() || frame_->IsMinimized()) { 880 if (frame_->IsMaximized() || frame_->IsMinimized()) {
880 maximize_button_->SetVisible(false); 881 maximize_button_->SetVisible(false);
881 restore_button_->SetVisible(true); 882 restore_button_->SetVisible(true);
882 } 883 }
883 884
884 if (frame_->IsMaximized()) { 885 if (frame_->IsMaximized()) {
885 close_button_->GetPreferredSize(&ps); 886 ps = close_button_->GetPreferredSize();
886 close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 887 close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
887 ChromeViews::Button::ALIGN_TOP); 888 ChromeViews::Button::ALIGN_TOP);
888 close_button_->SetBounds( 889 close_button_->SetBounds(
889 width() - ps.cx - kWindowControlsRightZoomedOffset, 890 width() - ps.width() - kWindowControlsRightZoomedOffset,
890 0, ps.cx + kWindowControlsRightZoomedOffset, 891 0, ps.width() + kWindowControlsRightZoomedOffset,
891 ps.cy + kWindowControlsTopZoomedOffset); 892 ps.height() + kWindowControlsTopZoomedOffset);
892 893
893 restore_button_->GetPreferredSize(&ps); 894 ps = restore_button_->GetPreferredSize();
894 restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 895 restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
895 ChromeViews::Button::ALIGN_TOP); 896 ChromeViews::Button::ALIGN_TOP);
896 restore_button_->SetBounds(close_button_->x() - ps.cx, 0, ps.cx, 897 restore_button_->SetBounds(close_button_->x() - ps.width(), 0, ps.width(),
897 ps.cy + kWindowControlsTopZoomedOffset); 898 ps.height() + kWindowControlsTopZoomedOffset);
898 899
899 minimize_button_->GetPreferredSize(&ps); 900 ps = minimize_button_->GetPreferredSize();
900 minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 901 minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
901 ChromeViews::Button::ALIGN_TOP); 902 ChromeViews::Button::ALIGN_TOP);
902 minimize_button_->SetBounds(restore_button_->x() - ps.cx, 0, ps.cx, 903 minimize_button_->SetBounds(restore_button_->x() - ps.width(), 0,
903 ps.cy + kWindowControlsTopZoomedOffset); 904 ps.width(),
905 ps.height() + kWindowControlsTopZoomedOffset);
904 } else if (frame_->IsMinimized()) { 906 } else if (frame_->IsMinimized()) {
905 close_button_->GetPreferredSize(&ps); 907 ps = close_button_->GetPreferredSize();
906 close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 908 close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
907 ChromeViews::Button::ALIGN_BOTTOM); 909 ChromeViews::Button::ALIGN_BOTTOM);
908 close_button_->SetBounds( 910 close_button_->SetBounds(
909 width() - ps.cx - kWindowControlsRightZoomedOffset, 911 width() - ps.width() - kWindowControlsRightZoomedOffset,
910 0, ps.cx + kWindowControlsRightZoomedOffset, 912 0, ps.width() + kWindowControlsRightZoomedOffset,
911 ps.cy + kWindowControlsTopZoomedOffset); 913 ps.height() + kWindowControlsTopZoomedOffset);
912 914
913 restore_button_->GetPreferredSize(&ps); 915 ps = restore_button_->GetPreferredSize();
914 restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 916 restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
915 ChromeViews::Button::ALIGN_BOTTOM); 917 ChromeViews::Button::ALIGN_BOTTOM);
916 restore_button_->SetBounds(close_button_->x() - ps.cx, 0, ps.cx, 918 restore_button_->SetBounds(close_button_->x() - ps.width(), 0, ps.width(),
917 ps.cy + kWindowControlsTopZoomedOffset); 919 ps.height() + kWindowControlsTopZoomedOffset);
918 920
919 minimize_button_->GetPreferredSize(&ps); 921 ps = minimize_button_->GetPreferredSize();
920 minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 922 minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
921 ChromeViews::Button::ALIGN_BOTTOM); 923 ChromeViews::Button::ALIGN_BOTTOM);
922 minimize_button_->SetBounds(restore_button_->x() - ps.cx, 0, ps.cx, 924 minimize_button_->SetBounds(restore_button_->x() - ps.width(), 0,
923 ps.cy + kWindowControlsTopZoomedOffset); 925 ps.width(),
926 ps.height() + kWindowControlsTopZoomedOffset);
924 } else { 927 } else {
925 close_button_->GetPreferredSize(&ps); 928 ps = close_button_->GetPreferredSize();
926 close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 929 close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
927 ChromeViews::Button::ALIGN_TOP); 930 ChromeViews::Button::ALIGN_TOP);
928 close_button_->SetBounds(width() - kWindowControlsRightOffset - ps.cx, 931 close_button_->SetBounds(width() - kWindowControlsRightOffset - ps.width(),
929 kWindowControlsTopOffset, ps.cx, ps.cy); 932 kWindowControlsTopOffset, ps.width(),
933 ps.height());
930 934
931 restore_button_->SetVisible(false); 935 restore_button_->SetVisible(false);
932 936
933 maximize_button_->SetVisible(true); 937 maximize_button_->SetVisible(true);
934 maximize_button_->GetPreferredSize(&ps); 938 ps = maximize_button_->GetPreferredSize();
935 maximize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 939 maximize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
936 ChromeViews::Button::ALIGN_TOP); 940 ChromeViews::Button::ALIGN_TOP);
937 maximize_button_->SetBounds(close_button_->x() - ps.cx, 941 maximize_button_->SetBounds(close_button_->x() - ps.width(),
938 kWindowControlsTopOffset, ps.cx, ps.cy); 942 kWindowControlsTopOffset, ps.width(),
943 ps.height());
939 944
940 minimize_button_->GetPreferredSize(&ps); 945 ps = minimize_button_->GetPreferredSize();
941 minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, 946 minimize_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT,
942 ChromeViews::Button::ALIGN_TOP); 947 ChromeViews::Button::ALIGN_TOP);
943 minimize_button_->SetBounds(maximize_button_->x() - ps.cx, 948 minimize_button_->SetBounds(maximize_button_->x() - ps.width(),
944 kWindowControlsTopOffset, ps.cx, ps.cy); 949 kWindowControlsTopOffset, ps.width(),
950 ps.height());
945 } 951 }
946 } 952 }
947 953
948 void OpaqueNonClientView::LayoutOTRAvatar() { 954 void OpaqueNonClientView::LayoutOTRAvatar() {
949 int otr_x = 0; 955 int otr_x = 0;
950 int top_spacing = 956 int top_spacing =
951 frame_->IsMaximized() ? kNoTitleOTRZoomedTopSpacing : kNoTitleTopSpacing; 957 frame_->IsMaximized() ? kNoTitleOTRZoomedTopSpacing : kNoTitleTopSpacing;
952 int otr_y = browser_view_->GetTabStripHeight() + top_spacing; 958 int otr_y = browser_view_->GetTabStripHeight() + top_spacing;
953 int otr_width = 0; 959 int otr_width = 0;
954 int otr_height = 0; 960 int otr_height = 0;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 } 1037 }
1032 1038
1033 // static 1039 // static
1034 void OpaqueNonClientView::InitAppWindowResources() { 1040 void OpaqueNonClientView::InitAppWindowResources() {
1035 static bool initialized = false; 1041 static bool initialized = false;
1036 if (!initialized) { 1042 if (!initialized) {
1037 title_font_ = win_util::GetWindowTitleFont(); 1043 title_font_ = win_util::GetWindowTitleFont();
1038 initialized = true; 1044 initialized = true;
1039 } 1045 }
1040 } 1046 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698