Commit 2860a178 authored by Taylor Bergquist's avatar Taylor Bergquist Committed by Commit Bot

Rename toggle button to tab counter and display hardcoded text.

Demotes the toggle button from a ToolbarButton to a LabelButton, and
the pointer to it all the way to View.  Some visual regressions
relative to the caret (i.e. no ink drop, and ':D' is not a useful
indicator of what the button does).  Also, the translation string is
about to be changed again so maybe this CL would add pointless
busywork for our translators?

This is an intermediate first step in changing the toggle button to
a tab counter. It replaces the caret image with a non-informative,
incorrectly styled, hardcoded-content text label.


Bug: 999557
Change-Id: I9f964dd22c251aceaf6c3faa5eb1106161663cf2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1885552Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Commit-Queue: Taylor Bergquist <tbergquist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712357}
parent 7c664425
......@@ -5420,7 +5420,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_TOOLTIP_FIND" desc="The tooltip for the find button">
Find
</message>
<message name="IDS_TOOLTIP_WEBUI_TAB_STRIP_TOGGLE_BUTTON" desc="The tooltip for toggling the tab strip">
<message name="IDS_TOOLTIP_WEBUI_TAB_STRIP_TAB_COUNTER" desc="The tooltip for the button which toggles the tab strip. It counts the number of open tabs.">
Toggle tab strip
</message>
......
......@@ -102,7 +102,7 @@ enum ViewID {
VIEW_ID_ACTION_BOX_BUTTON,
// IDs for the WebUI-based tab strip. See https://crbug.com/989131.
VIEW_ID_WEBUI_TAB_STRIP_TOGGLE_BUTTON,
VIEW_ID_WEBUI_TAB_STRIP_TAB_COUNTER,
VIEW_ID_WEBUI_TAB_STRIP_NEW_TAB_BUTTON,
};
......
......@@ -193,15 +193,40 @@ WebUITabStripContainerView::CreateNewTabButton() {
return new_tab_button;
}
// TODO(crbug.com/992972): Replace this button with tab counter. Consider
// replacing the "toggle" string with a separate show/hide tooltip string.
std::unique_ptr<ToolbarButton>
WebUITabStripContainerView::CreateToggleButton() {
auto toggle_button = std::make_unique<ToolbarButton>(this);
toggle_button->SetID(VIEW_ID_WEBUI_TAB_STRIP_TOGGLE_BUTTON);
toggle_button->SetTooltipText(
l10n_util::GetStringUTF16(IDS_TOOLTIP_WEBUI_TAB_STRIP_TOGGLE_BUTTON));
return toggle_button;
std::unique_ptr<views::View> WebUITabStripContainerView::CreateTabCounter() {
// TODO(999557): Create a custom text style to get the correct size/weight.
// TODO(999557): Figure out how to get the right font.
auto tab_counter = std::make_unique<views::LabelButton>(
this, base::string16(), views::style::CONTEXT_BUTTON_MD);
tab_counter->SetID(VIEW_ID_WEBUI_TAB_STRIP_TAB_COUNTER);
tab_counter->SetTooltipText(
l10n_util::GetStringUTF16(IDS_TOOLTIP_WEBUI_TAB_STRIP_TAB_COUNTER));
tab_counter->SetProperty(views::kFlexBehaviorKey,
views::FlexSpecification::ForSizeRule(
views::MinimumFlexSizeRule::kScaleToMinimum,
views::MaximumFlexSizeRule::kPreferred)
.WithOrder(1));
// TODO(999557): Correctly configure the size (height, minimum width).
// TODO(999557): Install an inkdrop.
// TODO(999557): Add a roundrect border, like below but more like spec.
// tab_counter->SetBorder(views::CreateRoundedRectBorder(
// 1,
// views::LayoutProvider::Get()->GetCornerRadiusMetric(
// views::EMPHASIS_MEDIUM),
// gfx::kGoogleGrey300));
// TODO(999557): I'd like to do this instead of making this be a LabelButton.
// But Button is not concrete... ?
// tab_counter->SetLayoutManager(std::make_unique<views::FillLayout>());
// auto* tab_count_label = tab_counter->AddChildView(
// std::make_unique<views::Label>(base::string16()));*/
// TODO(999557): Hook into tabstripmodel events to update text and tooltip.
return tab_counter;
}
void WebUITabStripContainerView::CloseContainer() {
......@@ -255,7 +280,7 @@ int WebUITabStripContainerView::GetHeightForWidth(int w) const {
void WebUITabStripContainerView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender->GetID() == VIEW_ID_WEBUI_TAB_STRIP_TOGGLE_BUTTON) {
if (sender->GetID() == VIEW_ID_WEBUI_TAB_STRIP_TAB_COUNTER) {
SetContainerTargetVisibility(!GetVisible());
} else if (sender->GetID() == VIEW_ID_WEBUI_TAB_STRIP_NEW_TAB_BUTTON) {
chrome::ExecuteCommand(browser_, IDC_NEW_TAB);
......
......@@ -45,7 +45,7 @@ class WebUITabStripContainerView : public TabStripUI::Embedder,
// Control buttons.
std::unique_ptr<ToolbarButton> CreateNewTabButton();
std::unique_ptr<ToolbarButton> CreateToggleButton();
std::unique_ptr<views::View> CreateTabCounter();
private:
class AutoCloser;
......
......@@ -281,8 +281,7 @@ void ToolbarView::Init() {
if (browser_view_->webui_tab_strip()) {
webui_new_tab_button_ =
AddChildView(browser_view_->webui_tab_strip()->CreateNewTabButton());
webui_toggle_button_ =
AddChildView(browser_view_->webui_tab_strip()->CreateToggleButton());
AddChildView(browser_view_->webui_tab_strip()->CreateTabCounter());
}
#endif // BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
......@@ -900,9 +899,6 @@ void ToolbarView::LoadImages() {
webui_new_tab_button_->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(kAddIcon, normal_color));
webui_toggle_button_->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(kCaretUpIcon, normal_color));
}
if (avatar_)
......
......@@ -275,7 +275,6 @@ class ToolbarView : public views::AccessiblePaneView,
media_router::CastToolbarButton* cast_ = nullptr;
ToolbarAccountIconContainerView* toolbar_account_icon_container_ = nullptr;
ToolbarButton* webui_new_tab_button_ = nullptr;
ToolbarButton* webui_toggle_button_ = nullptr;
AvatarToolbarButton* avatar_ = nullptr;
MediaToolbarButtonView* media_button_ = nullptr;
BrowserAppMenuButton* app_menu_button_ = nullptr;
......
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