From 08fdc76a61914436f4f28200f942d1a92db477f9 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 23 Jul 2022 14:14:31 -0400 Subject: [PATCH] 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? --- src/apps/webpositive/BrowserWindow.cpp | 17 ++++++++++++----- src/apps/webpositive/BrowserWindow.h | 5 ++--- src/apps/webpositive/tabview/TabManager.cpp | 17 ++++++----------- src/apps/webpositive/tabview/TabManager.h | 9 ++++++--- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 60c1317dba..edb646aa9c 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -390,7 +390,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, // Menu #if INTEGRATE_MENU_INTO_TAB_BAR - BMenu* mainMenu = fTabManager->Menu(); + BMenu* mainMenu = new BMenu("≡"); #else BMenu* mainMenu = new BMenuBar("Main menu"); #endif @@ -612,8 +612,16 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, new BMessage(TOGGLE_FULLSCREEN)); toggleFullscreenButton->SetBackgroundMode(BBitmapButton::MENUBAR_BACKGROUND); - BGroupLayout* menuBarGroup = BLayoutBuilder::Group<>(B_HORIZONTAL, 0.0) - .Add(mainMenu) +#if !INTEGRATE_MENU_INTO_TAB_BAR + 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) ; @@ -629,7 +637,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, BGroupView* topView = new BGroupView(B_VERTICAL, 0.0); #if !INTEGRATE_MENU_INTO_TAB_BAR - topView->AddChild(menuBarGroup); + topView->AddChild(fMenuGroup); #endif topView->AddChild(fTabManager->TabGroup()); topView->AddChild(navigationGroup); @@ -643,7 +651,6 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, fURLInputGroup->MakeFocus(true); - fMenuGroup = menuBarGroup; fTabGroup = fTabManager->TabGroup()->GetLayout(); fNavigationGroup = navigationGroup; fFindGroup = findGroup; diff --git a/src/apps/webpositive/BrowserWindow.h b/src/apps/webpositive/BrowserWindow.h index 1b292b550d..1a296dcd61 100644 --- a/src/apps/webpositive/BrowserWindow.h +++ b/src/apps/webpositive/BrowserWindow.h @@ -40,6 +40,7 @@ class BCheckBox; class BDirectory; class BFile; class BFilePanel; +class BGroupLayout; class BLayoutItem; class BMenu; class BMenuItem; @@ -93,8 +94,6 @@ enum { SHOW_COOKIE_WINDOW = 'skwd' }; -#define INTEGRATE_MENU_INTO_TAB_BAR 0 - class BrowserWindow : public BWebWindow { public: @@ -243,7 +242,7 @@ private: BStringView* fStatusText; BStatusBar* fLoadingProgressBar; - BLayoutItem* fMenuGroup; + BGroupLayout* fMenuGroup; BLayoutItem* fTabGroup; BLayoutItem* fNavigationGroup; BLayoutItem* fFindGroup; diff --git a/src/apps/webpositive/tabview/TabManager.cpp b/src/apps/webpositive/tabview/TabManager.cpp index 0e4de2496b..96c3513e5f 100644 --- a/src/apps/webpositive/tabview/TabManager.cpp +++ b/src/apps/webpositive/tabview/TabManager.cpp @@ -731,12 +731,9 @@ TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage) fController->SetTabContainerGroup(fTabContainerGroup); #if INTEGRATE_MENU_INTO_TAB_BAR - fMenu = new BMenu("Menu"); - BMenuBar* menuBar = new BMenuBar("Menu bar"); - menuBar->AddItem(fMenu); - TabButtonContainer* menuBarContainer = new TabButtonContainer(); - menuBarContainer->GroupLayout()->AddView(menuBar); - fTabContainerGroup->GroupLayout()->AddView(menuBarContainer, 0.0f); + fMenuContainer = new BGroupView(B_HORIZONTAL, 0); + fMenuContainer->GroupLayout()->SetInsets(0, -3, 0, -3); + fTabContainerGroup->GroupLayout()->AddView(fMenuContainer, 0.0f); #endif fTabContainerGroup->GroupLayout()->AddView(fTabContainerView); @@ -773,10 +770,10 @@ TabManager::Target() const #if INTEGRATE_MENU_INTO_TAB_BAR -BMenu* -TabManager::Menu() const +BGroupLayout* +TabManager::MenuContainerLayout() const { - return fMenu; + return fMenuContainer->GroupLayout(); } #endif @@ -938,5 +935,3 @@ TabManager::SetCloseButtonsAvailable(bool available) fController->SetCloseButtonsAvailable(available); fTabContainerView->Invalidate(); } - - diff --git a/src/apps/webpositive/tabview/TabManager.h b/src/apps/webpositive/tabview/TabManager.h index f64425b116..86cc2ee54c 100644 --- a/src/apps/webpositive/tabview/TabManager.h +++ b/src/apps/webpositive/tabview/TabManager.h @@ -1,6 +1,5 @@ /* * Copyright (C) 2010 Stephan Aßmus - * * All rights reserved. Distributed under the terms of the MIT License. */ @@ -18,11 +17,15 @@ enum { class BBitmap; class BCardLayout; class BGroupView; +class BGroupLayout; class BMenu; class TabContainerGroup; class TabContainerView; class TabManagerController; +#define INTEGRATE_MENU_INTO_TAB_BAR 0 + + class TabManager { public: TabManager(const BMessenger& target, @@ -33,7 +36,7 @@ public: const BMessenger& Target() const; #if INTEGRATE_MENU_INTO_TAB_BAR - BMenu* Menu() const; + BGroupLayout* MenuContainerLayout() const; #endif BView* TabGroup() const; @@ -62,7 +65,7 @@ public: private: #if INTEGRATE_MENU_INTO_TAB_BAR - BMenu* fMenu; + BGroupView* fMenuContainer; #endif TabContainerGroup* fTabContainerGroup; TabContainerView* fTabContainerView;