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/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
9 #include "app/gfx/path.h" | 9 #include "app/gfx/path.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 gfx::Size min_size(browser_view_->GetMinimumSize()); | 229 gfx::Size min_size(browser_view_->GetMinimumSize()); |
230 int border_thickness = NonClientBorderThickness(); | 230 int border_thickness = NonClientBorderThickness(); |
231 min_size.Enlarge(2 * border_thickness, | 231 min_size.Enlarge(2 * border_thickness, |
232 NonClientTopBorderHeight() + border_thickness); | 232 NonClientTopBorderHeight() + border_thickness); |
233 | 233 |
234 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); | 234 views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); |
235 int min_titlebar_width = (2 * FrameBorderThickness()) + kIconLeftSpacing + | 235 int min_titlebar_width = (2 * FrameBorderThickness()) + kIconLeftSpacing + |
236 (d->ShouldShowWindowIcon() ? | 236 (d->ShouldShowWindowIcon() ? |
237 (IconSize(NULL, NULL, NULL) + kTitleLogoSpacing) : 0) + | 237 (IconSize(NULL, NULL, NULL) + kTitleLogoSpacing) : 0) + |
238 ((distributor_logo_ && browser_view_->ShouldShowDistributorLogo()) ? | 238 ((distributor_logo_ && browser_view_->ShouldShowDistributorLogo()) ? |
239 (distributor_logo_->width() + kLogoCaptionSpacing) : 0) + | 239 (distributor_logo_->width() + kLogoCaptionSpacing) : 0); |
240 minimize_button_->GetMinimumSize().width() + | 240 |
241 restore_button_->GetMinimumSize().width() + | 241 #if !defined(OS_CHROMEOS) |
242 close_button_->GetMinimumSize().width(); | 242 min_titlebar_width += |
| 243 minimize_button_->GetMinimumSize().width() + |
| 244 restore_button_->GetMinimumSize().width() + |
| 245 close_button_->GetMinimumSize().width(); |
| 246 #endif |
243 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); | 247 min_size.set_width(std::max(min_size.width(), min_titlebar_width)); |
244 | 248 |
245 return min_size; | 249 return min_size; |
246 } | 250 } |
247 | 251 |
248 /////////////////////////////////////////////////////////////////////////////// | 252 /////////////////////////////////////////////////////////////////////////////// |
249 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: | 253 // OpaqueBrowserFrameView, views::NonClientFrameView implementation: |
250 | 254 |
251 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 255 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
252 return client_view_bounds_; | 256 return client_view_bounds_; |
(...skipping 25 matching lines...) Expand all Loading... |
278 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 282 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
279 if (!bounds().Contains(point)) | 283 if (!bounds().Contains(point)) |
280 return HTNOWHERE; | 284 return HTNOWHERE; |
281 | 285 |
282 int frame_component = | 286 int frame_component = |
283 frame_->GetWindow()->GetClientView()->NonClientHitTest(point); | 287 frame_->GetWindow()->GetClientView()->NonClientHitTest(point); |
284 if (frame_component != HTNOWHERE) | 288 if (frame_component != HTNOWHERE) |
285 return frame_component; | 289 return frame_component; |
286 | 290 |
287 // Then see if the point is within any of the window controls. | 291 // Then see if the point is within any of the window controls. |
288 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 292 if (close_button_->IsVisible() && |
| 293 close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
289 return HTCLOSE; | 294 return HTCLOSE; |
290 if (restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 295 if (restore_button_->IsVisible() && |
| 296 restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
291 point)) | 297 point)) |
292 return HTMAXBUTTON; | 298 return HTMAXBUTTON; |
293 if (maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 299 if (maximize_button_->IsVisible() && |
| 300 maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
294 point)) | 301 point)) |
295 return HTMAXBUTTON; | 302 return HTMAXBUTTON; |
296 if (minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 303 if (minimize_button_->IsVisible() && |
| 304 minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( |
297 point)) | 305 point)) |
298 return HTMINBUTTON; | 306 return HTMINBUTTON; |
299 if (window_icon_ && | 307 if (window_icon_ && |
300 window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 308 window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
301 return HTSYSMENU; | 309 return HTSYSMENU; |
302 | 310 |
303 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), | 311 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), |
304 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 312 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
305 frame_->GetWindow()->GetDelegate()->CanResize()); | 313 frame_->GetWindow()->GetDelegate()->CanResize()); |
306 // Fall back to the caption if no other component matches. | 314 // Fall back to the caption if no other component matches. |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 int title_thickness = std::max(title_font_->height(), | 531 int title_thickness = std::max(title_font_->height(), |
524 min_titlebar_height - title_top_spacing - title_bottom_spacing); | 532 min_titlebar_height - title_top_spacing - title_bottom_spacing); |
525 if (title_top_spacing_ptr) | 533 if (title_top_spacing_ptr) |
526 *title_top_spacing_ptr = title_top_spacing; | 534 *title_top_spacing_ptr = title_top_spacing; |
527 if (title_thickness_ptr) | 535 if (title_thickness_ptr) |
528 *title_thickness_ptr = title_thickness; | 536 *title_thickness_ptr = title_thickness; |
529 return title_top_spacing + title_thickness + title_bottom_spacing + | 537 return title_top_spacing + title_thickness + title_bottom_spacing + |
530 UnavailablePixelsAtBottomOfNonClientHeight(); | 538 UnavailablePixelsAtBottomOfNonClientHeight(); |
531 } | 539 } |
532 | 540 |
| 541 int OpaqueBrowserFrameView::RightEdge() const { |
| 542 return width() - FrameBorderThickness(); |
| 543 } |
| 544 |
533 int OpaqueBrowserFrameView::IconSize(int* title_top_spacing_ptr, | 545 int OpaqueBrowserFrameView::IconSize(int* title_top_spacing_ptr, |
534 int* title_thickness_ptr, | 546 int* title_thickness_ptr, |
535 int* available_height_ptr) const { | 547 int* available_height_ptr) const { |
536 // The usable height of the titlebar area is the total height minus the top | 548 // The usable height of the titlebar area is the total height minus the top |
537 // resize border and any edge area we draw at its bottom. | 549 // resize border and any edge area we draw at its bottom. |
538 int frame_thickness = FrameBorderThickness(); | 550 int frame_thickness = FrameBorderThickness(); |
539 int top_height = TitleCoordinates(title_top_spacing_ptr, title_thickness_ptr); | 551 int top_height = TitleCoordinates(title_top_spacing_ptr, title_thickness_ptr); |
540 int available_height = top_height - frame_thickness - | 552 int available_height = top_height - frame_thickness - |
541 UnavailablePixelsAtBottomOfNonClientHeight(); | 553 UnavailablePixelsAtBottomOfNonClientHeight(); |
542 if (available_height_ptr) | 554 if (available_height_ptr) |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); | 913 tp->GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); |
902 canvas->DrawBitmapInt(*bottom_left, | 914 canvas->DrawBitmapInt(*bottom_left, |
903 client_area_bounds.x() - bottom_left->width(), client_area_bottom); | 915 client_area_bounds.x() - bottom_left->width(), client_area_bottom); |
904 | 916 |
905 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); | 917 SkBitmap* left = tp->GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); |
906 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), | 918 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), |
907 client_area_top, left->width(), client_area_height); | 919 client_area_top, left->width(), client_area_height); |
908 } | 920 } |
909 | 921 |
910 void OpaqueBrowserFrameView::LayoutWindowControls() { | 922 void OpaqueBrowserFrameView::LayoutWindowControls() { |
| 923 bool is_maximized = frame_->GetWindow()->IsMaximized(); |
| 924 #if defined(OS_CHROMEOS) |
| 925 minimize_button_->SetVisible(!is_maximized); |
| 926 restore_button_->SetVisible(!is_maximized); |
| 927 maximize_button_->SetVisible(!is_maximized); |
| 928 close_button_->SetVisible(!is_maximized); |
| 929 if (is_maximized) { |
| 930 // Set the bounds of the minimize button so that we don't have to change |
| 931 // other places that rely on the bounds. |
| 932 minimize_button_->SetBounds(RightEdge(), 0, 0, 0); |
| 933 return; |
| 934 } |
| 935 #endif |
911 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, | 936 close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
912 views::ImageButton::ALIGN_BOTTOM); | 937 views::ImageButton::ALIGN_BOTTOM); |
913 // Maximized buttons start at window top so that even if their images aren't | 938 // Maximized buttons start at window top so that even if their images aren't |
914 // drawn flush with the screen edge, they still obey Fitts' Law. | 939 // drawn flush with the screen edge, they still obey Fitts' Law. |
915 bool is_maximized = frame_->GetWindow()->IsMaximized(); | |
916 int frame_thickness = FrameBorderThickness(); | 940 int frame_thickness = FrameBorderThickness(); |
917 int caption_y = is_maximized ? frame_thickness : kFrameShadowThickness; | 941 int caption_y = is_maximized ? frame_thickness : kFrameShadowThickness; |
918 // There should always be the same number of non-shadow pixels visible to the | 942 // There should always be the same number of non-shadow pixels visible to the |
919 // side of the caption buttons. In maximized mode we extend the rightmost | 943 // side of the caption buttons. In maximized mode we extend the rightmost |
920 // button to the screen corner to obey Fitts' Law. | 944 // button to the screen corner to obey Fitts' Law. |
921 int right_extra_width = is_maximized ? | 945 int right_extra_width = is_maximized ? |
922 (kFrameBorderThickness - kFrameShadowThickness) : 0; | 946 (kFrameBorderThickness - kFrameShadowThickness) : 0; |
923 gfx::Size close_button_size = close_button_->GetPreferredSize(); | 947 gfx::Size close_button_size = close_button_->GetPreferredSize(); |
924 close_button_->SetBounds(width() - close_button_size.width() - | 948 close_button_->SetBounds(RightEdge() - close_button_size.width() - |
925 right_extra_width - frame_thickness, caption_y, | 949 right_extra_width, caption_y, |
926 close_button_size.width() + right_extra_width, | 950 close_button_size.width() + right_extra_width, |
927 close_button_size.height()); | 951 close_button_size.height()); |
928 | 952 |
929 // When the window is restored, we show a maximized button; otherwise, we show | 953 // When the window is restored, we show a maximized button; otherwise, we show |
930 // a restore button. | 954 // a restore button. |
931 bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized(); | 955 bool is_restored = !is_maximized && !frame_->GetWindow()->IsMinimized(); |
932 views::ImageButton* invisible_button = is_restored ? | 956 views::ImageButton* invisible_button = is_restored ? |
933 restore_button_ : maximize_button_; | 957 restore_button_ : maximize_button_; |
934 invisible_button->SetVisible(false); | 958 invisible_button->SetVisible(false); |
935 | 959 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 static bool initialized = false; | 1075 static bool initialized = false; |
1052 if (!initialized) { | 1076 if (!initialized) { |
1053 #if defined(OS_WIN) | 1077 #if defined(OS_WIN) |
1054 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); | 1078 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); |
1055 #else | 1079 #else |
1056 title_font_ = new gfx::Font(); | 1080 title_font_ = new gfx::Font(); |
1057 #endif | 1081 #endif |
1058 initialized = true; | 1082 initialized = true; |
1059 } | 1083 } |
1060 } | 1084 } |
OLD | NEW |