OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ | 5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ |
6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ | 6 #define CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ |
7 | 7 |
| 8 #include "base/scoped_observer.h" |
8 #include "ui/gfx/image/image_skia.h" | 9 #include "ui/gfx/image/image_skia.h" |
9 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
| 11 #include "ui/native_theme/native_theme_observer.h" |
10 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
11 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/linux_ui/native_theme_change_observer.h" | |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class Canvas; | 16 class Canvas; |
16 } | 17 } |
17 | 18 |
18 namespace views { | 19 namespace views { |
19 class LabelButton; | 20 class LabelButton; |
20 class Border; | 21 class Border; |
21 } | 22 } |
22 | 23 |
23 namespace libgtk2ui { | 24 namespace libgtk2ui { |
24 class Gtk2UI; | 25 class Gtk2UI; |
25 | 26 |
26 // Draws a gtk button border, and manages the memory of the resulting pixbufs. | 27 // Draws a gtk button border, and manages the memory of the resulting pixbufs. |
27 class Gtk2Border : public views::Border, | 28 class Gtk2Border : public views::Border, public ui::NativeThemeObserver { |
28 public views::NativeThemeChangeObserver { | |
29 public: | 29 public: |
30 Gtk2Border(Gtk2UI* gtk2_ui, | 30 Gtk2Border(Gtk2UI* gtk2_ui, |
31 views::LabelButton* owning_button); | 31 views::LabelButton* owning_button); |
32 virtual ~Gtk2Border(); | 32 virtual ~Gtk2Border(); |
33 | 33 |
34 // Overridden from views::Border: | 34 // Overridden from views::Border: |
35 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; | 35 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; |
36 virtual gfx::Insets GetInsets() const OVERRIDE; | 36 virtual gfx::Insets GetInsets() const OVERRIDE; |
37 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 37 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
38 | 38 |
39 // Overridden from views::NativeThemeChangeObserver: | 39 // Overridden from views::NativeThemeChangeObserver: |
40 virtual void OnNativeThemeChanged() OVERRIDE; | 40 virtual void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) OVERRIDE; |
41 | 41 |
42 private: | 42 private: |
43 void PaintState(const ui::NativeTheme::State state, | 43 void PaintState(const ui::NativeTheme::State state, |
44 const ui::NativeTheme::ExtraParams& extra, | 44 const ui::NativeTheme::ExtraParams& extra, |
45 const gfx::Rect& rect, | 45 const gfx::Rect& rect, |
46 gfx::Canvas* canvas); | 46 gfx::Canvas* canvas); |
47 | 47 |
48 bool ShouldDrawBorder(bool focused, views::Button::ButtonState state); | 48 bool ShouldDrawBorder(bool focused, views::Button::ButtonState state); |
49 | 49 |
50 Gtk2UI* gtk2_ui_; | 50 Gtk2UI* gtk2_ui_; |
51 | 51 |
52 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; | 52 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; |
53 | 53 |
54 // The view to which we are a border. We keep track of this so that we can | 54 // The view to which we are a border. We keep track of this so that we can |
55 // force invalidate the layout on theme changes. | 55 // force invalidate the layout on theme changes. |
56 views::LabelButton* owning_button_; | 56 views::LabelButton* owning_button_; |
57 | 57 |
| 58 ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> observer_manager_; |
| 59 |
58 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); | 60 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); |
59 }; | 61 }; |
60 | 62 |
61 } // namespace libgtk2ui | 63 } // namespace libgtk2ui |
62 | 64 |
63 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ | 65 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ |
OLD | NEW |