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:
committed by
Alexandre Deckner
parent
e335cb654c
commit
e6809b325a
@@ -106,7 +106,8 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
|
|
||||||
if (toolbarPolicy == HaveToolbar) {
|
if (toolbarPolicy == HaveToolbar) {
|
||||||
// Menu
|
// Menu
|
||||||
fMenuBar = new BMenuBar("Main menu");
|
// BMenu* mainMenu = new BMenuBar("Main menu");
|
||||||
|
BMenu* mainMenu = fTabManager->Menu();
|
||||||
BMenu* menu = new BMenu("Window");
|
BMenu* menu = new BMenu("Window");
|
||||||
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
|
BMessage* newWindowMessage = new BMessage(NEW_WINDOW);
|
||||||
newWindowMessage->AddString("url", "");
|
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');
|
BMenuItem* quitItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q');
|
||||||
menu->AddItem(quitItem);
|
menu->AddItem(quitItem);
|
||||||
quitItem->SetTarget(be_app);
|
quitItem->SetTarget(be_app);
|
||||||
fMenuBar->AddItem(menu);
|
mainMenu->AddItem(menu);
|
||||||
|
|
||||||
menu = new BMenu("Text");
|
menu = new BMenu("Text");
|
||||||
menu->AddItem(new BMenuItem("Find", new BMessage(TEXT_SHOW_FIND_GROUP), 'F'));
|
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("Increase size", new BMessage(TEXT_SIZE_INCREASE), '+'));
|
||||||
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-'));
|
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-'));
|
||||||
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0'));
|
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0'));
|
||||||
fMenuBar->AddItem(menu);
|
mainMenu->AddItem(menu);
|
||||||
|
|
||||||
fGoMenu = new BMenu("Go");
|
fGoMenu = new BMenu("Go");
|
||||||
fMenuBar->AddItem(fGoMenu);
|
mainMenu->AddItem(fGoMenu);
|
||||||
|
|
||||||
// Back, Forward & Stop
|
// Back, Forward & Stop
|
||||||
fBackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
|
fBackButton = new IconButton("Back", 0, NULL, new BMessage(GO_BACK));
|
||||||
@@ -175,8 +176,8 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
fLoadingProgressBar->Hide();
|
fLoadingProgressBar->Hide();
|
||||||
fLoadingProgressBar->SetBarHeight(12);
|
fLoadingProgressBar->SetBarHeight(12);
|
||||||
|
|
||||||
const float kInsetSpacing = 5;
|
const float kInsetSpacing = 3;
|
||||||
const float kElementSpacing = 7;
|
const float kElementSpacing = 5;
|
||||||
|
|
||||||
fFindTextControl = new BTextControl("find", "Find:", "",
|
fFindTextControl = new BTextControl("find", "Find:", "",
|
||||||
new BMessage(TEXT_FIND_NEXT));
|
new BMessage(TEXT_FIND_NEXT));
|
||||||
@@ -196,7 +197,7 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
;
|
;
|
||||||
// Layout
|
// Layout
|
||||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||||
.Add(fMenuBar)
|
// .Add(mainMenu)
|
||||||
.Add(fTabManager->TabGroup())
|
.Add(fTabManager->TabGroup())
|
||||||
.Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
|
.Add(BGridLayoutBuilder(kElementSpacing, kElementSpacing)
|
||||||
.Add(fBackButton, 0, 0)
|
.Add(fBackButton, 0, 0)
|
||||||
@@ -228,7 +229,6 @@ BrowserWindow::BrowserWindow(BRect frame, const BMessenger& downloadListener,
|
|||||||
fStopButton = 0;
|
fStopButton = 0;
|
||||||
fGoButton = 0;
|
fGoButton = 0;
|
||||||
fURLTextControl = 0;
|
fURLTextControl = 0;
|
||||||
fMenuBar = 0;
|
|
||||||
fStatusText = 0;
|
fStatusText = 0;
|
||||||
fLoadingProgressBar = 0;
|
fLoadingProgressBar = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BMessenger fDownloadListener;
|
BMessenger fDownloadListener;
|
||||||
BMenuBar* fMenuBar;
|
|
||||||
BMenu* fGoMenu;
|
BMenu* fGoMenu;
|
||||||
IconButton* fBackButton;
|
IconButton* fBackButton;
|
||||||
IconButton* fForwardButton;
|
IconButton* fForwardButton;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <CardLayout.h>
|
#include <CardLayout.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
#include <GroupView.h>
|
#include <GroupView.h>
|
||||||
|
#include <MenuBar.h>
|
||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -863,10 +864,10 @@ void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
|
|||||||
|
|
||||||
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
float tint = B_DARKEN_1_TINT;
|
float tint = B_DARKEN_1_TINT;
|
||||||
if (!IsFront())
|
if (!IsFront()) {
|
||||||
|
base = tint_color(base, tint);
|
||||||
tint *= 1.02;
|
tint *= 1.02;
|
||||||
|
}
|
||||||
base = tint_color(base, tint);
|
|
||||||
|
|
||||||
if (fOverCloseRect)
|
if (fOverCloseRect)
|
||||||
tint *= 1.2;
|
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
|
// #pragma mark - TabButton
|
||||||
|
|
||||||
|
|
||||||
@@ -1058,7 +1083,6 @@ public:
|
|||||||
// #pragma mark - TabManager
|
// #pragma mark - TabManager
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
|
TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
|
||||||
:
|
:
|
||||||
fController(new TabManagerController(this)),
|
fController(new TabManagerController(this)),
|
||||||
@@ -1068,9 +1092,17 @@ TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
|
|||||||
fCardLayout = new BCardLayout();
|
fCardLayout = new BCardLayout();
|
||||||
fContainerView->SetLayout(fCardLayout);
|
fContainerView->SetLayout(fCardLayout);
|
||||||
|
|
||||||
|
fMenu = new BMenu("Menu");
|
||||||
fTabContainerView = new TabContainerView(fController);
|
fTabContainerView = new TabContainerView(fController);
|
||||||
fTabContainerGroup = new BGroupView(B_HORIZONTAL);
|
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(fTabContainerView);
|
||||||
// fTabContainerGroup->GroupLayout()->AddView(new ScrollLeftTabButton(NULL), 0.0f);
|
// fTabContainerGroup->GroupLayout()->AddView(new ScrollLeftTabButton(NULL), 0.0f);
|
||||||
// fTabContainerGroup->GroupLayout()->AddView(new ScrollRightTabButton(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*
|
BView*
|
||||||
TabManager::TabGroup() const
|
TabManager::TabGroup() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ enum {
|
|||||||
|
|
||||||
class BCardLayout;
|
class BCardLayout;
|
||||||
class BGroupView;
|
class BGroupView;
|
||||||
|
class BMenu;
|
||||||
class TabContainerView;
|
class TabContainerView;
|
||||||
class TabManagerController;
|
class TabManagerController;
|
||||||
|
|
||||||
@@ -50,6 +51,8 @@ public:
|
|||||||
void SetTarget(const BMessenger& target);
|
void SetTarget(const BMessenger& target);
|
||||||
const BMessenger& Target() const;
|
const BMessenger& Target() const;
|
||||||
|
|
||||||
|
BMenu* Menu() const;
|
||||||
|
|
||||||
BView* TabGroup() const;
|
BView* TabGroup() const;
|
||||||
BView* ContainerView() const;
|
BView* ContainerView() const;
|
||||||
|
|
||||||
@@ -69,6 +72,7 @@ public:
|
|||||||
void SetCloseButtonsAvailable(bool available);
|
void SetCloseButtonsAvailable(bool available);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
BMenu* fMenu;
|
||||||
BGroupView* fTabContainerGroup;
|
BGroupView* fTabContainerGroup;
|
||||||
TabContainerView* fTabContainerView;
|
TabContainerView* fTabContainerView;
|
||||||
BView* fContainerView;
|
BView* fContainerView;
|
||||||
|
|||||||
Reference in New Issue
Block a user