Chromium Code Reviews| 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 #include "chrome/browser/ui/libgtk2ui/gtk2_border.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_border.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" | 9 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
| 10 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 10 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 namespace libgtk2ui { | 27 namespace libgtk2ui { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const int kNumberOfFocusedStates = 2; | 31 const int kNumberOfFocusedStates = 2; |
| 32 | 32 |
| 33 class ButtonImageSkiaSource : public gfx::ImageSkiaSource { | 33 class ButtonImageSkiaSource : public gfx::ImageSkiaSource { |
| 34 public: | 34 public: |
| 35 ButtonImageSkiaSource(const Gtk2UI* gtk2_ui, | 35 ButtonImageSkiaSource(const Gtk2UI* gtk2_ui, |
| 36 const GtkStateType state, | 36 const GtkStateFlags state, |
| 37 const bool focused, | |
| 38 const bool call_to_action, | |
| 39 const gfx::Size& size) | 37 const gfx::Size& size) |
| 40 : gtk2_ui_(gtk2_ui), | 38 : gtk2_ui_(gtk2_ui), |
| 41 state_(state), | 39 state_(state), |
| 42 focused_(focused), | |
| 43 call_to_action_(call_to_action), | |
| 44 size_(size) { | 40 size_(size) { |
| 45 } | 41 } |
| 46 | 42 |
| 47 ~ButtonImageSkiaSource() override {} | 43 ~ButtonImageSkiaSource() override {} |
| 48 | 44 |
| 49 gfx::ImageSkiaRep GetImageForScale(float scale) override { | 45 gfx::ImageSkiaRep GetImageForScale(float scale) override { |
| 50 int w = size_.width() * scale; | 46 int w = size_.width() * scale; |
| 51 int h = size_.height() * scale; | 47 int h = size_.height() * scale; |
| 52 return gfx::ImageSkiaRep( | 48 return gfx::ImageSkiaRep( |
| 53 gtk2_ui_->DrawGtkButtonBorder(state_, focused_, call_to_action_, w, h), | 49 gtk2_ui_->DrawGtkButtonBorder(state_, w, h), |
| 54 scale); | 50 scale); |
| 55 } | 51 } |
| 56 | 52 |
| 57 private: | 53 private: |
| 58 const Gtk2UI* gtk2_ui_; | 54 const Gtk2UI* gtk2_ui_; |
| 59 const GtkStateType state_; | 55 const GtkStateFlags state_; |
| 60 const bool focused_; | |
| 61 const bool call_to_action_; | |
| 62 const gfx::Size size_; | 56 const gfx::Size size_; |
| 63 | 57 |
| 64 DISALLOW_COPY_AND_ASSIGN(ButtonImageSkiaSource); | 58 DISALLOW_COPY_AND_ASSIGN(ButtonImageSkiaSource); |
| 65 }; | 59 }; |
| 66 | 60 |
| 67 } // namespace | 61 } // namespace |
| 68 | 62 |
| 69 Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui, | 63 Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui, |
| 70 views::LabelButton* owning_button, | 64 views::LabelButton* owning_button, |
| 71 scoped_ptr<views::LabelButtonBorder> border) | 65 scoped_ptr<views::LabelButtonBorder> border) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 const gfx::Rect& rect, | 129 const gfx::Rect& rect, |
| 136 gfx::Canvas* canvas) { | 130 gfx::Canvas* canvas) { |
| 137 bool focused = extra.button.is_focused; | 131 bool focused = extra.button.is_focused; |
| 138 Button::ButtonState views_state = Button::GetButtonStateFrom(state); | 132 Button::ButtonState views_state = Button::GetButtonStateFrom(state); |
| 139 | 133 |
| 140 if (border_->GetPainter(focused, views_state) || | 134 if (border_->GetPainter(focused, views_state) || |
| 141 (focused && border_->GetPainter(false, views_state))) { | 135 (focused && border_->GetPainter(false, views_state))) { |
| 142 gfx::ImageSkia* image = &button_images_[focused][views_state]; | 136 gfx::ImageSkia* image = &button_images_[focused][views_state]; |
| 143 | 137 |
| 144 if (image->isNull() || image->size() != rect.size()) { | 138 if (image->isNull() || image->size() != rect.size()) { |
| 145 bool call_to_action = owning_button_->GetClassName() == | 139 int gtk_state = GetGtkState(state); |
| 146 views::BlueButton::kViewClassName; | 140 if (focused) |
|
Elliot Glaysher
2015/07/20 19:31:40
So while I personally don't like this feature, thi
knthzh
2015/07/21 15:48:27
Okay. Where are the BlueButtons on the Chrome UI?
| |
| 147 GtkStateType gtk_state = GetGtkState(state); | 141 gtk_state |= GTK_STATE_FLAG_FOCUSED; |
| 142 | |
| 148 *image = gfx::ImageSkia( | 143 *image = gfx::ImageSkia( |
| 149 new ButtonImageSkiaSource(gtk2_ui_, | 144 new ButtonImageSkiaSource(gtk2_ui_, |
| 150 gtk_state, | 145 (GtkStateFlags)gtk_state, |
| 151 focused, | |
| 152 call_to_action, | |
| 153 rect.size()), | 146 rect.size()), |
| 154 rect.size()); | 147 rect.size()); |
| 155 } | 148 } |
| 156 canvas->DrawImageInt(*image, rect.x(), rect.y()); | 149 canvas->DrawImageInt(*image, rect.x(), rect.y()); |
| 157 } | 150 } |
| 158 } | 151 } |
| 159 | 152 |
| 160 } // namespace libgtk2ui | 153 } // namespace libgtk2ui |
| OLD | NEW |