#include "ui/app_list/drop_shadow_label.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/insets.h"
namespace app_list {
DropShadowLabel::DropShadowLabel() {
}
DropShadowLabel::~DropShadowLabel() {
}
void DropShadowLabel::SetTextShadows(int shadow_count,
const gfx::ShadowValue* shadows) {
text_shadows_.clear();
if (shadow_count && shadows) {
for (int i = 0; i < shadow_count; ++i)
text_shadows_.push_back(shadows[i]);
}
}
gfx::Insets DropShadowLabel::GetInsets() const {
gfx::Insets insets = views::Label::GetInsets();
gfx::Insets shadow_margin = gfx::ShadowValue::GetMargin(text_shadows_);
insets += -shadow_margin;
return insets;
}
void DropShadowLabel::PaintText(gfx::Canvas* canvas,
const string16& text,
const gfx::Rect& text_bounds,
int flags) {
SkColor text_color = enabled() ? enabled_color() : disabled_color();
canvas->DrawStringWithShadows(text,
font(),
text_color,
text_bounds,
flags,
text_shadows_);
if (HasFocus() || paint_as_focused()) {
gfx::Rect focus_bounds = text_bounds;
focus_bounds.Inset(-views::Label::kFocusBorderPadding,
-views::Label::kFocusBorderPadding);
canvas->DrawFocusRect(focus_bounds);
}
}
}