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

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: Restore change from bad rebase. 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
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_border.h ('k') | chrome/browser/ui/libgtk2ui/gtk2_ui.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 const gfx::Size size_; 67 const gfx::Size size_;
67 68
68 DISALLOW_COPY_AND_ASSIGN(ButtonImageSkiaSource); 69 DISALLOW_COPY_AND_ASSIGN(ButtonImageSkiaSource);
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 : gtk2_ui_(gtk2_ui), 76 : gtk2_ui_(gtk2_ui),
76 owning_button_(owning_button) { 77 owning_button_(owning_button),
77 gtk2_ui_->AddNativeThemeChangeObserver(this); 78 observer_manager_(this) {
79 observer_manager_.Add(NativeThemeGtk2::instance());
78 } 80 }
79 81
80 Gtk2Border::~Gtk2Border() { 82 Gtk2Border::~Gtk2Border() {
81 gtk2_ui_->RemoveNativeThemeChangeObserver(this);
82 } 83 }
83 84
84 void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) { 85 void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) {
85 DCHECK_EQ(&view, owning_button_); 86 DCHECK_EQ(&view, owning_button_);
86 const NativeThemeDelegate* native_theme_delegate = owning_button_; 87 const NativeThemeDelegate* native_theme_delegate = owning_button_;
87 gfx::Rect rect(native_theme_delegate->GetThemePaintRect()); 88 gfx::Rect rect(native_theme_delegate->GetThemePaintRect());
88 ui::NativeTheme::ExtraParams extra; 89 ui::NativeTheme::ExtraParams extra;
89 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); 90 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra);
90 91
91 const gfx::Animation* animation = native_theme_delegate->GetThemeAnimation(); 92 const gfx::Animation* animation = native_theme_delegate->GetThemeAnimation();
(...skipping 23 matching lines...) Expand all
115 // On STYLE_TEXTUBTTON, we want the smaller insets so we can fit the GTK icon 116 // On STYLE_TEXTUBTTON, we want the smaller insets so we can fit the GTK icon
116 // in the toolbar without cutting off the edges of the GTK image. 117 // in the toolbar without cutting off the edges of the GTK image.
117 return gtk2_ui_->GetButtonInsets(); 118 return gtk2_ui_->GetButtonInsets();
118 } 119 }
119 120
120 gfx::Size Gtk2Border::GetMinimumSize() const { 121 gfx::Size Gtk2Border::GetMinimumSize() const {
121 gfx::Insets insets = GetInsets(); 122 gfx::Insets insets = GetInsets();
122 return gfx::Size(insets.width(), insets.height()); 123 return gfx::Size(insets.width(), insets.height());
123 } 124 }
124 125
125 void Gtk2Border::OnNativeThemeChanged() { 126 void Gtk2Border::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
127 DCHECK_EQ(observed_theme, NativeThemeGtk2::instance());
126 for (int i = 0; i < kNumberOfFocusedStates; ++i) { 128 for (int i = 0; i < kNumberOfFocusedStates; ++i) {
127 for (int j = 0; j < views::Button::STATE_COUNT; ++j) { 129 for (int j = 0; j < views::Button::STATE_COUNT; ++j) {
128 button_images_[i][j] = gfx::ImageSkia(); 130 button_images_[i][j] = gfx::ImageSkia();
129 } 131 }
130 } 132 }
131 133
132 // Our owning view must have its layout invalidated because the insets could 134 // Our owning view must have its layout invalidated because the insets could
133 // have changed. 135 // have changed.
134 owning_button_->InvalidateLayout(); 136 owning_button_->InvalidateLayout();
135 } 137 }
(...skipping 25 matching lines...) Expand all
161 return true; 163 return true;
162 } else if (owning_button_->style() == Button::STYLE_TEXTBUTTON) { 164 } else if (owning_button_->style() == Button::STYLE_TEXTBUTTON) {
163 return focused == false && (state == Button::STATE_HOVERED || 165 return focused == false && (state == Button::STATE_HOVERED ||
164 state == Button::STATE_PRESSED); 166 state == Button::STATE_PRESSED);
165 } 167 }
166 168
167 return false; 169 return false;
168 } 170 }
169 171
170 } // namespace libgtk2ui 172 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_border.h ('k') | chrome/browser/ui/libgtk2ui/gtk2_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698