Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Unified Diff: chrome/browser/ui/libgtk2ui/gtk2_border.cc

Issue 1234223005: Initial gtk3 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gtk2 colors Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/libgtk2ui/gtk2_border.cc
diff --git a/chrome/browser/ui/libgtk2ui/gtk2_border.cc b/chrome/browser/ui/libgtk2ui/gtk2_border.cc
index 8839f0b534fae15067f478470dd027fcc2170643..0c27c8706bca52f10bed365157dc4164c6138160 100644
--- a/chrome/browser/ui/libgtk2ui/gtk2_border.cc
+++ b/chrome/browser/ui/libgtk2ui/gtk2_border.cc
@@ -26,46 +26,6 @@ using views::NativeThemeDelegate;
namespace libgtk2ui {
-namespace {
-
-const int kNumberOfFocusedStates = 2;
-
-class ButtonImageSkiaSource : public gfx::ImageSkiaSource {
- public:
- ButtonImageSkiaSource(const Gtk2UI* gtk2_ui,
- const GtkStateType state,
- const bool focused,
- const bool call_to_action,
- const gfx::Size& size)
- : gtk2_ui_(gtk2_ui),
- state_(state),
- focused_(focused),
- call_to_action_(call_to_action),
- size_(size) {
- }
-
- ~ButtonImageSkiaSource() override {}
-
- gfx::ImageSkiaRep GetImageForScale(float scale) override {
- int w = size_.width() * scale;
- int h = size_.height() * scale;
- return gfx::ImageSkiaRep(
- gtk2_ui_->DrawGtkButtonBorder(state_, focused_, call_to_action_, w, h),
- scale);
- }
-
- private:
- const Gtk2UI* gtk2_ui_;
- const GtkStateType state_;
- const bool focused_;
- const bool call_to_action_;
- const gfx::Size size_;
-
- DISALLOW_COPY_AND_ASSIGN(ButtonImageSkiaSource);
-};
-
-} // namespace
-
Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui,
views::LabelButton* owning_button,
scoped_ptr<views::LabelButtonBorder> border)
@@ -119,7 +79,7 @@ gfx::Size Gtk2Border::GetMinimumSize() const {
void Gtk2Border::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
DCHECK_EQ(observed_theme, NativeThemeGtk2::instance());
- for (int i = 0; i < kNumberOfFocusedStates; ++i) {
+ for (int i = 0; i < 2; ++i) {
for (int j = 0; j < views::Button::STATE_COUNT; ++j) {
button_images_[i][j] = gfx::ImageSkia();
}
@@ -141,16 +101,10 @@ void Gtk2Border::PaintState(const ui::NativeTheme::State state,
gfx::ImageSkia* image = &button_images_[focused][views_state];
if (image->isNull() || image->size() != rect.size()) {
- bool call_to_action = owning_button_->GetClassName() ==
knthzh 2015/08/21 03:21:47 Okay, I put in some test code that sets state to k
Evan Stade 2015/08/21 15:24:17 yes, it's still used: https://code.google.com/p/c
- views::BlueButton::kViewClassName;
- GtkStateType gtk_state = GetGtkState(state);
- *image = gfx::ImageSkia(
- new ButtonImageSkiaSource(gtk2_ui_,
- gtk_state,
- focused,
- call_to_action,
- rect.size()),
- rect.size());
+ *image = gfx::ImageSkia::CreateFrom1xBitmap(
+ gtk2_ui_->DrawGtkButtonBorder(state,
+ rect.width(),
+ rect.height()));
}
canvas->DrawImageInt(*image, rect.x(), rect.y());
}

Powered by Google App Engine
This is Rietveld 408576698