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

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

Issue 292153008: linux_aura: Fix the insets on LabelButtons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved to a chain of CreateDefaultBorder()s instead. Created 6 years, 7 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 (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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 label_origin.set_x(image_origin.x() + image_size.width() + kSpacing); 259 label_origin.set_x(image_origin.x() + image_size.width() + kSpacing);
260 260
261 image_->SetBoundsRect(gfx::Rect(image_origin, image_size)); 261 image_->SetBoundsRect(gfx::Rect(image_origin, image_size));
262 label_->SetBoundsRect(gfx::Rect(label_origin, label_size)); 262 label_->SetBoundsRect(gfx::Rect(label_origin, label_size));
263 } 263 }
264 264
265 const char* LabelButton::GetClassName() const { 265 const char* LabelButton::GetClassName() const {
266 return kViewClassName; 266 return kViewClassName;
267 } 267 }
268 268
269 scoped_ptr<Border> LabelButton::CreateDefaultBorder() const { 269 scoped_ptr<LabelButtonBorder> LabelButton::CreateDefaultBorder() const {
270 return scoped_ptr<Border>(new LabelButtonBorder(style_)); 270 return scoped_ptr<LabelButtonBorder>(new LabelButtonBorder(style_));
271 } 271 }
272 272
273 void LabelButton::SetBorder(scoped_ptr<Border> border) { 273 void LabelButton::SetBorder(scoped_ptr<Border> border) {
274 border_is_themed_border_ = false; 274 border_is_themed_border_ = false;
275 View::SetBorder(border.Pass()); 275 View::SetBorder(border.Pass());
276 } 276 }
277 277
278 void LabelButton::OnPaint(gfx::Canvas* canvas) { 278 void LabelButton::OnPaint(gfx::Canvas* canvas) {
279 View::OnPaint(canvas); 279 View::OnPaint(canvas);
280 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); 280 Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 void LabelButton::UpdateImage() { 354 void LabelButton::UpdateImage() {
355 image_->SetImage(GetImage(state())); 355 image_->SetImage(GetImage(state()));
356 } 356 }
357 357
358 void LabelButton::UpdateThemedBorder() { 358 void LabelButton::UpdateThemedBorder() {
359 // Don't override borders set by others. 359 // Don't override borders set by others.
360 if (!border_is_themed_border_) 360 if (!border_is_themed_border_)
361 return; 361 return;
362 362
363 scoped_ptr<Border> label_button_border = CreateDefaultBorder(); 363 scoped_ptr<LabelButtonBorder> label_button_border = CreateDefaultBorder();
364 364
365 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 365 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
366 views::LinuxUI* linux_ui = views::LinuxUI::instance(); 366 views::LinuxUI* linux_ui = views::LinuxUI::instance();
367 if (linux_ui) { 367 if (linux_ui) {
368 SetBorder(linux_ui->CreateNativeBorder(this, label_button_border.Pass())); 368 SetBorder(linux_ui->CreateNativeBorder(
369 this, label_button_border.PassAs<Border>()));
369 } else 370 } else
370 #endif 371 #endif
371 { 372 {
372 SetBorder(label_button_border.Pass()); 373 SetBorder(label_button_border.PassAs<Border>());
373 } 374 }
374 375
375 border_is_themed_border_ = true; 376 border_is_themed_border_ = true;
376 } 377 }
377 378
378 void LabelButton::StateChanged() { 379 void LabelButton::StateChanged() {
379 const gfx::Size previous_image_size(image_->GetPreferredSize()); 380 const gfx::Size previous_image_size(image_->GetPreferredSize());
380 UpdateImage(); 381 UpdateImage();
381 const SkColor color = button_state_colors_[state()]; 382 const SkColor color = button_state_colors_[state()];
382 if (state() != STATE_DISABLED && label_->enabled_color() != color) 383 if (state() != STATE_DISABLED && label_->enabled_color() != color)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 return ui::NativeTheme::kNormal; 429 return ui::NativeTheme::kNormal;
429 } 430 }
430 431
431 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 432 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
432 ui::NativeTheme::ExtraParams* params) const { 433 ui::NativeTheme::ExtraParams* params) const {
433 GetExtraParams(params); 434 GetExtraParams(params);
434 return ui::NativeTheme::kHovered; 435 return ui::NativeTheme::kHovered;
435 } 436 }
436 437
437 } // namespace views 438 } // namespace views
OLDNEW
« chrome/browser/ui/views/toolbar/toolbar_button.h ('K') | « ui/views/controls/button/label_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698