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

Side by Side Diff: chrome/browser/views/bubble_border.cc

Issue 194110: Convert the AutocompletePopupPositioner into a BubblePositioner in preparatio... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/browser/views/bubble_border.h" 5 #include "chrome/browser/views/bubble_border.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/path.h" 8 #include "app/gfx/path.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "grit/theme_resources.h" 11 #include "grit/theme_resources.h"
12 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
13 13
14 // static 14 // static
15 SkBitmap* BubbleBorder::left_ = NULL; 15 SkBitmap* BubbleBorder::left_ = NULL;
16 SkBitmap* BubbleBorder::top_left_ = NULL; 16 SkBitmap* BubbleBorder::top_left_ = NULL;
17 SkBitmap* BubbleBorder::top_ = NULL; 17 SkBitmap* BubbleBorder::top_ = NULL;
18 SkBitmap* BubbleBorder::top_right_ = NULL; 18 SkBitmap* BubbleBorder::top_right_ = NULL;
19 SkBitmap* BubbleBorder::right_ = NULL; 19 SkBitmap* BubbleBorder::right_ = NULL;
20 SkBitmap* BubbleBorder::bottom_right_ = NULL; 20 SkBitmap* BubbleBorder::bottom_right_ = NULL;
21 SkBitmap* BubbleBorder::bottom_ = NULL; 21 SkBitmap* BubbleBorder::bottom_ = NULL;
22 SkBitmap* BubbleBorder::bottom_left_ = NULL; 22 SkBitmap* BubbleBorder::bottom_left_ = NULL;
23 23
24 gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to,
25 const gfx::Size& contents_size) const {
26 // The spacing (in pixels) between |position_relative_to| and the bubble
27 // content.
28 const int kBubbleSpacing = 2;
29
30 // Desired size is size of contents enlarged by the size of the border images.
31 gfx::Size border_size(contents_size);
32 gfx::Insets insets;
33 GetInsets(&insets);
34 border_size.Enlarge(insets.left() + insets.right(),
35 insets.top() + insets.bottom());
36
37 int x = position_relative_to.x() + (position_relative_to.width() / 2) -
38 (contents_size.width() / 2) - insets.left();
39 int y = position_relative_to.bottom() - (top_->height() - kBubbleSpacing);
40
41 return gfx::Rect(x, y, border_size.width(), border_size.height());
42 }
43
24 void BubbleBorder::GetInsets(gfx::Insets* insets) const { 44 void BubbleBorder::GetInsets(gfx::Insets* insets) const {
25 // The left, right and bottom edge image sizes define our insets. The corner
26 // images don't determine this because they can extend inside the border (onto
27 // the contained contents).
28 insets->Set(top_->height(), left_->width(), bottom_->height(), 45 insets->Set(top_->height(), left_->width(), bottom_->height(),
29 right_->width()); 46 right_->width());
30 } 47 }
31 48
32 // static 49 // static
33 void BubbleBorder::InitClass() { 50 void BubbleBorder::InitClass() {
34 static bool initialized = false; 51 static bool initialized = false;
35 if (!initialized) { 52 if (!initialized) {
36 // Load images. 53 // Load images.
37 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 54 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // Right edge 119 // Right edge
103 canvas->TileImageInt(*right_, width - r_width, tr_bottom, r_width, 120 canvas->TileImageInt(*right_, width - r_width, tr_bottom, r_width,
104 br_y - tr_bottom); 121 br_y - tr_bottom);
105 122
106 // Bottom right corner 123 // Bottom right corner
107 canvas->DrawBitmapInt(*bottom_right_, width - br_width, br_y); 124 canvas->DrawBitmapInt(*bottom_right_, width - br_width, br_y);
108 125
109 // Bottom edge 126 // Bottom edge
110 canvas->TileImageInt(*bottom_, bl_width, bottom, width - bl_width - br_width, 127 canvas->TileImageInt(*bottom_, bl_width, bottom, width - bl_width - br_width,
111 b_height); 128 b_height);
129
112 // Bottom left corner 130 // Bottom left corner
113 canvas->DrawBitmapInt(*bottom_left_, 0, bl_y); 131 canvas->DrawBitmapInt(*bottom_left_, 0, bl_y);
114 132
115 // Left edge 133 // Left edge
116 canvas->TileImageInt(*left_, 0, tl_bottom, left_->width(), bl_y - tl_bottom); 134 canvas->TileImageInt(*left_, 0, tl_bottom, left_->width(), bl_y - tl_bottom);
117 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698