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

Side by Side Diff: chrome/browser/views/tabs/tab_overview_container.cc

Issue 132059: Changes tab overview to create a window the max size it can possibly... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/tabs/tab_overview_container.h" 5 #include "chrome/browser/views/tabs/tab_overview_container.h"
6 6
7 #include <gtk/gtk.h>
8
9 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
10 #include "app/gfx/path.h"
11 #include "chrome/browser/views/tabs/tab_overview_grid.h" 8 #include "chrome/browser/views/tabs/tab_overview_grid.h"
12 #include "third_party/skia/include/effects/SkGradientShader.h" 9 #include "third_party/skia/include/effects/SkGradientShader.h"
13 #include "views/widget/widget_gtk.h"
14 10
15 // Padding between the edges of us and the grid. 11 // Padding between the edges of us and the grid.
16 static const int kVerticalPadding = 43; 12 static const int kVerticalPadding = 43;
17 static const int kHorizontalPadding = 30; 13 static const int kHorizontalPadding = 30;
18 14
19 // Height of the arrow. 15 // Height of the arrow.
20 static const int kArrowHeight = 28; 16 static const int kArrowHeight = 28;
21 17
22 // Inset of the slight rounding on the corners.
23 static const int kEdgeInset = 5;
24
25 TabOverviewContainer::TabOverviewContainer() { 18 TabOverviewContainer::TabOverviewContainer() {
26 } 19 }
27 20
28 TabOverviewContainer::~TabOverviewContainer() { 21 TabOverviewContainer::~TabOverviewContainer() {
29 } 22 }
30 23
31 void TabOverviewContainer::SetMaxSize(const gfx::Size& max_size) { 24 void TabOverviewContainer::SetMaxSize(const gfx::Size& max_size) {
32 GetTabOverviewGrid()->set_max_size( 25 GetTabOverviewGrid()->set_max_size(
33 gfx::Size(max_size.width() - kHorizontalPadding * 2, 26 gfx::Size(max_size.width() - kHorizontalPadding * 2,
34 max_size.height() - kVerticalPadding * 2 - kArrowHeight)); 27 max_size.height() - kVerticalPadding * 2 - kArrowHeight));
35 } 28 }
36 29
37 void TabOverviewContainer::UpdateWidgetShape(int horizontal_center,
38 int width, int height) {
39 int bottom_y = height - kArrowHeight;
40 int right_edge = width - 1;
41 int center = width / 2;
42 // The points, in alternating x,y pairs.
43 int points[] = {
44 kEdgeInset, 0,
45 right_edge - kEdgeInset, 0,
46 right_edge, kEdgeInset,
47 right_edge, bottom_y - kEdgeInset - 1,
48 right_edge - kEdgeInset, bottom_y - 1,
49 center + kArrowHeight / 2, bottom_y - 1,
50 center, bottom_y - 1 + kArrowHeight,
51 center - kArrowHeight / 2, bottom_y - 1,
52 kEdgeInset, bottom_y - 1,
53 0, bottom_y - 1 - kEdgeInset,
54 0, kEdgeInset,
55 };
56 gfx::Path path;
57 path.moveTo(SkIntToScalar(points[0]), SkIntToScalar(points[1]));
58 for (size_t i = 2; i < arraysize(points); i += 2)
59 path.lineTo(SkIntToScalar(points[i]), SkIntToScalar(points[i + 1]));
60
61 GetWidget()->SetShape(path);
62 }
63
64 gfx::Size TabOverviewContainer::GetPreferredSize() { 30 gfx::Size TabOverviewContainer::GetPreferredSize() {
65 gfx::Size tab_overview_pref = GetTabOverviewGrid()->GetPreferredSize(); 31 gfx::Size tab_overview_pref = GetTabOverviewGrid()->GetPreferredSize();
66 return gfx::Size(kHorizontalPadding * 2 + tab_overview_pref.width(), 32 return gfx::Size(kHorizontalPadding * 2 + tab_overview_pref.width(),
67 kVerticalPadding * 2 + tab_overview_pref.height() + 33 kVerticalPadding * 2 + tab_overview_pref.height() +
68 kArrowHeight); 34 kArrowHeight);
69 } 35 }
70 36
71 void TabOverviewContainer::Layout() { 37 void TabOverviewContainer::Layout() {
72 GetTabOverviewGrid()->SetBounds(kHorizontalPadding, kVerticalPadding, 38 GetTabOverviewGrid()->SetBounds(kHorizontalPadding, kVerticalPadding,
73 width() - kHorizontalPadding * 2, 39 width() - kHorizontalPadding * 2,
74 height() - kVerticalPadding * 2 - 40 height() - kVerticalPadding * 2 -
75 kArrowHeight); 41 kArrowHeight);
76 } 42 }
77 43
78 void TabOverviewContainer::Paint(gfx::Canvas* canvas) { 44 void TabOverviewContainer::Paint(gfx::Canvas* canvas) {
79 SkPoint points[] = { { SkIntToScalar(0), SkIntToScalar(0) }, 45 SkPoint points[] = { { SkIntToScalar(0), SkIntToScalar(0) },
80 { SkIntToScalar(0), SkIntToScalar(height()) } }; 46 { SkIntToScalar(0), SkIntToScalar(height()) } };
81 SkColor colors[] = { SkColorSetARGB(242, 255, 255, 255), 47 SkColor colors[] = { SkColorSetARGB(242, 255, 255, 255),
82 SkColorSetARGB(212, 255, 255, 255), }; 48 SkColorSetARGB(212, 255, 255, 255), };
83 SkShader* shader = SkGradientShader::CreateLinear( 49 SkShader* shader = SkGradientShader::CreateLinear(
84 points, colors, NULL, 2, SkShader::kRepeat_TileMode); 50 points, colors, NULL, 2, SkShader::kRepeat_TileMode);
85 SkPaint paint; 51 SkPaint paint;
86 paint.setShader(shader); 52 paint.setShader(shader);
87 shader = NULL; 53 shader = NULL;
88 paint.setStyle(SkPaint::kFill_Style); 54 paint.setStyle(SkPaint::kFill_Style);
89 paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode); 55 paint.setPorterDuffXfermode(SkPorterDuff::kSrcOver_Mode);
90 canvas->drawPaint(paint); 56 canvas->drawPaint(paint);
91 } 57 }
92 58
93 void TabOverviewContainer::DidChangeBounds(const gfx::Rect& previous,
94 const gfx::Rect& current) {
95 Layout();
96 }
97
98 TabOverviewGrid* TabOverviewContainer::GetTabOverviewGrid() { 59 TabOverviewGrid* TabOverviewContainer::GetTabOverviewGrid() {
99 return static_cast<TabOverviewGrid*>(GetChildViewAt(0)); 60 return static_cast<TabOverviewGrid*>(GetChildViewAt(0));
100 } 61 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/tab_overview_container.h ('k') | chrome/browser/views/tabs/tab_overview_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698