* Added small symbol buttons to tab container view. Currently only "New tab" is

added and works.
* Added "Open location" shortcut Cmd-L as in Firefox.
* Moved "Show downloads" shortcut to Cmd-J, again as in Firefox. It uses Cmd-D
  for "Bookmark this page". Though I have no idea why we simply shouldn't use
  Cmd-D for Downloads and Cmd-B for Bookmark this page.


git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@229 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi
2010-02-26 23:17:51 +00:00
parent 72664707fa
commit 84c9928e40
3 changed files with 166 additions and 9 deletions
+17 -7
View File
@@ -62,6 +62,7 @@
#include <stdio.h>
enum {
OPEN_LOCATION = 'open',
GO_BACK = 'goba',
GO_FORWARD = 'gofo',
STOP = 'stop',
@@ -95,7 +96,11 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS)
, m_downloadListener(downloadListener)
{
m_tabManager = new TabManager(BMessenger(this));
BMessage* newTabMessage = new BMessage(NEW_TAB);
newTabMessage->AddString("url", "");
newTabMessage->AddPointer("window", this);
newTabMessage->AddBool("select", true);
m_tabManager = new TabManager(BMessenger(this), newTabMessage);
if (toolbarPolicy == HaveToolbar) {
// Menu
@@ -106,18 +111,15 @@ LauncherWindow::LauncherWindow(BRect frame, const BMessenger& downloadListener,
BMenuItem* newItem = new BMenuItem("New window", newWindowMessage, 'N');
menu->AddItem(newItem);
newItem->SetTarget(be_app);
BMessage* newTabMessage = new BMessage(NEW_TAB);
newTabMessage->AddString("url", "");
newTabMessage->AddPointer("window", this);
newTabMessage->AddBool("select", true);
newItem = new BMenuItem("New tab", newTabMessage, 'T');
newItem = new BMenuItem("New tab", new BMessage(*newTabMessage), 'T');
menu->AddItem(newItem);
newItem->SetTarget(be_app);
menu->AddItem(new BMenuItem("Open location", new BMessage(OPEN_LOCATION), 'L'));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Close window", new BMessage(B_QUIT_REQUESTED), 'W', B_SHIFT_KEY));
menu->AddItem(new BMenuItem("Close tab", new BMessage(CLOSE_TAB), 'W'));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Show downloads", new BMessage(SHOW_DOWNLOAD_WINDOW), 'D'));
menu->AddItem(new BMenuItem("Show downloads", new BMessage(SHOW_DOWNLOAD_WINDOW), 'J'));
menu->AddSeparatorItem();
BMenuItem* quitItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q');
menu->AddItem(quitItem);
@@ -253,6 +255,14 @@ LauncherWindow::~LauncherWindow()
void LauncherWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case OPEN_LOCATION:
if (m_url) {
if (m_url->TextView()->IsFocus())
m_url->TextView()->SelectAll();
else
m_url->MakeFocus(true);
}
break;
case RELOAD:
CurrentWebView()->LoadURL(m_url->Text());
break;
+147 -1
View File
@@ -29,7 +29,9 @@
#include "WebTabView.h"
#include "WebView.h"
#include <Application.h>
#include <AbstractLayoutItem.h>
#include <Button.h>
#include <CardLayout.h>
#include <ControlLook.h>
#include <GroupView.h>
@@ -884,11 +886,149 @@ TabManagerController::CloseTab(int32 index)
}
// #pragma mark - TabButton
class TabButton : public BButton {
public:
TabButton(BMessage* message)
: BButton("", message)
{
}
virtual BSize MinSize()
{
return BSize(12, 12);
}
virtual BSize MaxSize()
{
return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
}
virtual BSize PreferredSize()
{
return MinSize();
}
virtual void Draw(BRect updateRect)
{
BRect bounds(Bounds());
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
SetHighColor(tint_color(base, B_DARKEN_2_TINT));
StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
bounds.bottom--;
uint32 flags = be_control_look->Flags(this);
uint32 borders = BControlLook::B_TOP_BORDER
| BControlLook::B_BOTTOM_BORDER;
be_control_look->DrawInactiveTab(this, bounds, updateRect, base,
flags, borders);
if (IsEnabled()) {
rgb_color button = tint_color(base, 1.07);
be_control_look->DrawButtonBackground(this, bounds, updateRect,
button, flags, 0);
}
bounds.left = (bounds.left + bounds.right) / 2 - 6;
bounds.top = (bounds.top + bounds.bottom) / 2 - 6;
bounds.right = bounds.left + 12;
bounds.bottom = bounds.top + 12;
DrawSymbol(bounds, updateRect, base);
}
virtual void DrawSymbol(BRect frame, const BRect& updateRect,
const rgb_color& base)
{
}
};
class ScrollLeftTabButton : public TabButton {
public:
ScrollLeftTabButton(BMessage* message)
: TabButton(message)
{
}
virtual void DrawSymbol(BRect frame, const BRect& updateRect,
const rgb_color& base)
{
be_control_look->DrawArrowShape(this, frame, updateRect,
base, BControlLook::B_LEFT_ARROW, 0, B_DARKEN_4_TINT);
}
};
class ScrollRightTabButton : public TabButton {
public:
ScrollRightTabButton(BMessage* message)
: TabButton(message)
{
}
virtual void DrawSymbol(BRect frame, const BRect& updateRect,
const rgb_color& base)
{
be_control_look->DrawArrowShape(this, frame, updateRect,
base, BControlLook::B_RIGHT_ARROW, 0, B_DARKEN_4_TINT);
}
};
class NewTabButton : public TabButton {
public:
NewTabButton(BMessage* message)
: TabButton(message)
{
}
virtual BSize MinSize()
{
return BSize(18, 12);
}
virtual void DrawSymbol(BRect frame, const BRect& updateRect,
const rgb_color& base)
{
SetHighColor(tint_color(base, B_DARKEN_4_TINT));
float inset = 3;
frame.InsetBy(2, 2);
frame.top++;
frame.left++;
FillRoundRect(BRect(frame.left, frame.top + inset,
frame.right, frame.bottom - inset), 1, 1);
FillRoundRect(BRect(frame.left + inset, frame.top,
frame.right - inset, frame.bottom), 1, 1);
}
};
class TabMenuTabButton : public TabButton {
public:
TabMenuTabButton(BMessage* message)
: TabButton(message)
{
}
virtual BSize MinSize()
{
return BSize(18, 12);
}
virtual void DrawSymbol(BRect frame, const BRect& updateRect,
const rgb_color& base)
{
be_control_look->DrawArrowShape(this, frame, updateRect,
base, BControlLook::B_DOWN_ARROW, 0, B_DARKEN_4_TINT);
}
};
// #pragma mark - TabManager
TabManager::TabManager(const BMessenger& target)
TabManager::TabManager(const BMessenger& target, BMessage* newTabMessage)
:
fTarget(target)
{
@@ -900,6 +1040,12 @@ TabManager::TabManager(const BMessenger& target)
fTabContainerGroup = new BGroupView(B_HORIZONTAL);
fTabContainerGroup->GroupLayout()->SetInsets(0, 5, 0, 0);
fTabContainerGroup->GroupLayout()->AddView(fTabContainerView);
// fTabContainerGroup->GroupLayout()->AddView(new ScrollLeftTabButton(NULL), 0.0f);
// fTabContainerGroup->GroupLayout()->AddView(new ScrollRightTabButton(NULL), 0.0f);
NewTabButton* newTabButton = new NewTabButton(newTabMessage);
newTabButton->SetTarget(be_app);
fTabContainerGroup->GroupLayout()->AddView(newTabButton, 0.0f);
// fTabContainerGroup->GroupLayout()->AddView(new TabMenuTabButton(NULL), 0.0f);
}
+2 -1
View File
@@ -42,7 +42,8 @@ class TabContainerView;
class TabManager {
public:
TabManager(const BMessenger& target);
TabManager(const BMessenger& target,
BMessage* newTabMessage);
virtual ~TabManager();
void SetTarget(const BMessenger& target);