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

Side by Side Diff: chrome/browser/ui/libgtk2ui/gtk2_border.cc

Issue 239093007: Update Windows UI on system color changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make Widget the observer, address additional comments. Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/native_theme_gtk2.h"
10 #include "third_party/skia/include/effects/SkLerpXfermode.h" 11 #include "third_party/skia/include/effects/SkLerpXfermode.h"
11 #include "ui/base/theme_provider.h" 12 #include "ui/base/theme_provider.h"
12 #include "ui/gfx/animation/animation.h" 13 #include "ui/gfx/animation/animation.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/image/image_skia_source.h" 15 #include "ui/gfx/image/image_skia_source.h"
15 #include "ui/gfx/rect.h" 16 #include "ui/gfx/rect.h"
16 #include "ui/gfx/skia_util.h" 17 #include "ui/gfx/skia_util.h"
17 #include "ui/views/controls/button/label_button.h" 18 #include "ui/views/controls/button/label_button.h"
18 #include "ui/views/native_theme_delegate.h" 19 #include "ui/views/native_theme_delegate.h"
19 20
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 }; 70 };
70 71
71 } // namespace 72 } // namespace
72 73
73 Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui, 74 Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui,
74 views::LabelButton* owning_button, 75 views::LabelButton* owning_button,
75 scoped_ptr<views::Border> border) 76 scoped_ptr<views::Border> border)
76 : gtk2_ui_(gtk2_ui), 77 : gtk2_ui_(gtk2_ui),
77 owning_button_(owning_button), 78 owning_button_(owning_button),
78 border_(border.Pass()) { 79 border_(border.Pass()) {
79 gtk2_ui_->AddNativeThemeChangeObserver(this); 80 NativeThemeGtk2::instance()->AddObserver(this);
Evan Stade 2014/04/24 01:14:52 nit: ScopedObserver
msw 2014/04/24 18:32:00 Done.
80 } 81 }
81 82
82 Gtk2Border::~Gtk2Border() { 83 Gtk2Border::~Gtk2Border() {
83 gtk2_ui_->RemoveNativeThemeChangeObserver(this); 84 NativeThemeGtk2::instance()->RemoveObserver(this);
84 } 85 }
85 86
86 void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) { 87 void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) {
87 ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); 88 ui::ThemeProvider* provider = owning_button_->GetThemeProvider();
88 if (!provider || !provider->UsingNativeTheme()) { 89 if (!provider || !provider->UsingNativeTheme()) {
89 border_->Paint(view, canvas); 90 border_->Paint(view, canvas);
90 return; 91 return;
91 } 92 }
92 93
93 DCHECK_EQ(&view, owning_button_); 94 DCHECK_EQ(&view, owning_button_);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 gfx::Size Gtk2Border::GetMinimumSize() const { 139 gfx::Size Gtk2Border::GetMinimumSize() const {
139 ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); 140 ui::ThemeProvider* provider = owning_button_->GetThemeProvider();
140 if (!provider || !provider->UsingNativeTheme()) 141 if (!provider || !provider->UsingNativeTheme())
141 return border_->GetMinimumSize(); 142 return border_->GetMinimumSize();
142 143
143 gfx::Insets insets = GetInsets(); 144 gfx::Insets insets = GetInsets();
144 return gfx::Size(insets.width(), insets.height()); 145 return gfx::Size(insets.width(), insets.height());
145 } 146 }
146 147
147 void Gtk2Border::OnNativeThemeChanged() { 148 void Gtk2Border::OnNativeThemeUpdate() {
148 for (int i = 0; i < kNumberOfFocusedStates; ++i) { 149 for (int i = 0; i < kNumberOfFocusedStates; ++i) {
149 for (int j = 0; j < views::Button::STATE_COUNT; ++j) { 150 for (int j = 0; j < views::Button::STATE_COUNT; ++j) {
150 button_images_[i][j] = gfx::ImageSkia(); 151 button_images_[i][j] = gfx::ImageSkia();
151 } 152 }
152 } 153 }
153 154
154 // Our owning view must have its layout invalidated because the insets could 155 // Our owning view must have its layout invalidated because the insets could
155 // have changed. 156 // have changed.
156 owning_button_->InvalidateLayout(); 157 owning_button_->InvalidateLayout();
157 } 158 }
(...skipping 25 matching lines...) Expand all
183 return true; 184 return true;
184 } else if (owning_button_->style() == Button::STYLE_TEXTBUTTON) { 185 } else if (owning_button_->style() == Button::STYLE_TEXTBUTTON) {
185 return focused == false && (state == Button::STATE_HOVERED || 186 return focused == false && (state == Button::STATE_HOVERED ||
186 state == Button::STATE_PRESSED); 187 state == Button::STATE_PRESSED);
187 } 188 }
188 189
189 return false; 190 return false;
190 } 191 }
191 192
192 } // namespace libgtk2ui 193 } // namespace libgtk2ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698