Commit 0919936b authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Remove views::BlueButton

This class is superseded by MdTextButton and was only used in views
example files.

Bug: None
Change-Id: Ic8740ff51e87bea5e753467ca017db181db76c30
Reviewed-on: https://chromium-review.googlesource.com/c/1298639Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603150}
parent 38dbc5e3
......@@ -67,7 +67,6 @@
#include "ui/gfx/x/x11_types.h"
#include "ui/native_theme/native_theme.h"
#include "ui/shell_dialogs/select_file_policy.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/linux_ui/device_scale_factor_observer.h"
......@@ -604,54 +603,41 @@ std::unique_ptr<views::Border> GtkUi::CreateNativeBorder(
static struct {
const char* idr;
const char* idr_blue;
bool focus;
views::Button::ButtonState state;
} const paintstate[] = {
{
"IDR_BUTTON_NORMAL", "IDR_BLUE_BUTTON_NORMAL", false,
views::Button::STATE_NORMAL,
"IDR_BUTTON_NORMAL", false, views::Button::STATE_NORMAL,
},
{
"IDR_BUTTON_HOVER", "IDR_BLUE_BUTTON_HOVER", false,
views::Button::STATE_HOVERED,
"IDR_BUTTON_HOVER", false, views::Button::STATE_HOVERED,
},
{
"IDR_BUTTON_PRESSED", "IDR_BLUE_BUTTON_PRESSED", false,
views::Button::STATE_PRESSED,
"IDR_BUTTON_PRESSED", false, views::Button::STATE_PRESSED,
},
{
"IDR_BUTTON_DISABLED", "IDR_BLUE_BUTTON_DISABLED", false,
views::Button::STATE_DISABLED,
"IDR_BUTTON_DISABLED", false, views::Button::STATE_DISABLED,
},
{
"IDR_BUTTON_FOCUSED_NORMAL", "IDR_BLUE_BUTTON_FOCUSED_NORMAL", true,
views::Button::STATE_NORMAL,
"IDR_BUTTON_FOCUSED_NORMAL", true, views::Button::STATE_NORMAL,
},
{
"IDR_BUTTON_FOCUSED_HOVER", "IDR_BLUE_BUTTON_FOCUSED_HOVER", true,
views::Button::STATE_HOVERED,
"IDR_BUTTON_FOCUSED_HOVER", true, views::Button::STATE_HOVERED,
},
{
"IDR_BUTTON_FOCUSED_PRESSED", "IDR_BLUE_BUTTON_FOCUSED_PRESSED", true,
views::Button::STATE_PRESSED,
"IDR_BUTTON_FOCUSED_PRESSED", true, views::Button::STATE_PRESSED,
},
{
"IDR_BUTTON_DISABLED", "IDR_BLUE_BUTTON_DISABLED", true,
views::Button::STATE_DISABLED,
"IDR_BUTTON_DISABLED", true, views::Button::STATE_DISABLED,
},
};
bool is_blue =
owning_button->GetClassName() == views::BlueButton::kViewClassName;
for (unsigned i = 0; i < arraysize(paintstate); i++) {
std::string idr = is_blue ? paintstate[i].idr_blue : paintstate[i].idr;
gtk_border->SetPainter(
paintstate[i].focus, paintstate[i].state,
border->PaintsButtonState(paintstate[i].focus, paintstate[i].state)
? std::make_unique<GtkButtonPainter>(idr)
? std::make_unique<GtkButtonPainter>(paintstate[i].idr)
: nullptr);
}
......
......@@ -191,25 +191,6 @@ SkColor SkColorFromColorId(ui::NativeTheme::ColorId color_id) {
case ui::NativeTheme::kColorId_ButtonPressedShade:
return SK_ColorTRANSPARENT;
// BlueButton
case ui::NativeTheme::kColorId_BlueButtonEnabledColor:
return GetFgColor(
"GtkButton#button.text-button.default.suggested-action GtkLabel");
case ui::NativeTheme::kColorId_BlueButtonDisabledColor:
return GetFgColor(
"GtkButton#button.text-button.default.suggested-action:disabled "
"GtkLabel");
case ui::NativeTheme::kColorId_BlueButtonHoverColor:
return GetFgColor(
"GtkButton#button.text-button.default.suggested-action:hover "
"GtkLabel");
case ui::NativeTheme::kColorId_BlueButtonPressedColor:
return GetFgColor(
"GtkButton#button.text-button.default.suggested-action:hover:active "
"GtkLabel");
case ui::NativeTheme::kColorId_BlueButtonShadowColor:
return SK_ColorTRANSPARENT;
// ProminentButton
case ui::NativeTheme::kColorId_ProminentButtonColor:
return GetBgColor(
......
......@@ -24,7 +24,6 @@
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
......
......@@ -27,7 +27,6 @@
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/bubble/tooltip_icon.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/styled_label.h"
......
......@@ -29,7 +29,6 @@
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/bubble/tooltip_icon.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/separator.h"
......
......@@ -27,7 +27,6 @@
#include "ui/base/ui_features.h"
#include "ui/gfx/image/image.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/image_view.h"
......
......@@ -91,7 +91,6 @@
#include "ui/gfx/text_elider.h"
#include "ui/native_theme/common_theme.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/label_button_border.h"
......
......@@ -18,7 +18,6 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/common/result_codes.h"
#include "content/public/test/browser_test_utils.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/widget/widget.h"
......
......@@ -41,7 +41,6 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/md_text_button.h"
......
......@@ -90,14 +90,6 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
case NativeTheme::kColorId_ButtonEnabledColor:
case NativeTheme::kColorId_ButtonHoverColor:
return kButtonEnabledColor;
// TODO(estade): remove the BlueButton colors.
case NativeTheme::kColorId_BlueButtonEnabledColor:
case NativeTheme::kColorId_BlueButtonDisabledColor:
case NativeTheme::kColorId_BlueButtonPressedColor:
case NativeTheme::kColorId_BlueButtonHoverColor:
return SK_ColorWHITE;
case NativeTheme::kColorId_BlueButtonShadowColor:
return SkColorSetRGB(0x53, 0x8C, 0xEA);
case NativeTheme::kColorId_ProminentButtonColor:
return gfx::kGoogleBlue500;
case NativeTheme::kColorId_TextOnProminentButtonColor:
......
......@@ -303,11 +303,6 @@ class NATIVE_THEME_EXPORT NativeTheme {
kColorId_ButtonDisabledColor,
kColorId_ButtonHoverColor,
kColorId_ButtonPressedShade,
kColorId_BlueButtonEnabledColor,
kColorId_BlueButtonDisabledColor,
kColorId_BlueButtonPressedColor,
kColorId_BlueButtonHoverColor,
kColorId_BlueButtonShadowColor,
kColorId_ProminentButtonColor,
kColorId_TextOnProminentButtonColor,
// MenuItem
......
......@@ -82,11 +82,6 @@ SkColor NativeThemeDarkAura::GetSystemColor(ColorId color_id) const {
case kColorId_UnfocusedBorderColor:
case kColorId_ButtonDisabledColor:
case kColorId_ButtonHoverColor:
case kColorId_BlueButtonEnabledColor:
case kColorId_BlueButtonDisabledColor:
case kColorId_BlueButtonPressedColor:
case kColorId_BlueButtonHoverColor:
case kColorId_BlueButtonShadowColor:
case kColorId_EnabledMenuItemForegroundColor:
case kColorId_DisabledMenuItemForegroundColor:
case kColorId_SelectedMenuItemForegroundColor:
......
......@@ -96,7 +96,6 @@ jumbo_component("views") {
"context_menu_controller.h",
"controls/animated_icon_view.h",
"controls/animated_image_view.h",
"controls/button/blue_button.h",
"controls/button/button.h",
"controls/button/checkbox.h",
"controls/button/image_button.h",
......@@ -295,7 +294,6 @@ jumbo_component("views") {
"color_chooser/color_chooser_view.cc",
"controls/animated_icon_view.cc",
"controls/animated_image_view.cc",
"controls/button/blue_button.cc",
"controls/button/button.cc",
"controls/button/checkbox.cc",
"controls/button/image_button.cc",
......@@ -970,7 +968,6 @@ source_set("views_unittests_sources") {
"cocoa/bridged_native_widget_unittest.mm",
"cocoa/cocoa_mouse_capture_unittest.mm",
"cocoa/drag_drop_client_mac_unittest.mm",
"controls/button/blue_button_unittest.cc",
"controls/button/button_unittest.cc",
"controls/button/checkbox_unittest.cc",
"controls/button/image_button_factory_unittest.cc",
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/controls/button/blue_button.h"
#include <utility>
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/resources/grit/views_resources.h"
namespace views {
// static
const char BlueButton::kViewClassName[] = "views/BlueButton";
BlueButton::BlueButton(ButtonListener* listener, const base::string16& text)
: LabelButton(listener, text) {
// Inherit STYLE_BUTTON insets, minimum size, alignment, etc.
SetStyleDeprecated(STYLE_BUTTON);
UpdateThemedBorder();
}
BlueButton::~BlueButton() {}
void BlueButton::ResetColorsFromNativeTheme() {
LabelButton::ResetColorsFromNativeTheme();
if (!color_utils::IsInvertedColorScheme()) {
SetTextColor(STATE_NORMAL, GetNativeTheme()->
GetSystemColor(ui::NativeTheme::kColorId_BlueButtonEnabledColor));
SetTextColor(STATE_HOVERED, GetNativeTheme()->
GetSystemColor(ui::NativeTheme::kColorId_BlueButtonHoverColor));
SetTextColor(STATE_PRESSED, GetNativeTheme()->
GetSystemColor(ui::NativeTheme::kColorId_BlueButtonPressedColor));
SetTextColor(STATE_DISABLED, GetNativeTheme()->
GetSystemColor(ui::NativeTheme::kColorId_BlueButtonDisabledColor));
label()->SetShadows(gfx::ShadowValues(
1, gfx::ShadowValue(
gfx::Vector2d(0, 1), 0,
GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_BlueButtonShadowColor))));
}
}
const char* BlueButton::GetClassName() const {
return BlueButton::kViewClassName;
}
std::unique_ptr<LabelButtonBorder> BlueButton::CreateDefaultBorder() const {
// Insets for splitting the images.
const gfx::Insets insets(5);
std::unique_ptr<LabelButtonAssetBorder> button_border(
new LabelButtonAssetBorder(style()));
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
button_border->SetPainter(false, STATE_NORMAL, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_NORMAL), insets));
button_border->SetPainter(false, STATE_HOVERED, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_HOVER), insets));
button_border->SetPainter(false, STATE_PRESSED, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_PRESSED), insets));
button_border->SetPainter(false, STATE_DISABLED, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets));
button_border->SetPainter(true, STATE_NORMAL, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_NORMAL), insets));
button_border->SetPainter(true, STATE_HOVERED, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_HOVER), insets));
button_border->SetPainter(true, STATE_PRESSED, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_FOCUSED_PRESSED), insets));
button_border->SetPainter(true, STATE_DISABLED, Painter::CreateImagePainter(
*rb.GetImageSkiaNamed(IDR_BLUE_BUTTON_DISABLED), insets));
return std::move(button_border);
}
} // namespace views
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_CONTROLS_BUTTON_BLUE_BUTTON_H_
#define UI_VIEWS_CONTROLS_BUTTON_BLUE_BUTTON_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "ui/views/controls/button/label_button.h"
namespace views {
// A class representing a blue button.
class VIEWS_EXPORT BlueButton : public LabelButton {
public:
static const char kViewClassName[];
BlueButton(ButtonListener* listener, const base::string16& text);
~BlueButton() override;
private:
// Overridden from LabelButton:
void ResetColorsFromNativeTheme() override;
const char* GetClassName() const override;
std::unique_ptr<LabelButtonBorder> CreateDefaultBorder() const override;
DISALLOW_COPY_AND_ASSIGN(BlueButton);
};
} // namespace views
#endif // UI_VIEWS_CONTROLS_BUTTON_BLUE_BUTTON_H_
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/controls/button/blue_button.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "cc/paint/skia_paint_canvas.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/skia_util.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/test/widget_test.h"
namespace views {
using BlueButtonTest = test::WidgetTest;
TEST_F(BlueButtonTest, Border) {
// The buttons must be added to a Widget so that borders are correctly
// applied once the NativeTheme is determined.
Widget* widget = CreateTopLevelPlatformWidget();
// Compared to a normal LabelButton...
LabelButton* button = new LabelButton(nullptr, base::ASCIIToUTF16("foo"));
EXPECT_EQ(Button::STYLE_TEXTBUTTON, button->style());
// Focus painter by default.
EXPECT_TRUE(button->focus_painter_.get());
// Switch to the same style as BlueButton for a more compelling comparison.
button->SetStyleDeprecated(Button::STYLE_BUTTON);
EXPECT_EQ(Button::STYLE_BUTTON, button->style());
EXPECT_FALSE(button->focus_painter_.get());
widget->GetContentsView()->AddChildView(button);
button->SizeToPreferredSize();
SkBitmap button_bitmap;
button_bitmap.allocN32Pixels(button->size().width(), button->size().height(),
true /* opaque */);
cc::SkiaPaintCanvas button_paint_canvas(button_bitmap);
gfx::Canvas button_canvas(&button_paint_canvas, 1.f);
button->border()->Paint(*button, &button_canvas);
// ... a special blue border should be used.
BlueButton* blue_button = new BlueButton(nullptr, base::ASCIIToUTF16("foo"));
EXPECT_EQ(Button::STYLE_BUTTON, blue_button->style());
EXPECT_FALSE(blue_button->focus_painter_.get());
widget->GetContentsView()->AddChildView(blue_button);
blue_button->SizeToPreferredSize();
SkBitmap blue_button_bitmap;
blue_button_bitmap.allocN32Pixels(blue_button->size().width(),
blue_button->size().height(),
true /* opaque */);
cc::SkiaPaintCanvas blue_button_paint_canvas(blue_button_bitmap);
gfx::Canvas blue_button_canvas(&blue_button_paint_canvas, 1.f);
blue_button->border()->Paint(*blue_button, &blue_button_canvas);
EXPECT_EQ(button->GetText(), blue_button->GetText());
EXPECT_EQ(button->size(), blue_button->size());
EXPECT_FALSE(gfx::BitmapsAreEqual(button_bitmap, blue_button_bitmap));
widget->CloseNow();
}
} // namespace views
......@@ -15,7 +15,6 @@
#include "ui/native_theme/native_theme.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_impl.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/label_button.h"
......
......@@ -17,7 +17,6 @@
#include "ui/views/animation/ink_drop_painted_layer_delegates.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/painter.h"
......
......@@ -9,7 +9,6 @@
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/image/image.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/md_text_button.h"
......@@ -58,8 +57,6 @@ void ButtonExample::CreateExampleView(View* container) {
disabled_button_->SetState(Button::STATE_DISABLED);
container->AddChildView(disabled_button_);
container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button")));
md_button_ =
MdTextButton::Create(this, base::ASCIIToUTF16("Material design"));
container->AddChildView(md_button_);
......
......@@ -22,13 +22,6 @@
<structure type="chrome_scaled_image" name="IDR_BUTTON_HOVER" file="common/button_hover.png" />
<structure type="chrome_scaled_image" name="IDR_BUTTON_NORMAL" file="common/button.png" />
<structure type="chrome_scaled_image" name="IDR_BUTTON_PRESSED" file="common/button_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_BLUE_BUTTON_DISABLED" file="common/blue_button_inactive.png" />
<structure type="chrome_scaled_image" name="IDR_BLUE_BUTTON_FOCUSED_HOVER" file="common/blue_button_focused_hover.png" />
<structure type="chrome_scaled_image" name="IDR_BLUE_BUTTON_FOCUSED_NORMAL" file="common/blue_button_focused.png" />
<structure type="chrome_scaled_image" name="IDR_BLUE_BUTTON_FOCUSED_PRESSED" file="common/blue_button_focused_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_BLUE_BUTTON_HOVER" file="common/blue_button_hover.png" />
<structure type="chrome_scaled_image" name="IDR_BLUE_BUTTON_NORMAL" file="common/blue_button.png" />
<structure type="chrome_scaled_image" name="IDR_BLUE_BUTTON_PRESSED" file="common/blue_button_pressed.png" />
<structure type="chrome_scaled_image" name="IDR_CHECKBOX" file="common/checkbox.png" />
<structure type="chrome_scaled_image" name="IDR_CHECKBOX_CHECKED" file="common/checkbox_checked.png" />
<structure type="chrome_scaled_image" name="IDR_CHECKBOX_CHECKED_DISABLED" file="common/checkbox_checked_inactive.png" />
......
......@@ -10,7 +10,6 @@
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/blue_button.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/image_button.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment