Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Side by Side Diff: views/window/custom_frame_view.cc

Issue 145017: Fix dialog edges - error was because we made the top edges the same height bu... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/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"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 SkBitmap* top_right = rb.GetBitmapNamed(IDR_APP_TOP_RIGHT); 415 SkBitmap* top_right = rb.GetBitmapNamed(IDR_APP_TOP_RIGHT);
416 SkBitmap* right = rb.GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); 416 SkBitmap* right = rb.GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE);
417 SkBitmap* bottom_right = 417 SkBitmap* bottom_right =
418 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER); 418 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER);
419 SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); 419 SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER);
420 SkBitmap* bottom_left = 420 SkBitmap* bottom_left =
421 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); 421 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
422 SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); 422 SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE);
423 423
424 // Top. 424 // Top.
425 // This next calculation is necessary because the top center bitmap is shorter
426 // than the top left and right bitmaps. We need their top edges to line up,
427 // and we need the left and right edges to start below the corners' bottoms.
428 int top_edge_y = client_area_top - top->height(); 425 int top_edge_y = client_area_top - top->height();
429 client_area_top = top_edge_y + top_left->height();
430 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(), 426 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(),
431 top_edge_y); 427 top_edge_y);
432 canvas->TileImageInt(*top, client_area_bounds.x(), top_edge_y, 428 canvas->TileImageInt(*top, client_area_bounds.x(), top_edge_y,
433 client_area_bounds.width(), top->height()); 429 client_area_bounds.width(), top->height());
434 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y); 430 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y);
435 431
436 // Right. 432 // Right.
437 int client_area_bottom = 433 int client_area_bottom =
438 std::max(client_area_top, client_area_bounds.bottom()); 434 std::max(client_area_top, client_area_bounds.bottom());
439 int client_area_height = client_area_bottom - client_area_top; 435 int client_area_height = client_area_bottom - client_area_top;
440 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, 436 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
441 right->width(), client_area_height); 437 right->width(), client_area_height);
442 438
443 // Bottom. 439 // Bottom.
444 canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right(), 440 canvas->DrawBitmapInt(*bottom_right, client_area_bounds.right(),
445 client_area_bottom); 441 client_area_bottom);
446 canvas->TileImageInt(*bottom, client_area_bounds.x(), client_area_bottom, 442 canvas->TileImageInt(*bottom, client_area_bounds.x(), client_area_bottom,
447 client_area_bounds.width(), bottom_right->height()); 443 client_area_bounds.width(), bottom_right->height());
448 canvas->DrawBitmapInt(*bottom_left, 444 canvas->DrawBitmapInt(*bottom_left,
449 client_area_bounds.x() - bottom_left->width(), client_area_bottom); 445 client_area_bounds.x() - bottom_left->width(), client_area_bottom);
450 446
451 // Left. 447 // Left.
452 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(), 448 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
453 client_area_top, left->width(), client_area_height); 449 client_area_top, left->width(), client_area_height);
454 450
455 // Draw the toolbar color to fill in the edges. 451 // Draw the toolbar color to fill in the edges.
456 canvas->DrawRectInt(ResourceBundle::toolbar_color, 452 canvas->DrawRectInt(ResourceBundle::toolbar_color,
457 client_area_bounds.x() - 1, client_area_top - 2, 453 client_area_bounds.x() - 1, client_area_top - 1,
458 client_area_bounds.width() + 1, client_area_bottom - client_area_top + 2); 454 client_area_bounds.width() + 1, client_area_bottom - client_area_top + 1);
459 } 455 }
460 456
461 void CustomFrameView::LayoutWindowControls() { 457 void CustomFrameView::LayoutWindowControls() {
462 close_button_->SetImageAlignment(ImageButton::ALIGN_LEFT, 458 close_button_->SetImageAlignment(ImageButton::ALIGN_LEFT,
463 ImageButton::ALIGN_BOTTOM); 459 ImageButton::ALIGN_BOTTOM);
464 // Maximized buttons start at window top so that even if their images aren't 460 // Maximized buttons start at window top so that even if their images aren't
465 // drawn flush with the screen edge, they still obey Fitts' Law. 461 // drawn flush with the screen edge, they still obey Fitts' Law.
466 bool is_maximized = frame_->IsMaximized(); 462 bool is_maximized = frame_->IsMaximized();
467 int frame_thickness = FrameBorderThickness(); 463 int frame_thickness = FrameBorderThickness();
468 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; 464 int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); 587 title_font_ = new gfx::Font(win_util::GetWindowTitleFont());
592 #elif defined(OS_LINUX) 588 #elif defined(OS_LINUX)
593 // TODO: need to resolve what font this is. 589 // TODO: need to resolve what font this is.
594 title_font_ = new gfx::Font(); 590 title_font_ = new gfx::Font();
595 #endif 591 #endif
596 initialized = true; 592 initialized = true;
597 } 593 }
598 } 594 }
599 595
600 } // namespace views 596 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698