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 CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_FRAME_VIEW_H_
8 #include "chrome/browser/ui/panels/panel_constants.h"
9 #include "chrome/browser/ui/views/tab_icon_view_model.h"
10 #include "ui/views/controls/button/button.h"
11 #include "ui/views/window/non_client_view.h"
21 class PanelFrameView
: public views::NonClientFrameView
,
22 public views::ButtonListener
,
23 public chrome::TabIconViewModel
{
32 explicit PanelFrameView(PanelView
* panel_view
);
33 virtual ~PanelFrameView();
38 void UpdateThrobber();
39 void UpdateTitlebarMinimizeRestoreButtonVisibility();
40 void SetWindowCornerStyle(panel::CornerStyle corner_style
);
42 // Returns the size of the non-client area, that is, the window size minus
43 // the size of the client area.
44 gfx::Size
NonClientAreaSize() const;
46 int BorderThickness() const;
48 PaintState
GetPaintState() const;
50 views::ImageButton
* close_button() const { return close_button_
; }
51 views::ImageButton
* minimize_button() const { return minimize_button_
; }
52 views::ImageButton
* restore_button() const { return restore_button_
; }
53 TabIconView
* title_icon() const { return title_icon_
; }
54 views::Label
* title_label() const { return title_label_
; }
55 panel::CornerStyle
corner_style() const { return corner_style_
; }
58 // Overridden from views::NonClientFrameView:
59 virtual gfx::Rect
GetBoundsForClientView() const OVERRIDE
;
60 virtual gfx::Rect
GetWindowBoundsForClientBounds(
61 const gfx::Rect
& client_bounds
) const OVERRIDE
;
62 virtual int NonClientHitTest(const gfx::Point
& point
) OVERRIDE
;
63 virtual void GetWindowMask(const gfx::Size
& size
,
64 gfx::Path
* window_mask
) OVERRIDE
;
65 virtual void ResetWindowControls() OVERRIDE
;
66 virtual void UpdateWindowIcon() OVERRIDE
;
67 virtual void UpdateWindowTitle() OVERRIDE
;
69 // Overridden from views::View:
70 virtual gfx::Size
GetPreferredSize() const OVERRIDE
;
71 virtual const char* GetClassName() const OVERRIDE
;
72 virtual gfx::Size
GetMinimumSize() const OVERRIDE
;
73 virtual gfx::Size
GetMaximumSize() OVERRIDE
;
74 virtual void Layout() OVERRIDE
;
75 virtual void OnPaint(gfx::Canvas
* canvas
) OVERRIDE
;
76 virtual bool OnMousePressed(const ui::MouseEvent
& event
) OVERRIDE
;
77 virtual bool OnMouseDragged(const ui::MouseEvent
& event
) OVERRIDE
;
78 virtual void OnMouseReleased(const ui::MouseEvent
& event
) OVERRIDE
;
79 virtual void OnMouseCaptureLost() OVERRIDE
;
81 // Overridden from views::ButtonListener:
82 virtual void ButtonPressed(views::Button
* sender
, const ui::Event
& event
)
85 // Overridden from chrome::TabIconViewModel:
86 virtual bool ShouldTabIconViewAnimate() const OVERRIDE
;
87 virtual gfx::ImageSkia
GetFaviconForTabIconView() OVERRIDE
;
89 int TitlebarHeight() const;
91 const gfx::ImageSkia
* GetFrameBackground(PaintState paint_state
) const;
93 // Update control styles to indicate if the titlebar is active or not.
94 void UpdateControlStyles(PaintState paint_state
);
96 // Custom draw the frame.
97 void PaintFrameBackground(gfx::Canvas
* canvas
);
98 void PaintFrameEdge(gfx::Canvas
* canvas
);
100 // Retrieves the drawing metrics based on the current painting state.
101 SkColor
GetTitleColor(PaintState paint_state
) const;
103 static const char kViewClassName
[];
106 PanelView
* panel_view_
;
107 views::ImageButton
* close_button_
;
108 views::ImageButton
* minimize_button_
;
109 views::ImageButton
* restore_button_
;
110 TabIconView
* title_icon_
;
111 views::Label
* title_label_
;
112 panel::CornerStyle corner_style_
;
114 DISALLOW_COPY_AND_ASSIGN(PanelFrameView
);
117 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_FRAME_VIEW_H_