Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ui / views / window / custom_frame_view.h
blobb8fc5c4d86de7a5155965edce87c31a4ddb4a585
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.
5 #ifndef UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_
6 #define UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/views/controls/button/button.h"
12 #include "ui/views/window/frame_buttons.h"
13 #include "ui/views/window/non_client_view.h"
15 namespace gfx {
16 class ImageSkia;
19 namespace views {
21 class FrameBackground;
22 class ImageButton;
23 class Widget;
25 ///////////////////////////////////////////////////////////////////////////////
27 // CustomFrameView
29 // A view that provides the non client frame for Windows. This means
30 // rendering the non-standard window caption, border, and controls.
32 ////////////////////////////////////////////////////////////////////////////////
33 class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
34 public ButtonListener {
35 public:
36 CustomFrameView();
37 ~CustomFrameView() override;
39 void Init(Widget* frame);
41 // Overridden from NonClientFrameView:
42 gfx::Rect GetBoundsForClientView() const override;
43 gfx::Rect GetWindowBoundsForClientBounds(
44 const gfx::Rect& client_bounds) const override;
45 int NonClientHitTest(const gfx::Point& point) override;
46 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override;
47 void ResetWindowControls() override;
48 void UpdateWindowIcon() override;
49 void UpdateWindowTitle() override;
50 void SizeConstraintsChanged() override;
52 // Overridden from View:
53 void OnPaint(gfx::Canvas* canvas) override;
54 void Layout() override;
55 gfx::Size GetPreferredSize() const override;
56 gfx::Size GetMinimumSize() const override;
57 gfx::Size GetMaximumSize() const override;
59 // Overridden from ButtonListener:
60 void ButtonPressed(Button* sender, const ui::Event& event) override;
62 private:
63 friend class CustomFrameViewTest;
65 // Returns the thickness of the border that makes up the window frame edges.
66 // This does not include any client edge.
67 int FrameBorderThickness() const;
69 // Returns the thickness of the entire nonclient left, right, and bottom
70 // borders, including both the window frame and any client edge.
71 int NonClientBorderThickness() const;
73 // Returns the height of the entire nonclient top border, including the window
74 // frame, any title area, and any connected client edge.
75 int NonClientTopBorderHeight() const;
77 // Returns the y-coordinate of the caption buttons.
78 int CaptionButtonY() const;
80 // Returns the thickness of the nonclient portion of the 3D edge along the
81 // bottom of the titlebar.
82 int TitlebarBottomThickness() const;
84 // Returns the size of the titlebar icon. This is used even when the icon is
85 // not shown, e.g. to set the titlebar height.
86 int IconSize() const;
88 // Returns the bounds of the titlebar icon (or where the icon would be if
89 // there was one).
90 gfx::Rect IconBounds() const;
92 // Returns true if the title bar, caption buttons, and frame border should be
93 // drawn. If false, the client view occupies the full area of this view.
94 bool ShouldShowTitleBarAndBorder() const;
96 // Returns true if the client edge should be drawn. This is true if
97 // the window is not maximized.
98 bool ShouldShowClientEdge() const;
100 // Paint various sub-components of this view.
101 void PaintRestoredFrameBorder(gfx::Canvas* canvas);
102 void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
103 void PaintTitleBar(gfx::Canvas* canvas);
104 void PaintRestoredClientEdge(gfx::Canvas* canvas);
106 // Compute aspects of the frame needed to paint the frame background.
107 SkColor GetFrameColor() const;
108 const gfx::ImageSkia* GetFrameImage() const;
110 // Performs the layout for the window control buttons based on the
111 // configuration specified in WindowButtonOrderProvider. The sizing and
112 // positions of the buttons affects LayoutTitleBar, call this beforehand.
113 void LayoutWindowControls();
115 // Calculations depend on the positions of the window controls. Always call
116 // LayoutWindowControls beforehand.
117 void LayoutTitleBar();
118 void LayoutClientView();
120 // Creates, adds and returns a new window caption button (e.g, minimize,
121 // maximize, restore).
122 ImageButton* InitWindowCaptionButton(int accessibility_string_id,
123 int normal_image_id,
124 int hot_image_id,
125 int pushed_image_id);
127 // Returns the window caption button for the given FrameButton type, if it
128 // should be visible. Otherwise NULL.
129 ImageButton* GetImageButton(views::FrameButton button);
131 // The bounds of the client view, in this view's coordinates.
132 gfx::Rect client_view_bounds_;
134 // The layout rect of the title, if visible.
135 gfx::Rect title_bounds_;
137 // Not owned.
138 Widget* frame_;
140 // The icon of this window. May be NULL.
141 ImageButton* window_icon_;
143 // Window caption buttons.
144 ImageButton* minimize_button_;
145 ImageButton* maximize_button_;
146 ImageButton* restore_button_;
147 ImageButton* close_button_;
149 // Background painter for the window frame.
150 scoped_ptr<FrameBackground> frame_background_;
152 // The horizontal boundaries for the title bar to layout within. Restricted
153 // by the space used by the leading and trailing buttons.
154 int minimum_title_bar_x_;
155 int maximum_title_bar_x_;
157 DISALLOW_COPY_AND_ASSIGN(CustomFrameView);
160 } // namespace views
162 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_