From 74ff8b833c7bffa7675ecd0ac46d182c41d97689 Mon Sep 17 00:00:00 2001 From: Simon Hong Date: Wed, 18 Jan 2023 16:47:27 +0900 Subject: [PATCH] Added separator to sidebar ctx menu between show sidebar and position fix https://github.com/brave/brave-browser/issues/27880 New separator type(BOTH_SIDE_PADDED_SEPARATOR) is introduced to have padding on both side. --- browser/ui/views/sidebar/sidebar_control_view.cc | 2 ++ .../ui/base/models/menu_separator_types.h | 15 +++++++++++++++ .../ui/views/controls/menu/menu_separator.cc | 12 ++++++++++++ ...ui-views-controls-menu-menu_separator.cc.patch | 12 ++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 chromium_src/ui/base/models/menu_separator_types.h create mode 100644 chromium_src/ui/views/controls/menu/menu_separator.cc create mode 100644 patches/ui-views-controls-menu-menu_separator.cc.patch diff --git a/browser/ui/views/sidebar/sidebar_control_view.cc b/browser/ui/views/sidebar/sidebar_control_view.cc index dcd620fa1917..57efb809a1dd 100644 --- a/browser/ui/views/sidebar/sidebar_control_view.cc +++ b/browser/ui/views/sidebar/sidebar_control_view.cc @@ -160,6 +160,8 @@ void SidebarControlView::ShowContextMenuForViewImpl( static_cast(ShowSidebarOption::kShowNever), brave_l10n::GetLocalizedResourceUTF16String( IDS_SIDEBAR_SHOW_OPTION_NEVER)); + context_menu_model_->AddSeparator( + ui::MenuSeparatorType::BOTH_SIDE_PADDED_SEPARATOR); context_menu_model_->AddTitle(brave_l10n::GetLocalizedResourceUTF16String( IDS_SIDEBAR_MENU_MODEL_POSITION_OPTION_TITLE)); context_menu_model_->AddItemWithStringId( diff --git a/chromium_src/ui/base/models/menu_separator_types.h b/chromium_src/ui/base/models/menu_separator_types.h new file mode 100644 index 000000000000..bf0846a6d676 --- /dev/null +++ b/chromium_src/ui/base/models/menu_separator_types.h @@ -0,0 +1,15 @@ +// Copyright (c) 2023 The Brave Authors. All rights reserved. +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at https://mozilla.org/MPL/2.0/. + +#ifndef BRAVE_CHROMIUM_SRC_UI_BASE_MODELS_MENU_SEPARATOR_TYPES_H_ +#define BRAVE_CHROMIUM_SRC_UI_BASE_MODELS_MENU_SEPARATOR_TYPES_H_ + +#define PADDED_SEPARATOR BOTH_SIDE_PADDED_SEPARATOR, PADDED_SEPARATOR + +#include "src/ui/base/models/menu_separator_types.h" + +#undef PADDED_SEPARATOR + +#endif // BRAVE_CHROMIUM_SRC_UI_BASE_MODELS_MENU_SEPARATOR_TYPES_H_ diff --git a/chromium_src/ui/views/controls/menu/menu_separator.cc b/chromium_src/ui/views/controls/menu/menu_separator.cc new file mode 100644 index 000000000000..02bdbc80aced --- /dev/null +++ b/chromium_src/ui/views/controls/menu/menu_separator.cc @@ -0,0 +1,12 @@ +// Copyright (c) 2023 The Brave Authors. All rights reserved. +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at https://mozilla.org/MPL/2.0/. + +#define BRAVE_MENU_SEPARATOR_ON_PAINT \ + else if (type_ == ui::BOTH_SIDE_PADDED_SEPARATOR) \ + paint_rect.Inset(gfx::Insets::VH(0, 8)); + +#include "src/ui/views/controls/menu/menu_separator.cc" + +#undef BRAVE_MENU_SEPARATOR_ON_PAINT diff --git a/patches/ui-views-controls-menu-menu_separator.cc.patch b/patches/ui-views-controls-menu-menu_separator.cc.patch new file mode 100644 index 000000000000..a766e30a0ab1 --- /dev/null +++ b/patches/ui-views-controls-menu-menu_separator.cc.patch @@ -0,0 +1,12 @@ +diff --git a/ui/views/controls/menu/menu_separator.cc b/ui/views/controls/menu/menu_separator.cc +index be7ca4059bc2d7f78419dbf863fdb7c74070e9dc..6391ae9d86b0d66cca37d98f71506c2733b12edd 100644 +--- a/ui/views/controls/menu/menu_separator.cc ++++ b/ui/views/controls/menu/menu_separator.cc +@@ -43,6 +43,7 @@ void MenuSeparator::OnPaint(gfx::Canvas* canvas) { + if (type_ == ui::PADDED_SEPARATOR) + paint_rect.Inset( + gfx::Insets::TLBR(0, menu_config.padded_separator_left_margin, 0, 0)); ++ BRAVE_MENU_SEPARATOR_ON_PAINT + else if (menu_config.use_outer_border) + paint_rect.Inset(gfx::Insets::VH(0, 1)); +