Chromium Code Reviews

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

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.
Jump to:
View unified diff | | 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 #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ 5 #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_
6 #define CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ 6 #define CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_
7 7
8 #include "third_party/skia/include/core/SkColor.h" 8 #include "third_party/skia/include/core/SkColor.h"
9 #include "views/border.h" 9 #include "views/border.h"
10 10
11 class SkBitmap; 11 class SkBitmap;
12 12
13 // Renders a round-rect border and a custom dropshadow. This can be used to 13 // Renders a round-rect border and a custom dropshadow. This can be used to
14 // produce floating "bubble" objects. 14 // produce floating "bubble" objects.
15 class BubbleBorder : public views::Border { 15 class BubbleBorder : public views::Border {
16 public: 16 public:
17 BubbleBorder() { 17 BubbleBorder() {
18 InitClass(); 18 InitClass();
19 } 19 }
20 20
21 // Returns the radius of the corner of the border. 21 // Returns the radius of the corner of the border.
22 static int GetCornerRadius() { 22 static int GetCornerRadius() {
23 // We can't safely calculate a border radius by comparing the sizes of the 23 // We can't safely calculate a border radius by comparing the sizes of the
24 // side and corner images, because either may have been extended in various 24 // side and corner images, because either may have been extended in various
25 // directions in order to do more subtle dropshadow fading or other effects. 25 // directions in order to do more subtle dropshadow fading or other effects.
26 // So we hardcode the most accurate value. 26 // So we hardcode the most accurate value.
27 return 4; 27 return 4;
28 } 28 }
29 29
30 // Gives the desired bounds (in screen coordinates) given the rect to position
31 // relative to and the size of the contained contents. The contents are
32 // centered underneath the supplied rect.
33 gfx::Rect GetBounds(const gfx::Rect& position_relative_to,
34 const gfx::Size& contents_size) const;
35
30 // Overridden from views::Border: 36 // Overridden from views::Border:
31 virtual void GetInsets(gfx::Insets* insets) const; 37 virtual void GetInsets(gfx::Insets* insets) const;
32 38
33 private: 39 private:
34 // Loads images if necessary. 40 // Loads images if necessary.
35 static void InitClass(); 41 static void InitClass();
36 42
37 virtual ~BubbleBorder() { } 43 virtual ~BubbleBorder() { }
38 44
39 // Overridden from views::Border: 45 // Overridden from views::Border:
40 virtual void Paint(const views::View& view, gfx::Canvas* canvas) const; 46 virtual void Paint(const views::View& view, gfx::Canvas* canvas) const;
41 47
42 // Border graphics. 48 // Border graphics.
43 static SkBitmap* left_; 49 static SkBitmap* left_;
44 static SkBitmap* top_left_; 50 static SkBitmap* top_left_;
45 static SkBitmap* top_; 51 static SkBitmap* top_;
46 static SkBitmap* top_right_; 52 static SkBitmap* top_right_;
47 static SkBitmap* right_; 53 static SkBitmap* right_;
48 static SkBitmap* bottom_right_; 54 static SkBitmap* bottom_right_;
49 static SkBitmap* bottom_; 55 static SkBitmap* bottom_;
50 static SkBitmap* bottom_left_; 56 static SkBitmap* bottom_left_;
51 57
52 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); 58 DISALLOW_COPY_AND_ASSIGN(BubbleBorder);
53 }; 59 };
54 60
55 #endif // #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ 61 #endif // #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_
OLDNEW

Powered by Google App Engine