- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / app_panel_browser_frame_view.h
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_APP_PANEL_BROWSER_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_APP_PANEL_BROWSER_FRAME_VIEW_H_
7
8 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
9 #include "chrome/browser/ui/views/tab_icon_view_model.h"
10 #include "ui/views/controls/button/button.h"
11
12 class BrowserFrame;
13 class BrowserView;
14 class TabIconView;
15
16 namespace views {
17 class ImageButton;
18 }
19
20 // The frame view which is used for Application Panels.
21 // TODO(rafaelw): Refactor. This shares much duplicated code with
22 // OpaqueBrowserFrameView.
23 class AppPanelBrowserFrameView : public BrowserNonClientFrameView,
24                                  public views::ButtonListener,
25                                  public chrome::TabIconViewModel {
26  public:
27   // Constructs a non-client view for an BrowserFrame.
28   AppPanelBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
29   virtual ~AppPanelBrowserFrameView();
30
31   // Overridden from BrowserNonClientFrameView:
32   virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
33   virtual TabStripInsets GetTabStripInsets(bool restored) const OVERRIDE;
34   virtual int GetThemeBackgroundXInset() const OVERRIDE;
35   virtual void UpdateThrobber(bool running) OVERRIDE;
36   virtual gfx::Size GetMinimumSize() OVERRIDE;
37
38  protected:
39   // Overridden from views::NonClientFrameView:
40   virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
41   virtual gfx::Rect GetWindowBoundsForClientBounds(
42       const gfx::Rect& client_bounds) const OVERRIDE;
43   virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
44   virtual void GetWindowMask(const gfx::Size& size,
45                              gfx::Path* window_mask) OVERRIDE;
46   virtual void ResetWindowControls() OVERRIDE;
47   virtual void UpdateWindowIcon() OVERRIDE;
48
49   // Overridden from views::View:
50   virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
51   virtual void Layout() OVERRIDE;
52
53   // Overridden from views::ButtonListener:
54   virtual void ButtonPressed(views::Button* sender,
55                              const ui::Event& event) OVERRIDE;
56
57   // Overridden from chrome::TabIconViewModel:
58   virtual bool ShouldTabIconViewAnimate() const OVERRIDE;
59   virtual gfx::ImageSkia GetFaviconForTabIconView() OVERRIDE;
60
61  private:
62   // Returns the thickness of the border that makes up the window frame edges.
63   // This does not include any client edge.
64   int FrameBorderThickness() const;
65
66   // Returns the thickness of the entire nonclient left, right, and bottom
67   // borders, including both the window frame and any client edge.
68   int NonClientBorderThickness() const;
69
70   // Returns the height of the entire nonclient top border, including the window
71   // frame, any title area, and any connected client edge.
72   int NonClientTopBorderHeight() const;
73
74   // Returns the thickness of the nonclient portion of the 3D edge along the
75   // bottom of the titlebar.
76   int TitlebarBottomThickness() const;
77
78   // Returns the size of the titlebar icon.
79   int IconSize() const;
80
81   // Returns the bounds of the titlebar icon.
82   gfx::Rect IconBounds() const;
83
84   // Paint various sub-components of this view.  The *FrameBorder() function
85   // also paints the background of the titlebar area, since the top frame border
86   // and titlebar background are a contiguous component.
87   void PaintRestoredFrameBorder(gfx::Canvas* canvas);
88   void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
89   void PaintTitleBar(gfx::Canvas* canvas);
90   void PaintRestoredClientEdge(gfx::Canvas* canvas);
91
92   // Layout various sub-components of this view.
93   void LayoutWindowControls();
94   void LayoutTitleBar();
95
96   // Returns the bounds of the client area for the specified view size.
97   gfx::Rect CalculateClientAreaBounds(int width, int height) const;
98
99   // The layout rect of the title, if visible.
100   gfx::Rect title_bounds_;
101
102   // Window controls.
103   views::ImageButton* close_button_;
104
105   // The Window icon.
106   TabIconView* window_icon_;
107
108   // The bounds of the ClientView.
109   gfx::Rect client_view_bounds_;
110
111   DISALLOW_COPY_AND_ASSIGN(AppPanelBrowserFrameView);
112 };
113
114 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_APP_PANEL_BROWSER_FRAME_VIEW_H_