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

Side by Side Diff: chrome/browser/views/extensions/extension_installed_bubble.cc

Issue 413005: ExtensionInstalledBubble border/sizing polish (Closed)
Patch Set: pre commit Created 11 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | 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) 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/extensions/extension_installed_bubble.h" 5 #include "chrome/browser/views/extensions/extension_installed_bubble.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 12 matching lines...) Expand all
23 #include "views/view.h" 23 #include "views/view.h"
24 24
25 namespace { 25 namespace {
26 26
27 const int kIconSize = 43; 27 const int kIconSize = 43;
28 28
29 const int kRightColumnWidth = 285; 29 const int kRightColumnWidth = 285;
30 30
31 // The InfoBubble uses a BubbleBorder which adds about 6 pixels of whitespace 31 // The InfoBubble uses a BubbleBorder which adds about 6 pixels of whitespace
32 // around the content view. We compensate by reducing our outer borders by this 32 // around the content view. We compensate by reducing our outer borders by this
33 // amount. 33 // amount + 4px.
34 const int kBubbleBorderInsert = 6; 34 const int kOuterMarginInset = 10;
35 const int kHorizOuterMargin = kPanelHorizMargin - kBubbleBorderInsert; 35 const int kHorizOuterMargin = kPanelHorizMargin - kOuterMarginInset;
36 const int kVertOuterMargin = kPanelVertMargin - kBubbleBorderInsert; 36 const int kVertOuterMargin = kPanelVertMargin - kOuterMarginInset;
37
38 // Interior vertical margin is 8px smaller than standard
39 const int kVertInnerMargin = kPanelVertMargin - 8;
37 40
38 // The image we use for the close button has three pixels of whitespace padding. 41 // The image we use for the close button has three pixels of whitespace padding.
39 const int kCloseButtonPadding = 3; 42 const int kCloseButtonPadding = 3;
40 43
44 // We want to shift the right column (which contains the header and text) up
45 // 4px to align with icon.
46 const int kRightcolumnVerticalShift = -4;
47
41 // InstalledBubbleContent is the content view which is placed in the 48 // InstalledBubbleContent is the content view which is placed in the
42 // ExtensionInstalledBubble. It displays the install icon and explanatory 49 // ExtensionInstalledBubble. It displays the install icon and explanatory
43 // text about the installed extension. 50 // text about the installed extension.
44 class InstalledBubbleContent : public views::View, 51 class InstalledBubbleContent : public views::View,
45 public views::ButtonListener { 52 public views::ButtonListener {
46 public: 53 public:
47 InstalledBubbleContent(Extension* extension, 54 InstalledBubbleContent(Extension* extension,
48 ExtensionInstalledBubble::BubbleType type, 55 ExtensionInstalledBubble::BubbleType type,
49 SkBitmap* icon) 56 SkBitmap* icon)
50 : type_(type), 57 : type_(type),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 103 }
97 104
98 virtual void ButtonPressed( 105 virtual void ButtonPressed(
99 views::Button* sender, 106 views::Button* sender,
100 const views::Event& event) { 107 const views::Event& event) {
101 GetWidget()->Close(); 108 GetWidget()->Close();
102 } 109 }
103 110
104 private: 111 private:
105 virtual gfx::Size GetPreferredSize() { 112 virtual gfx::Size GetPreferredSize() {
106 int width = kRightColumnWidth + kHorizOuterMargin + kHorizOuterMargin; 113 int width = kHorizOuterMargin;
107 width += kIconSize; 114 width += kIconSize;
108 width += kPanelHorizMargin; 115 width += kPanelHorizMargin;
109 width += close_button_->GetPreferredSize().width(); 116 width += kRightColumnWidth;
110 width -= 2 * kCloseButtonPadding; 117 width += 2*kPanelHorizMargin;
111 width += kPanelHorizMargin; 118 width += kHorizOuterMargin;
112 119
113 int height = kVertOuterMargin * 2; 120 int height = kVertOuterMargin;
114 height += heading_->GetHeightForWidth(kRightColumnWidth); 121 height += heading_->GetHeightForWidth(kRightColumnWidth);
115 height += kPanelVertMargin; 122 height += kVertInnerMargin;
116 if (type_ == ExtensionInstalledBubble::PAGE_ACTION) { 123 if (type_ == ExtensionInstalledBubble::PAGE_ACTION) {
117 height += info_->GetHeightForWidth(kRightColumnWidth); 124 height += info_->GetHeightForWidth(kRightColumnWidth);
118 height += kPanelVertMargin; 125 height += kVertInnerMargin;
119 } 126 }
120 height += manage_->GetHeightForWidth(kRightColumnWidth); 127 height += manage_->GetHeightForWidth(kRightColumnWidth);
121 128 height += kVertOuterMargin;
122 return gfx::Size(width, std::max(height, kIconSize + kVertOuterMargin * 2)); 129 return gfx::Size(width, std::max(height, kIconSize + 2 * kVertOuterMargin));
123 } 130 }
124 131
125 virtual void Layout() { 132 virtual void Layout() {
126 int x = kHorizOuterMargin; 133 int x = kHorizOuterMargin;
127 int y = kVertOuterMargin; 134 int y = kVertOuterMargin;
128 135
129 icon_->SetBounds(x, y, kIconSize, kIconSize); 136 icon_->SetBounds(x, y, kIconSize, kIconSize);
130 x += kIconSize; 137 x += kIconSize;
131 x += kPanelHorizMargin; 138 x += kPanelHorizMargin;
132 139
140 y += kRightcolumnVerticalShift;
133 heading_->SizeToFit(kRightColumnWidth); 141 heading_->SizeToFit(kRightColumnWidth);
134 heading_->SetX(x); 142 heading_->SetX(x);
135 heading_->SetY(y); 143 heading_->SetY(y);
136 y += heading_->height(); 144 y += heading_->height();
137 y += kPanelVertMargin; 145 y += kVertInnerMargin;
138 146
139 if (type_ == ExtensionInstalledBubble::PAGE_ACTION) { 147 if (type_ == ExtensionInstalledBubble::PAGE_ACTION) {
140 info_->SizeToFit(kRightColumnWidth); 148 info_->SizeToFit(kRightColumnWidth);
141 info_->SetX(x); 149 info_->SetX(x);
142 info_->SetY(y); 150 info_->SetY(y);
143 y += info_->height(); 151 y += info_->height();
144 y += kPanelVertMargin; 152 y += kVertInnerMargin;
145 } 153 }
146 154
147 manage_->SizeToFit(kRightColumnWidth); 155 manage_->SizeToFit(kRightColumnWidth);
148 manage_->SetX(x); 156 manage_->SetX(x);
149 manage_->SetY(y); 157 manage_->SetY(y);
150 158
151 x += kRightColumnWidth + kPanelHorizMargin; 159 x += kRightColumnWidth + 2*kPanelHorizMargin + kHorizOuterMargin -
160 close_button_->GetPreferredSize().width();
152 y = kVertOuterMargin; 161 y = kVertOuterMargin;
153 gfx::Size sz = close_button_->GetPreferredSize(); 162 gfx::Size sz = close_button_->GetPreferredSize();
154 close_button_->SetBounds(x - kCloseButtonPadding, 163 // x-1 & y-1 is just slop to get the close button visually aligned with the
155 y - kCloseButtonPadding, 164 // title text and bubble arrow.
156 sz.width(), 165 close_button_->SetBounds(x - 1, y - 1, sz.width(), sz.height());
157 sz.height());
158 } 166 }
159 167
160 ExtensionInstalledBubble::BubbleType type_; 168 ExtensionInstalledBubble::BubbleType type_;
161 views::ImageView* icon_; 169 views::ImageView* icon_;
162 views::Label* heading_; 170 views::Label* heading_;
163 views::Label* info_; 171 views::Label* info_;
164 views::Label* manage_; 172 views::Label* manage_;
165 views::ImageButton* close_button_; 173 views::ImageButton* close_button_;
166 174
167 DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent); 175 DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 bool closed_by_escape) { 261 bool closed_by_escape) {
254 if (extension_->page_action()) { 262 if (extension_->page_action()) {
255 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( 263 BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow(
256 browser_->window()->GetNativeHandle()); 264 browser_->window()->GetNativeHandle());
257 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( 265 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction(
258 extension_->page_action(), 266 extension_->page_action(),
259 false); // preview_enabled 267 false); // preview_enabled
260 } 268 }
261 Release(); // Balanced in ctor. 269 Release(); // Balanced in ctor.
262 } 270 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698