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

Side by Side Diff: ui/views/controls/button/label_button.cc

Issue 243703009: Linux Aura: Use appropriate button style depending on aura/gtk NativeTheme (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updat 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_ui.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/controls/button/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/base/resource/resource_bundle.h" 9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/animation/throb_animation.h" 10 #include "ui/gfx/animation/throb_animation.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets( 158 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(
159 gfx::Insets(3, 3, 3, 3))); 159 gfx::Insets(3, 3, 3, 3)));
160 } 160 }
161 if (style == STYLE_BUTTON) { 161 if (style == STYLE_BUTTON) {
162 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 162 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
163 SetFocusable(true); 163 SetFocusable(true);
164 } 164 }
165 if (style == STYLE_BUTTON) 165 if (style == STYLE_BUTTON)
166 set_min_size(gfx::Size(70, 33)); 166 set_min_size(gfx::Size(70, 33));
167 167
168 ResetColorsFromNativeTheme(); 168 OnNativeThemeChanged(GetNativeTheme());
169
170 UpdateThemedBorder(scoped_ptr<Border>(new LabelButtonBorder(style_)));
171
172 // Invalidate the layout to pickup the new insets from the border.
173 InvalidateLayout();
174 } 169 }
175 170
176 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { 171 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) {
177 focus_painter_ = focus_painter.Pass(); 172 focus_painter_ = focus_painter.Pass();
178 } 173 }
179 174
180 gfx::Size LabelButton::GetPreferredSize() { 175 gfx::Size LabelButton::GetPreferredSize() {
181 // Use a temporary label copy for sizing to avoid calculation side-effects. 176 // Use a temporary label copy for sizing to avoid calculation side-effects.
182 Label label(GetText(), cached_normal_font_list_); 177 Label label(GetText(), cached_normal_font_list_);
183 label.SetMultiLine(GetTextMultiLine()); 178 label.SetMultiLine(GetTextMultiLine());
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if (image_->GetPreferredSize() != previous_image_size) 367 if (image_->GetPreferredSize() != previous_image_size)
373 Layout(); 368 Layout();
374 } 369 }
375 370
376 void LabelButton::ChildPreferredSizeChanged(View* child) { 371 void LabelButton::ChildPreferredSizeChanged(View* child) {
377 PreferredSizeChanged(); 372 PreferredSizeChanged();
378 } 373 }
379 374
380 void LabelButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { 375 void LabelButton::OnNativeThemeChanged(const ui::NativeTheme* theme) {
381 ResetColorsFromNativeTheme(); 376 ResetColorsFromNativeTheme();
377 UpdateThemedBorder(scoped_ptr<Border>(new LabelButtonBorder(style_)));
378 // Invalidate the layout to pickup the new insets from the border.
379 InvalidateLayout();
382 } 380 }
383 381
384 ui::NativeTheme::Part LabelButton::GetThemePart() const { 382 ui::NativeTheme::Part LabelButton::GetThemePart() const {
385 return ui::NativeTheme::kPushButton; 383 return ui::NativeTheme::kPushButton;
386 } 384 }
387 385
388 gfx::Rect LabelButton::GetThemePaintRect() const { 386 gfx::Rect LabelButton::GetThemePaintRect() const {
389 return GetLocalBounds(); 387 return GetLocalBounds();
390 } 388 }
391 389
(...skipping 20 matching lines...) Expand all
412 return ui::NativeTheme::kNormal; 410 return ui::NativeTheme::kNormal;
413 } 411 }
414 412
415 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 413 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
416 ui::NativeTheme::ExtraParams* params) const { 414 ui::NativeTheme::ExtraParams* params) const {
417 GetExtraParams(params); 415 GetExtraParams(params);
418 return ui::NativeTheme::kHovered; 416 return ui::NativeTheme::kHovered;
419 } 417 }
420 418
421 } // namespace views 419 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/gtk2_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698