Experimental integration of the main menu into the tab bar. Please tell me what

you think, I am not 100% it's nicer than before. Can be easily reverted in any
case.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@248 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2012-07-03 15:30:47 +02:00
committed by Alexandre Deckner
parent e335cb654c
commit e6809b325a
4 changed files with 56 additions and 14 deletions
+8 -8
View File
@@ -106,7 +106,8 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
if (toolbarPolicy == HaveToolbar) {
// Menu
fMenuBar = new BMenuBar("Main menu");
// BMenu* mainMenu = new BMenuBar("Main menu");
BMenu* mainMenu = fTabManager->Menu();
BMenu* menu = new BMenu("Window");
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
newWindowMessage->AddString("url", "");
@@ -126,7 +127,7 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
BMenuItem* quitItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q');
menu->AddItem(quitItem);
quitItem->SetTarget(be_app);
fMenuBar->AddItem(menu);
mainMenu->AddItem(menu);
menu = new BMenu("Text");
menu->AddItem(new BMenuItem("Find", new BMessage(TEXT_SHOW_FIND_GROUP), 'F'));
@@ -134,10 +135,10 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
menu->AddItem(new BMenuItem("Increase size", new BMessage(TEXT_SIZE_INCREASE), '+'));
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-'));
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0'));
fMenuBar->AddItem(menu);
mainMenu->AddItem(menu);
fGoMenu = new BMenu("Go");
fMenuBar->AddItem(fGoMenu);
mainMenu->AddItem(fGoMenu);
// Back, Forward & Stop
fBackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
@@ -175,8 +176,8 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
fLoadingProgressBar->Hide();
fLoadingProgressBar->SetBarHeight(12);
const float kInsetSpacing = 5;
const float kElementSpacing = 7;
const float kInsetSpacing = 3;
const float kElementSpacing = 5;
fFindTextControl = new BTextControl("find", "Find:", "",
new BMessage(TEXT_FIND_NEXT));
@@ -196,7 +197,7 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
;
// Layout
AddChild(BGroupLayoutBuilder(B_VERTICAL)
.Add(fMenuBar)
// .Add(mainMenu)
.Add(fTabManager->TabGroup())
.Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
.Add(fBackButton, 0, 0)
@@ -228,7 +229,6 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
fStopButton = 0;
fGoButton = 0;
fURLTextControl = 0;
fMenuBar = 0;
fStatusText = 0;
fLoadingProgressBar = 0;
-1
View File
@@ -115,7 +115,6 @@ private:
private:
BMessenger fDownloadListener;
BMenuBar* fMenuBar;
BMenu* fGoMenu;
IconButton* fBackButton;
IconButton* fForwardButton;
+44 -5
View File
@@ -35,6 +35,7 @@
#include <CardLayout.h>
#include <ControlLook.h>
#include <GroupView.h>
#include <MenuBar.h>
#include <SpaceLayoutItem.h>
#include <Window.h>
#include <stdio.h>
@@ -863,10 +864,10 @@ void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
float tint = B_DARKEN_1_TINT;
if (!IsFront())
if (!IsFront()) {
base = tint_color(base, tint);
tint *= 1.02;
base = tint_color(base, tint);
}
if (fOverCloseRect)
tint *= 1.2;
@@ -916,6 +917,30 @@ TabManagerController::CloseTab(int32 index)
}
// #pragma mark - TabButtonContainer
class TabButtonContainer : public BGroupView {
public:
TabButtonContainer()
: BGroupView(B_HORIZONTAL)
{
SetFlags(Flags() | B_WILL_DRAW);
SetViewColor(B_TRANSPARENT_COLOR);
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
GroupLayout()->SetInsets(0, 6, 0, 0);
}
virtual void Draw(BRect updateRect)
{
BRect bounds(Bounds());
rgb_color base = LowColor();
be_control_look->DrawInactiveTab(this, bounds, updateRect,
base, 0, BControlLook::B_TOP_BORDER);
}
};
// #pragma mark - TabButton
@@ -1058,7 +1083,6 @@ public:
// #pragma mark - TabManager
TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
:
fController(new TabManagerController(this)),
@@ -1068,9 +1092,17 @@ TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
fCardLayout = new BCardLayout();
fContainerView->SetLayout(fCardLayout);
fMenu = new BMenu("Menu");
fTabContainerView = new TabContainerView(fController);
fTabContainerGroup = new BGroupView(B_HORIZONTAL);
fTabContainerGroup->GroupLayout()->SetInsets(0, 5, 0, 0);
fTabContainerGroup->GroupLayout()->SetInsets(0, 3, 0, 0);
BMenuBar* menuBar = new BMenuBar("Menu bar");
menuBar->AddItem(fMenu);
TabButtonContainer* menuBarContainer = new TabButtonContainer();
menuBarContainer->GroupLayout()->AddView(menuBar);
fTabContainerGroup->GroupLayout()->AddView(menuBarContainer, 0.0f);
fTabContainerGroup->GroupLayout()->AddView(fTabContainerView);
// fTabContainerGroup->GroupLayout()->AddView(new ScrollLeftTabButton(NULL), 0.0f);
// fTabContainerGroup->GroupLayout()->AddView(new ScrollRightTabButton(NULL), 0.0f);
@@ -1101,6 +1133,13 @@ TabManager::Target() const
}
BMenu*
TabManager::Menu() const
{
return fMenu;
}
BView*
TabManager::TabGroup() const
{
+4
View File
@@ -38,6 +38,7 @@ enum {
class BCardLayout;
class BGroupView;
class BMenu;
class TabContainerView;
class TabManagerController;
@@ -50,6 +51,8 @@ public:
void SetTarget(const BMessenger& target);
const BMessenger& Target() const;
BMenu* Menu() const;
BView* TabGroup() const;
BView* ContainerView() const;
@@ -69,6 +72,7 @@ public:
void SetCloseButtonsAvailable(bool available);
private:
BMenu* fMenu;
BGroupView* fTabContainerGroup;
TabContainerView* fTabContainerView;
BView* fContainerView;