Add GetBubbleArrowForSidebar() utility to dynamically set bubble arrows (LEFT_TOP or RIGHT_TOP) based on sidebar horizontal alignment preference. Applied to: SidebarAddItemBubbleDelegateView SidebarEditItemBubbleDelegateView SidebarItemAddedFeedbackBubble This ensures bubbles point toward the sidebar regardless of whether it's positioned on the left or right side of the browser window. This change fixes sidebar bubble's offscreen position on some Linux environments by setting bubble arrow position based on sidebar position. TEST=SidebarUtilTest.GetBubbleArrowForSidebarTest Resolves brave/brave-browser#50967 Resolves brave/brave-browser#49174
57 lines
2.1 KiB
C++
57 lines
2.1 KiB
C++
/* Copyright (c) 2021 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef BRAVE_BROWSER_UI_SIDEBAR_SIDEBAR_UTILS_H_
|
|
#define BRAVE_BROWSER_UI_SIDEBAR_SIDEBAR_UTILS_H_
|
|
|
|
#include <optional>
|
|
|
|
#include "brave/components/sidebar/browser/sidebar_item.h"
|
|
#include "brave/components/sidebar/browser/sidebar_service.h"
|
|
#include "components/version_info/channel.h"
|
|
#include "ui/views/bubble/bubble_border.h"
|
|
|
|
class Browser;
|
|
class GURL;
|
|
class PrefService;
|
|
enum class SidePanelEntryId;
|
|
|
|
namespace sidebar {
|
|
|
|
bool CanUseSidebar(Browser* browser);
|
|
bool CanAddCurrentActiveTabToSidebar(Browser* browser);
|
|
bool IsWebPanelFeatureEnabled();
|
|
|
|
// Exported for testing.
|
|
bool HiddenDefaultSidebarItemsContains(SidebarService* service,
|
|
const GURL& url);
|
|
GURL ConvertURLToBuiltInItemURL(const GURL& url);
|
|
SidePanelEntryId SidePanelIdFromSideBarItemType(
|
|
SidebarItem::BuiltInItemType type);
|
|
SidePanelEntryId SidePanelIdFromSideBarItem(const SidebarItem& item);
|
|
std::optional<SidebarItem::BuiltInItemType> BuiltInItemTypeFromSidePanelId(
|
|
SidePanelEntryId id);
|
|
void SetLastUsedSidePanel(PrefService* prefs,
|
|
std::optional<SidePanelEntryId> id);
|
|
std::optional<SidePanelEntryId> GetLastUsedSidePanel(Browser* browser);
|
|
|
|
// Return the added item if item for |id| is added.
|
|
std::optional<SidebarItem> AddItemForSidePanelIdIfNeeded(Browser* browser,
|
|
SidePanelEntryId id);
|
|
|
|
bool IsDisabledItemForPrivate(SidebarItem::BuiltInItemType type);
|
|
bool IsDisabledItemForGuest(SidebarItem::BuiltInItemType type);
|
|
|
|
SidebarService::ShowSidebarOption GetDefaultShowSidebarOption(
|
|
version_info::Channel channel);
|
|
|
|
// Get bubble arrow direction based on sidebar position.
|
|
// Returns RIGHT_TOP if sidebar is on right.
|
|
views::BubbleBorder::Arrow GetBubbleArrowForSidebar(PrefService* prefs);
|
|
|
|
} // namespace sidebar
|
|
|
|
#endif // BRAVE_BROWSER_UI_SIDEBAR_SIDEBAR_UTILS_H_
|