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

Side by Side Diff: ui/views/bubble/bubble_border.cc

Issue 23661003: Explicitly list IDR resource ids in ui/views/bubble_border.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
« 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/bubble/bubble_border.h" 5 #include "ui/views/bubble/bubble_border.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 } 67 }
68 68
69 } // namespace internal 69 } // namespace internal
70 70
71 namespace { 71 namespace {
72 72
73 // The border and arrow stroke size used in image assets, in pixels. 73 // The border and arrow stroke size used in image assets, in pixels.
74 const int kStroke = 1; 74 const int kStroke = 1;
75 75
76 // Macros to define arrays of IDR constants used with CreateImageGridPainter. 76 // Bubble border and arrow image resource ids. They don't use the IMAGE_GRID
77 #define IMAGE_BORDER(x) { x ## _TOP_LEFT, x ## _TOP, x ## _TOP_RIGHT, \ 77 // macro because there is no center image.
78 x ## _LEFT, 0, x ## _RIGHT, \ 78 const int kShadowImages[] = {
79 x ## _BOTTOM_LEFT, x ## _BOTTOM, x ## _BOTTOM_RIGHT, } 79 IDR_BUBBLE_SHADOW_TL, IDR_BUBBLE_SHADOW_T, IDR_BUBBLE_SHADOW_TR,
80 #define IMAGE_BORDER_ACRONYM(x) { x ## _TL, x ## _T, x ## _TR, \ 80 IDR_BUBBLE_SHADOW_L, 0, IDR_BUBBLE_SHADOW_R,
81 x ## _L, 0, x ## _R, \ 81 IDR_BUBBLE_SHADOW_BL, IDR_BUBBLE_SHADOW_B, IDR_BUBBLE_SHADOW_BR };
82 x ## _BL, x ## _B, x ## _BR, } 82 const int kShadowArrows[] = { 0, 0, 0, 0 };
83 #define ARROWS(x) { x ## _LEFT, x ## _TOP, x ## _RIGHT, x ## _BOTTOM, }
84 83
85 // Bubble border and arrow image resource ids. 84 const int kNoShadowImages[] = {
86 const int kShadowImages[] = IMAGE_BORDER_ACRONYM(IDR_BUBBLE_SHADOW); 85 IDR_BUBBLE_TL, IDR_BUBBLE_T, IDR_BUBBLE_TR,
87 const int kShadowArrows[] = { 0, 0, 0, 0 }; 86 IDR_BUBBLE_L, 0, IDR_BUBBLE_R,
88 const int kNoShadowImages[] = IMAGE_BORDER_ACRONYM(IDR_BUBBLE); 87 IDR_BUBBLE_BL, IDR_BUBBLE_B, IDR_BUBBLE_BR };
89 const int kNoShadowArrows[] = { IDR_BUBBLE_L_ARROW, IDR_BUBBLE_T_ARROW, 88 const int kNoShadowArrows[] = {
90 IDR_BUBBLE_R_ARROW, IDR_BUBBLE_B_ARROW, }; 89 IDR_BUBBLE_L_ARROW, IDR_BUBBLE_T_ARROW,
91 const int kBigShadowImages[] = IMAGE_BORDER(IDR_WINDOW_BUBBLE_SHADOW_BIG); 90 IDR_BUBBLE_R_ARROW, IDR_BUBBLE_B_ARROW, };
92 const int kBigShadowArrows[] = ARROWS(IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG); 91
93 const int kSmallShadowImages[] = IMAGE_BORDER(IDR_WINDOW_BUBBLE_SHADOW_SMALL); 92 const int kBigShadowImages[] = {
94 const int kSmallShadowArrows[] = ARROWS(IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL); 93 IDR_WINDOW_BUBBLE_SHADOW_BIG_TOP_LEFT,
94 IDR_WINDOW_BUBBLE_SHADOW_BIG_TOP,
95 IDR_WINDOW_BUBBLE_SHADOW_BIG_TOP_RIGHT,
96 IDR_WINDOW_BUBBLE_SHADOW_BIG_LEFT,
97 0,
98 IDR_WINDOW_BUBBLE_SHADOW_BIG_RIGHT,
99 IDR_WINDOW_BUBBLE_SHADOW_BIG_BOTTOM_LEFT,
100 IDR_WINDOW_BUBBLE_SHADOW_BIG_BOTTOM,
101 IDR_WINDOW_BUBBLE_SHADOW_BIG_BOTTOM_RIGHT };
102 const int kBigShadowArrows[] = {
103 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_LEFT,
104 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_TOP,
105 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_RIGHT,
106 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_BIG_BOTTOM };
107
108 const int kSmallShadowImages[] = {
109 IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP_LEFT,
110 IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP,
111 IDR_WINDOW_BUBBLE_SHADOW_SMALL_TOP_RIGHT,
112 IDR_WINDOW_BUBBLE_SHADOW_SMALL_LEFT,
113 0,
114 IDR_WINDOW_BUBBLE_SHADOW_SMALL_RIGHT,
115 IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM_LEFT,
116 IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM,
117 IDR_WINDOW_BUBBLE_SHADOW_SMALL_BOTTOM_RIGHT };
118 const int kSmallShadowArrows[] = {
119 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_LEFT,
120 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_TOP,
121 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_RIGHT,
122 IDR_WINDOW_BUBBLE_SHADOW_SPIKE_SMALL_BOTTOM };
95 123
96 using internal::BorderImages; 124 using internal::BorderImages;
97 125
98 // Returns the cached BorderImages for the given |shadow| type. 126 // Returns the cached BorderImages for the given |shadow| type.
99 BorderImages* GetBorderImages(BubbleBorder::Shadow shadow) { 127 BorderImages* GetBorderImages(BubbleBorder::Shadow shadow) {
100 // Keep a cache of bubble border image-set painters, arrows, and metrics. 128 // Keep a cache of bubble border image-set painters, arrows, and metrics.
101 static BorderImages* kBorderImages[BubbleBorder::SHADOW_COUNT] = { NULL }; 129 static BorderImages* kBorderImages[BubbleBorder::SHADOW_COUNT] = { NULL };
102 130
103 CHECK_LT(shadow, BubbleBorder::SHADOW_COUNT); 131 CHECK_LT(shadow, BubbleBorder::SHADOW_COUNT);
104 struct BorderImages*& set = kBorderImages[shadow]; 132 struct BorderImages*& set = kBorderImages[shadow];
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // Note: This matches the legacy appearance of SHADOW's extra large inset. 383 // Note: This matches the legacy appearance of SHADOW's extra large inset.
356 if (border_->shadow() == BubbleBorder::SHADOW) 384 if (border_->shadow() == BubbleBorder::SHADOW)
357 bounds.Inset(-10, -10); 385 bounds.Inset(-10, -10);
358 386
359 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius()); 387 SkScalar radius = SkIntToScalar(border_->GetBorderCornerRadius());
360 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius); 388 path.addRoundRect(gfx::RectToSkRect(bounds), radius, radius);
361 canvas->DrawPath(path, paint); 389 canvas->DrawPath(path, paint);
362 } 390 }
363 391
364 } // namespace views 392 } // 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