Skip to content

Commit

Permalink
Migrate more vector icons to chrome/.
Browse files Browse the repository at this point in the history
- Move and rename the find bar buttons (since they're used beyond just
  the find bar these days).
- Fix VectorIconButton's disabled state.

BUG=626786

Review-Url: https://codereview.chromium.org/2625273002
Cr-Commit-Position: refs/heads/master@{#443275}
  • Loading branch information
estade authored and Commit bot committed Jan 12, 2017
1 parent 69056e5 commit 48d29c2
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 23 deletions.
4 changes: 4 additions & 0 deletions chrome/app/vector_icons/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ action("aggregate_vector_icons") {
"browser_tools.icon",
"browser_tools_error.icon",
"browser_tools_update.icon",
"caret_down.1x.icon",
"caret_down.icon",
"caret_up.1x.icon",
"caret_up.icon",
"laptop.icon",
"navigate_back.1x.icon",
"navigate_back.icon",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/auto_reset.h"
#include "base/mac/bundle_locations.h"
#include "base/strings/sys_string_conversions.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/cocoa/browser_window_controller.h"
Expand All @@ -32,7 +33,6 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia_util_mac.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/resources/grit/ui_resources.h"

using content::NativeWebKeyboardEvent;
Expand Down Expand Up @@ -135,12 +135,12 @@ - (void)awakeFromNib {
[nextButton_ setTitle:l10n_util::GetNSString(IDS_ACCNAME_NEXT)];

NSImage* image = NSImageFromImageSkia(
gfx::CreateVectorIcon(gfx::VectorIconId::FIND_NEXT, SK_ColorBLACK));
gfx::CreateVectorIcon(kCaretDownIcon, SK_ColorBLACK));
[image setTemplate:YES];
[nextButton_ setImage:image];

image = NSImageFromImageSkia(
gfx::CreateVectorIcon(gfx::VectorIconId::FIND_PREV, SK_ColorBLACK));
image =
NSImageFromImageSkia(gfx::CreateVectorIcon(kCaretUpIcon, SK_ColorBLACK));
[image setTemplate:YES];
[previousButton_ setImage:image];

Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/ui/views/download/download_item_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_item_model.h"
Expand Down Expand Up @@ -881,8 +882,8 @@ void DownloadItemView::SetDropdownState(State new_state) {
!dropdown_button_->GetImage(views::CustomButton::STATE_NORMAL).isNull())
return;

dropdown_button_->SetIcon(new_state == PUSHED ? gfx::VectorIconId::FIND_NEXT
: gfx::VectorIconId::FIND_PREV);
dropdown_button_->SetIcon(new_state == PUSHED ? kCaretDownIcon
: kCaretUpIcon);
if (new_state != dropdown_state_) {
dropdown_button_->AnimateInkDrop(new_state == PUSHED
? views::InkDropState::ACTIVATED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/experience_sampling_private/experience_sampling.h"
#include "chrome/browser/extensions/extension_install_prompt_show_params.h"
Expand All @@ -38,7 +39,6 @@
#include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/text_utils.h"
#include "ui/gfx/vector_icons_public.h"
#include "ui/native_theme/common_theme.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
Expand Down Expand Up @@ -729,8 +729,7 @@ void ExpandableContainerView::ToggleDetailLevel() {

void ExpandableContainerView::UpdateArrowToggle(bool expanded) {
gfx::ImageSkia icon = gfx::CreateVectorIcon(
expanded ? gfx::VectorIconId::FIND_PREV : gfx::VectorIconId::FIND_NEXT,
gfx::kChromeIconGrey);
expanded ? kCaretUpIcon : kCaretDownIcon, gfx::kChromeIconGrey);
arrow_toggle_->SetImage(views::Button::STATE_NORMAL, &icon);
}

Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/ui/views/find_bar_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
Expand Down Expand Up @@ -126,8 +127,8 @@ FindBarView::FindBarView(FindBarHost* host)
find_text_->SetTextInputFlags(ui::TEXT_INPUT_FLAG_AUTOCORRECT_OFF);
AddChildView(find_text_);

find_previous_button_->SetIcon(gfx::VectorIconId::FIND_PREV);
find_next_button_->SetIcon(gfx::VectorIconId::FIND_NEXT);
find_previous_button_->SetIcon(kCaretUpIcon);
find_next_button_->SetIcon(kCaretDownIcon);
close_button_->SetIcon(gfx::VectorIconId::BAR_CLOSE);

find_previous_button_->set_id(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
Expand Down
4 changes: 0 additions & 4 deletions ui/gfx/vector_icons/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ action("aggregate_vector_icons") {
"file_download_incognito.1x.icon",
"file_download_incognito.icon",
"file_download_shelf.icon",
"find_next.1x.icon",
"find_next.icon",
"find_prev.1x.icon",
"find_prev.icon",
"folder.1x.icon",
"folder.icon",
"folder_managed.1x.icon",
Expand Down
20 changes: 12 additions & 8 deletions ui/views/controls/button/vector_icon_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ void VectorIconButton::SetIcon(const gfx::VectorIcon& icon) {
void VectorIconButton::OnThemeChanged() {
SkColor icon_color =
color_utils::DeriveDefaultIconColor(delegate_->GetVectorIconBaseColor());
gfx::ImageSkia image;
if (icon_)
image = gfx::CreateVectorIcon(*icon_, icon_color);
else
image = gfx::CreateVectorIcon(id_, icon_color);
SetImage(views::CustomButton::STATE_NORMAL, &image);
image = gfx::CreateVectorIcon(id_, SkColorSetA(icon_color, 0xff / 2));
SetImage(views::CustomButton::STATE_DISABLED, &image);
SkColor disabled_color = SkColorSetA(icon_color, 0xff / 2);
if (icon_) {
SetImage(views::CustomButton::STATE_NORMAL,
gfx::CreateVectorIcon(*icon_, icon_color));
SetImage(views::CustomButton::STATE_DISABLED,
gfx::CreateVectorIcon(*icon_, disabled_color));
} else {
SetImage(views::CustomButton::STATE_NORMAL,
gfx::CreateVectorIcon(id_, icon_color));
SetImage(views::CustomButton::STATE_DISABLED,
gfx::CreateVectorIcon(id_, disabled_color));
}
set_ink_drop_base_color(icon_color);
}

Expand Down

0 comments on commit 48d29c2

Please sign in to comment.