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/frame/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 new_avatar_button()->GetMirroredBounds().Contains(point))) | 214 new_avatar_button()->GetMirroredBounds().Contains(point))) |
215 return HTCLIENT; | 215 return HTCLIENT; |
216 | 216 |
217 int frame_component = frame()->client_view()->NonClientHitTest(point); | 217 int frame_component = frame()->client_view()->NonClientHitTest(point); |
218 | 218 |
219 // See if we're in the sysmenu region. We still have to check the tabstrip | 219 // See if we're in the sysmenu region. We still have to check the tabstrip |
220 // first so that clicks in a tab don't get treated as sysmenu clicks. | 220 // first so that clicks in a tab don't get treated as sysmenu clicks. |
221 gfx::Rect sysmenu_rect(IconBounds()); | 221 gfx::Rect sysmenu_rect(IconBounds()); |
222 // In maximized mode we extend the rect to the screen corner to take advantage | 222 // In maximized mode we extend the rect to the screen corner to take advantage |
223 // of Fitts' Law. | 223 // of Fitts' Law. |
224 if (frame()->IsMaximized()) | 224 if (layout_->IsTitleBarCondensed()) |
225 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); | 225 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); |
226 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect)); | 226 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect)); |
227 if (sysmenu_rect.Contains(point)) | 227 if (sysmenu_rect.Contains(point)) |
228 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; | 228 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; |
229 | 229 |
230 if (frame_component != HTNOWHERE) | 230 if (frame_component != HTNOWHERE) |
231 return frame_component; | 231 return frame_component; |
232 | 232 |
233 // Then see if the point is within any of the window controls. | 233 // Then see if the point is within any of the window controls. |
234 if (close_button_ && close_button_->visible() && | 234 if (close_button_ && close_button_->visible() && |
(...skipping 18 matching lines...) Expand all Loading... |
253 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 253 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
254 delegate->CanResize()); | 254 delegate->CanResize()); |
255 // Fall back to the caption if no other component matches. | 255 // Fall back to the caption if no other component matches. |
256 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 256 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
257 } | 257 } |
258 | 258 |
259 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, | 259 void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size, |
260 gfx::Path* window_mask) { | 260 gfx::Path* window_mask) { |
261 DCHECK(window_mask); | 261 DCHECK(window_mask); |
262 | 262 |
263 if (frame()->IsMaximized() || frame()->IsFullscreen()) | 263 if (layout_->IsTitleBarCondensed() || frame()->IsFullscreen()) |
264 return; | 264 return; |
265 | 265 |
266 views::GetDefaultWindowMask(size, window_mask); | 266 views::GetDefaultWindowMask(size, window_mask); |
267 } | 267 } |
268 | 268 |
269 void OpaqueBrowserFrameView::ResetWindowControls() { | 269 void OpaqueBrowserFrameView::ResetWindowControls() { |
270 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) | 270 if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) |
271 return; | 271 return; |
272 restore_button_->SetState(views::CustomButton::STATE_NORMAL); | 272 restore_button_->SetState(views::CustomButton::STATE_NORMAL); |
273 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); | 273 minimize_button_->SetState(views::CustomButton::STATE_NORMAL); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 default: | 404 default: |
405 NOTREACHED() << "Got a notification we didn't register for!"; | 405 NOTREACHED() << "Got a notification we didn't register for!"; |
406 break; | 406 break; |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 /////////////////////////////////////////////////////////////////////////////// | 410 /////////////////////////////////////////////////////////////////////////////// |
411 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: | 411 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: |
412 | 412 |
413 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { | 413 bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const { |
| 414 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 415 // If using the system title bar, we do not want to show a second title bar |
| 416 // inside the client area. |
| 417 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) |
| 418 return false; |
| 419 #endif |
| 420 |
414 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 421 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
415 return delegate && delegate->ShouldShowWindowIcon(); | 422 return delegate && delegate->ShouldShowWindowIcon(); |
416 } | 423 } |
417 | 424 |
418 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { | 425 bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const { |
| 426 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 427 // If using the system title bar, we do not want to show a second title bar |
| 428 // inside the client area. |
| 429 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) |
| 430 return false; |
| 431 #endif |
| 432 |
419 // |delegate| may be NULL if called from callback of InputMethodChanged while | 433 // |delegate| may be NULL if called from callback of InputMethodChanged while |
420 // a window is being destroyed. | 434 // a window is being destroyed. |
421 // See more discussion at http://crosbug.com/8958 | 435 // See more discussion at http://crosbug.com/8958 |
422 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 436 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
423 return delegate && delegate->ShouldShowWindowTitle(); | 437 return delegate && delegate->ShouldShowWindowTitle(); |
424 } | 438 } |
425 | 439 |
426 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { | 440 base::string16 OpaqueBrowserFrameView::GetWindowTitle() const { |
427 return frame()->widget_delegate()->GetWindowTitle(); | 441 return frame()->widget_delegate()->GetWindowTitle(); |
428 } | 442 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 return s; | 513 return s; |
500 } | 514 } |
501 | 515 |
502 /////////////////////////////////////////////////////////////////////////////// | 516 /////////////////////////////////////////////////////////////////////////////// |
503 // OpaqueBrowserFrameView, views::View overrides: | 517 // OpaqueBrowserFrameView, views::View overrides: |
504 | 518 |
505 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 519 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
506 if (frame()->IsFullscreen()) | 520 if (frame()->IsFullscreen()) |
507 return; // Nothing is visible, so don't bother to paint. | 521 return; // Nothing is visible, so don't bother to paint. |
508 | 522 |
509 if (frame()->IsMaximized()) | 523 if (layout_->IsTitleBarCondensed()) |
510 PaintMaximizedFrameBorder(canvas); | 524 PaintMaximizedFrameBorder(canvas); |
511 else | 525 else |
512 PaintRestoredFrameBorder(canvas); | 526 PaintRestoredFrameBorder(canvas); |
513 | 527 |
514 // The window icon and title are painted by their respective views. | 528 // The window icon and title are painted by their respective views. |
515 /* TODO(pkasting): If this window is active, we should also draw a drop | 529 /* TODO(pkasting): If this window is active, we should also draw a drop |
516 * shadow on the title. This is tricky, because we don't want to hardcode a | 530 * shadow on the title. This is tricky, because we don't want to hardcode a |
517 * shadow color (since we want to work with various themes), but we can't | 531 * shadow color (since we want to work with various themes), but we can't |
518 * alpha-blend either (since the Windows text APIs don't really do this). | 532 * alpha-blend either (since the Windows text APIs don't really do this). |
519 * So we'd need to sample the background color at the right location and | 533 * So we'd need to sample the background color at the right location and |
520 * synthesize a good shadow color. */ | 534 * synthesize a good shadow color. */ |
521 | 535 |
522 if (browser_view()->IsToolbarVisible()) | 536 if (browser_view()->IsToolbarVisible()) |
523 PaintToolbarBackground(canvas); | 537 PaintToolbarBackground(canvas); |
524 if (!frame()->IsMaximized()) | 538 if (!layout_->IsTitleBarCondensed()) |
525 PaintRestoredClientEdge(canvas); | 539 PaintRestoredClientEdge(canvas); |
526 } | 540 } |
527 | 541 |
528 /////////////////////////////////////////////////////////////////////////////// | 542 /////////////////////////////////////////////////////////////////////////////// |
529 // OpaqueBrowserFrameView, private: | 543 // OpaqueBrowserFrameView, private: |
530 | 544 |
531 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( | 545 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( |
532 int normal_image_id, | 546 int normal_image_id, |
533 int hot_image_id, | 547 int hot_image_id, |
534 int pushed_image_id, | 548 int pushed_image_id, |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 | 892 |
879 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 893 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
880 gfx::ImageSkia* frame_image = GetFrameImage(); | 894 gfx::ImageSkia* frame_image = GetFrameImage(); |
881 int top_area_height = frame_image->height(); | 895 int top_area_height = frame_image->height(); |
882 if (browser_view()->IsTabStripVisible()) { | 896 if (browser_view()->IsTabStripVisible()) { |
883 top_area_height = std::max(top_area_height, | 897 top_area_height = std::max(top_area_height, |
884 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 898 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
885 } | 899 } |
886 return top_area_height; | 900 return top_area_height; |
887 } | 901 } |
OLD | NEW |