diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 19:18:15 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-10 19:18:15 +0000 |
commit | 6d7b953ec6132658ec7f85c2976c98ecd0c852b2 (patch) | |
tree | c318e59ed09ce88dafb5fabc094a26247bf52ebd /chrome/browser/views | |
parent | 08658a41d004daaf4183537fe2314eb2532881ee (diff) | |
download | chromium_src-6d7b953ec6132658ec7f85c2976c98ecd0c852b2.zip chromium_src-6d7b953ec6132658ec7f85c2976c98ecd0c852b2.tar.gz chromium_src-6d7b953ec6132658ec7f85c2976c98ecd0c852b2.tar.bz2 |
Relanding of http://codereview.chromium.org/16488.
Adding proper project dependency in chrome.sln.
Review URL: http://codereview.chromium.org/21188
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9493 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/download_shelf_view.cc | 8 | ||||
-rw-r--r-- | chrome/browser/views/download_shelf_view.h | 10 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 115 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 5 |
4 files changed, 126 insertions, 12 deletions
diff --git a/chrome/browser/views/download_shelf_view.cc b/chrome/browser/views/download_shelf_view.cc index 5467be7..d4e02ed 100644 --- a/chrome/browser/views/download_shelf_view.cc +++ b/chrome/browser/views/download_shelf_view.cc @@ -73,7 +73,7 @@ int CenterPosition(int size, int target_size) { return std::max((target_size - size) / 2, kTopBottomPadding); } -} // namespace +} // namespace DownloadShelfView::DownloadShelfView(TabContents* tab_contents) : tab_contents_(tab_contents) { @@ -207,6 +207,9 @@ void DownloadShelfView::Layout() { if (!GetWidget()) return; + // Let our base class layout our child views + views::View::Layout(); + gfx::Size image_size = arrow_image_->GetPreferredSize(); gfx::Size close_button_size = close_button_->GetPreferredSize(); gfx::Size show_all_size = show_all_view_->GetPreferredSize(); @@ -270,3 +273,6 @@ void DownloadShelfView::ButtonPressed(views::BaseButton* button) { shelf_animation_->Hide(); } +bool DownloadShelfView::IsShowing() const { + return shelf_animation_->IsShowing(); +} diff --git a/chrome/browser/views/download_shelf_view.h b/chrome/browser/views/download_shelf_view.h index 35213a8..3f157a4 100644 --- a/chrome/browser/views/download_shelf_view.h +++ b/chrome/browser/views/download_shelf_view.h @@ -31,7 +31,7 @@ class DownloadShelfView : public views::View, public views::LinkController, public AnimationDelegate { public: - DownloadShelfView(TabContents* tab_contents); + explicit DownloadShelfView(TabContents* tab_contents); // A new download has started, so add it to our shelf. void AddDownload(DownloadItem* download); @@ -68,6 +68,12 @@ class DownloadShelfView : public views::View, // one. void ChangeTabContents(TabContents* old_contents, TabContents* new_contents); + // The browser view needs to know when we are going away to properly return + // the resize corner size to WebKit so that we don't draw on top of it. + // This returns the showing state of our animation which is set to false at + // the beginning Show and true at the beginning of a Hide. + bool IsShowing() const; + private: void Init(); @@ -107,5 +113,5 @@ class DownloadShelfView : public views::View, DISALLOW_EVIL_CONSTRUCTORS(DownloadShelfView); }; -#endif // CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H__ +#endif // CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H__ diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index e57b2cc..8ccb3e5 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -47,12 +47,15 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" #include "chrome/views/hwnd_notification_source.h" +#include "chrome/views/native_scroll_bar.h" #include "chrome/views/non_client_view.h" #include "chrome/views/view.h" #include "chrome/views/window.h" #include "chromium_strings.h" #include "generated_resources.h" +#include "webkit_resources.h" + using base::TimeDelta; @@ -86,7 +89,11 @@ static const int kLoadingAnimationFrameTimeMs = 30; // If not -1, windows are shown with this state. static int explicit_show_state = -1; -static const struct { bool separator; int command; int label; } kMenuLayout[] = { +static const struct { + bool separator; + int command; + int label; +} kMenuLayout[] = { { true, 0, 0 }, { false, IDC_TASK_MANAGER, IDS_TASK_MANAGER }, { true, 0, 0 }, @@ -111,6 +118,53 @@ static const struct { bool separator; int command; int label; } kMenuLayout[] = }; /////////////////////////////////////////////////////////////////////////////// +// ResizeCorner, private: + +class ResizeCorner : public views::View { + public: + ResizeCorner() {} + virtual void Paint(ChromeCanvas* canvas) { + SkBitmap * bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_TEXTAREA_RESIZER); + bitmap->buildMipMap(false); + bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); + if (rtl_dir) { + canvas->TranslateInt(width(), 0); + canvas->ScaleInt(-1, 1); + canvas->save(); + } + canvas->DrawBitmapInt(*bitmap, width() - bitmap->width(), + height() - bitmap->height()); + if (rtl_dir) + canvas->restore(); + } + + static gfx::Size GetSize() { + return gfx::Size(views::NativeScrollBar::GetVerticalScrollBarWidth(), + views::NativeScrollBar::GetHorizontalScrollBarHeight()); + } + + virtual gfx::Size GetPreferredSize() { + return GetSize(); + } + + virtual void Layout() { + views::View* parent_view = GetParent(); + if (parent_view) { + gfx::Size ps = GetPreferredSize(); + // No need to handle Right to left text direction here, + // our parent must take care of it for us... + SetBounds(parent_view->width() - ps.width(), + parent_view->height() - ps.height(), ps.width(), ps.height()); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(ResizeCorner); +}; + + +/////////////////////////////////////////////////////////////////////////////// // BrowserView, public: // static @@ -119,7 +173,7 @@ void BrowserView::SetShowState(int state) { } BrowserView::BrowserView(Browser* browser) - : ClientView(NULL, NULL), + : views::ClientView(NULL, NULL), frame_(NULL), browser_(browser), active_bookmark_bar_(NULL), @@ -177,7 +231,7 @@ void BrowserView::WindowMoved() { // Cancel any tabstrip animations, some of them may be invalidated by the // window being repositioned. // Comment out for one cycle to see if this fixes dist tests. - //tabstrip_->DestroyDragController(); + // tabstrip_->DestroyDragController(); status_bubble_->Reposition(); @@ -491,7 +545,7 @@ gfx::Rect BrowserView::GetNormalBounds() const { return gfx::Rect(wp.rcNormalPosition); } -bool BrowserView::IsMaximized() { +bool BrowserView::IsMaximized() const { return frame_->GetWindow()->IsMaximized(); } @@ -535,6 +589,32 @@ bool BrowserView::IsBookmarkBarVisible() const { return bookmark_bar_view_->GetPreferredSize().height() > 1; } +gfx::Rect BrowserView::GetRootWindowResizerRect() const { + // There is no resize corner when we are maximized + if (IsMaximized()) + return gfx::Rect(); + + // We don't specify a resize corner size if we have a bottom shelf either. + // This is because we take care of drawing the resize corner on top of that + // shelf, so we don't want others to do it for us in this case. + // Currently, the only visible bottom shelf is the download shelf. + // Other tests should be added here if we add more bottom shelves. + TabContents* current_tab = browser_->GetSelectedTabContents(); + if (current_tab && current_tab->IsDownloadShelfVisible()) { + DownloadShelfView* download_shelf = current_tab->GetDownloadShelfView(); + if (download_shelf && download_shelf->IsShowing()) + return gfx::Rect(); + } + + gfx::Rect client_rect = contents_container_->bounds(); + gfx::Size resize_corner_size = ResizeCorner::GetSize(); + int x = client_rect.width() - resize_corner_size.width(); + if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) + x = 0; + return gfx::Rect(x, client_rect.height() - resize_corner_size.height(), + resize_corner_size.width(), resize_corner_size.height()); +} + void BrowserView::ToggleBookmarkBar() { BookmarkBarView::ToggleWhenVisible(browser_->profile()); } @@ -887,6 +967,24 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { // area of the window. So we need to treat hit-tests in these regions as // hit-tests of the titlebar. + // There is not resize corner when we are maximised + if (!IsMaximized()) { + CRect client_rect; + ::GetClientRect(frame_->GetWindow()->GetHWND(), &client_rect); + gfx::Size resize_corner_size = ResizeCorner::GetSize(); + gfx::Rect resize_corner_rect(client_rect.right - resize_corner_size.width(), + client_rect.bottom - resize_corner_size.height(), + resize_corner_size.width(), resize_corner_size.height()); + bool rtl_dir = (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT); + if (rtl_dir) + resize_corner_rect.set_x(0); + if (resize_corner_rect.Contains(point)) { + if (rtl_dir) + return HTBOTTOMLEFT; + return HTBOTTOMRIGHT; + } + } + // Determine if the TabStrip exists and is capable of being clicked on. We // might be a popup window without a TabStrip, or the TabStrip could be // animating. @@ -940,7 +1038,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { return HTNOWHERE; // If the point is somewhere else, delegate to the default implementation. - return ClientView::NonClientHitTest(point); + return views::ClientView::NonClientHitTest(point); } /////////////////////////////////////////////////////////////////////////////// @@ -1119,7 +1217,7 @@ int BrowserView::LayoutBookmarkAndInfoBars(int top) { return LayoutBookmarkBar(top); } - // If we're showing a regular bookmark bar and it's not below an infobar, + // If we're showing a regular bookmark bar and it's not below an infobar, // make it overlap the toolbar so that the bar items can be drawn higher. if (active_bookmark_bar_) top -= bookmark_bar_view_->GetToolbarOverlap(); @@ -1200,8 +1298,11 @@ bool BrowserView::MaybeShowInfoBar(TabContents* contents) { bool BrowserView::MaybeShowDownloadShelf(TabContents* contents) { views::View* new_shelf = NULL; - if (contents && contents->IsDownloadShelfVisible()) + if (contents && contents->IsDownloadShelfVisible()) { new_shelf = contents->GetDownloadShelfView(); + if (new_shelf != active_download_shelf_) + new_shelf->AddChildView(new ResizeCorner()); + } return UpdateChildViewAndLayout(new_shelf, &active_download_shelf_); } diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 7be0501..ba247c9 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -172,13 +172,14 @@ class BrowserView : public BrowserWindow, virtual void UpdateLoadingAnimations(bool should_animate); virtual void SetStarredState(bool is_starred); virtual gfx::Rect GetNormalBounds() const; - virtual bool IsMaximized(); + virtual bool IsMaximized() const; virtual LocationBar* GetLocationBar() const; virtual void UpdateStopGoState(bool is_loading); virtual void UpdateToolbar(TabContents* contents, bool should_restore_state); virtual void FocusToolbar(); virtual void DestroyBrowser(); virtual bool IsBookmarkBarVisible() const; + virtual gfx::Rect GetRootWindowResizerRect() const; virtual void ToggleBookmarkBar(); virtual void ShowAboutChromeDialog(); virtual void ShowBookmarkManager(); @@ -428,4 +429,4 @@ class BrowserView : public BrowserWindow, DISALLOW_EVIL_CONSTRUCTORS(BrowserView); }; -#endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_H_ +#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_H_ |