Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set tooltip texts for toggle button on vertical tabs #17974

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/brave_generated_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,26 @@ Or change later at <ph name="SETTINGS_EXTENIONS_LINK">$2<ex>brave://settings/ext
<message name="IDS_IMPORTED_FROM_BOOKMARK_FOLDER" desc="Name for bookmark panel folder imported from another browser">
Imported from <ph name="BROWSER_NAME">$1<ex>Chrome</ex></ph>.
</message>

<!-- Vertical tab strip -->
<if expr="toolkit_views">
<if expr="use_titlecase">
<message name="IDS_VERTICAL_TABS_EXPAND" desc="A tooltip text for button when vertical tab strip is minimized or floating">
Expand Tabs
</message>
<message name="IDS_VERTICAL_TABS_MINIMIZE" desc="A tooltip text for button when vertical tab strip is expanded">
Minimize Tabs
</message>
</if>
<if expr="not use_titlecase">
<message name="IDS_VERTICAL_TABS_EXPAND" desc="A tooltip text for button when vertical tab strip is minimized or floating">
Expand tabs
</message>
<message name="IDS_VERTICAL_TABS_MINIMIZE" desc="A tooltip text for button when vertical tab strip is expanded">
Minimize tabs
</message>
</if>
</if>
<!--Add new items to the appropriate sections above -->
</messages>
</release>
Expand Down
21 changes: 13 additions & 8 deletions browser/ui/views/frame/vertical_tab_strip_region_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ class ToggleButton : public BraveNewTabButton {
std::move(std::move(callback))),
region_view_(region_view),
tab_strip_(region_view_->tab_strip()) {
// TODO(sangwoo.ko) Temporary workaround before we have a proper tooltip
// text.
// https://github.com/brave/brave-browser/issues/24717
SetProperty(views::kSkipAccessibilityPaintChecks, true);
SetPreferredSize(gfx::Size{GetIconWidth(), GetIconWidth()});
}
~ToggleButton() override = default;
Expand Down Expand Up @@ -107,6 +103,15 @@ class ToggleButton : public BraveNewTabButton {
// dont' fill
}

std::u16string GetTooltipText(const gfx::Point& p) const override {
if (region_view_->state() == VerticalTabStripRegionView::State::kExpanded) {
return l10n_util::GetStringUTF16(IDS_VERTICAL_TABS_MINIMIZE);
}

// When it's minimized or floating.
return l10n_util::GetStringUTF16(IDS_VERTICAL_TABS_EXPAND);
}

#if DCHECK_IS_ON()
void OnBoundsChanged(const gfx::Rect& previous_bounds) override {
CHECK_EQ(width(), GetIconWidth());
Expand Down Expand Up @@ -251,10 +256,10 @@ class VerticalTabNewTabButton : public BraveNewTabButton {
// Set additional horizontal inset for '+' icon.
if (region_view_->state() ==
VerticalTabStripRegionView::State::kCollapsed) {
// // When |text_| is empty, the vertical tab strip could be minimized.
// // In this case we should align icon center.
// // TODO(sko) Should we keep this padding when it's transitioned to
// // floating mode?
// When |text_| is empty, the vertical tab strip could be minimized.
// In this case we should align icon center.
// TODO(sko) Should we keep this padding when it's transitioned to
// floating mode?
SetImageHorizontalAlignment(
views::ImageButton::HorizontalAlignment::ALIGN_CENTER);
} else {
Expand Down