| 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 "ash/wm/frame_painter.h" | 5 #include "ash/wm/frame_painter.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // right relative to the header. Now that we have removed the left edge frame | 69 // right relative to the header. Now that we have removed the left edge frame |
| 70 // we need to copy the theme image for the window header from a few pixels | 70 // we need to copy the theme image for the window header from a few pixels |
| 71 // inset to preserve alignment with the NTP image, or else we'll break a bunch | 71 // inset to preserve alignment with the NTP image, or else we'll break a bunch |
| 72 // of existing themes. We do something similar on OS X for the same reason. | 72 // of existing themes. We do something similar on OS X for the same reason. |
| 73 const int kThemeFrameImageInsetX = 5; | 73 const int kThemeFrameImageInsetX = 5; |
| 74 // Duration of crossfade animation for activating and deactivating frame. | 74 // Duration of crossfade animation for activating and deactivating frame. |
| 75 const int kActivationCrossfadeDurationMs = 200; | 75 const int kActivationCrossfadeDurationMs = 200; |
| 76 // Alpha/opacity value for fully-opaque headers. | 76 // Alpha/opacity value for fully-opaque headers. |
| 77 const int kFullyOpaque = 255; | 77 const int kFullyOpaque = 255; |
| 78 | 78 |
| 79 // A flag to enable/disable solo window header. |
| 80 bool solo_window_header_enabled = true; |
| 81 |
| 79 // Tiles an image into an area, rounding the top corners. Samples |image| | 82 // Tiles an image into an area, rounding the top corners. Samples |image| |
| 80 // starting |image_inset_x| pixels from the left of the image. | 83 // starting |image_inset_x| pixels from the left of the image. |
| 81 void TileRoundRect(gfx::Canvas* canvas, | 84 void TileRoundRect(gfx::Canvas* canvas, |
| 82 const gfx::ImageSkia& image, | 85 const gfx::ImageSkia& image, |
| 83 const SkPaint& paint, | 86 const SkPaint& paint, |
| 84 const gfx::Rect& bounds, | 87 const gfx::Rect& bounds, |
| 85 int top_left_corner_radius, | 88 int top_left_corner_radius, |
| 86 int top_right_corner_radius, | 89 int top_right_corner_radius, |
| 87 int image_inset_x) { | 90 int image_inset_x) { |
| 88 SkRect rect = gfx::RectToSkRect(bounds); | 91 SkRect rect = gfx::RectToSkRect(bounds); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Watch for maximize/restore/fullscreen state changes. Observer removes | 272 // Watch for maximize/restore/fullscreen state changes. Observer removes |
| 270 // itself in OnWindowDestroying() below, or in the destructor if we go away | 273 // itself in OnWindowDestroying() below, or in the destructor if we go away |
| 271 // before the window. | 274 // before the window. |
| 272 window_->AddObserver(this); | 275 window_->AddObserver(this); |
| 273 | 276 |
| 274 // Solo-window header updates are handled by the workspace controller when | 277 // Solo-window header updates are handled by the workspace controller when |
| 275 // this window is added to the desktop. | 278 // this window is added to the desktop. |
| 276 } | 279 } |
| 277 | 280 |
| 278 // static | 281 // static |
| 282 void FramePainter::SetSoloWindowHeadersEnabled(bool enabled) { |
| 283 solo_window_header_enabled = enabled; |
| 284 } |
| 285 |
| 286 // static |
| 279 void FramePainter::UpdateSoloWindowHeader(RootWindow* root_window) { | 287 void FramePainter::UpdateSoloWindowHeader(RootWindow* root_window) { |
| 280 // Use a separate function here so callers outside of FramePainter don't need | 288 // Use a separate function here so callers outside of FramePainter don't need |
| 281 // to know about "ignorable_window". | 289 // to know about "ignorable_window". |
| 282 UpdateSoloWindowInRoot(root_window, NULL /* ignorable_window */); | 290 UpdateSoloWindowInRoot(root_window, NULL /* ignorable_window */); |
| 283 } | 291 } |
| 284 | 292 |
| 285 gfx::Rect FramePainter::GetBoundsForClientView( | 293 gfx::Rect FramePainter::GetBoundsForClientView( |
| 286 int top_height, | 294 int top_height, |
| 287 const gfx::Rect& window_bounds) const { | 295 const gfx::Rect& window_bounds) const { |
| 288 return gfx::Rect( | 296 return gfx::Rect( |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 if (UseSoloWindowHeader()) | 749 if (UseSoloWindowHeader()) |
| 742 return kSoloWindowOpacity; | 750 return kSoloWindowOpacity; |
| 743 | 751 |
| 744 // Otherwise, change transparency based on window activation status. | 752 // Otherwise, change transparency based on window activation status. |
| 745 if (header_mode == ACTIVE) | 753 if (header_mode == ACTIVE) |
| 746 return kActiveWindowOpacity; | 754 return kActiveWindowOpacity; |
| 747 return kInactiveWindowOpacity; | 755 return kInactiveWindowOpacity; |
| 748 } | 756 } |
| 749 | 757 |
| 750 bool FramePainter::UseSoloWindowHeader() const { | 758 bool FramePainter::UseSoloWindowHeader() const { |
| 759 if (!solo_window_header_enabled) |
| 760 return false; |
| 751 // Don't use transparent headers for panels, pop-ups, etc. | 761 // Don't use transparent headers for panels, pop-ups, etc. |
| 752 if (!IsSoloWindowHeaderCandidate(window_)) | 762 if (!IsSoloWindowHeaderCandidate(window_)) |
| 753 return false; | 763 return false; |
| 754 aura::RootWindow* root = window_->GetRootWindow(); | 764 aura::RootWindow* root = window_->GetRootWindow(); |
| 755 if (!root || root->GetProperty(internal::kIgnoreSoloWindowFramePainterPolicy)) | |
| 756 return false; | |
| 757 // Don't recompute every time, as it would require many window property | 765 // Don't recompute every time, as it would require many window property |
| 758 // lookups. | 766 // lookups. |
| 759 return internal::GetRootWindowSettings(root)->solo_window_header; | 767 return internal::GetRootWindowSettings(root)->solo_window_header; |
| 760 } | 768 } |
| 761 | 769 |
| 762 // static | 770 // static |
| 763 bool FramePainter::UseSoloWindowHeaderInRoot(RootWindow* root_window, | 771 bool FramePainter::UseSoloWindowHeaderInRoot(RootWindow* root_window, |
| 764 Window* ignore_window) { | 772 Window* ignore_window) { |
| 765 int visible_window_count = 0; | 773 int visible_window_count = 0; |
| 766 std::vector<Window*> windows = GetWindowsForSoloHeaderUpdate(root_window); | 774 std::vector<Window*> windows = GetWindowsForSoloHeaderUpdate(root_window); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 // icon. Don't use |window_icon_| for this computation as it may be NULL. | 838 // icon. Don't use |window_icon_| for this computation as it may be NULL. |
| 831 int title_y = GetCaptionButtonContainerCenterY() - title_font.GetHeight() / 2; | 839 int title_y = GetCaptionButtonContainerCenterY() - title_font.GetHeight() / 2; |
| 832 return gfx::Rect( | 840 return gfx::Rect( |
| 833 title_x, | 841 title_x, |
| 834 std::max(0, title_y), | 842 std::max(0, title_y), |
| 835 std::max(0, caption_button_container_->x() - kTitleLogoSpacing - title_x), | 843 std::max(0, caption_button_container_->x() - kTitleLogoSpacing - title_x), |
| 836 title_font.GetHeight()); | 844 title_font.GetHeight()); |
| 837 } | 845 } |
| 838 | 846 |
| 839 } // namespace ash | 847 } // namespace ash |
| OLD | NEW |