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 "base/scoped_observer.h" |
9 #include "ui/gfx/image/image_skia.h" | 9 #include "ui/gfx/image/image_skia.h" |
10 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 class Border; | 21 class Border; |
22 } | 22 } |
23 | 23 |
24 namespace libgtk2ui { | 24 namespace libgtk2ui { |
25 class Gtk2UI; | 25 class Gtk2UI; |
26 | 26 |
27 // 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. |
28 class Gtk2Border : public views::Border, public ui::NativeThemeObserver { | 28 class Gtk2Border : public views::Border, public ui::NativeThemeObserver { |
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 virtual ~Gtk2Border(); | 33 virtual ~Gtk2Border(); |
33 | 34 |
34 // Overridden from views::Border: | 35 // Overridden from views::Border: |
35 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; | 36 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; |
36 virtual gfx::Insets GetInsets() const OVERRIDE; | 37 virtual gfx::Insets GetInsets() const OVERRIDE; |
37 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 38 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
38 | 39 |
39 // Overridden from views::NativeThemeChangeObserver: | 40 // Overridden from views::NativeThemeChangeObserver: |
40 virtual void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) OVERRIDE; | 41 virtual void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) OVERRIDE; |
41 | 42 |
42 private: | 43 private: |
43 void PaintState(const ui::NativeTheme::State state, | 44 void PaintState(const ui::NativeTheme::State state, |
44 const ui::NativeTheme::ExtraParams& extra, | 45 const ui::NativeTheme::ExtraParams& extra, |
45 const gfx::Rect& rect, | 46 const gfx::Rect& rect, |
46 gfx::Canvas* canvas); | 47 gfx::Canvas* canvas); |
47 | 48 |
48 bool ShouldDrawBorder(bool focused, views::Button::ButtonState state); | 49 bool ShouldDrawBorder(bool focused, views::Button::ButtonState state); |
49 | 50 |
50 Gtk2UI* gtk2_ui_; | 51 Gtk2UI* gtk2_ui_; |
51 | 52 |
52 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; | 53 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; |
53 | 54 |
54 // 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 |
55 // force invalidate the layout on theme changes. | 56 // force invalidate the layout on theme changes. |
56 views::LabelButton* owning_button_; | 57 views::LabelButton* owning_button_; |
57 | 58 |
| 59 // The views::Border that we are replacing in native mode. We keep track of |
| 60 // this for inset information. |
| 61 scoped_ptr<views::Border> border_; |
| 62 |
58 ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> observer_manager_; | 63 ScopedObserver<ui::NativeTheme, ui::NativeThemeObserver> observer_manager_; |
59 | 64 |
60 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); | 65 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); |
61 }; | 66 }; |
62 | 67 |
63 } // namespace libgtk2ui | 68 } // namespace libgtk2ui |
64 | 69 |
65 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ | 70 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ |
OLD | NEW |