158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// found in the LICENSE file. 458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ 658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#define CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ 758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" 958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "ui/views/layout/layout_manager.h" 10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "ui/views/window/frame_buttons.h" 1158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class AvatarLabel; 13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class AvatarMenuButton; 148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)class NewAvatarButton; 1558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class OpaqueBrowserFrameViewLayoutDelegate; 1658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 1758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace views { 1858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class ImageButton; 1958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class Label; 2058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)} 2158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 2258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Calculates the position of the widgets in the opaque browser frame view. 2358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// 2458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// This is separated out for testing reasons. OpaqueBrowserFrameView has tight 2558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// dependencies with Browser and classes that depend on Browser. 2658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class OpaqueBrowserFrameViewLayout : public views::LayoutManager { 2758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) public: 2858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) explicit OpaqueBrowserFrameViewLayout( 2958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) OpaqueBrowserFrameViewLayoutDelegate* delegate); 3058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) virtual ~OpaqueBrowserFrameViewLayout(); 3158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 32a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Whether we should add the (minimize,maximize,close) buttons. This should be 33a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // true if the buttons could be shown at any time in this session (see 34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // OpaqueBrowserFrameViewLayoutDelegate::ShouldShowCaptionButtons for whether 35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // they are currently visible). 3658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) static bool ShouldAddDefaultCaptionButtons(); 3758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Configures the button ordering in the frame. 39d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void SetButtonOrdering( 40d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const std::vector<views::FrameButton>& leading_buttons, 41d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) const std::vector<views::FrameButton>& trailing_buttons); 42d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) 4358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect GetBoundsForTabStrip( 4458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) const gfx::Size& tabstrip_preferred_size, 4558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int available_width) const; 4658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 4758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Size GetMinimumSize(int available_width) const; 4858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 4958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the bounds of the window required to display the content area at 5058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // the specified bounds. 5158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect GetWindowBoundsForClientBounds( 5258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) const gfx::Rect& client_bounds) const; 5358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 5458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the thickness of the border that makes up the window frame edges. 5558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // This does not include any client edge. If |restored| is true, acts as if 5658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // the window is restored regardless of the real mode. 5758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int FrameBorderThickness(bool restored) const; 5858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 5958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the thickness of the entire nonclient left, right, and bottom 6058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // borders, including both the window frame and any client edge. 6158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int NonClientBorderThickness() const; 6258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 6358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the height of the entire nonclient top border, including the window 6458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // frame, any title area, and any connected client edge. If |restored| is 6558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // true, acts as if the window is restored regardless of the real mode. 6658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int NonClientTopBorderHeight(bool restored) const; 6758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 6858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int GetTabStripInsetsTop(bool restored) const; 6958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 7058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the y-coordinate of the caption buttons. If |restored| is true, 7158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // acts as if the window is restored regardless of the real mode. 7258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int CaptionButtonY(bool restored) const; 7358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 7458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the thickness of the 3D edge along the bottom of the titlebar. If 7558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // |restored| is true, acts as if the window is restored regardless of the 7658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // real mode. 7758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int TitlebarBottomThickness(bool restored) const; 7858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 7958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the bounds of the titlebar icon (or where the icon would be if 8058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // there was one). 8158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect IconBounds() const; 8258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 8358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Returns the bounds of the client area for the specified view size. 8458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect CalculateClientAreaBounds(int width, int height) const; 8558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 8658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void set_extra_caption_y(int extra_caption_y) { 8758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) extra_caption_y_ = extra_caption_y; 8858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 8958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 9058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void set_window_caption_spacing(int window_caption_spacing) { 9158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) window_caption_spacing_ = window_caption_spacing; 9258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) } 9358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 9458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) const gfx::Rect& client_view_bounds() const { return client_view_bounds_; } 9558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Determines whether the title bar is condensed vertically, as when the 975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // window is maximized. If true, the title bar is just the height of a tab, 985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // rather than having extra vertical space above the tabs. This also removes 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // the thick frame border and rounded corners. 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool IsTitleBarCondensed() const; 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 10258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) private: 10358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Whether a specific button should be inserted on the leading or trailing 10458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // side. 10558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) enum ButtonAlignment { 10658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) ALIGN_LEADING, 10758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) ALIGN_TRAILING 10858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) }; 10958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 110a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Determines whether the avatar should be shown on the right side of the tab 111a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // strip (instead of the usual left). 112a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) bool ShouldAvatarBeOnRight() const; 113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Determines the amount of spacing between the New Tab button and the element 1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // to its immediate right. 1165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) int NewTabCaptionSpacing() const; 1175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 11858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Layout various sub-components of this view. 11958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void LayoutWindowControls(views::View* host); 12058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void LayoutTitleBar(views::View* host); 121a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void LayoutAvatar(views::View* host); 1228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void LayoutNewStyleAvatar(views::View* host); 12358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 12458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void ConfigureButton(views::View* host, 125d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) views::FrameButton button_id, 12658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) ButtonAlignment align, 12758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int caption_y); 12858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 12958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Sets the visibility of all buttons associated with |button_id| to false. 130d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) void HideButton(views::FrameButton button_id); 13158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 13258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Adds a window caption button to either the leading or trailing side. 13358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void SetBoundsForButton(views::View* host, 13458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) views::ImageButton* button, 13558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) ButtonAlignment align, 13658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int caption_y); 13758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 13858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Internal implementation of ViewAdded() and ViewRemoved(). 13958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) void SetView(int id, views::View* view); 14058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 14158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Overriden from views::LayoutManager: 14258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) virtual void Layout(views::View* host) OVERRIDE; 143cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual gfx::Size GetPreferredSize(const views::View* host) const OVERRIDE; 14458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) virtual void ViewAdded(views::View* host, views::View* view) OVERRIDE; 14558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) virtual void ViewRemoved(views::View* host, views::View* view) OVERRIDE; 14658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 14758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) OpaqueBrowserFrameViewLayoutDelegate* delegate_; 14858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 14958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // The layout rect of the avatar icon, if visible. 15058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect avatar_bounds_; 15158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 15258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // The bounds of the ClientView. 15358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect client_view_bounds_; 15458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 15558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // The layout of the window icon, if visible. 15658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) gfx::Rect window_icon_bounds_; 15758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 15858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // How far from the leading/trailing edge of the view the next window control 15958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // should be placed. 16058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int leading_button_start_; 16158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int trailing_button_start_; 16258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 16358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // The size of the window buttons, and the avatar menu item (if any). This 16458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // does not count labels or other elements that should be counted in a 16558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // minimal frame. 16658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int minimum_size_for_buttons_; 16758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 16858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Whether any of the window control buttons were packed on the leading. 16958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) bool has_leading_buttons_; 17058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) bool has_trailing_buttons_; 17158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 17258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Extra offset from the top of the frame to the top of the window control 17358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // buttons. Configurable based on platform and whether we are under test. 17458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int extra_caption_y_; 17558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 17658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Extra offset between the individual window caption buttons. 17758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) int window_caption_spacing_; 17858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 17958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) // Window controls. 18058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) views::ImageButton* minimize_button_; 18158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) views::ImageButton* maximize_button_; 18258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) views::ImageButton* restore_button_; 18358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) views::ImageButton* close_button_; 18458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 18558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) views::View* window_icon_; 18658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) views::Label* window_title_; 18758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 1885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AvatarLabel* avatar_label_; 189a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) AvatarMenuButton* avatar_button_; 190f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) views::View* new_avatar_button_; 19158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 192d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) std::vector<views::FrameButton> leading_buttons_; 193d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) std::vector<views::FrameButton> trailing_buttons_; 19458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 19558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameViewLayout); 19658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}; 19758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 19858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif // CHROME_BROWSER_UI_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_LAYOUT_H_ 199