Double clicking beside the tabs opens a new tab.

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@264 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-03-02 01:27:14 +00:00 committed by Alexandre Deckner
parent ea77068a8e
commit 39274de5a3

View File

@ -127,6 +127,7 @@ public:
virtual void TabSelected(int32 tabIndex) = 0; virtual void TabSelected(int32 tabIndex) = 0;
virtual bool HasFrames() = 0; virtual bool HasFrames() = 0;
virtual TabView* CreateTabView() = 0; virtual TabView* CreateTabView() = 0;
virtual void DoubleClickOutsideTabs() = 0;
}; };
public: public:
@ -252,10 +253,15 @@ TabContainerView::MouseDown(BPoint where)
uint32 buttons; uint32 buttons;
if (Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons) != B_OK) if (Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons) != B_OK)
buttons = B_PRIMARY_MOUSE_BUTTON; buttons = B_PRIMARY_MOUSE_BUTTON;
uint32 clicks;
if (Window()->CurrentMessage()->FindInt32("clicks", (int32*)&clicks) != B_OK)
clicks = 1;
fMouseDown = true; fMouseDown = true;
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
if (fLastMouseEventTab) if (fLastMouseEventTab)
fLastMouseEventTab->MouseDown(where, buttons); fLastMouseEventTab->MouseDown(where, buttons);
else if (clicks > 1)
fController->DoubleClickOutsideTabs();
} }
@ -715,6 +721,8 @@ class TabManagerController : public TabContainerView::Controller {
public: public:
TabManagerController(TabManager* manager); TabManagerController(TabManager* manager);
virtual ~TabManagerController();
virtual void TabSelected(int32 index) virtual void TabSelected(int32 index)
{ {
fManager->SelectTab(index); fManager->SelectTab(index);
@ -727,6 +735,8 @@ public:
virtual TabView* CreateTabView(); virtual TabView* CreateTabView();
virtual void DoubleClickOutsideTabs();
void CloseTab(int32 index); void CloseTab(int32 index);
void SetCloseButtonsAvailable(bool available) void SetCloseButtonsAvailable(bool available)
@ -739,9 +749,14 @@ public:
return fCloseButtonsAvailable; return fCloseButtonsAvailable;
} }
void SetDoubleClickOutsideTabsMessage(const BMessage& message,
const BMessenger& target);
private: private:
TabManager* fManager; TabManager* fManager;
bool fCloseButtonsAvailable; bool fCloseButtonsAvailable;
BMessage* fDoubleClickOutsideTabsMessage;
BMessenger fTarget;
}; };
@ -955,11 +970,18 @@ void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
TabManagerController::TabManagerController(TabManager* manager) TabManagerController::TabManagerController(TabManager* manager)
: :
fManager(manager), fManager(manager),
fCloseButtonsAvailable(false) fCloseButtonsAvailable(false),
fDoubleClickOutsideTabsMessage(NULL)
{ {
} }
TabManagerController::~TabManagerController()
{
delete fDoubleClickOutsideTabsMessage;
}
TabView* TabView*
TabManagerController::CreateTabView() TabManagerController::CreateTabView()
{ {
@ -967,6 +989,13 @@ TabManagerController::CreateTabView()
} }
void
TabManagerController::DoubleClickOutsideTabs()
{
fTarget.SendMessage(fDoubleClickOutsideTabsMessage);
}
void void
TabManagerController::CloseTab(int32 index) TabManagerController::CloseTab(int32 index)
{ {
@ -974,6 +1003,16 @@ TabManagerController::CloseTab(int32 index)
} }
void
TabManagerController::SetDoubleClickOutsideTabsMessage(const BMessage& message,
const BMessenger& target)
{
delete fDoubleClickOutsideTabsMessage;
fDoubleClickOutsideTabsMessage = new BMessage(message);
fTarget = target;
}
// #pragma mark - TabButtonContainer // #pragma mark - TabButtonContainer
@ -1145,6 +1184,9 @@ TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
fController(new TabManagerController(this)), fController(new TabManagerController(this)),
fTarget(target) fTarget(target)
{ {
fController->SetDoubleClickOutsideTabsMessage(*newTabMessage,
be_app_messenger);
fContainerView = new BView("web view container", 0); fContainerView = new BView("web view container", 0);
fCardLayout = new BCardLayout(); fCardLayout = new BCardLayout();
fContainerView->SetLayout(fCardLayout); fContainerView->SetLayout(fCardLayout);