Commit 0fc24d12 authored by estade's avatar estade Committed by Commit bot

Reland f5157480 with fix for compile failure.

```---------------------
Move more vector icons to respective directories and update code to
use gfx::VectorIcon structs instead of the VectorIconId enum.

Also add version of ImageButton::SetImage that takes a const ref image.

BUG=626786
Review-Url: https://codereview.chromium.org/2620613005
```

---------------------

Review-Url: https://codereview.chromium.org/2622893003
Cr-Commit-Position: refs/heads/master@{#442920}
parent 36860c01
......@@ -1342,6 +1342,7 @@ test("ash_unittests") {
"//ash/public/cpp",
"//ash/public/interfaces",
"//ash/resources",
"//ash/resources/vector_icons",
"//ash/test:ash_with_aura_test_support",
"//ash/test:test_support_without_content",
"//ash/touch_hud",
......
......@@ -56,9 +56,10 @@ FrameCaptionButton::~FrameCaptionButton() {}
void FrameCaptionButton::SetImage(CaptionButtonIcon icon,
Animate animate,
gfx::VectorIconId icon_image_id) {
const gfx::VectorIcon& icon_definition) {
gfx::ImageSkia new_icon_image = gfx::CreateVectorIcon(
icon_image_id, use_light_images_ ? SK_ColorWHITE : gfx::kChromeIconGrey);
icon_definition,
use_light_images_ ? SK_ColorWHITE : gfx::kChromeIconGrey);
// The early return is dependent on |animate| because callers use SetImage()
// with ANIMATE_NO to progress the crossfade animation to the end.
......@@ -72,7 +73,7 @@ void FrameCaptionButton::SetImage(CaptionButtonIcon icon,
crossfade_icon_image_ = icon_image_;
icon_ = icon;
icon_image_id_ = icon_image_id;
icon_definition_ = &icon_definition;
icon_image_ = new_icon_image;
if (animate == ANIMATE_YES) {
......
......@@ -15,7 +15,7 @@
namespace gfx {
class SlideAnimation;
enum class VectorIconId;
struct VectorIcon;
}
namespace ash {
......@@ -32,12 +32,12 @@ class ASH_EXPORT FrameCaptionButton : public views::CustomButton {
~FrameCaptionButton() override;
// Sets the image to use to paint the button. If |animate| is ANIMATE_YES,
// the button crossfades to the new visuals. If the image id matches the one
// the button crossfades to the new visuals. If the image matches the one
// currently used by the button and |animate| is ANIMATE_NO, the crossfade
// animation is progressed to the end.
void SetImage(CaptionButtonIcon icon,
Animate animate,
gfx::VectorIconId icon_image_id);
const gfx::VectorIcon& icon_image);
// Returns true if the button is crossfading to new visuals set in
// SetImage().
......@@ -59,8 +59,6 @@ class ASH_EXPORT FrameCaptionButton : public views::CustomButton {
CaptionButtonIcon icon() const { return icon_; }
gfx::VectorIconId icon_image_id() const { return icon_image_id_; }
void set_size(const gfx::Size& size) { size_ = size; }
protected:
......@@ -90,7 +88,7 @@ class ASH_EXPORT FrameCaptionButton : public views::CustomButton {
// The image id (kept for the purposes of testing) and image used to paint the
// button's icon.
gfx::VectorIconId icon_image_id_;
const gfx::VectorIcon* icon_definition_ = nullptr;
gfx::ImageSkia icon_image_;
// The icon image to crossfade from.
......
......@@ -19,7 +19,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/gfx/vector_icon_types.h"
#include "ui/strings/grit/ui_strings.h" // Accessibility names
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -148,14 +148,15 @@ void FrameCaptionButtonContainerView::TestApi::EndAnimations() {
void FrameCaptionButtonContainerView::SetButtonImage(
CaptionButtonIcon icon,
gfx::VectorIconId icon_image_id) {
button_icon_id_map_[icon] = icon_image_id;
const gfx::VectorIcon& icon_definition) {
button_icon_map_[icon] = &icon_definition;
FrameCaptionButton* buttons[] = {minimize_button_, size_button_,
close_button_};
for (size_t i = 0; i < arraysize(buttons); ++i) {
if (buttons[i]->icon() == icon)
buttons[i]->SetImage(icon, FrameCaptionButton::ANIMATE_NO, icon_image_id);
buttons[i]->SetImage(icon, FrameCaptionButton::ANIMATE_NO,
icon_definition);
}
}
......@@ -299,9 +300,9 @@ void FrameCaptionButtonContainerView::SetButtonIcon(FrameCaptionButton* button,
FrameCaptionButton::Animate fcb_animate =
(animate == ANIMATE_YES) ? FrameCaptionButton::ANIMATE_YES
: FrameCaptionButton::ANIMATE_NO;
auto it = button_icon_id_map_.find(icon);
if (it != button_icon_id_map_.end())
button->SetImage(icon, fcb_animate, it->second);
auto it = button_icon_map_.find(icon);
if (it != button_icon_map_.end())
button->SetImage(icon, fcb_animate, *it->second);
}
bool FrameCaptionButtonContainerView::ShouldSizeButtonBeVisible() const {
......
......@@ -16,7 +16,7 @@
namespace gfx {
class SlideAnimation;
enum class VectorIconId;
struct VectorIcon;
}
namespace views {
......@@ -68,7 +68,8 @@ class ASH_EXPORT FrameCaptionButtonContainerView
// Sets the id of the vector image to paint the button for |icon|. The
// FrameCaptionButtonContainerView will keep track of the image to use for
// |icon| even if none of the buttons currently use |icon|.
void SetButtonImage(CaptionButtonIcon icon, gfx::VectorIconId icon_image_id);
void SetButtonImage(CaptionButtonIcon icon,
const gfx::VectorIcon& icon_definition);
// Sets whether the buttons should be painted as active. Does not schedule
// a repaint.
......@@ -141,9 +142,9 @@ class ASH_EXPORT FrameCaptionButtonContainerView
FrameCaptionButton* size_button_;
FrameCaptionButton* close_button_;
// Mapping of the image ID needed to paint a button for each of the values of
// Mapping of the image needed to paint a button for each of the values of
// CaptionButtonIcon.
std::map<CaptionButtonIcon, gfx::VectorIconId> button_icon_id_map_;
std::map<CaptionButtonIcon, const gfx::VectorIcon*> button_icon_map_;
// Animation that affects the position of |minimize_button_| and the
// visibility of |size_button_|.
......
......@@ -8,10 +8,10 @@
#include "ash/common/frame/caption_buttons/frame_caption_button.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/test/ash_test_base.h"
#include "grit/ash_resources.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -71,7 +71,7 @@ class FrameCaptionButtonContainerViewTest : public ash::test::AshTestBase {
GetAshLayoutSize(AshLayoutSize::NON_BROWSER_CAPTION_BUTTON));
for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) {
container->SetButtonImage(static_cast<CaptionButtonIcon>(icon),
gfx::VectorIconId::WINDOW_CONTROL_CLOSE);
ash::kWindowControlCloseIcon);
}
}
......
......@@ -7,6 +7,7 @@
#include "ash/common/ash_layout_constants.h"
#include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/common/frame/header_painter_util.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/debug/leak_annotations.h"
#include "base/logging.h" // DCHECK
#include "grit/ash_resources.h"
......@@ -21,7 +22,6 @@
#include "ui/gfx/image/image.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/views/view.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/widget.h"
......@@ -283,29 +283,27 @@ bool DefaultHeaderPainter::ShouldUseLightImages() {
void DefaultHeaderPainter::UpdateAllButtonImages() {
caption_button_container_->SetUseLightImages(ShouldUseLightImages());
caption_button_container_->SetButtonImage(
CAPTION_BUTTON_ICON_MINIMIZE, gfx::VectorIconId::WINDOW_CONTROL_MINIMIZE);
caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_MINIMIZE,
kWindowControlMinimizeIcon);
UpdateSizeButtonImages();
caption_button_container_->SetButtonImage(
CAPTION_BUTTON_ICON_CLOSE, gfx::VectorIconId::WINDOW_CONTROL_CLOSE);
caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_CLOSE,
kWindowControlCloseIcon);
caption_button_container_->SetButtonImage(
CAPTION_BUTTON_ICON_LEFT_SNAPPED,
gfx::VectorIconId::WINDOW_CONTROL_LEFT_SNAPPED);
caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_LEFT_SNAPPED,
kWindowControlLeftSnappedIcon);
caption_button_container_->SetButtonImage(
CAPTION_BUTTON_ICON_RIGHT_SNAPPED,
gfx::VectorIconId::WINDOW_CONTROL_RIGHT_SNAPPED);
caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_RIGHT_SNAPPED,
kWindowControlRightSnappedIcon);
}
void DefaultHeaderPainter::UpdateSizeButtonImages() {
gfx::VectorIconId icon_id = frame_->IsMaximized() || frame_->IsFullscreen()
? gfx::VectorIconId::WINDOW_CONTROL_RESTORE
: gfx::VectorIconId::WINDOW_CONTROL_MAXIMIZE;
const gfx::VectorIcon& icon = frame_->IsMaximized() || frame_->IsFullscreen()
? kWindowControlRestoreIcon
: kWindowControlMaximizeIcon;
caption_button_container_->SetButtonImage(
CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, icon_id);
CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, icon);
}
gfx::Rect DefaultHeaderPainter::GetLocalBounds() const {
......
......@@ -44,7 +44,7 @@ TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
SetToggledImage(views::Button::STATE_NORMAL,
bundle.GetImageNamed(disabled_resource_id).ToImageSkia());
SetImage(views::Button::STATE_HOVERED,
bundle.GetImageNamed(enabled_resource_id_hover).ToImageSkia());
*bundle.GetImageNamed(enabled_resource_id_hover).ToImageSkia());
SetToggledImage(
views::Button::STATE_HOVERED,
bundle.GetImageNamed(disabled_resource_id_hover).ToImageSkia());
......@@ -74,7 +74,7 @@ void TrayPopupHeaderButton::StateChanged() {
void TrayPopupHeaderButton::Initialize(const gfx::ImageSkia& icon,
int accessible_name_id) {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
SetImage(views::Button::STATE_NORMAL, &icon);
SetImage(views::Button::STATE_NORMAL, icon);
SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
SetAccessibleName(bundle.GetLocalizedString(accessible_name_id));
......
......@@ -23,6 +23,7 @@
#include "ash/common/wm_window.h"
#include "ash/common/wm_window_property.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/auto_reset.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
......@@ -37,7 +38,6 @@
#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/transform_util.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
......@@ -130,9 +130,8 @@ void SetupFadeInAfterLayout(views::Widget* widget) {
WindowSelectorItem::OverviewCloseButton::OverviewCloseButton(
views::ButtonListener* listener)
: views::ImageButton(listener) {
icon_image_ = gfx::CreateVectorIcon(gfx::VectorIconId::WINDOW_CONTROL_CLOSE,
kCloseButtonColor);
SetImage(views::CustomButton::STATE_NORMAL, &icon_image_);
SetImage(views::CustomButton::STATE_NORMAL,
gfx::CreateVectorIcon(kWindowControlCloseIcon, kCloseButtonColor));
SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
SetMinimumImageSize(gfx::Size(kHeaderHeight, kHeaderHeight));
......
......@@ -75,8 +75,6 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
void ResetListener() { listener_ = nullptr; }
private:
gfx::ImageSkia icon_image_;
DISALLOW_COPY_AND_ASSIGN(OverviewCloseButton);
};
......
......@@ -8,6 +8,7 @@
#include "ash/common/frame/caption_buttons/frame_caption_button.h"
#include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/common/wm/window_state.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_state_aura.h"
......@@ -18,7 +19,6 @@
#include "ui/display/screen.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -65,8 +65,7 @@ class TestWidgetDelegate : public views::WidgetDelegateView {
GetAshLayoutSize(AshLayoutSize::NON_BROWSER_CAPTION_BUTTON));
for (int icon = 0; icon < CAPTION_BUTTON_ICON_COUNT; ++icon) {
caption_button_container_->SetButtonImage(
static_cast<CaptionButtonIcon>(icon),
gfx::VectorIconId::WINDOW_CONTROL_CLOSE);
static_cast<CaptionButtonIcon>(icon), kWindowControlCloseIcon);
}
AddChildView(caption_button_container_);
......
......@@ -206,6 +206,20 @@ action("aggregate_vector_icons") {
"system_tray_update.icon",
"system_tray_volume_mute.1x.icon",
"system_tray_volume_mute.icon",
"window_control_back.1x.icon",
"window_control_back.icon",
"window_control_close.1x.icon",
"window_control_close.icon",
"window_control_left_snapped.1x.icon",
"window_control_left_snapped.icon",
"window_control_maximize.1x.icon",
"window_control_maximize.icon",
"window_control_minimize.1x.icon",
"window_control_minimize.icon",
"window_control_restore.1x.icon",
"window_control_restore.icon",
"window_control_right_snapped.1x.icon",
"window_control_right_snapped.icon",
]
output_cc = "$target_gen_dir/vector_icons.cc"
......
......@@ -1119,12 +1119,12 @@ void WifiConfigView::Init(bool show_8021x) {
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE_HIDE));
passphrase_visible_button_->SetImage(
views::ImageButton::STATE_NORMAL,
ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_NETWORK_SHOW_PASSWORD));
*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_NETWORK_SHOW_PASSWORD));
passphrase_visible_button_->SetImage(
views::ImageButton::STATE_HOVERED,
ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_NETWORK_SHOW_PASSWORD_HOVER));
*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_NETWORK_SHOW_PASSWORD_HOVER));
passphrase_visible_button_->SetToggledImage(
views::ImageButton::STATE_NORMAL,
ResourceBundle::GetSharedInstance().
......
......@@ -280,12 +280,12 @@ void WimaxConfigView::Init() {
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE_HIDE));
passphrase_visible_button_->SetImage(
views::ImageButton::STATE_NORMAL,
ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_NETWORK_SHOW_PASSWORD));
*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_NETWORK_SHOW_PASSWORD));
passphrase_visible_button_->SetImage(
views::ImageButton::STATE_HOVERED,
ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_NETWORK_SHOW_PASSWORD_HOVER));
*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_NETWORK_SHOW_PASSWORD_HOVER));
passphrase_visible_button_->SetToggledImage(
views::ImageButton::STATE_NORMAL,
ResourceBundle::GetSharedInstance().
......
......@@ -1417,6 +1417,7 @@ split_static_library("ui") {
"//ash/common/strings",
"//ash/public/cpp",
"//ash/public/interfaces",
"//ash/resources/vector_icons",
"//components/session_manager/core",
"//components/user_manager",
"//services/ui/public/cpp",
......
......@@ -7,6 +7,7 @@
#include "ash/common/ash_layout_constants.h"
#include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/common/frame/header_painter_util.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/logging.h" // DCHECK
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser.h"
......@@ -22,7 +23,6 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
......@@ -285,29 +285,27 @@ void BrowserHeaderPainterAsh::PaintTitleBar(gfx::Canvas* canvas) {
}
void BrowserHeaderPainterAsh::UpdateCaptionButtons() {
caption_button_container_->SetButtonImage(
ash::CAPTION_BUTTON_ICON_MINIMIZE,
gfx::VectorIconId::WINDOW_CONTROL_MINIMIZE);
caption_button_container_->SetButtonImage(
ash::CAPTION_BUTTON_ICON_CLOSE, gfx::VectorIconId::WINDOW_CONTROL_CLOSE);
caption_button_container_->SetButtonImage(ash::CAPTION_BUTTON_ICON_MINIMIZE,
ash::kWindowControlMinimizeIcon);
caption_button_container_->SetButtonImage(ash::CAPTION_BUTTON_ICON_CLOSE,
ash::kWindowControlCloseIcon);
caption_button_container_->SetButtonImage(
ash::CAPTION_BUTTON_ICON_LEFT_SNAPPED,
gfx::VectorIconId::WINDOW_CONTROL_LEFT_SNAPPED);
ash::kWindowControlLeftSnappedIcon);
caption_button_container_->SetButtonImage(
ash::CAPTION_BUTTON_ICON_RIGHT_SNAPPED,
gfx::VectorIconId::WINDOW_CONTROL_RIGHT_SNAPPED);
ash::kWindowControlRightSnappedIcon);
gfx::VectorIconId size_icon_id = gfx::VectorIconId::WINDOW_CONTROL_MAXIMIZE;
const gfx::VectorIcon* size_icon = &ash::kWindowControlMaximizeIcon;
gfx::Size button_size(
GetAshLayoutSize(AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON));
if (frame_->IsMaximized() || frame_->IsFullscreen()) {
size_icon_id = gfx::VectorIconId::WINDOW_CONTROL_RESTORE;
size_icon = &ash::kWindowControlRestoreIcon;
button_size =
GetAshLayoutSize(AshLayoutSize::BROWSER_MAXIMIZED_CAPTION_BUTTON);
}
caption_button_container_->SetButtonImage(
ash::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE,
size_icon_id);
ash::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, *size_icon);
caption_button_container_->SetButtonSize(button_size);
}
......
......@@ -122,20 +122,6 @@ action("aggregate_vector_icons") {
"warning.icon",
"warning_badge.icon",
"web.icon",
"window_control_back.1x.icon",
"window_control_back.icon",
"window_control_close.1x.icon",
"window_control_close.icon",
"window_control_left_snapped.1x.icon",
"window_control_left_snapped.icon",
"window_control_maximize.1x.icon",
"window_control_maximize.icon",
"window_control_minimize.1x.icon",
"window_control_minimize.icon",
"window_control_restore.1x.icon",
"window_control_restore.icon",
"window_control_right_snapped.1x.icon",
"window_control_right_snapped.icon",
"zoom_minus.icon",
"zoom_plus.icon",
"${branding_path_component}/product.icon",
......
......@@ -68,9 +68,9 @@ NotificationCenterButton::NotificationCenterButton(
int text_id)
: views::ToggleImageButton(listener), size_(kButtonSize, kButtonSize) {
ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
SetImage(STATE_NORMAL, resource_bundle.GetImageSkiaNamed(normal_id));
SetImage(STATE_HOVERED, resource_bundle.GetImageSkiaNamed(hover_id));
SetImage(STATE_PRESSED, resource_bundle.GetImageSkiaNamed(pressed_id));
SetImage(STATE_NORMAL, *resource_bundle.GetImageSkiaNamed(normal_id));
SetImage(STATE_HOVERED, *resource_bundle.GetImageSkiaNamed(hover_id));
SetImage(STATE_PRESSED, *resource_bundle.GetImageSkiaNamed(pressed_id));
SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
if (text_id)
......@@ -159,7 +159,7 @@ MessageCenterButtonBar::MessageCenterButtonBar(
IDS_MESSAGE_CENTER_CLEAR_ALL);
close_all_button_->SetImage(
views::Button::STATE_DISABLED,
resource_bundle.GetImageSkiaNamed(IDR_NOTIFICATION_CLEAR_ALL_DISABLED));
*resource_bundle.GetImageSkiaNamed(IDR_NOTIFICATION_CLEAR_ALL_DISABLED));
button_container_->AddChildView(close_all_button_);
settings_button_ =
......
......@@ -48,10 +48,14 @@ const gfx::ImageSkia& ImageButton::GetImage(ButtonState state) const {
}
void ImageButton::SetImage(ButtonState for_state, const gfx::ImageSkia* image) {
SetImage(for_state, image ? *image : gfx::ImageSkia());
}
void ImageButton::SetImage(ButtonState for_state, const gfx::ImageSkia& image) {
if (for_state == STATE_HOVERED)
set_animate_on_state_change(image != nullptr);
set_animate_on_state_change(!image.isNull());
const gfx::Size old_preferred_size = GetPreferredSize();
images_[for_state] = image ? *image : gfx::ImageSkia();
images_[for_state] = image;
if (old_preferred_size != GetPreferredSize())
PreferredSizeChanged();
......@@ -250,11 +254,11 @@ const gfx::ImageSkia& ToggleImageButton::GetImage(
}
void ToggleImageButton::SetImage(ButtonState image_state,
const gfx::ImageSkia* image) {
const gfx::ImageSkia& image) {
if (toggled_) {
alternate_images_[image_state] = image ? *image : gfx::ImageSkia();
alternate_images_[image_state] = image;
} else {
images_[image_state] = image ? *image : gfx::ImageSkia();
images_[image_state] = image;
if (state() == image_state)
SchedulePaint();
}
......
......@@ -44,7 +44,12 @@ class VIEWS_EXPORT ImageButton : public CustomButton {
virtual const gfx::ImageSkia& GetImage(ButtonState state) const;
// Set the image the button should use for the provided state.
virtual void SetImage(ButtonState state, const gfx::ImageSkia* image);
void SetImage(ButtonState state, const gfx::ImageSkia* image);
// As above, but takes a const ref. TODO(estade): all callers should be
// updated to use this version, and then the implementations can be
// consolidated.
virtual void SetImage(ButtonState state, const gfx::ImageSkia& image);
// Set the background details.
void SetBackground(SkColor color,
......@@ -142,7 +147,7 @@ class VIEWS_EXPORT ToggleImageButton : public ImageButton {
// Overridden from ImageButton:
const gfx::ImageSkia& GetImage(ButtonState state) const override;
void SetImage(ButtonState state, const gfx::ImageSkia* image) override;
void SetImage(ButtonState state, const gfx::ImageSkia& image) override;
// Overridden from View:
bool GetTooltipText(const gfx::Point& p,
......
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