Skip to content

Commit

Permalink
Added separator to sidebar ctx menu between show sidebar and position
Browse files Browse the repository at this point in the history
fix brave/brave-browser#27880

New separator type(BOTH_SIDE_PADDED_SEPARATOR) is introduced to have
padding on both side.
  • Loading branch information
simonhong committed Jan 18, 2023
1 parent 71c0d34 commit 74ff8b8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions browser/ui/views/sidebar/sidebar_control_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ void SidebarControlView::ShowContextMenuForViewImpl(
static_cast<int>(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(
Expand Down
15 changes: 15 additions & 0 deletions chromium_src/ui/base/models/menu_separator_types.h
Original file line number Diff line number Diff line change
@@ -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_
12 changes: 12 additions & 0 deletions chromium_src/ui/views/controls/menu/menu_separator.cc
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions patches/ui-views-controls-menu-menu_separator.cc.patch
Original file line number Diff line number Diff line change
@@ -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));

0 comments on commit 74ff8b8

Please sign in to comment.