| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/window/custom_frame_view.h" | 5 #include "views/window/custom_frame_view.h" |
| 6 | 6 |
| 7 #include "app/gfx/chrome_canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/chrome_font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "app/gfx/path.h" | 9 #include "app/gfx/path.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "app/theme_provider.h" | 11 #include "app/theme_provider.h" |
| 12 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 13 #include "app/win_util.h" | 13 #include "app/win_util.h" |
| 14 #include "base/win_util.h" | 14 #include "base/win_util.h" |
| 15 #endif | 15 #endif |
| 16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #include "views/window/client_view.h" | 17 #include "views/window/client_view.h" |
| 18 #if defined(OS_LINUX) | 18 #if defined(OS_LINUX) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 void CustomFrameView::ResetWindowControls() { | 203 void CustomFrameView::ResetWindowControls() { |
| 204 restore_button_->SetState(CustomButton::BS_NORMAL); | 204 restore_button_->SetState(CustomButton::BS_NORMAL); |
| 205 minimize_button_->SetState(CustomButton::BS_NORMAL); | 205 minimize_button_->SetState(CustomButton::BS_NORMAL); |
| 206 maximize_button_->SetState(CustomButton::BS_NORMAL); | 206 maximize_button_->SetState(CustomButton::BS_NORMAL); |
| 207 // The close button isn't affected by this constraint. | 207 // The close button isn't affected by this constraint. |
| 208 } | 208 } |
| 209 | 209 |
| 210 /////////////////////////////////////////////////////////////////////////////// | 210 /////////////////////////////////////////////////////////////////////////////// |
| 211 // CustomFrameView, View overrides: | 211 // CustomFrameView, View overrides: |
| 212 | 212 |
| 213 void CustomFrameView::Paint(ChromeCanvas* canvas) { | 213 void CustomFrameView::Paint(gfx::Canvas* canvas) { |
| 214 if (frame_->IsMaximized()) | 214 if (frame_->IsMaximized()) |
| 215 PaintMaximizedFrameBorder(canvas); | 215 PaintMaximizedFrameBorder(canvas); |
| 216 else | 216 else |
| 217 PaintRestoredFrameBorder(canvas); | 217 PaintRestoredFrameBorder(canvas); |
| 218 PaintTitleBar(canvas); | 218 PaintTitleBar(canvas); |
| 219 if (!frame_->IsMaximized()) | 219 if (!frame_->IsMaximized()) |
| 220 PaintRestoredClientEdge(canvas); | 220 PaintRestoredClientEdge(canvas); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void CustomFrameView::Layout() { | 223 void CustomFrameView::Layout() { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 int title_adjust = (kFrameBorderThickness / 2); | 288 int title_adjust = (kFrameBorderThickness / 2); |
| 289 *title_top_spacing += title_adjust; | 289 *title_top_spacing += title_adjust; |
| 290 title_bottom_spacing -= title_adjust; | 290 title_bottom_spacing -= title_adjust; |
| 291 } | 291 } |
| 292 *title_thickness = std::max(title_font_->height(), | 292 *title_thickness = std::max(title_font_->height(), |
| 293 min_titlebar_height - *title_top_spacing - title_bottom_spacing); | 293 min_titlebar_height - *title_top_spacing - title_bottom_spacing); |
| 294 return *title_top_spacing + *title_thickness + title_bottom_spacing + | 294 return *title_top_spacing + *title_thickness + title_bottom_spacing + |
| 295 BottomEdgeThicknessWithinNonClientHeight(); | 295 BottomEdgeThicknessWithinNonClientHeight(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void CustomFrameView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { | 298 void CustomFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
| 299 // Window frame mode. | 299 // Window frame mode. |
| 300 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 300 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 301 | 301 |
| 302 SkBitmap* theme_frame; | 302 SkBitmap* theme_frame; |
| 303 SkColor frame_color; | 303 SkColor frame_color; |
| 304 | 304 |
| 305 if (frame_->IsActive()) { | 305 if (frame_->IsActive()) { |
| 306 theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME); | 306 theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME); |
| 307 frame_color = ResourceBundle::frame_color; | 307 frame_color = ResourceBundle::frame_color; |
| 308 } else { | 308 } else { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 canvas->DrawBitmapInt(*bottom_left_corner, 0, | 366 canvas->DrawBitmapInt(*bottom_left_corner, 0, |
| 367 height() - bottom_left_corner->height()); | 367 height() - bottom_left_corner->height()); |
| 368 | 368 |
| 369 // Left. | 369 // Left. |
| 370 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), | 370 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), |
| 371 left_edge->width(), | 371 left_edge->width(), |
| 372 height() - top_left_corner->height() - bottom_left_corner->height()); | 372 height() - top_left_corner->height() - bottom_left_corner->height()); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void CustomFrameView::PaintMaximizedFrameBorder( | 375 void CustomFrameView::PaintMaximizedFrameBorder( |
| 376 ChromeCanvas* canvas) { | 376 gfx::Canvas* canvas) { |
| 377 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 377 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 378 | 378 |
| 379 SkBitmap* top_edge = rb.GetBitmapNamed(IDR_WINDOW_TOP_CENTER); | 379 SkBitmap* top_edge = rb.GetBitmapNamed(IDR_WINDOW_TOP_CENTER); |
| 380 canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(), | 380 canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(), |
| 381 top_edge->height()); | 381 top_edge->height()); |
| 382 | 382 |
| 383 // The bottom of the titlebar actually comes from the top of the Client Edge | 383 // The bottom of the titlebar actually comes from the top of the Client Edge |
| 384 // graphic, with the actual client edge clipped off the bottom. | 384 // graphic, with the actual client edge clipped off the bottom. |
| 385 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); | 385 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); |
| 386 int edge_height = titlebar_bottom->height() - kClientEdgeThickness; | 386 int edge_height = titlebar_bottom->height() - kClientEdgeThickness; |
| 387 canvas->TileImageInt(*titlebar_bottom, 0, | 387 canvas->TileImageInt(*titlebar_bottom, 0, |
| 388 frame_->GetClientView()->y() - edge_height, width(), edge_height); | 388 frame_->GetClientView()->y() - edge_height, width(), edge_height); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void CustomFrameView::PaintTitleBar(ChromeCanvas* canvas) { | 391 void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) { |
| 392 WindowDelegate* d = frame_->GetDelegate(); | 392 WindowDelegate* d = frame_->GetDelegate(); |
| 393 | 393 |
| 394 // It seems like in some conditions we can be asked to paint after the window | 394 // It seems like in some conditions we can be asked to paint after the window |
| 395 // that contains us is WM_DESTROYed. At this point, our delegate is NULL. The | 395 // that contains us is WM_DESTROYed. At this point, our delegate is NULL. The |
| 396 // correct long term fix may be to shut down the RootView in WM_DESTROY. | 396 // correct long term fix may be to shut down the RootView in WM_DESTROY. |
| 397 if (!d) | 397 if (!d) |
| 398 return; | 398 return; |
| 399 | 399 |
| 400 canvas->DrawStringInt(d->GetWindowTitle(), *title_font_, SK_ColorWHITE, | 400 canvas->DrawStringInt(d->GetWindowTitle(), *title_font_, SK_ColorWHITE, |
| 401 MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), | 401 MirroredLeftPointForRect(title_bounds_), title_bounds_.y(), |
| 402 title_bounds_.width(), title_bounds_.height()); | 402 title_bounds_.width(), title_bounds_.height()); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void CustomFrameView::PaintRestoredClientEdge(ChromeCanvas* canvas) { | 405 void CustomFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
| 406 gfx::Rect client_area_bounds = frame_->GetClientView()->bounds(); | 406 gfx::Rect client_area_bounds = frame_->GetClientView()->bounds(); |
| 407 int client_area_top = client_area_bounds.y(); | 407 int client_area_top = client_area_bounds.y(); |
| 408 | 408 |
| 409 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 409 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 410 SkBitmap* top_left = rb.GetBitmapNamed(IDR_APP_TOP_LEFT); | 410 SkBitmap* top_left = rb.GetBitmapNamed(IDR_APP_TOP_LEFT); |
| 411 SkBitmap* top = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); | 411 SkBitmap* top = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); |
| 412 SkBitmap* top_right = rb.GetBitmapNamed(IDR_APP_TOP_RIGHT); | 412 SkBitmap* top_right = rb.GetBitmapNamed(IDR_APP_TOP_RIGHT); |
| 413 SkBitmap* right = rb.GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 413 SkBitmap* right = rb.GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
| 414 SkBitmap* bottom_right = | 414 SkBitmap* bottom_right = |
| 415 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER); | 415 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); | 588 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); |
| 589 #elif defined(OS_LINUX) | 589 #elif defined(OS_LINUX) |
| 590 // TODO: need to resolve what font this is. | 590 // TODO: need to resolve what font this is. |
| 591 title_font_ = new gfx::Font(); | 591 title_font_ = new gfx::Font(); |
| 592 #endif | 592 #endif |
| 593 initialized = true; | 593 initialized = true; |
| 594 } | 594 } |
| 595 } | 595 } |
| 596 | 596 |
| 597 } // namespace views | 597 } // namespace views |
| OLD | NEW |