Added option and infrastructure to zoom the whole page instead of the text only.

(Currently not remembered, but the default (off) is often better than zooming
images.)

git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@381 94f232f2-1747-11df-bad5-a5bfde151594
This commit is contained in:
stippi 2010-04-03 19:32:47 +00:00 committed by Alexandre Deckner
parent 062b237237
commit 92e8b344ac
2 changed files with 28 additions and 13 deletions

View File

@ -82,9 +82,10 @@ enum {
CREATE_BOOKMARK = 'crbm', CREATE_BOOKMARK = 'crbm',
SHOW_BOOKMARKS = 'shbm', SHOW_BOOKMARKS = 'shbm',
TEXT_SIZE_INCREASE = 'tsin', ZOOM_FACTOR_INCREASE = 'zfin',
TEXT_SIZE_DECREASE = 'tsdc', ZOOM_FACTOR_DECREASE = 'zfdc',
TEXT_SIZE_RESET = 'tsrs', ZOOM_FACTOR_RESET = 'zfrs',
ZOOM_TEXT_ONLY = 'zfto',
TEXT_SHOW_FIND_GROUP = 'sfnd', TEXT_SHOW_FIND_GROUP = 'sfnd',
TEXT_HIDE_FIND_GROUP = 'hfnd', TEXT_HIDE_FIND_GROUP = 'hfnd',
@ -243,7 +244,8 @@ BrowserWindow::BrowserWindow(BRect frame, ToolbarPolicy toolbarPolicy,
: :
BWebWindow(frame, kApplicationName, BWebWindow(frame, kApplicationName,
B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS) B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS),
fZoomTextOnly(true)
{ {
BMessage* newTabMessage = new BMessage(NEW_TAB); BMessage* newTabMessage = new BMessage(NEW_TAB);
newTabMessage->AddString("url", ""); newTabMessage->AddString("url", "");
@ -282,9 +284,13 @@ BrowserWindow::BrowserWindow(BRect frame, ToolbarPolicy toolbarPolicy,
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'));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Increase size", new BMessage(TEXT_SIZE_INCREASE), '+')); menu->AddItem(new BMenuItem("Increase size", new BMessage(ZOOM_FACTOR_INCREASE), '+'));
menu->AddItem(new BMenuItem("Decrease size", new BMessage(TEXT_SIZE_DECREASE), '-')); menu->AddItem(new BMenuItem("Decrease size", new BMessage(ZOOM_FACTOR_DECREASE), '-'));
menu->AddItem(new BMenuItem("Reset size", new BMessage(TEXT_SIZE_RESET), '0')); menu->AddItem(new BMenuItem("Reset size", new BMessage(ZOOM_FACTOR_RESET), '0'));
fZoomTextOnlyMenuItem = new BMenuItem("Zoom text only",
new BMessage(ZOOM_TEXT_ONLY));
fZoomTextOnlyMenuItem->SetMarked(fZoomTextOnly);
menu->AddItem(fZoomTextOnlyMenuItem);
mainMenu->AddItem(menu); mainMenu->AddItem(menu);
fGoMenu = new BMenu("Go"); fGoMenu = new BMenu("Go");
@ -593,14 +599,20 @@ printf(" file ok\n");
break; break;
} }
case TEXT_SIZE_INCREASE: case ZOOM_FACTOR_INCREASE:
CurrentWebView()->IncreaseTextSize(); CurrentWebView()->IncreaseZoomFactor(fZoomTextOnly);
break; break;
case TEXT_SIZE_DECREASE: case ZOOM_FACTOR_DECREASE:
CurrentWebView()->DecreaseTextSize(); CurrentWebView()->DecreaseZoomFactor(fZoomTextOnly);
break; break;
case TEXT_SIZE_RESET: case ZOOM_FACTOR_RESET:
CurrentWebView()->ResetTextSize(); CurrentWebView()->ResetZoomFactor();
break;
case ZOOM_TEXT_ONLY:
fZoomTextOnly = !fZoomTextOnly;
fZoomTextOnlyMenuItem->SetMarked(fZoomTextOnly);
// TODO: Would be nice to have an instant update if the page is already
// zoomed.
break; break;
case TEXT_FIND_NEXT: case TEXT_FIND_NEXT:

View File

@ -40,6 +40,7 @@ class BDirectory;
class BFile; class BFile;
class BLayoutItem; class BLayoutItem;
class BMenu; class BMenu;
class BMenuItem;
class BPath; class BPath;
class BStatusBar; class BStatusBar;
class BStringView; class BStringView;
@ -142,6 +143,8 @@ private:
private: private:
BMenu* fGoMenu; BMenu* fGoMenu;
BMenuItem* fZoomTextOnlyMenuItem;
bool fZoomTextOnly;
IconButton* fBackButton; IconButton* fBackButton;
IconButton* fForwardButton; IconButton* fForwardButton;
IconButton* fStopButton; IconButton* fStopButton;