OLD | NEW |
| (Empty) |
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_PANELS_PANEL_FRAME_VIEW_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_FRAME_VIEW_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "chrome/browser/ui/panels/panel_constants.h" | |
10 #include "chrome/browser/ui/views/tab_icon_view_model.h" | |
11 #include "ui/views/controls/button/button.h" | |
12 #include "ui/views/window/non_client_view.h" | |
13 | |
14 class PanelView; | |
15 class TabIconView; | |
16 | |
17 namespace views { | |
18 class ImageButton; | |
19 class Label; | |
20 } | |
21 | |
22 class PanelFrameView : public views::NonClientFrameView, | |
23 public views::ButtonListener, | |
24 public TabIconViewModel { | |
25 public: | |
26 enum PaintState { | |
27 PAINT_AS_INACTIVE, | |
28 PAINT_AS_ACTIVE, | |
29 PAINT_AS_MINIMIZED, | |
30 PAINT_FOR_ATTENTION | |
31 }; | |
32 | |
33 explicit PanelFrameView(PanelView* panel_view); | |
34 ~PanelFrameView() override; | |
35 | |
36 void Init(); | |
37 void UpdateTitle(); | |
38 void UpdateIcon(); | |
39 void UpdateThrobber(); | |
40 void UpdateTitlebarMinimizeRestoreButtonVisibility(); | |
41 void SetWindowCornerStyle(panel::CornerStyle corner_style); | |
42 | |
43 // Returns the size of the non-client area, that is, the window size minus | |
44 // the size of the client area. | |
45 gfx::Size NonClientAreaSize() const; | |
46 | |
47 int BorderThickness() const; | |
48 | |
49 PaintState GetPaintState() const; | |
50 | |
51 views::ImageButton* close_button() const { return close_button_; } | |
52 views::ImageButton* minimize_button() const { return minimize_button_; } | |
53 views::ImageButton* restore_button() const { return restore_button_; } | |
54 TabIconView* title_icon() const { return title_icon_; } | |
55 views::Label* title_label() const { return title_label_; } | |
56 panel::CornerStyle corner_style() const { return corner_style_; } | |
57 | |
58 private: | |
59 // Overridden from views::NonClientFrameView: | |
60 gfx::Rect GetBoundsForClientView() const override; | |
61 gfx::Rect GetWindowBoundsForClientBounds( | |
62 const gfx::Rect& client_bounds) const override; | |
63 int NonClientHitTest(const gfx::Point& point) override; | |
64 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; | |
65 void ResetWindowControls() override; | |
66 void UpdateWindowIcon() override; | |
67 void UpdateWindowTitle() override; | |
68 void SizeConstraintsChanged() override; | |
69 | |
70 // Overridden from views::View: | |
71 gfx::Size GetPreferredSize() const override; | |
72 const char* GetClassName() const override; | |
73 gfx::Size GetMinimumSize() const override; | |
74 gfx::Size GetMaximumSize() const override; | |
75 void Layout() override; | |
76 void OnPaint(gfx::Canvas* canvas) override; | |
77 bool OnMousePressed(const ui::MouseEvent& event) override; | |
78 bool OnMouseDragged(const ui::MouseEvent& event) override; | |
79 void OnMouseReleased(const ui::MouseEvent& event) override; | |
80 void OnMouseCaptureLost() override; | |
81 | |
82 // Overridden from views::ButtonListener: | |
83 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
84 | |
85 // Overridden from TabIconViewModel: | |
86 bool ShouldTabIconViewAnimate() const override; | |
87 gfx::ImageSkia GetFaviconForTabIconView() override; | |
88 | |
89 int TitlebarHeight() const; | |
90 | |
91 const gfx::ImageSkia* GetFrameBackground(PaintState paint_state) const; | |
92 | |
93 // Update control styles to indicate if the titlebar is active or not. | |
94 void UpdateControlStyles(PaintState paint_state); | |
95 | |
96 // Custom draw the frame. | |
97 void PaintFrameBackground(gfx::Canvas* canvas); | |
98 void PaintFrameEdge(gfx::Canvas* canvas); | |
99 | |
100 // Retrieves the drawing metrics based on the current painting state. | |
101 SkColor GetTitleColor(PaintState paint_state) const; | |
102 | |
103 // Returns true if |mouse_location| is within the panel's resizing area. | |
104 bool IsWithinResizingArea(const gfx::Point& mouse_location) const; | |
105 | |
106 static const char kViewClassName[]; | |
107 | |
108 bool is_frameless_; | |
109 PanelView* panel_view_; | |
110 views::ImageButton* close_button_; | |
111 views::ImageButton* minimize_button_; | |
112 views::ImageButton* restore_button_; | |
113 TabIconView* title_icon_; | |
114 views::Label* title_label_; | |
115 panel::CornerStyle corner_style_; | |
116 | |
117 DISALLOW_COPY_AND_ASSIGN(PanelFrameView); | |
118 }; | |
119 | |
120 #endif // CHROME_BROWSER_UI_VIEWS_PANELS_PANEL_FRAME_VIEW_H_ | |
OLD | NEW |