WebPositive: Fix INTEGRATE_MENU_INTO_TAB_BAR.

It seems to have been broken for some time. Maybe some users
want this and we should expose it in settings instead of hiding it
behind #ifs?
This commit is contained in:
Augustin Cavalier 2022-07-23 14:14:31 -04:00
parent 730f5df354
commit 08fdc76a61
4 changed files with 26 additions and 22 deletions

View File

@ -390,7 +390,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
// Menu // Menu
#if INTEGRATE_MENU_INTO_TAB_BAR #if INTEGRATE_MENU_INTO_TAB_BAR
BMenu* mainMenu = fTabManager->Menu(); BMenu* mainMenu = new BMenu("");
#else #else
BMenu* mainMenu = new BMenuBar("Main menu"); BMenu* mainMenu = new BMenuBar("Main menu");
#endif #endif
@ -612,8 +612,16 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
new BMessage(TOGGLE_FULLSCREEN)); new BMessage(TOGGLE_FULLSCREEN));
toggleFullscreenButton->SetBackgroundMode(BBitmapButton::MENUBAR_BACKGROUND); toggleFullscreenButton->SetBackgroundMode(BBitmapButton::MENUBAR_BACKGROUND);
BGroupLayout* menuBarGroup = BLayoutBuilder::Group<>(B_HORIZONTAL, 0.0) #if !INTEGRATE_MENU_INTO_TAB_BAR
.Add(mainMenu) BMenu* mainMenuItem = mainMenu;
fMenuGroup = (new BGroupView(B_HORIZONTAL, 0))->GroupLayout();
#else
BMenu* mainMenuItem = new BMenuBar("Main menu");
mainMenuItem->AddItem(mainMenu);
fMenuGroup = fTabManager->MenuContainerLayout();
#endif
BLayoutBuilder::Group<>(fMenuGroup)
.Add(mainMenuItem)
.Add(toggleFullscreenButton, 0.0f) .Add(toggleFullscreenButton, 0.0f)
; ;
@ -629,7 +637,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
BGroupView* topView = new BGroupView(B_VERTICAL, 0.0); BGroupView* topView = new BGroupView(B_VERTICAL, 0.0);
#if !INTEGRATE_MENU_INTO_TAB_BAR #if !INTEGRATE_MENU_INTO_TAB_BAR
topView->AddChild(menuBarGroup); topView->AddChild(fMenuGroup);
#endif #endif
topView->AddChild(fTabManager->TabGroup()); topView->AddChild(fTabManager->TabGroup());
topView->AddChild(navigationGroup); topView->AddChild(navigationGroup);
@ -643,7 +651,6 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings,
fURLInputGroup->MakeFocus(true); fURLInputGroup->MakeFocus(true);
fMenuGroup = menuBarGroup;
fTabGroup = fTabManager->TabGroup()->GetLayout(); fTabGroup = fTabManager->TabGroup()->GetLayout();
fNavigationGroup = navigationGroup; fNavigationGroup = navigationGroup;
fFindGroup = findGroup; fFindGroup = findGroup;

View File

@ -40,6 +40,7 @@ class BCheckBox;
class BDirectory; class BDirectory;
class BFile; class BFile;
class BFilePanel; class BFilePanel;
class BGroupLayout;
class BLayoutItem; class BLayoutItem;
class BMenu; class BMenu;
class BMenuItem; class BMenuItem;
@ -93,8 +94,6 @@ enum {
SHOW_COOKIE_WINDOW = 'skwd' SHOW_COOKIE_WINDOW = 'skwd'
}; };
#define INTEGRATE_MENU_INTO_TAB_BAR 0
class BrowserWindow : public BWebWindow { class BrowserWindow : public BWebWindow {
public: public:
@ -243,7 +242,7 @@ private:
BStringView* fStatusText; BStringView* fStatusText;
BStatusBar* fLoadingProgressBar; BStatusBar* fLoadingProgressBar;
BLayoutItem* fMenuGroup; BGroupLayout* fMenuGroup;
BLayoutItem* fTabGroup; BLayoutItem* fTabGroup;
BLayoutItem* fNavigationGroup; BLayoutItem* fNavigationGroup;
BLayoutItem* fFindGroup; BLayoutItem* fFindGroup;

View File

@ -731,12 +731,9 @@ TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
fController->SetTabContainerGroup(fTabContainerGroup); fController->SetTabContainerGroup(fTabContainerGroup);
#if INTEGRATE_MENU_INTO_TAB_BAR #if INTEGRATE_MENU_INTO_TAB_BAR
fMenu = new BMenu("Menu"); fMenuContainer = new BGroupView(B_HORIZONTAL, 0);
BMenuBar* menuBar = new BMenuBar("Menu bar"); fMenuContainer->GroupLayout()->SetInsets(0, -3, 0, -3);
menuBar->AddItem(fMenu); fTabContainerGroup->GroupLayout()->AddView(fMenuContainer, 0.0f);
TabButtonContainer* menuBarContainer = new TabButtonContainer();
menuBarContainer->GroupLayout()->AddView(menuBar);
fTabContainerGroup->GroupLayout()->AddView(menuBarContainer, 0.0f);
#endif #endif
fTabContainerGroup->GroupLayout()->AddView(fTabContainerView); fTabContainerGroup->GroupLayout()->AddView(fTabContainerView);
@ -773,10 +770,10 @@ TabManager::Target() const
#if INTEGRATE_MENU_INTO_TAB_BAR #if INTEGRATE_MENU_INTO_TAB_BAR
BMenu* BGroupLayout*
TabManager::Menu() const TabManager::MenuContainerLayout() const
{ {
return fMenu; return fMenuContainer->GroupLayout();
} }
#endif #endif
@ -938,5 +935,3 @@ TabManager::SetCloseButtonsAvailable(bool available)
fController->SetCloseButtonsAvailable(available); fController->SetCloseButtonsAvailable(available);
fTabContainerView->Invalidate(); fTabContainerView->Invalidate();
} }

View File

@ -1,6 +1,5 @@
/* /*
* Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de> * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
*
* All rights reserved. Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
*/ */
@ -18,11 +17,15 @@ enum {
class BBitmap; class BBitmap;
class BCardLayout; class BCardLayout;
class BGroupView; class BGroupView;
class BGroupLayout;
class BMenu; class BMenu;
class TabContainerGroup; class TabContainerGroup;
class TabContainerView; class TabContainerView;
class TabManagerController; class TabManagerController;
#define INTEGRATE_MENU_INTO_TAB_BAR 0
class TabManager { class TabManager {
public: public:
TabManager(const BMessenger& target, TabManager(const BMessenger& target,
@ -33,7 +36,7 @@ public:
const BMessenger& Target() const; const BMessenger& Target() const;
#if INTEGRATE_MENU_INTO_TAB_BAR #if INTEGRATE_MENU_INTO_TAB_BAR
BMenu* Menu() const; BGroupLayout* MenuContainerLayout() const;
#endif #endif
BView* TabGroup() const; BView* TabGroup() const;
@ -62,7 +65,7 @@ public:
private: private:
#if INTEGRATE_MENU_INTO_TAB_BAR #if INTEGRATE_MENU_INTO_TAB_BAR
BMenu* fMenu; BGroupView* fMenuContainer;
#endif #endif
TabContainerGroup* fTabContainerGroup; TabContainerGroup* fTabContainerGroup;
TabContainerView* fTabContainerView; TabContainerView* fTabContainerView;