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: ash/app_list/drop_shadow_label.cc

Issue 10388032: Move app list from ash to ui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix win_aura bot and comments in #5 Created 8 years, 7 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 | « ash/app_list/drop_shadow_label.h ('k') | ash/app_list/icon_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/app_list/drop_shadow_label.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "third_party/skia/include/effects/SkGradientShader.h"
9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/color_utils.h"
11 #include "ui/gfx/insets.h"
12 #include "ui/gfx/skbitmap_operations.h"
13
14 using views::Label;
15
16 namespace ash {
17
18 DropShadowLabel::DropShadowLabel() {
19 }
20
21 DropShadowLabel::~DropShadowLabel() {
22 }
23
24 void DropShadowLabel::SetTextShadows(int shadow_count,
25 const gfx::ShadowValue* shadows) {
26 text_shadows_.clear();
27
28 if (shadow_count && shadows) {
29 for (int i = 0; i < shadow_count; ++i)
30 text_shadows_.push_back(shadows[i]);
31 }
32 }
33
34 gfx::Insets DropShadowLabel::GetInsets() const {
35 gfx::Insets insets = views::Label::GetInsets();
36 gfx::Insets shadow_margin = gfx::ShadowValue::GetMargin(text_shadows_);
37 // Negate |shadow_margin| to convert it to a padding insets needed inside
38 // the bounds and combine with label's insets.
39 insets += -shadow_margin;
40 return insets;
41 }
42
43 void DropShadowLabel::PaintText(gfx::Canvas* canvas,
44 const string16& text,
45 const gfx::Rect& text_bounds,
46 int flags) {
47 SkColor text_color = enabled() ? enabled_color() : disabled_color();
48 canvas->DrawStringWithShadows(text,
49 font(),
50 text_color,
51 text_bounds,
52 flags,
53 text_shadows_);
54
55 if (HasFocus() || paint_as_focused()) {
56 gfx::Rect focus_bounds = text_bounds;
57 focus_bounds.Inset(-Label::kFocusBorderPadding,
58 -Label::kFocusBorderPadding);
59 canvas->DrawFocusRect(focus_bounds);
60 }
61 }
62
63 } // namespace ash
OLDNEW
« no previous file with comments | « ash/app_list/drop_shadow_label.h ('k') | ash/app_list/icon_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698