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 "ui/gfx/image/image_skia.h" | 8 #include "ui/gfx/image/image_skia.h" |
9 #include "ui/native_theme/native_theme.h" | 9 #include "ui/native_theme/native_theme.h" |
10 #include "ui/views/border.h" | 10 #include "ui/views/border.h" |
11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/linux_ui/native_theme_change_observer.h" | 12 #include "ui/views/linux_ui/system_theme_change_observer.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class Canvas; | 15 class Canvas; |
16 } | 16 } |
17 | 17 |
18 namespace views { | 18 namespace views { |
19 class LabelButton; | 19 class LabelButton; |
20 class Border; | 20 class Border; |
21 } | 21 } |
22 | 22 |
23 namespace libgtk2ui { | 23 namespace libgtk2ui { |
24 class Gtk2UI; | 24 class Gtk2UI; |
25 | 25 |
26 // Draws a gtk button border, and manages the memory of the resulting pixbufs. | 26 // Draws a gtk button border, and manages the memory of the resulting pixbufs. |
27 class Gtk2Border : public views::Border, | 27 class Gtk2Border : public views::Border, |
28 public views::NativeThemeChangeObserver { | 28 public views::SystemThemeChangeObserver { |
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 scoped_ptr<views::Border> border); | 32 scoped_ptr<views::Border> border); |
33 virtual ~Gtk2Border(); | 33 virtual ~Gtk2Border(); |
34 | 34 |
35 // Overridden from views::Border: | 35 // Overridden from views::Border: |
36 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; | 36 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; |
37 virtual gfx::Insets GetInsets() const OVERRIDE; | 37 virtual gfx::Insets GetInsets() const OVERRIDE; |
38 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 38 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
39 | 39 |
40 // Overridden from views::NativeThemeChangeObserver: | 40 // Overridden from views::SystemThemeChangeObserver: |
41 virtual void OnNativeThemeChanged() OVERRIDE; | 41 virtual void OnSystemThemeChanged() OVERRIDE; |
42 | 42 |
43 private: | 43 private: |
44 void PaintState(const ui::NativeTheme::State state, | 44 void PaintState(const ui::NativeTheme::State state, |
45 const ui::NativeTheme::ExtraParams& extra, | 45 const ui::NativeTheme::ExtraParams& extra, |
46 const gfx::Rect& rect, | 46 const gfx::Rect& rect, |
47 gfx::Canvas* canvas); | 47 gfx::Canvas* canvas); |
48 | 48 |
49 bool ShouldDrawBorder(bool focused, views::Button::ButtonState state); | 49 bool ShouldDrawBorder(bool focused, views::Button::ButtonState state); |
50 | 50 |
51 Gtk2UI* gtk2_ui_; | 51 Gtk2UI* gtk2_ui_; |
52 | 52 |
53 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; | 53 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; |
54 | 54 |
55 // The view to which we are a border. We keep track of this so that we can | 55 // The view to which we are a border. We keep track of this so that we can |
56 // force invalidate the layout on theme changes. | 56 // force invalidate the layout on theme changes. |
57 views::LabelButton* owning_button_; | 57 views::LabelButton* owning_button_; |
58 | 58 |
59 // Since we don't want to expose the concept of whether we're using a GTK | 59 // Since we don't want to expose the concept of whether we're using a GTK |
60 // theme down to the cross platform views layer, we keep a normal Border and | 60 // theme down to the cross platform views layer, we keep a normal Border and |
61 // delegate to it whenever we aren't in GTK theme mode. | 61 // delegate to it whenever we aren't in GTK theme mode. |
62 scoped_ptr<views::Border> border_; | 62 scoped_ptr<views::Border> border_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); | 64 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace libgtk2ui | 67 } // namespace libgtk2ui |
68 | 68 |
69 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ | 69 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ |
OLD | NEW |