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/browser_non_client_frame_view_aura.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h" |
6 | 6 |
7 #include "ash/wm/frame_painter.h" | 7 #include "ash/wm/frame_painter.h" |
8 #include "ash/wm/workspace/frame_maximize_button.h" | 8 #include "ash/wm/workspace/frame_maximize_button.h" |
9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
10 #include "chrome/browser/ui/views/avatar_menu_button.h" | 10 #include "chrome/browser/ui/views/avatar_menu_button.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 174 |
175 void BrowserNonClientFrameViewAura::OnPaint(gfx::Canvas* canvas) { | 175 void BrowserNonClientFrameViewAura::OnPaint(gfx::Canvas* canvas) { |
176 if (frame()->IsFullscreen()) | 176 if (frame()->IsFullscreen()) |
177 return; // Nothing visible, don't paint. | 177 return; // Nothing visible, don't paint. |
178 // The primary header image changes based on window activation state and | 178 // The primary header image changes based on window activation state and |
179 // theme, so we look it up for each paint. | 179 // theme, so we look it up for each paint. |
180 frame_painter_->PaintHeader(this, | 180 frame_painter_->PaintHeader(this, |
181 canvas, | 181 canvas, |
182 GetThemeFrameBitmap(), | 182 GetThemeFrameBitmap(), |
183 GetThemeFrameOverlayBitmap()); | 183 GetThemeFrameOverlayBitmap()); |
184 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); | 184 if (browser_view()->ShouldShowWindowTitle()) |
| 185 frame_painter_->PaintTitleBar(this, canvas, BrowserFrame::GetTitleFont()); |
185 if (browser_view()->IsToolbarVisible()) | 186 if (browser_view()->IsToolbarVisible()) |
186 PaintToolbarBackground(canvas); | 187 PaintToolbarBackground(canvas); |
| 188 else |
| 189 PaintContentEdge(canvas); |
187 } | 190 } |
188 | 191 |
189 void BrowserNonClientFrameViewAura::Layout() { | 192 void BrowserNonClientFrameViewAura::Layout() { |
190 // Maximized windows and app/popup windows use shorter buttons. | 193 // Maximized windows and app/popup windows use shorter buttons. |
191 bool maximized_layout = | 194 bool maximized_layout = |
192 frame()->IsMaximized() || !browser_view()->IsBrowserTypeNormal(); | 195 frame()->IsMaximized() || !browser_view()->IsBrowserTypeNormal(); |
193 frame_painter_->LayoutHeader(this, maximized_layout); | 196 frame_painter_->LayoutHeader(this, maximized_layout); |
194 if (avatar_button()) | 197 if (avatar_button()) |
195 LayoutAvatar(); | 198 LayoutAvatar(); |
196 BrowserNonClientFrameView::Layout(); | 199 BrowserNonClientFrameView::Layout(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 /////////////////////////////////////////////////////////////////////////////// | 270 /////////////////////////////////////////////////////////////////////////////// |
268 // BrowserNonClientFrameViewAura, private: | 271 // BrowserNonClientFrameViewAura, private: |
269 | 272 |
270 | 273 |
271 int BrowserNonClientFrameViewAura::NonClientTopBorderHeight( | 274 int BrowserNonClientFrameViewAura::NonClientTopBorderHeight( |
272 bool force_restored) const { | 275 bool force_restored) const { |
273 if (force_restored) | 276 if (force_restored) |
274 return kTabstripTopSpacingRestored; | 277 return kTabstripTopSpacingRestored; |
275 if (frame()->IsFullscreen()) | 278 if (frame()->IsFullscreen()) |
276 return 0; | 279 return 0; |
277 if (frame()->IsMaximized()) | 280 // Windows with tab strips need a smaller non-client area. |
278 return kTabstripTopSpacingMaximized; | 281 if (browser_view()->IsTabStripVisible()) { |
279 if (frame()->widget_delegate() && | 282 if (frame()->IsMaximized()) |
280 frame()->widget_delegate()->ShouldShowWindowTitle()) { | 283 return kTabstripTopSpacingMaximized; |
281 // For popups ensure we have enough space to see the full window buttons. | 284 return kTabstripTopSpacingRestored; |
282 return close_button_->bounds().bottom(); | |
283 } | 285 } |
284 return kTabstripTopSpacingRestored; | 286 // For windows without a tab strip (popups, etc.) ensure we have enough space |
| 287 // to see the window caption buttons and the content separator line. |
| 288 return close_button_->bounds().bottom() + kClientEdgeThickness; |
285 } | 289 } |
286 | 290 |
287 void BrowserNonClientFrameViewAura::LayoutAvatar() { | 291 void BrowserNonClientFrameViewAura::LayoutAvatar() { |
288 DCHECK(avatar_button()); | 292 DCHECK(avatar_button()); |
289 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); | 293 SkBitmap incognito_icon = browser_view()->GetOTRAvatarIcon(); |
290 | 294 |
291 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + | 295 int avatar_bottom = GetHorizontalTabStripVerticalOffset(false) + |
292 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; | 296 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; |
293 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 297 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
294 int avatar_y = frame()->IsMaximized() ? | 298 int avatar_y = frame()->IsMaximized() ? |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 w, split_point + kContentShadowHeight + 1); | 355 w, split_point + kContentShadowHeight + 1); |
352 | 356 |
353 // Draw the content/toolbar separator. | 357 // Draw the content/toolbar separator. |
354 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, | 358 canvas->FillRect(gfx::Rect(x + kClientEdgeThickness, |
355 toolbar_bounds.bottom() - kClientEdgeThickness, | 359 toolbar_bounds.bottom() - kClientEdgeThickness, |
356 w - (2 * kClientEdgeThickness), | 360 w - (2 * kClientEdgeThickness), |
357 kClientEdgeThickness), | 361 kClientEdgeThickness), |
358 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); | 362 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
359 } | 363 } |
360 | 364 |
| 365 void BrowserNonClientFrameViewAura::PaintContentEdge(gfx::Canvas* canvas) { |
| 366 canvas->FillRect(gfx::Rect(0, close_button_->bounds().bottom(), |
| 367 width(), kClientEdgeThickness), |
| 368 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); |
| 369 } |
| 370 |
361 const SkBitmap* BrowserNonClientFrameViewAura::GetThemeFrameBitmap() const { | 371 const SkBitmap* BrowserNonClientFrameViewAura::GetThemeFrameBitmap() const { |
362 bool is_incognito = browser_view()->IsOffTheRecord(); | 372 bool is_incognito = browser_view()->IsOffTheRecord(); |
363 int resource_id; | 373 int resource_id; |
364 if (browser_view()->IsBrowserTypeNormal()) { | 374 if (browser_view()->IsBrowserTypeNormal()) { |
365 if (ShouldPaintAsActive()) { | 375 if (ShouldPaintAsActive()) { |
366 // Use the standard resource ids to allow users to theme the frames. | 376 // Use the standard resource ids to allow users to theme the frames. |
367 // TODO(jamescook): If this becomes the only frame we use on Aura, define | 377 // TODO(jamescook): If this becomes the only frame we use on Aura, define |
368 // the resources to use the standard ids like IDR_THEME_FRAME, etc. | 378 // the resources to use the standard ids like IDR_THEME_FRAME, etc. |
369 if (is_incognito) { | 379 if (is_incognito) { |
370 return GetCustomBitmap(IDR_THEME_FRAME_INCOGNITO, | 380 return GetCustomBitmap(IDR_THEME_FRAME_INCOGNITO, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 417 } |
408 | 418 |
409 SkBitmap* BrowserNonClientFrameViewAura::GetCustomBitmap( | 419 SkBitmap* BrowserNonClientFrameViewAura::GetCustomBitmap( |
410 int bitmap_id, | 420 int bitmap_id, |
411 int fallback_bitmap_id) const { | 421 int fallback_bitmap_id) const { |
412 ui::ThemeProvider* tp = GetThemeProvider(); | 422 ui::ThemeProvider* tp = GetThemeProvider(); |
413 if (tp->HasCustomImage(bitmap_id)) | 423 if (tp->HasCustomImage(bitmap_id)) |
414 return tp->GetBitmapNamed(bitmap_id); | 424 return tp->GetBitmapNamed(bitmap_id); |
415 return tp->GetBitmapNamed(fallback_bitmap_id); | 425 return tp->GetBitmapNamed(fallback_bitmap_id); |
416 } | 426 } |
OLD | NEW |