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

Side by Side Diff: chrome/browser/views/constrained_window_impl.cc

Issue 20161: Make aero glass code look more like other nonclient views in hopes of easing ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/views/frame/aero_glass_frame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/constrained_window_impl.h" 5 #include "chrome/browser/views/constrained_window_impl.h"
6 6
7 #include "base/gfx/rect.h" 7 #include "base/gfx/rect.h"
8 #include "chrome/app/chrome_dll_resource.h" 8 #include "chrome/app/chrome_dll_resource.h"
9 #include "chrome/app/theme/theme_resources.h" 9 #include "chrome/app/theme/theme_resources.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 public views::BaseButton::ButtonListener { 192 public views::BaseButton::ButtonListener {
193 public: 193 public:
194 ConstrainedWindowNonClientView(ConstrainedWindowImpl* container, 194 ConstrainedWindowNonClientView(ConstrainedWindowImpl* container,
195 TabContents* owner); 195 TabContents* owner);
196 virtual ~ConstrainedWindowNonClientView(); 196 virtual ~ConstrainedWindowNonClientView();
197 197
198 void UpdateWindowTitle(); 198 void UpdateWindowTitle();
199 199
200 // Overridden from views::NonClientView: 200 // Overridden from views::NonClientView:
201 virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const; 201 virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const;
202 virtual gfx::Size CalculateWindowSizeForClientSize(int width,
203 int height) const;
204 virtual CPoint GetSystemMenuPoint() const; 202 virtual CPoint GetSystemMenuPoint() const;
205 virtual int NonClientHitTest(const gfx::Point& point); 203 virtual int NonClientHitTest(const gfx::Point& point);
206 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); 204 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask);
207 virtual void EnableClose(bool enable); 205 virtual void EnableClose(bool enable);
208 virtual void ResetWindowControls() { } 206 virtual void ResetWindowControls() { }
209 207
210 // Overridden from views::View: 208 // Overridden from views::View:
211 virtual void Paint(ChromeCanvas* canvas); 209 virtual void Paint(ChromeCanvas* canvas);
212 virtual void Layout(); 210 virtual void Layout();
213 virtual gfx::Size GetPreferredSize();
214 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); 211 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child);
215 212
216 // Overridden from views::BaseButton::ButtonListener: 213 // Overridden from views::BaseButton::ButtonListener:
217 virtual void ButtonPressed(views::BaseButton* sender); 214 virtual void ButtonPressed(views::BaseButton* sender);
218 215
219 private: 216 private:
220 // Returns the thickness of the border that makes up the window frame edges. 217 // Returns the thickness of the border that makes up the window frame edges.
221 // This does not include any client edge. 218 // This does not include any client edge.
222 int FrameBorderThickness() const; 219 int FrameBorderThickness() const;
223 220
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 gfx::Rect ConstrainedWindowNonClientView::CalculateClientAreaBounds( 336 gfx::Rect ConstrainedWindowNonClientView::CalculateClientAreaBounds(
340 int width, 337 int width,
341 int height) const { 338 int height) const {
342 int top_height = NonClientTopBorderHeight(); 339 int top_height = NonClientTopBorderHeight();
343 int border_thickness = NonClientBorderThickness(); 340 int border_thickness = NonClientBorderThickness();
344 return gfx::Rect(border_thickness, top_height, 341 return gfx::Rect(border_thickness, top_height,
345 std::max(0, width - (2 * border_thickness)), 342 std::max(0, width - (2 * border_thickness)),
346 std::max(0, height - top_height - border_thickness)); 343 std::max(0, height - top_height - border_thickness));
347 } 344 }
348 345
349 gfx::Size ConstrainedWindowNonClientView::CalculateWindowSizeForClientSize(
350 int width,
351 int height) const {
352 int border_thickness = NonClientBorderThickness();
353 return gfx::Size(width + (2 * border_thickness),
354 height + NonClientTopBorderHeight() + border_thickness);
355 }
356
357 CPoint ConstrainedWindowNonClientView::GetSystemMenuPoint() const { 346 CPoint ConstrainedWindowNonClientView::GetSystemMenuPoint() const {
358 // Doesn't matter what we return, since this is only used when the user clicks 347 // Doesn't matter what we return, since this is only used when the user clicks
359 // a window icon, and we never have an icon. 348 // a window icon, and we never have an icon.
360 return CPoint(); 349 return CPoint();
361 } 350 }
362 351
363 int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) { 352 int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) {
364 // First see if it's within the grow box area, since that overlaps the client 353 if (!bounds().Contains(point))
365 // bounds. 354 return HTNOWHERE;
355
366 int frame_component = container_->client_view()->NonClientHitTest(point); 356 int frame_component = container_->client_view()->NonClientHitTest(point);
367 if (frame_component != HTNOWHERE) 357 if (frame_component != HTNOWHERE)
368 return frame_component; 358 return frame_component;
369 359
370 // Then see if the point is within any of the window controls. 360 // Then see if the point is within any of the window controls.
371 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) 361 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point))
372 return HTCLOSE; 362 return HTCLOSE;
373 363
374 int window_component = GetHTComponentForFrame(point, FrameBorderThickness(), 364 int window_component = GetHTComponentForFrame(point, FrameBorderThickness(),
375 NonClientBorderThickness(), kResizeAreaCornerSize, 365 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
376 container_->window_delegate()->CanResize()); 366 container_->window_delegate()->CanResize());
377 // Fall back to the caption if no other component matches. 367 // Fall back to the caption if no other component matches.
378 return ((window_component == HTNOWHERE) && bounds().Contains(point)) ? 368 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
379 HTCAPTION : window_component;
380 } 369 }
381 370
382 void ConstrainedWindowNonClientView::GetWindowMask(const gfx::Size& size, 371 void ConstrainedWindowNonClientView::GetWindowMask(const gfx::Size& size,
383 gfx::Path* window_mask) { 372 gfx::Path* window_mask) {
384 DCHECK(window_mask); 373 DCHECK(window_mask);
385 374
386 // Redefine the window visible region for the new size. 375 // Redefine the window visible region for the new size.
387 window_mask->moveTo(0, 3); 376 window_mask->moveTo(0, 3);
388 window_mask->lineTo(1, 2); 377 window_mask->lineTo(1, 2);
389 window_mask->lineTo(1, 1); 378 window_mask->lineTo(1, 1);
(...skipping 24 matching lines...) Expand all
414 PaintTitleBar(canvas); 403 PaintTitleBar(canvas);
415 PaintClientEdge(canvas); 404 PaintClientEdge(canvas);
416 } 405 }
417 406
418 void ConstrainedWindowNonClientView::Layout() { 407 void ConstrainedWindowNonClientView::Layout() {
419 LayoutWindowControls(); 408 LayoutWindowControls();
420 LayoutTitleBar(); 409 LayoutTitleBar();
421 LayoutClientView(); 410 LayoutClientView();
422 } 411 }
423 412
424 gfx::Size ConstrainedWindowNonClientView::GetPreferredSize() {
425 gfx::Size prefsize(container_->client_view()->GetPreferredSize());
426 int border_thickness = NonClientBorderThickness();
427 prefsize.Enlarge(2 * border_thickness,
428 NonClientTopBorderHeight() + border_thickness);
429 return prefsize;
430 }
431
432 void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add, 413 void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add,
433 View *parent, 414 View *parent,
434 View *child) { 415 View *child) {
435 // Add our Client View as we are added to the Container so that if we are 416 // Add our Client View as we are added to the Container so that if we are
436 // subsequently resized all the parent-child relationships are established. 417 // subsequently resized all the parent-child relationships are established.
437 if (is_add && GetWidget() && child == this) 418 if (is_add && GetWidget() && child == this)
438 AddChildView(container_->client_view()); 419 AddChildView(container_->client_view());
439 } 420 }
440 421
441 //////////////////////////////////////////////////////////////////////////////// 422 ////////////////////////////////////////////////////////////////////////////////
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( 727 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog(
747 TabContents* parent, 728 TabContents* parent,
748 const gfx::Rect& initial_bounds, 729 const gfx::Rect& initial_bounds,
749 views::View* contents_view, 730 views::View* contents_view,
750 views::WindowDelegate* window_delegate) { 731 views::WindowDelegate* window_delegate) {
751 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, 732 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent,
752 window_delegate); 733 window_delegate);
753 window->InitAsDialog(initial_bounds); 734 window->InitAsDialog(initial_bounds);
754 return window; 735 return window;
755 } 736 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/views/frame/aero_glass_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698