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

Side by Side Diff: ui/views/shadow_border.cc

Issue 82483003: Add GetMinimumSize() for Borders, and make LabelButton auto-size to at least as (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shadow_border.h" 5 #include "ui/views/shadow_border.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/insets.h" 8 #include "ui/gfx/insets.h"
9 #include "ui/gfx/shadow_value.h" 9 #include "ui/gfx/shadow_value.h"
10 #include "ui/gfx/skia_util.h" 10 #include "ui/gfx/skia_util.h"
(...skipping 16 matching lines...) Expand all
27 // poor performance. Ideally we should be caching the border to bitmaps. 27 // poor performance. Ideally we should be caching the border to bitmaps.
28 void ShadowBorder::Paint(const views::View& view, gfx::Canvas* canvas) { 28 void ShadowBorder::Paint(const views::View& view, gfx::Canvas* canvas) {
29 SkPaint paint; 29 SkPaint paint;
30 std::vector<gfx::ShadowValue> shadows; 30 std::vector<gfx::ShadowValue> shadows;
31 shadows.push_back(gfx::ShadowValue(gfx::Point(), blur_, color_)); 31 shadows.push_back(gfx::ShadowValue(gfx::Point(), blur_, color_));
32 skia::RefPtr<SkDrawLooper> looper = gfx::CreateShadowDrawLooper(shadows); 32 skia::RefPtr<SkDrawLooper> looper = gfx::CreateShadowDrawLooper(shadows);
33 paint.setLooper(looper.get()); 33 paint.setLooper(looper.get());
34 paint.setColor(SK_ColorTRANSPARENT); 34 paint.setColor(SK_ColorTRANSPARENT);
35 paint.setStrokeJoin(SkPaint::kRound_Join); 35 paint.setStrokeJoin(SkPaint::kRound_Join);
36 gfx::Rect bounds(view.size()); 36 gfx::Rect bounds(view.size());
37 // This isn't really right if one of the offsets is larger than (blur_ / 2)...
msw 2013/11/22 18:00:25 nit: fix it, file an issue, or make this a TODO.
Peter Kasting 2013/11/22 22:07:55 Done.
37 bounds.Inset(gfx::Insets(blur_ / 2, blur_ / 2, blur_ / 2, blur_ / 2)); 38 bounds.Inset(gfx::Insets(blur_ / 2, blur_ / 2, blur_ / 2, blur_ / 2));
38 canvas->DrawRect(bounds, paint); 39 canvas->DrawRect(bounds, paint);
39 } 40 }
40 41
41 gfx::Insets ShadowBorder::GetInsets() const { 42 gfx::Insets ShadowBorder::GetInsets() const {
42 return gfx::Insets(blur_ / 2 - vertical_offset_, 43 return gfx::Insets(blur_ / 2 - vertical_offset_,
43 blur_ / 2 - horizontal_offset_, 44 blur_ / 2 - horizontal_offset_,
44 blur_ / 2 + vertical_offset_, 45 blur_ / 2 + vertical_offset_,
45 blur_ / 2 + horizontal_offset_); 46 blur_ / 2 + horizontal_offset_);
46 } 47 }
47 48
49 gfx::Size ShadowBorder::GetMinimumSize() const {
50 return gfx::Size(blur_, blur_);
51 }
52
48 } // namespace views 53 } // namespace views
OLDNEW
« ui/views/controls/focusable_border.cc ('K') | « ui/views/shadow_border.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698