Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / views / controls / button / label_button_border.h
blob746ed37827e6c5f1747aa628aaf4b331843fbda7
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.
5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/geometry/insets.h"
12 #include "ui/views/border.h"
13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/painter.h"
16 namespace views {
18 // An empty Border with customizable insets used by a LabelButton.
19 class VIEWS_EXPORT LabelButtonBorder : public Border {
20 public:
21 LabelButtonBorder();
22 ~LabelButtonBorder() override;
24 void set_insets(const gfx::Insets& insets) { insets_ = insets; }
26 // Returns true if |this| is able to paint for the given |focused| and |state|
27 // values.
28 virtual bool PaintsButtonState(bool focused, Button::ButtonState state);
30 // Overridden from Border:
31 void Paint(const View& view, gfx::Canvas* canvas) override;
32 gfx::Insets GetInsets() const override;
33 gfx::Size GetMinimumSize() const override;
35 private:
36 gfx::Insets insets_;
38 DISALLOW_COPY_AND_ASSIGN(LabelButtonBorder);
41 // A Border that paints a LabelButton's background frame using image assets.
42 class VIEWS_EXPORT LabelButtonAssetBorder : public LabelButtonBorder {
43 public:
44 explicit LabelButtonAssetBorder(Button::ButtonStyle style);
45 ~LabelButtonAssetBorder() override;
47 // Returns the default insets for a given |style|.
48 static gfx::Insets GetDefaultInsetsForStyle(Button::ButtonStyle style);
50 // Overridden from LabelButtonBorder:
51 bool PaintsButtonState(bool focused, Button::ButtonState state) override;
53 // Overridden from Border:
54 void Paint(const View& view, gfx::Canvas* canvas) override;
55 gfx::Size GetMinimumSize() const override;
57 // Get or set the painter used for the specified |focused| button |state|.
58 // LabelButtonAssetBorder takes and retains ownership of |painter|.
59 Painter* GetPainter(bool focused, Button::ButtonState state);
60 void SetPainter(bool focused, Button::ButtonState state, Painter* painter);
62 private:
63 // The painters used for each unfocused or focused button state.
64 scoped_ptr<Painter> painters_[2][Button::STATE_COUNT];
66 DISALLOW_COPY_AND_ASSIGN(LabelButtonAssetBorder);
69 } // namespace views
71 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_BORDER_H_