| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 class Gtk2UI; | 23 class Gtk2UI; |
| 24 | 24 |
| 25 // 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. |
| 26 class Gtk2Border : public views::Border { | 26 class Gtk2Border : public views::Border { |
| 27 public: | 27 public: |
| 28 Gtk2Border(Gtk2UI* gtk2_ui, | 28 Gtk2Border(Gtk2UI* gtk2_ui, |
| 29 views::LabelButton* owning_button, | 29 views::LabelButton* owning_button, |
| 30 scoped_ptr<views::Border> border); | 30 scoped_ptr<views::Border> border); |
| 31 virtual ~Gtk2Border(); | 31 virtual ~Gtk2Border(); |
| 32 | 32 |
| 33 // Called on theme changes. We invalidate the layout, drop our cached images, | 33 // Called on theme changes. We invalidate the layout and drop our cached GTK |
| 34 // and update our GTK state. | 34 // rendered images. |
| 35 void InvalidateAndSetUsesGtk(bool use_gtk); | 35 void InvalidateGtkImages(); |
| 36 | 36 |
| 37 // Overridden from views::Border: | 37 // Overridden from views::Border: |
| 38 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; | 38 virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE; |
| 39 virtual gfx::Insets GetInsets() const OVERRIDE; | 39 virtual gfx::Insets GetInsets() const OVERRIDE; |
| 40 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 40 virtual gfx::Size GetMinimumSize() const 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 bool use_gtk_; | |
| 52 | 51 |
| 53 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; | 52 gfx::ImageSkia button_images_[2][views::Button::STATE_COUNT]; |
| 54 | 53 |
| 55 // 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 |
| 56 // force invalidate the layout on theme changes. | 55 // force invalidate the layout on theme changes. |
| 57 views::LabelButton* owning_button_; | 56 views::LabelButton* owning_button_; |
| 58 | 57 |
| 59 // Since we don't want to expose the concept of whether we're using a GTK | 58 // 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 | 59 // 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. | 60 // delegate to it whenever we aren't in GTK theme mode. |
| 62 scoped_ptr<views::Border> border_; | 61 scoped_ptr<views::Border> border_; |
| 63 | 62 |
| 64 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); | 63 DISALLOW_COPY_AND_ASSIGN(Gtk2Border); |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 } // namespace libgtk2ui | 66 } // namespace libgtk2ui |
| 68 | 67 |
| 69 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ | 68 #endif // CHROME_BROWSER_UI_LIBGTK2UI_GTK2_BORDER_H_ |
| OLD | NEW |