1 // Copyright 2014 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 APPS_UI_VIEWS_APP_WINDOW_FRAME_VIEW_H_
6 #define APPS_UI_VIEWS_APP_WINDOW_FRAME_VIEW_H_
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/geometry/size.h"
13 #include "ui/gfx/path.h"
14 #include "ui/views/controls/button/button.h"
15 #include "ui/views/window/non_client_view.h"
19 namespace extensions
{
20 class NativeAppWindow
;
39 // A frameless or non-Ash, non-panel NonClientFrameView for app windows.
40 class AppWindowFrameView
: public views::NonClientFrameView
,
41 public views::ButtonListener
{
43 static const char kViewClassName
[];
45 // AppWindowFrameView is used to draw frames for app windows when a non
46 // standard frame is needed. This occurs if there is no frame needed, or if
47 // there is a frame color.
48 // If |draw_frame| is true, the view draws its own window title area and
49 // controls, using |frame_color|. If |draw_frame| is not true, no frame is
51 // TODO(benwells): Refactor this to split out frameless and colored frame
52 // views. See http://crbug.com/359432.
53 AppWindowFrameView(views::Widget
* widget
,
54 extensions::NativeAppWindow
* window
,
56 const SkColor
& active_frame_color
,
57 const SkColor
& inactive_frame_color
);
58 ~AppWindowFrameView() override
;
62 void SetResizeSizes(int resize_inside_bounds_size
,
63 int resize_outside_bounds_size
,
64 int resize_area_corner_size
);
65 int resize_inside_bounds_size() const {
66 return resize_inside_bounds_size_
;
70 // views::NonClientFrameView implementation.
71 gfx::Rect
GetBoundsForClientView() const override
;
72 gfx::Rect
GetWindowBoundsForClientBounds(
73 const gfx::Rect
& client_bounds
) const override
;
74 int NonClientHitTest(const gfx::Point
& point
) override
;
75 void GetWindowMask(const gfx::Size
& size
, gfx::Path
* window_mask
) override
;
76 void ResetWindowControls() override
{}
77 void UpdateWindowIcon() override
{}
78 void UpdateWindowTitle() override
{}
79 void SizeConstraintsChanged() override
;
81 // views::View implementation.
82 gfx::Size
GetPreferredSize() const override
;
83 void Layout() override
;
84 const char* GetClassName() const override
;
85 void OnPaint(gfx::Canvas
* canvas
) override
;
86 gfx::Size
GetMinimumSize() const override
;
87 gfx::Size
GetMaximumSize() const override
;
89 // views::ButtonListener implementation.
90 void ButtonPressed(views::Button
* sender
, const ui::Event
& event
) override
;
92 // Some button images we use depend on the color of the frame. This
93 // will set these images based on the color of the frame.
94 void SetButtonImagesForFrame();
96 // Return the current frame color based on the active state of the window.
97 SkColor
CurrentFrameColor();
99 views::Widget
* widget_
;
100 extensions::NativeAppWindow
* window_
;
102 SkColor active_frame_color_
;
103 SkColor inactive_frame_color_
;
104 views::ImageButton
* close_button_
;
105 views::ImageButton
* maximize_button_
;
106 views::ImageButton
* restore_button_
;
107 views::ImageButton
* minimize_button_
;
109 // Allow resize for clicks this many pixels inside the bounds.
110 int resize_inside_bounds_size_
;
112 // Allow resize for clicks this many pixels outside the bounds.
113 int resize_outside_bounds_size_
;
115 // Size in pixels of the lower-right corner resize handle.
116 int resize_area_corner_size_
;
118 DISALLOW_COPY_AND_ASSIGN(AppWindowFrameView
);
123 #endif // APPS_UI_VIEWS_APP_WINDOW_FRAME_VIEW_H_