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

Side by Side Diff: chrome/browser/ui/views/frame/browser_frame_aura.cc

Issue 9580001: Aura: Update window frames, allow resize from outside window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix caption for maximized windows, new resize cursor tweak Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_frame_aura.h" 5 #include "chrome/browser/ui/views/frame/browser_frame_aura.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/chromeos/status/status_area_view.h" 10 #include "chrome/browser/chromeos/status/status_area_view.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Gross hack: We split the toolbar images into two pieces, since sometimes 65 // Gross hack: We split the toolbar images into two pieces, since sometimes
66 // (popup mode) the toolbar isn't tall enough to show the whole image. The 66 // (popup mode) the toolbar isn't tall enough to show the whole image. The
67 // split happens between the top shadow section and the bottom gradient 67 // split happens between the top shadow section and the bottom gradient
68 // section so that we never break the gradient. 68 // section so that we never break the gradient.
69 int split_point = views::NonClientFrameView::kFrameShadowThickness * 2; 69 int split_point = views::NonClientFrameView::kFrameShadowThickness * 2;
70 int bottom_y = y + split_point; 70 int bottom_y = y + split_point;
71 ui::ThemeProvider* tp = browser_view_->GetThemeProvider(); 71 ui::ThemeProvider* tp = browser_view_->GetThemeProvider();
72 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER); 72 SkBitmap* toolbar_left = tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
73 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point; 73 int bottom_edge_height = std::min(toolbar_left->height(), h) - split_point;
74 74
75 // Split our canvas out so we can mask out the corners of the toolbar
76 // without masking out the frame.
77 canvas->SaveLayerAlpha(
78 255, gfx::Rect(x - views::NonClientFrameView::kClientEdgeThickness,
79 y,
80 w + views::NonClientFrameView::kClientEdgeThickness * 3,
81 h));
82 canvas->GetSkCanvas()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode);
83
84 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height), 75 canvas->FillRect(gfx::Rect(x, bottom_y, w, bottom_edge_height),
85 tp->GetColor(ThemeService::COLOR_TOOLBAR)); 76 tp->GetColor(ThemeService::COLOR_TOOLBAR));
86 77
87 // Tile the toolbar image starting at the frame edge on the left and where the 78 // Tile the toolbar image starting at the frame edge on the left and where the
88 // horizontal tabstrip is (or would be) on the top. 79 // horizontal tabstrip is (or would be) on the top.
89 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR); 80 SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
90 canvas->TileImageInt(*theme_toolbar, x, 81 canvas->TileImageInt(*theme_toolbar,
91 bottom_y, x, 82 x, bottom_y,
92 bottom_y, w, theme_toolbar->height()); 83 x, bottom_y,
93 84 w, theme_toolbar->height());
94 // Draw rounded corners for the tab.
95 SkBitmap* toolbar_left_mask =
96 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK);
97 SkBitmap* toolbar_right_mask =
98 tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK);
99
100 // We mask out the corners by using the DestinationIn transfer mode,
101 // which keeps the RGB pixels from the destination and the alpha from
102 // the source.
103 SkPaint paint;
104 paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
105
106 // Mask the left edge.
107 int left_x = x - kContentEdgeShadowThickness;
108 canvas->DrawBitmapInt(*toolbar_left_mask, 0, 0, toolbar_left_mask->width(),
109 split_point, left_x, y, toolbar_left_mask->width(),
110 split_point, false, paint);
111 canvas->DrawBitmapInt(*toolbar_left_mask, 0,
112 toolbar_left_mask->height() - bottom_edge_height,
113 toolbar_left_mask->width(), bottom_edge_height, left_x, bottom_y,
114 toolbar_left_mask->width(), bottom_edge_height, false, paint);
115
116 // Mask the right edge.
117 int right_x =
118 x + w - toolbar_right_mask->width() + kContentEdgeShadowThickness;
119 canvas->DrawBitmapInt(*toolbar_right_mask, 0, 0, toolbar_right_mask->width(),
120 split_point, right_x, y, toolbar_right_mask->width(),
121 split_point, false, paint);
122 canvas->DrawBitmapInt(*toolbar_right_mask, 0,
123 toolbar_right_mask->height() - bottom_edge_height,
124 toolbar_right_mask->width(), bottom_edge_height, right_x, bottom_y,
125 toolbar_right_mask->width(), bottom_edge_height, false, paint);
126 canvas->Restore();
127
128 canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point,
129 left_x, y, toolbar_left->width(), split_point, false);
130 canvas->DrawBitmapInt(*toolbar_left, 0,
131 toolbar_left->height() - bottom_edge_height, toolbar_left->width(),
132 bottom_edge_height, left_x, bottom_y, toolbar_left->width(),
133 bottom_edge_height, false);
134 85
135 SkBitmap* toolbar_center = 86 SkBitmap* toolbar_center =
136 tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER); 87 tp->GetBitmapNamed(IDR_CONTENT_TOP_CENTER);
137 canvas->TileImageInt(*toolbar_center, 0, 0, left_x + toolbar_left->width(), 88 canvas->TileImageInt(*toolbar_center,
138 y, right_x - (left_x + toolbar_left->width()), 89 0, 0,
139 split_point); 90 x, y,
140 91 w, split_point);
141 SkBitmap* toolbar_right = tp->GetBitmapNamed(IDR_CONTENT_TOP_RIGHT_CORNER);
142 canvas->DrawBitmapInt(*toolbar_right, 0, 0, toolbar_right->width(),
143 split_point, right_x, y, toolbar_right->width(), split_point, false);
144 canvas->DrawBitmapInt(*toolbar_right, 0,
145 toolbar_right->height() - bottom_edge_height, toolbar_right->width(),
146 bottom_edge_height, right_x, bottom_y, toolbar_right->width(),
147 bottom_edge_height, false);
148 92
149 // Draw the content/toolbar separator. 93 // Draw the content/toolbar separator.
150 canvas->FillRect(gfx::Rect( 94 canvas->FillRect(gfx::Rect(
151 x + views::NonClientFrameView::kClientEdgeThickness, 95 x + views::NonClientFrameView::kClientEdgeThickness,
152 toolbar_bounds.bottom() - views::NonClientFrameView::kClientEdgeThickness, 96 toolbar_bounds.bottom() - views::NonClientFrameView::kClientEdgeThickness,
153 w - (2 * views::NonClientFrameView::kClientEdgeThickness), 97 w - (2 * views::NonClientFrameView::kClientEdgeThickness),
154 views::NonClientFrameView::kClientEdgeThickness), 98 views::NonClientFrameView::kClientEdgeThickness),
155 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); 99 ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR));
156 } 100 }
157 101
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 /////////////////////////////////////////////////////////////////////////////// 207 ///////////////////////////////////////////////////////////////////////////////
264 // BrowserFrameAura, public: 208 // BrowserFrameAura, public:
265 209
266 BrowserFrameAura::BrowserFrameAura(BrowserFrame* browser_frame, 210 BrowserFrameAura::BrowserFrameAura(BrowserFrame* browser_frame,
267 BrowserView* browser_view) 211 BrowserView* browser_view)
268 : views::NativeWidgetAura(browser_frame), 212 : views::NativeWidgetAura(browser_frame),
269 browser_view_(browser_view), 213 browser_view_(browser_view),
270 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) { 214 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) {
271 CommandLine* command_line = CommandLine::ForCurrentProcess(); 215 CommandLine* command_line = CommandLine::ForCurrentProcess();
272 if (command_line->HasSwitch(ash::switches::kAuraTranslucentFrames)) { 216 if (command_line->HasSwitch(ash::switches::kAuraTranslucentFrames)) {
273 // Aura paints layers behind this view, so this must be a layer also.
274 // TODO: see if we can avoid this, layers are expensive.
275 browser_view_->SetPaintToLayer(true);
276 browser_view_->layer()->SetFillsBoundsOpaquely(false);
277 // Background only needed for Aura-style windows. 217 // Background only needed for Aura-style windows.
278 browser_view_->set_background(new ToolbarBackground(browser_view)); 218 browser_view_->set_background(new ToolbarBackground(browser_view));
279 } 219 }
280 GetNativeWindow()->SetName("BrowserFrameAura"); 220 GetNativeWindow()->SetName("BrowserFrameAura");
281 GetNativeWindow()->AddObserver(window_property_watcher_.get()); 221 GetNativeWindow()->AddObserver(window_property_watcher_.get());
282 } 222 }
283 223
284 BrowserFrameAura::~BrowserFrameAura() { 224 BrowserFrameAura::~BrowserFrameAura() {
285 } 225 }
286 226
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 263
324 //////////////////////////////////////////////////////////////////////////////// 264 ////////////////////////////////////////////////////////////////////////////////
325 // NativeBrowserFrame, public: 265 // NativeBrowserFrame, public:
326 266
327 // static 267 // static
328 NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame( 268 NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame(
329 BrowserFrame* browser_frame, 269 BrowserFrame* browser_frame,
330 BrowserView* browser_view) { 270 BrowserView* browser_view) {
331 return new BrowserFrameAura(browser_frame, browser_view); 271 return new BrowserFrameAura(browser_frame, browser_view);
332 } 272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698