| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser_non_client_frame_view_mac.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h" |
| 6 | 6 |
| 7 #include "chrome/browser/themes/theme_properties.h" | 7 #include "chrome/browser/themes/theme_properties.h" |
| 8 #include "chrome/browser/ui/views/frame/browser_frame.h" | 8 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 9 #include "chrome/browser/ui/views/frame/browser_view.h" | 9 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_view_layout.h" | 10 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 11 #include "chrome/browser/ui/views/layout_constants.h" |
| 11 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 12 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
| 13 #include "ui/base/theme_provider.h" | 14 #include "ui/base/theme_provider.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // How far to inset the tabstrip from the sides of the window. | 19 // How far to inset the tabstrip from the sides of the window. |
| 19 const int kTabstripTopInset = 8; | 20 const int kTabstripTopInset = 8; |
| 20 const int kTabstripLeftInset = 70; // Make room for window control buttons. | 21 const int kTabstripLeftInset = 70; // Make room for window control buttons. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 140 } |
| 140 | 141 |
| 141 void BrowserNonClientFrameViewMac::PaintToolbarBackground(gfx::Canvas* canvas) { | 142 void BrowserNonClientFrameViewMac::PaintToolbarBackground(gfx::Canvas* canvas) { |
| 142 gfx::Rect bounds(browser_view()->GetToolbarBounds()); | 143 gfx::Rect bounds(browser_view()->GetToolbarBounds()); |
| 143 if (bounds.IsEmpty()) | 144 if (bounds.IsEmpty()) |
| 144 return; | 145 return; |
| 145 | 146 |
| 146 ui::ThemeProvider* tp = GetThemeProvider(); | 147 ui::ThemeProvider* tp = GetThemeProvider(); |
| 147 gfx::ImageSkia* border = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); | 148 gfx::ImageSkia* border = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); |
| 148 const int top_inset = | 149 const int top_inset = |
| 149 BrowserViewLayout::kToolbarTabStripVerticalOverlap - border->height(); | 150 GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) - border->height(); |
| 150 | 151 |
| 151 const int x = bounds.x(); | 152 const int x = bounds.x(); |
| 152 const int y = bounds.y() + top_inset; | 153 const int y = bounds.y() + top_inset; |
| 153 const int w = bounds.width(); | 154 const int w = bounds.width(); |
| 154 const int h = bounds.height() - top_inset; | 155 const int h = bounds.height() - top_inset; |
| 155 | 156 |
| 156 // The tabstrip border image height is 2*scale pixels, but only the bottom 2 | 157 // The tabstrip border image height is 2*scale pixels, but only the bottom 2 |
| 157 // pixels contain the actual border (the rest is transparent). We can't draw | 158 // pixels contain the actual border (the rest is transparent). We can't draw |
| 158 // the toolbar image below this transparent upper area when scale > 1. | 159 // the toolbar image below this transparent upper area when scale > 1. |
| 159 const int fill_y = y + canvas->image_scale() - 1; | 160 const int fill_y = y + canvas->image_scale() - 1; |
| 160 const int fill_height = bounds.bottom() - fill_y; | 161 const int fill_height = bounds.bottom() - fill_y; |
| 161 | 162 |
| 162 // Draw the toolbar fill. | 163 // Draw the toolbar fill. |
| 163 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR), | 164 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR), |
| 164 x + GetThemeBackgroundXInset(), fill_y - GetTopInset(), | 165 x + GetThemeBackgroundXInset(), fill_y - GetTopInset(), |
| 165 x, fill_y, w, fill_height); | 166 x, fill_y, w, fill_height); |
| 166 | 167 |
| 167 // Draw the tabstrip/toolbar separator. | 168 // Draw the tabstrip/toolbar separator. |
| 168 canvas->TileImageInt(*border, 0, 0, x, y, w, border->height()); | 169 canvas->TileImageInt(*border, 0, 0, x, y, w, border->height()); |
| 169 | 170 |
| 170 // Draw the content/toolbar separator. | 171 // Draw the content/toolbar separator. |
| 171 canvas->FillRect( | 172 canvas->FillRect( |
| 172 gfx::Rect(x, y + h - kClientEdgeThickness, w, kClientEdgeThickness), | 173 gfx::Rect(x, y + h - kClientEdgeThickness, w, kClientEdgeThickness), |
| 173 ThemeProperties::GetDefaultColor( | 174 ThemeProperties::GetDefaultColor( |
| 174 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 175 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 175 } | 176 } |
| OLD | NEW |