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

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

Issue 244893004: Improve some naming (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 "third_party/skia/include/effects/SkLerpXfermode.h" 10 #include "third_party/skia/include/effects/SkLerpXfermode.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 }; 69 };
70 70
71 } // namespace 71 } // namespace
72 72
73 Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui, 73 Gtk2Border::Gtk2Border(Gtk2UI* gtk2_ui,
74 views::LabelButton* owning_button, 74 views::LabelButton* owning_button,
75 scoped_ptr<views::Border> border) 75 scoped_ptr<views::Border> border)
76 : gtk2_ui_(gtk2_ui), 76 : gtk2_ui_(gtk2_ui),
77 owning_button_(owning_button), 77 owning_button_(owning_button),
78 border_(border.Pass()) { 78 border_(border.Pass()) {
79 gtk2_ui_->AddNativeThemeChangeObserver(this); 79 gtk2_ui_->AddSystemThemeChangeObserver(this);
80 } 80 }
81 81
82 Gtk2Border::~Gtk2Border() { 82 Gtk2Border::~Gtk2Border() {
83 gtk2_ui_->RemoveNativeThemeChangeObserver(this); 83 gtk2_ui_->RemoveSystemThemeChangeObserver(this);
84 } 84 }
85 85
86 void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) { 86 void Gtk2Border::Paint(const views::View& view, gfx::Canvas* canvas) {
87 ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); 87 ui::ThemeProvider* provider = owning_button_->GetThemeProvider();
88 if (!provider || !provider->UsingNativeTheme()) { 88 if (!provider || !provider->UsingSystemTheme()) {
89 border_->Paint(view, canvas); 89 border_->Paint(view, canvas);
90 return; 90 return;
91 } 91 }
92 92
93 DCHECK_EQ(&view, owning_button_); 93 DCHECK_EQ(&view, owning_button_);
94 const NativeThemeDelegate* native_theme_delegate = owning_button_; 94 const NativeThemeDelegate* native_theme_delegate = owning_button_;
95 gfx::Rect rect(native_theme_delegate->GetThemePaintRect()); 95 gfx::Rect rect(native_theme_delegate->GetThemePaintRect());
96 ui::NativeTheme::ExtraParams extra; 96 ui::NativeTheme::ExtraParams extra;
97 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); 97 ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra);
98 98
(...skipping 21 matching lines...) Expand all
120 } 120 }
121 121
122 gfx::Insets Gtk2Border::GetInsets() const { 122 gfx::Insets Gtk2Border::GetInsets() const {
123 // TODO(erg): We want to differentiate between buttons on the toolbar and 123 // TODO(erg): We want to differentiate between buttons on the toolbar and
124 // buttons everywhere else. Right now, the only way to do this is to check 124 // buttons everywhere else. Right now, the only way to do this is to check
125 // the style. STYLE_BUTTON is the button style used in dialogs, and 125 // the style. STYLE_BUTTON is the button style used in dialogs, and
126 // STYLE_TEXTUBTTON is the button style used in the toolbar, including all 126 // STYLE_TEXTUBTTON is the button style used in the toolbar, including all
127 // the buttons which are just toolbar images. 127 // the buttons which are just toolbar images.
128 ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); 128 ui::ThemeProvider* provider = owning_button_->GetThemeProvider();
129 if (owning_button_->style() == views::Button::STYLE_BUTTON || 129 if (owning_button_->style() == views::Button::STYLE_BUTTON ||
130 (!provider || !provider->UsingNativeTheme())) 130 (!provider || !provider->UsingSystemTheme()))
131 return border_->GetInsets(); 131 return border_->GetInsets();
132 132
133 // On STYLE_TEXTUBTTON, we want the smaller insets so we can fit the GTK icon 133 // On STYLE_TEXTUBTTON, we want the smaller insets so we can fit the GTK icon
134 // in the toolbar without cutting off the edges of the GTK image. 134 // in the toolbar without cutting off the edges of the GTK image.
135 return gtk2_ui_->GetButtonInsets(); 135 return gtk2_ui_->GetButtonInsets();
136 } 136 }
137 137
138 gfx::Size Gtk2Border::GetMinimumSize() const { 138 gfx::Size Gtk2Border::GetMinimumSize() const {
139 ui::ThemeProvider* provider = owning_button_->GetThemeProvider(); 139 ui::ThemeProvider* provider = owning_button_->GetThemeProvider();
140 if (!provider || !provider->UsingNativeTheme()) 140 if (!provider || !provider->UsingSystemTheme())
141 return border_->GetMinimumSize(); 141 return border_->GetMinimumSize();
142 142
143 gfx::Insets insets = GetInsets(); 143 gfx::Insets insets = GetInsets();
144 return gfx::Size(insets.width(), insets.height()); 144 return gfx::Size(insets.width(), insets.height());
145 } 145 }
146 146
147 void Gtk2Border::OnNativeThemeChanged() { 147 void Gtk2Border::OnSystemThemeChanged() {
148 for (int i = 0; i < kNumberOfFocusedStates; ++i) { 148 for (int i = 0; i < kNumberOfFocusedStates; ++i) {
149 for (int j = 0; j < views::Button::STATE_COUNT; ++j) { 149 for (int j = 0; j < views::Button::STATE_COUNT; ++j) {
150 button_images_[i][j] = gfx::ImageSkia(); 150 button_images_[i][j] = gfx::ImageSkia();
151 } 151 }
152 } 152 }
153 153
154 // Our owning view must have its layout invalidated because the insets could 154 // Our owning view must have its layout invalidated because the insets could
155 // have changed. 155 // have changed.
156 owning_button_->InvalidateLayout(); 156 owning_button_->InvalidateLayout();
157 } 157 }
(...skipping 25 matching lines...) Expand all
183 return true; 183 return true;
184 } else if (owning_button_->style() == Button::STYLE_TEXTBUTTON) { 184 } else if (owning_button_->style() == Button::STYLE_TEXTBUTTON) {
185 return focused == false && (state == Button::STATE_HOVERED || 185 return focused == false && (state == Button::STATE_HOVERED ||
186 state == Button::STATE_PRESSED); 186 state == Button::STATE_PRESSED);
187 } 187 }
188 188
189 return false; 189 return false;
190 } 190 }
191 191
192 } // namespace libgtk2ui 192 } // namespace libgtk2ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698