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

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: Add comments about where the smaller insets come from. 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 }
272
273 void LabelButton::SetDefaultBorderInsets(views::LabelButtonBorder* border) {
271 } 274 }
272 275
273 void LabelButton::SetBorder(scoped_ptr<Border> border) { 276 void LabelButton::SetBorder(scoped_ptr<Border> border) {
274 border_is_themed_border_ = false; 277 border_is_themed_border_ = false;
275 View::SetBorder(border.Pass()); 278 View::SetBorder(border.Pass());
276 } 279 }
277 280
278 void LabelButton::OnPaint(gfx::Canvas* canvas) { 281 void LabelButton::OnPaint(gfx::Canvas* canvas) {
279 View::OnPaint(canvas); 282 View::OnPaint(canvas);
280 Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); 283 Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 356
354 void LabelButton::UpdateImage() { 357 void LabelButton::UpdateImage() {
355 image_->SetImage(GetImage(state())); 358 image_->SetImage(GetImage(state()));
356 } 359 }
357 360
358 void LabelButton::UpdateThemedBorder() { 361 void LabelButton::UpdateThemedBorder() {
359 // Don't override borders set by others. 362 // Don't override borders set by others.
360 if (!border_is_themed_border_) 363 if (!border_is_themed_border_)
361 return; 364 return;
362 365
363 scoped_ptr<Border> label_button_border = CreateDefaultBorder(); 366 scoped_ptr<LabelButtonBorder> label_button_border = CreateDefaultBorder();
367 SetDefaultBorderInsets(label_button_border.get());
364 368
365 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 369 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
366 views::LinuxUI* linux_ui = views::LinuxUI::instance(); 370 views::LinuxUI* linux_ui = views::LinuxUI::instance();
367 if (linux_ui) { 371 if (linux_ui) {
368 SetBorder(linux_ui->CreateNativeBorder(this, label_button_border.Pass())); 372 SetBorder(linux_ui->CreateNativeBorder(
373 this, label_button_border.PassAs<Border>()));
369 } else 374 } else
370 #endif 375 #endif
371 { 376 {
372 SetBorder(label_button_border.Pass()); 377 SetBorder(label_button_border.PassAs<Border>());
373 } 378 }
374 379
375 border_is_themed_border_ = true; 380 border_is_themed_border_ = true;
376 } 381 }
377 382
378 void LabelButton::StateChanged() { 383 void LabelButton::StateChanged() {
379 const gfx::Size previous_image_size(image_->GetPreferredSize()); 384 const gfx::Size previous_image_size(image_->GetPreferredSize());
380 UpdateImage(); 385 UpdateImage();
381 const SkColor color = button_state_colors_[state()]; 386 const SkColor color = button_state_colors_[state()];
382 if (state() != STATE_DISABLED && label_->enabled_color() != color) 387 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; 433 return ui::NativeTheme::kNormal;
429 } 434 }
430 435
431 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 436 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
432 ui::NativeTheme::ExtraParams* params) const { 437 ui::NativeTheme::ExtraParams* params) const {
433 GetExtraParams(params); 438 GetExtraParams(params);
434 return ui::NativeTheme::kHovered; 439 return ui::NativeTheme::kHovered;
435 } 440 }
436 441
437 } // namespace views 442 } // namespace views
OLDNEW
« chrome/browser/ui/views/toolbar/toolbar_button.cc ('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