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

Side by Side Diff: views/bubble/bubble_border.h

Issue 8493011: Merge 108537 - Align avatar bubble with edge of anchor control (Closed) Base URL: svn://svn.chromium.org/chrome/branches/912/src/
Patch Set: Created 9 years, 1 month 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 | « chrome/browser/ui/views/web_intent_picker_view.cc ('k') | views/bubble/bubble_border.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef VIEWS_BUBBLE_BUBBLE_BORDER_H_ 5 #ifndef VIEWS_BUBBLE_BUBBLE_BORDER_H_
6 #define VIEWS_BUBBLE_BUBBLE_BORDER_H_ 6 #define VIEWS_BUBBLE_BUBBLE_BORDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "views/background.h" 10 #include "views/background.h"
(...skipping 17 matching lines...) Expand all
28 BOTTOM_LEFT = 2, 28 BOTTOM_LEFT = 2,
29 BOTTOM_RIGHT = 3, 29 BOTTOM_RIGHT = 3,
30 LEFT_TOP = 4, 30 LEFT_TOP = 4,
31 RIGHT_TOP = 5, 31 RIGHT_TOP = 5,
32 LEFT_BOTTOM = 6, 32 LEFT_BOTTOM = 6,
33 RIGHT_BOTTOM = 7, 33 RIGHT_BOTTOM = 7,
34 NONE = 8, // No arrow. Positioned under the supplied rect. 34 NONE = 8, // No arrow. Positioned under the supplied rect.
35 FLOAT = 9 // No arrow. Centered over the supplied rect. 35 FLOAT = 9 // No arrow. Centered over the supplied rect.
36 }; 36 };
37 37
38 // The position of the bubble in relation to the anchor.
39 enum BubbleAlignment {
40 // The tip of the arrow points to the middle of the anchor.
41 ALIGN_ARROW_TO_MID_ANCHOR,
42 // The edge nearest to the arrow is lined up with the edge of the anchor.
43 ALIGN_EDGE_TO_ANCHOR_EDGE
44 };
45
38 explicit BubbleBorder(ArrowLocation arrow_location) 46 explicit BubbleBorder(ArrowLocation arrow_location)
39 : override_arrow_offset_(0), 47 : override_arrow_offset_(0),
40 arrow_location_(arrow_location), 48 arrow_location_(arrow_location),
49 alignment_(ALIGN_ARROW_TO_MID_ANCHOR),
41 background_color_(SK_ColorWHITE) { 50 background_color_(SK_ColorWHITE) {
42 InitClass(); 51 InitClass();
43 } 52 }
44 53
45 // Returns the radius of the corner of the border. 54 // Returns the radius of the corner of the border.
46 static int GetCornerRadius() { 55 static int GetCornerRadius() {
47 // We can't safely calculate a border radius by comparing the sizes of the 56 // We can't safely calculate a border radius by comparing the sizes of the
48 // side and corner images, because either may have been extended in various 57 // side and corner images, because either may have been extended in various
49 // directions in order to do more subtle dropshadow fading or other effects. 58 // directions in order to do more subtle dropshadow fading or other effects.
50 // So we hardcode the most accurate value. 59 // So we hardcode the most accurate value.
51 return 4; 60 return 4;
52 } 61 }
53 62
54 // Sets the location for the arrow. 63 // Sets the location for the arrow.
55 void set_arrow_location(ArrowLocation arrow_location) { 64 void set_arrow_location(ArrowLocation arrow_location) {
56 arrow_location_ = arrow_location; 65 arrow_location_ = arrow_location;
57 } 66 }
58 ArrowLocation arrow_location() const { return arrow_location_; } 67 ArrowLocation arrow_location() const { return arrow_location_; }
59 68
69 // Sets the alignment.
70 void set_alignment(BubbleAlignment alignment) { alignment_ = alignment; }
71 BubbleAlignment alignment() const { return alignment_; }
72
60 static ArrowLocation horizontal_mirror(ArrowLocation loc) { 73 static ArrowLocation horizontal_mirror(ArrowLocation loc) {
61 return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 1); 74 return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 1);
62 } 75 }
63 76
64 static ArrowLocation vertical_mirror(ArrowLocation loc) { 77 static ArrowLocation vertical_mirror(ArrowLocation loc) {
65 return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 2); 78 return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 2);
66 } 79 }
67 80
68 static bool has_arrow(ArrowLocation loc) { 81 static bool has_arrow(ArrowLocation loc) {
69 return loc >= NONE ? false : true; 82 return loc >= NONE ? false : true;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 static SkBitmap* right_arrow_; 157 static SkBitmap* right_arrow_;
145 static SkBitmap* bottom_arrow_; 158 static SkBitmap* bottom_arrow_;
146 159
147 // Minimal offset of the arrow from the closet edge of bounding rect. 160 // Minimal offset of the arrow from the closet edge of bounding rect.
148 static int arrow_offset_; 161 static int arrow_offset_;
149 162
150 // If specified, overrides the pre-calculated |arrow_offset_| of the arrow. 163 // If specified, overrides the pre-calculated |arrow_offset_| of the arrow.
151 int override_arrow_offset_; 164 int override_arrow_offset_;
152 165
153 ArrowLocation arrow_location_; 166 ArrowLocation arrow_location_;
167 BubbleAlignment alignment_;
154 SkColor background_color_; 168 SkColor background_color_;
155 169
156 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); 170 DISALLOW_COPY_AND_ASSIGN(BubbleBorder);
157 }; 171 };
158 172
159 // A Background that clips itself to the specified BubbleBorder and uses 173 // A Background that clips itself to the specified BubbleBorder and uses
160 // the background color of the BubbleBorder. 174 // the background color of the BubbleBorder.
161 class VIEWS_EXPORT BubbleBackground : public views::Background { 175 class VIEWS_EXPORT BubbleBackground : public views::Background {
162 public: 176 public:
163 explicit BubbleBackground(BubbleBorder* border) : border_(border) {} 177 explicit BubbleBackground(BubbleBorder* border) : border_(border) {}
164 178
165 // Background overrides. 179 // Background overrides.
166 virtual void Paint(gfx::Canvas* canvas, views::View* view) const; 180 virtual void Paint(gfx::Canvas* canvas, views::View* view) const;
167 181
168 private: 182 private:
169 BubbleBorder* border_; 183 BubbleBorder* border_;
170 184
171 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); 185 DISALLOW_COPY_AND_ASSIGN(BubbleBackground);
172 }; 186 };
173 187
174 } // namespace views 188 } // namespace views
175 189
176 #endif // VIEWS_BUBBLE_BUBBLE_BORDER_H_ 190 #endif // VIEWS_BUBBLE_BUBBLE_BORDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/web_intent_picker_view.cc ('k') | views/bubble/bubble_border.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698