Commit 96ccb077 authored by cpu@chromium.org's avatar cpu@chromium.org

Adding the flip windows button to the browser window

-This is for metro mode
-The image is a placeholder, image to be provided later

BUG=127489
TEST=see the bug for details.
Review URL: https://chromiumcodereview.appspot.com/10388156

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137544 0039d316-1c4b-4281-b951-d872f2087c98
parent 95bc59ce
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/theme_provider.h" #include "ui/base/theme_provider.h"
#include "ui/gfx/font.h" #include "ui/gfx/font.h"
#include "ui/views/controls/menu/native_menu_win.h" #include "ui/views/controls/menu/native_menu_win.h"
...@@ -58,11 +59,25 @@ using content::WebContents; ...@@ -58,11 +59,25 @@ using content::WebContents;
#if !defined(USE_AURA) #if !defined(USE_AURA)
extern "C" { extern "C" {
// Windows metro exported functions from metro_driver.
typedef void (*SetFrameWindow)(HWND window); typedef void (*SetFrameWindow)(HWND window);
typedef void (*CloseFrameWindow)(HWND window); typedef void (*CloseFrameWindow)(HWND window);
typedef void (*FlipFrameWindows)();
} }
#endif // USE_AURA #endif // USE_AURA
views::Button* MakeWindowSwitcherButton(views::ButtonListener* listener) {
views::ImageButton* switcher_button = new views::ImageButton(listener);
switcher_button->SetImage(
views::ImageButton::BS_NORMAL,
ui::ResourceBundle::GetSharedInstance().GetBitmapNamed(
IDR_PAGEINFO_WARNING_MINOR));
// TODO(cpu): Replace IDR_PAGEINFO_WARNING_MINOR with actual image.
switcher_button->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
return switcher_button;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// BrowserFrameWin, public: // BrowserFrameWin, public:
...@@ -73,6 +88,8 @@ BrowserFrameWin::BrowserFrameWin(BrowserFrame* browser_frame, ...@@ -73,6 +88,8 @@ BrowserFrameWin::BrowserFrameWin(BrowserFrame* browser_frame,
browser_frame_(browser_frame), browser_frame_(browser_frame),
system_menu_delegate_(new SystemMenuModelDelegate(browser_view, system_menu_delegate_(new SystemMenuModelDelegate(browser_view,
browser_view->browser())) { browser_view->browser())) {
if (base::win::GetMetroModule())
browser_view->SetWindowSwitcherButton(MakeWindowSwitcherButton(this));
} }
BrowserFrameWin::~BrowserFrameWin() { BrowserFrameWin::~BrowserFrameWin() {
...@@ -263,6 +280,19 @@ void BrowserFrameWin::TabStripDisplayModeChanged() { ...@@ -263,6 +280,19 @@ void BrowserFrameWin::TabStripDisplayModeChanged() {
UpdateDWMFrame(); UpdateDWMFrame();
} }
void BrowserFrameWin::ButtonPressed(views::Button* sender,
const views::Event& event) {
HMODULE metro = base::win::GetMetroModule();
if (!metro)
return;
// Tell the metro_driver to flip our window. This causes the current
// browser window to be hidden and the next window to be shown.
static FlipFrameWindows flip_window_fn = reinterpret_cast<FlipFrameWindows>(
::GetProcAddress(metro, "FlipFrameWindows"));
if (flip_window_fn)
flip_window_fn();
}
LRESULT BrowserFrameWin::OnWndProc(UINT message, LRESULT BrowserFrameWin::OnWndProc(UINT message,
WPARAM w_param, WPARAM w_param,
LPARAM l_param) { LPARAM l_param) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/views/frame/browser_frame.h" #include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/native_browser_frame.h" #include "chrome/browser/ui/views/frame/native_browser_frame.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/widget/native_widget_win.h" #include "ui/views/widget/native_widget_win.h"
class BrowserView; class BrowserView;
...@@ -29,7 +30,8 @@ class NativeMenuWin; ...@@ -29,7 +30,8 @@ class NativeMenuWin;
// for the Chrome browser window. // for the Chrome browser window.
// //
class BrowserFrameWin : public views::NativeWidgetWin, class BrowserFrameWin : public views::NativeWidgetWin,
public NativeBrowserFrame { public NativeBrowserFrame,
public views::ButtonListener {
public: public:
BrowserFrameWin(BrowserFrame* browser_frame, BrowserView* browser_view); BrowserFrameWin(BrowserFrame* browser_frame, BrowserView* browser_view);
virtual ~BrowserFrameWin(); virtual ~BrowserFrameWin();
...@@ -66,6 +68,10 @@ class BrowserFrameWin : public views::NativeWidgetWin, ...@@ -66,6 +68,10 @@ class BrowserFrameWin : public views::NativeWidgetWin,
virtual int GetMinimizeButtonOffset() const OVERRIDE; virtual int GetMinimizeButtonOffset() const OVERRIDE;
virtual void TabStripDisplayModeChanged() OVERRIDE; virtual void TabStripDisplayModeChanged() OVERRIDE;
// Overriden from views::ImageButton override:
virtual void ButtonPressed(views::Button* sender,
const views::Event& event) OVERRIDE;
// Overridden from WindowImpl: // Overridden from WindowImpl:
virtual LRESULT OnWndProc(UINT message, virtual LRESULT OnWndProc(UINT message,
WPARAM w_param, WPARAM w_param,
......
...@@ -297,6 +297,7 @@ BrowserView::BrowserView(Browser* browser) ...@@ -297,6 +297,7 @@ BrowserView::BrowserView(Browser* browser)
active_bookmark_bar_(NULL), active_bookmark_bar_(NULL),
tabstrip_(NULL), tabstrip_(NULL),
toolbar_(NULL), toolbar_(NULL),
window_switcher_button_(NULL),
infobar_container_(NULL), infobar_container_(NULL),
contents_container_(NULL), contents_container_(NULL),
devtools_container_(NULL), devtools_container_(NULL),
...@@ -798,6 +799,13 @@ void BrowserView::RestoreFocus() { ...@@ -798,6 +799,13 @@ void BrowserView::RestoreFocus() {
selected_web_contents->GetView()->RestoreFocus(); selected_web_contents->GetView()->RestoreFocus();
} }
void BrowserView::SetWindowSwitcherButton(views::Button* button) {
if (window_switcher_button_)
RemoveChildView(window_switcher_button_);
window_switcher_button_ = button;
AddChildView(button);
}
LocationBar* BrowserView::GetLocationBar() const { LocationBar* BrowserView::GetLocationBar() const {
return GetLocationBarView(); return GetLocationBarView();
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/sys_color_change_listener.h" #include "ui/gfx/sys_color_change_listener.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/single_split_view_listener.h" #include "ui/views/controls/single_split_view_listener.h"
#include "ui/views/widget/widget_delegate.h" #include "ui/views/widget/widget_delegate.h"
#include "ui/views/window/client_view.h" #include "ui/views/window/client_view.h"
...@@ -200,6 +201,8 @@ class BrowserView : public BrowserWindow, ...@@ -200,6 +201,8 @@ class BrowserView : public BrowserWindow,
// when a new browser window is created. // when a new browser window is created.
void RestoreFocus(); void RestoreFocus();
void SetWindowSwitcherButton(views::Button* button);
#if defined(USE_ASH) #if defined(USE_ASH)
BrowserLauncherItemController* launcher_item_controller() const { BrowserLauncherItemController* launcher_item_controller() const {
return launcher_item_controller_.get(); return launcher_item_controller_.get();
...@@ -580,6 +583,11 @@ class BrowserView : public BrowserWindow, ...@@ -580,6 +583,11 @@ class BrowserView : public BrowserWindow,
// The Toolbar containing the navigation buttons, menus and the address bar. // The Toolbar containing the navigation buttons, menus and the address bar.
ToolbarView* toolbar_; ToolbarView* toolbar_;
// This button sits next to the tabs on the right hand side and it is used
// only in windows metro metro mode to allow the user to flip among browser
// windows.
views::Button* window_switcher_button_;
// The Bookmark Bar View for this window. Lazily created. // The Bookmark Bar View for this window. Lazily created.
scoped_ptr<BookmarkBarView> bookmark_bar_view_; scoped_ptr<BookmarkBarView> bookmark_bar_view_;
......
...@@ -32,6 +32,8 @@ const int kToolbarTabStripVerticalOverlap = 3; ...@@ -32,6 +32,8 @@ const int kToolbarTabStripVerticalOverlap = 3;
// The number of pixels the bookmark bar should overlap the spacer by if the // The number of pixels the bookmark bar should overlap the spacer by if the
// spacer is visible. // spacer is visible.
const int kSpacerBookmarkBarOverlap = 1; const int kSpacerBookmarkBarOverlap = 1;
// The number of pixels the metro switcher is offset from the right edge.
const int kWindowSwitcherOffsetX = 5;
// Combines View::ConvertPointToView and View::HitTest for a given |point|. // Combines View::ConvertPointToView and View::HitTest for a given |point|.
// Converts |point| from |src| to |dst| and hit tests it against |dst|. The // Converts |point| from |src| to |dst| and hit tests it against |dst|. The
...@@ -297,7 +299,6 @@ int BrowserViewLayout::LayoutTabStripRegion() { ...@@ -297,7 +299,6 @@ int BrowserViewLayout::LayoutTabStripRegion() {
tabstrip_->SetBounds(0, 0, 0, 0); tabstrip_->SetBounds(0, 0, 0, 0);
return 0; return 0;
} }
// This retrieves the bounds for the tab strip based on whether or not we show // This retrieves the bounds for the tab strip based on whether or not we show
// anything to the left of it, like the incognito avatar. // anything to the left of it, like the incognito avatar.
gfx::Rect tabstrip_bounds( gfx::Rect tabstrip_bounds(
...@@ -309,7 +310,21 @@ int BrowserViewLayout::LayoutTabStripRegion() { ...@@ -309,7 +310,21 @@ int BrowserViewLayout::LayoutTabStripRegion() {
tabstrip_->SetVisible(true); tabstrip_->SetVisible(true);
tabstrip_->SetBoundsRect(tabstrip_bounds); tabstrip_->SetBoundsRect(tabstrip_bounds);
return tabstrip_bounds.bottom(); int bottom = tabstrip_bounds.bottom();
// The metro window switcher sits at the far right edge of the tabstrip
// a |kWindowSwitcherOffsetY| pixels above the base of the tabstrip.
views::Button* switcher_button = browser_view_->window_switcher_button_;
if (switcher_button) {
int width = browser_view_->width();
gfx::Size ps = switcher_button->GetPreferredSize();
if (width > ps.width()) {
switcher_button->SetBounds(width - ps.width() - kWindowSwitcherOffsetX, 0,
ps.width(), ps.height());
}
}
return bottom;
} }
int BrowserViewLayout::LayoutToolbar(int top) { int BrowserViewLayout::LayoutToolbar(int top) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment