Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.mm

Issue 1019023002: MacViews: Implement non-client frame view (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wrench-menu
Patch Set: Use Yosemite colors Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mac.h"
6
7 #include "chrome/browser/themes/theme_properties.h"
8 #include "chrome/browser/ui/views/frame/browser_frame.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
11 #include "grit/theme_resources.h"
12 #include "ui/base/hit_test.h"
13 #include "ui/base/theme_provider.h"
14 #include "ui/gfx/canvas.h"
15
16 namespace {
17
18 // How far to inset the tabstrip from the sides of the window.
19 const int kTabstripTopInset = 8;
20 const int kTabstripLeftInset = 70; // Make room for window control buttons.
21 const int kTabstripRightInset = 0;
22
23 } // namespace
24
25 ///////////////////////////////////////////////////////////////////////////////
26 // BrowserNonClientFrameViewMac, public:
27
28 BrowserNonClientFrameViewMac::BrowserNonClientFrameViewMac(
29 BrowserFrame* frame, BrowserView* browser_view)
30 : BrowserNonClientFrameView(frame, browser_view) {
31 }
32
33 BrowserNonClientFrameViewMac::~BrowserNonClientFrameViewMac() {
34 }
35
36 ///////////////////////////////////////////////////////////////////////////////
37 // BrowserNonClientFrameViewMac, BrowserNonClientFrameView implementation:
38
39 gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForTabStrip(
40 views::View* tabstrip) const {
41 DCHECK(tabstrip);
42 gfx::Rect bounds = gfx::Rect(0, kTabstripTopInset,
43 width(), tabstrip->GetPreferredSize().height());
44 bounds.Inset(kTabstripLeftInset, 0, kTabstripRightInset, 0);
45 return bounds;
46 }
47
48 int BrowserNonClientFrameViewMac::GetTopInset() const {
49 return browser_view()->IsTabStripVisible() ? kTabstripTopInset : 0;
50 }
51
52 int BrowserNonClientFrameViewMac::GetThemeBackgroundXInset() const {
53 return 0;
54 }
55
56 void BrowserNonClientFrameViewMac::UpdateThrobber(bool running) {
57 }
58
59 ///////////////////////////////////////////////////////////////////////////////
60 // BrowserNonClientFrameViewMac, views::NonClientFrameView implementation:
61
62 gfx::Rect BrowserNonClientFrameViewMac::GetBoundsForClientView() const {
63 return bounds();
64 }
65
66 gfx::Rect BrowserNonClientFrameViewMac::GetWindowBoundsForClientBounds(
67 const gfx::Rect& client_bounds) const {
68 return client_bounds;
69 }
70
71 int BrowserNonClientFrameViewMac::NonClientHitTest(const gfx::Point& point) {
72 return frame()->client_view()->NonClientHitTest(point);
73 }
74
75 void BrowserNonClientFrameViewMac::GetWindowMask(const gfx::Size& size,
76 gfx::Path* window_mask) {
77 }
78
79 void BrowserNonClientFrameViewMac::ResetWindowControls() {
80 }
81
82 void BrowserNonClientFrameViewMac::UpdateWindowIcon() {
83 }
84
85 void BrowserNonClientFrameViewMac::UpdateWindowTitle() {
86 }
87
88 void BrowserNonClientFrameViewMac::SizeConstraintsChanged() {
89 }
90
91 ///////////////////////////////////////////////////////////////////////////////
92 // BrowserNonClientFrameViewMac, views::View implementation:
93
94 gfx::Size BrowserNonClientFrameViewMac::GetMinimumSize() const {
95 return browser_view()->GetMinimumSize();
96 }
97
98 ///////////////////////////////////////////////////////////////////////////////
99 // BrowserNonClientFrameViewMac, protected:
100
101 // views::View:
102 void BrowserNonClientFrameViewMac::OnPaint(gfx::Canvas* canvas) {
103 if (!browser_view()->IsBrowserTypeNormal())
104 return;
105
106 canvas->DrawColor(GetFrameColor());
107
108 if (!GetThemeProvider()->UsingSystemTheme())
109 PaintThemedFrame(canvas);
110
111 if (browser_view()->IsToolbarVisible())
112 PaintToolbarBackground(canvas);
113 }
114
115 // BrowserNonClientFrameView:
116 void BrowserNonClientFrameViewMac::UpdateNewStyleAvatar() {
117 NOTIMPLEMENTED();
118 }
119
120 ///////////////////////////////////////////////////////////////////////////////
121 // BrowserNonClientFrameViewMac, private:
122
123 void BrowserNonClientFrameViewMac::PaintThemedFrame(gfx::Canvas* canvas) {
124 gfx::ImageSkia* image = GetFrameImage();
125 if (image)
126 canvas->TileImageInt(*image, 0, 0, width(), image->height());
127
128 gfx::ImageSkia* overlay = GetFrameOverlayImage();
129 if (overlay)
130 canvas->TileImageInt(*overlay, 0, 0, width(), overlay->height());
131 }
132
133 void BrowserNonClientFrameViewMac::PaintToolbarBackground(gfx::Canvas* canvas) {
134 gfx::Rect bounds(browser_view()->GetToolbarBounds());
135 if (bounds.IsEmpty())
136 return;
137
138 ui::ThemeProvider* tp = GetThemeProvider();
139 gfx::ImageSkia* border = tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP);
140 const int top_inset =
141 BrowserViewLayout::kToolbarTabStripVerticalOverlap - border->height();
142
143 const int x = bounds.x();
144 const int y = bounds.y() + top_inset;
145 const int w = bounds.width();
146 const int h = bounds.height() - top_inset;
147
148 // The tabstrip border image height is 2*scale pixels, but only the bottom 2
149 // pixels contain the actual border (the rest is transparent). We can't draw
150 // the toolbar image below this transparent upper area when scale > 1.
151 const int fill_y = y + canvas->image_scale() - 1;
152 const int fill_height = bounds.bottom() - fill_y;
153
154 // Draw the toolbar fill.
155 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR),
156 x + GetThemeBackgroundXInset(), fill_y - GetTopInset(),
157 x, fill_y, w, fill_height);
158
159 // Draw the tabstrip/toolbar separator.
160 canvas->TileImageInt(*border, 0, 0, x, y, w, border->height());
161
162 // Draw the content/toolbar separator.
163 canvas->FillRect(
164 gfx::Rect(x, y + h - kClientEdgeThickness, w, kClientEdgeThickness),
165 ThemeProperties::GetDefaultColor(
166 ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698