Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / libgtk2ui / gtk2_border.h
blobfba75e1b4e8d83e08f5071dac805e703a75ef2ca
1 // Copyright 2014 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 CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_
8 #include "base/scoped_observer.h"
9 #include "ui/gfx/image/image_skia.h"
10 #include "ui/native_theme/native_theme.h"
11 #include "ui/native_theme/native_theme_observer.h"
12 #include "ui/views/border.h"
13 #include "ui/views/controls/button/button.h"
15 namespace gfx {
16 class Canvas;
19 namespace views {
20 class LabelButton;
21 class LabelButtonBorder;
24 namespace libgtk2ui {
25 class Gtk2UI;
27 // Draws a gtk button border, and manages the memory of the resulting pixbufs.
28 class Gtk2Border : public views::Border, public ui::NativeThemeObserver {
29 public:
30 Gtk2Border(Gtk2UI* gtk2_ui,
31 views::LabelButton* owning_button,
32 scoped_ptr<views::LabelButtonBorder> border);
33 ~Gtk2Border() override;
35 // Overridden from views::Border:
36 void Paint(const views::View& view, gfx::Canvas* canvas) override;
37 gfx::Insets GetInsets() const override;
38 gfx::Size GetMinimumSize() const override;
40 // Overridden from views::NativeThemeChangeObserver:
41 void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
43 private:
44 void PaintState(const ui::NativeTheme::State state,
45 const ui::NativeTheme::ExtraParams& extra,
46 const gfx::Rect& rect,
47 gfx::Canvas* canvas);
49 Gtk2UI* gtk2_ui_;
51 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT];
53 // The view to which we are a border. We keep track of this so that we can
54 // force invalidate the layout on theme changes.
55 views::LabelButton* owning_button_;
57 // The views::Border that we are replacing in native mode. We keep track of
58 // this for inset information.
59 scoped_ptr<views::LabelButtonBorder> border_;
61 ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> observer_manager_;
63 DISALLOW_COPY_AND_ASSIGN(Gtk2Border);
66 } // namespace libgtk2ui
68 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_