This source file includes following definitions.
- margin_leading_
- GetThemePaintRect
- SetLeadingMargin
#include "chrome/browser/ui/views/toolbar/back_button.h"
#include "ui/gfx/insets.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/painter.h"
BackButton::BackButton(views::ButtonListener* listener,
ui::MenuModel* model)
: ToolbarButton(listener, model),
margin_leading_(0) {
}
BackButton::~BackButton() {
}
gfx::Rect BackButton::GetThemePaintRect() const {
gfx::Rect rect(LabelButton::GetThemePaintRect());
rect.Inset(margin_leading_, 0, 0, 0);
return rect;
}
void BackButton::SetLeadingMargin(int margin) {
scoped_ptr<views::LabelButtonBorder> border(
new views::LabelButtonBorder(style()));
const gfx::Insets insets(border->GetInsets());
border->set_insets(gfx::Insets(insets.top(), insets.left() + margin,
insets.bottom(), insets.right()));
UpdateThemedBorder(border.PassAs<views::Border>());
const int kFocusRectInset = 3;
SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
gfx::Insets(kFocusRectInset, kFocusRectInset + margin,
kFocusRectInset, kFocusRectInset)));
margin_leading_ = margin;
InvalidateLayout();
}