OLD | NEW |
---|---|
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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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<Border> 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 Border* default_border = label_button_border.get(); | |
368 SetBorder(linux_ui->CreateNativeBorder(this, label_button_border.Pass())); | 369 SetBorder(linux_ui->CreateNativeBorder(this, label_button_border.Pass())); |
370 // If we're using a system-themed border, make sure the text is legible. | |
371 label_->SetAutoColorReadabilityEnabled(border() != default_border); | |
msw
2014/05/29 19:52:23
Should the label background color be initialized h
| |
369 } else | 372 } else |
370 #endif | 373 #endif |
371 { | 374 { |
372 SetBorder(label_button_border.Pass()); | 375 SetBorder(label_button_border.Pass()); |
373 } | 376 } |
374 | 377 |
375 border_is_themed_border_ = true; | 378 border_is_themed_border_ = true; |
376 } | 379 } |
377 | 380 |
378 void LabelButton::StateChanged() { | 381 void LabelButton::StateChanged() { |
382 if (border_is_themed_border_) { | |
383 label_->SetBackgroundColor(GetNativeTheme()->GetSystemColor( | |
msw
2014/05/29 02:03:55
Does this work right if gfx::IsInvertedColorScheme
Evan Stade
2014/05/29 19:04:45
Do I need a Windows machine to test that? Is the b
msw
2014/05/29 19:52:23
Yeah, IsInvertedColorScheme is only supported on W
| |
384 state() == STATE_HOVERED ? | |
385 ui::NativeTheme::kColorId_ButtonHoverBackgroundColor : | |
386 ui::NativeTheme::kColorId_ButtonBackgroundColor)); | |
387 } | |
388 | |
379 const gfx::Size previous_image_size(image_->GetPreferredSize()); | 389 const gfx::Size previous_image_size(image_->GetPreferredSize()); |
380 UpdateImage(); | 390 UpdateImage(); |
381 const SkColor color = button_state_colors_[state()]; | 391 const SkColor color = button_state_colors_[state()]; |
382 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 392 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
383 label_->SetEnabledColor(color); | 393 label_->SetEnabledColor(color); |
384 label_->SetEnabled(state() != STATE_DISABLED); | 394 label_->SetEnabled(state() != STATE_DISABLED); |
385 if (image_->GetPreferredSize() != previous_image_size) | 395 if (image_->GetPreferredSize() != previous_image_size) |
386 Layout(); | 396 Layout(); |
387 } | 397 } |
388 | 398 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 return ui::NativeTheme::kNormal; | 438 return ui::NativeTheme::kNormal; |
429 } | 439 } |
430 | 440 |
431 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 441 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
432 ui::NativeTheme::ExtraParams* params) const { | 442 ui::NativeTheme::ExtraParams* params) const { |
433 GetExtraParams(params); | 443 GetExtraParams(params); |
434 return ui::NativeTheme::kHovered; | 444 return ui::NativeTheme::kHovered; |
435 } | 445 } |
436 | 446 |
437 } // namespace views | 447 } // namespace views |
OLD | NEW |