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