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

Side by Side Diff: chrome/browser/chromeos/frame/bubble_frame_view.cc

Issue 8479042: UI polish for certificate viewer (Closed) Base URL: /usr/local/google/home/bshe/NoTouchChromium/../TouchChromium/src/@trunk
Patch Set: Add x button and remove padding and close button for certificate viewer. Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/frame/bubble_frame_view.h" 5 #include "chrome/browser/chromeos/frame/bubble_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/frame/bubble_window.h" 10 #include "chrome/browser/chromeos/frame/bubble_window.h"
(...skipping 10 matching lines...) Expand all
21 #include "views/controls/throbber.h" 21 #include "views/controls/throbber.h"
22 #include "views/widget/widget.h" 22 #include "views/widget/widget.h"
23 #include "views/widget/widget_delegate.h" 23 #include "views/widget/widget_delegate.h"
24 #include "views/window/hit_test.h" 24 #include "views/window/hit_test.h"
25 #include "third_party/skia/include/core/SkColor.h" 25 #include "third_party/skia/include/core/SkColor.h"
26 #include "third_party/skia/include/core/SkPaint.h" 26 #include "third_party/skia/include/core/SkPaint.h"
27 27
28 namespace { 28 namespace {
29 29
30 const int kTitleTopPadding = 10; 30 const int kTitleTopPadding = 10;
31 const int kTitleLeftPadding = 10;
32 const int kTitleRightPadding = 10;
flackr 2011/11/10 16:03:16 I don't think there's a need for these extra conte
bshe 2011/11/21 16:09:37 Done.
31 const int kTitleContentPadding = 10; 33 const int kTitleContentPadding = 10;
32 const int kHorizontalPadding = 10; 34 const int kHorizontalPadding = 10;
33 35
34 // Title font size correction. 36 // Title font size correction.
35 #if defined(CROS_FONTS_USING_BCI) 37 #if defined(CROS_FONTS_USING_BCI)
36 const int kTitleFontSizeDelta = 0; 38 const int kTitleFontSizeDelta = 0;
37 #else 39 #else
38 const int kTitleFontSizeDelta = 1; 40 const int kTitleFontSizeDelta = 1;
39 #endif 41 #endif
40 42
(...skipping 10 matching lines...) Expand all
51 close_button_(NULL), 53 close_button_(NULL),
52 throbber_(NULL) { 54 throbber_(NULL) {
53 if (widget_delegate->ShouldShowWindowTitle()) { 55 if (widget_delegate->ShouldShowWindowTitle()) {
54 title_ = new views::Label(widget_delegate->GetWindowTitle()); 56 title_ = new views::Label(widget_delegate->GetWindowTitle());
55 title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 57 title_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
56 title_->SetFont(title_->font().DeriveFont(kFontSizeCorrectionDelta, 58 title_->SetFont(title_->font().DeriveFont(kFontSizeCorrectionDelta,
57 gfx::Font::BOLD)); 59 gfx::Font::BOLD));
58 AddChildView(title_); 60 AddChildView(title_);
59 } 61 }
60 62
61 if (style_ & STYLE_XBAR) { 63 if (style_ & STYLE_XBAR || style_ & STYLE_CERT) {
flackr 2011/11/10 16:03:16 Your new style should only be for the custom paddi
bshe 2011/11/21 16:09:37 Done.
62 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 64 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
63 close_button_ = new views::ImageButton(this); 65 close_button_ = new views::ImageButton(this);
64 close_button_->SetImage(views::CustomButton::BS_NORMAL, 66 close_button_->SetImage(views::CustomButton::BS_NORMAL,
65 rb.GetBitmapNamed(IDR_CLOSE_BAR)); 67 rb.GetBitmapNamed(IDR_CLOSE_BAR));
66 close_button_->SetImage(views::CustomButton::BS_HOT, 68 close_button_->SetImage(views::CustomButton::BS_HOT,
67 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); 69 rb.GetBitmapNamed(IDR_CLOSE_BAR_H));
68 close_button_->SetImage(views::CustomButton::BS_PUSHED, 70 close_button_->SetImage(views::CustomButton::BS_PUSHED,
69 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); 71 rb.GetBitmapNamed(IDR_CLOSE_BAR_P));
70 AddChildView(close_button_); 72 AddChildView(close_button_);
71 } 73 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 140
139 void BubbleFrameView::ResetWindowControls() { 141 void BubbleFrameView::ResetWindowControls() {
140 } 142 }
141 143
142 void BubbleFrameView::UpdateWindowIcon() { 144 void BubbleFrameView::UpdateWindowIcon() {
143 } 145 }
144 146
145 gfx::Insets BubbleFrameView::GetInsets() const { 147 gfx::Insets BubbleFrameView::GetInsets() const {
146 return (style_ & STYLE_FLUSH) ? 148 return (style_ & STYLE_FLUSH) ?
147 gfx::Insets() : 149 gfx::Insets() :
148 gfx::Insets(kTitleTopPadding, 150 ((style_ & STYLE_CERT) ?
149 kHorizontalPadding, 151 gfx::Insets(kTitleTopPadding,
150 0, 152 0,
151 kHorizontalPadding); 153 0,
154 0) :
155 gfx::Insets(kTitleTopPadding,
156 kHorizontalPadding,
157 0,
158 kHorizontalPadding));
152 } 159 }
153 160
154 gfx::Size BubbleFrameView::GetPreferredSize() { 161 gfx::Size BubbleFrameView::GetPreferredSize() {
155 gfx::Size pref = frame_->client_view()->GetPreferredSize(); 162 gfx::Size pref = frame_->client_view()->GetPreferredSize();
156 gfx::Rect bounds(0, 0, pref.width(), pref.height()); 163 gfx::Rect bounds(0, 0, pref.width(), pref.height());
157 return frame_->non_client_view()->GetWindowBoundsForClientBounds( 164 return frame_->non_client_view()->GetWindowBoundsForClientBounds(
158 bounds).size(); 165 bounds).size();
159 } 166 }
160 167
161 void BubbleFrameView::Layout() { 168 void BubbleFrameView::Layout() {
162 gfx::Insets insets = GetInsets(); 169 gfx::Insets insets = GetInsets();
163 170
164 gfx::Size title_size; 171 gfx::Size title_size;
165 if (title_) 172 if (title_)
166 title_size = title_->GetPreferredSize(); 173 title_size = title_->GetPreferredSize();
167 gfx::Size close_button_size; 174 gfx::Size close_button_size;
168 if (close_button_) 175 if (close_button_)
169 close_button_size = close_button_->GetPreferredSize(); 176 close_button_size = close_button_->GetPreferredSize();
170 gfx::Size throbber_size; 177 gfx::Size throbber_size;
171 if (throbber_) 178 if (throbber_)
172 throbber_size = throbber_->GetPreferredSize(); 179 throbber_size = throbber_->GetPreferredSize();
173 180
181 // Need to center elements which are shorter.
182 int max_height = std::max(title_size.height(),
183 std::max(close_button_size.height(),
184 throbber_size.height()));
flackr 2011/11/10 16:03:16 The following cases for STYLE_CERT seem to introdu
bshe 2011/11/21 16:09:37 I use titleBarInsets at first. Then I figure out t
185
174 if (title_) { 186 if (title_) {
175 title_->SetBounds( 187 // Insert left padding to title area.
176 insets.left(), insets.top(), 188 if (style_ & STYLE_CERT)
177 std::max(0, width() - insets.width() - close_button_size.width()), 189 title_->SetBounds(
178 title_size.height()); 190 insets.left() + kTitleLeftPadding,
191 insets.top() + ((max_height - title_size.height()) >> 1), // Center
flackr 2011/11/10 16:03:16 Are divisions by 2 of this style (>> 1) used elsew
bshe 2011/11/21 16:09:37 Done.
192 std::max(0, width() - insets.width() - close_button_size.width()
193 - kTitleLeftPadding - kTitleRightPadding),
194 title_size.height());
195 else
196 title_->SetBounds(
197 insets.left(),
198 insets.top() + ((max_height - title_size.height()) >> 1),
199 std::max(0, width() - insets.width() - close_button_size.width()),
200 title_size.height());
179 } 201 }
180 202
181 if (close_button_) { 203 if (close_button_) {
182 close_button_->SetBounds( 204 // Insert right padding to title area.
183 width() - insets.right() - close_button_size.width(), insets.top(), 205 if (style_ & STYLE_CERT)
184 close_button_size.width(), close_button_size.height()); 206 close_button_->SetBounds(
207 width() - insets.right() - close_button_size.width()
208 - kTitleRightPadding,
209 insets.top() + ((max_height - close_button_size.height()) >> 1),
210 close_button_size.width(), close_button_size.height());
211 else
212 close_button_->SetBounds(
213 width() - insets.right() - close_button_size.width(),
214 insets.top() + ((max_height - close_button_size.height()) >> 1),
215 close_button_size.width(), close_button_size.height());
185 } 216 }
186 217
187 if (throbber_) { 218 if (throbber_) {
188 throbber_->SetBounds( 219 throbber_->SetBounds(
189 insets.left(), insets.top(), 220 insets.left(),
221 insets.top() + ((max_height - throbber_size.height()) >> 1),
190 std::min(throbber_size.width(), width()), 222 std::min(throbber_size.width(), width()),
191 throbber_size.height()); 223 throbber_size.height());
192 } 224 }
193 225
194 int top_height = insets.top(); 226 int top_height = insets.top();
195 if (title_size.height() > 0 || 227 if (title_size.height() > 0 ||
196 close_button_size.height() > 0 || 228 close_button_size.height() > 0 ||
197 throbber_size.height() > 0) { 229 throbber_size.height() > 0) {
198 top_height += kTitleContentPadding + std::max( 230 top_height += kTitleContentPadding + std::max(
199 std::max(title_size.height(), close_button_size.height()), 231 std::max(title_size.height(), close_button_size.height()),
(...skipping 17 matching lines...) Expand all
217 canvas->GetSkCanvas()->drawPath(path, paint); 249 canvas->GetSkCanvas()->drawPath(path, paint);
218 } 250 }
219 251
220 void BubbleFrameView::ButtonPressed(views::Button* sender, 252 void BubbleFrameView::ButtonPressed(views::Button* sender,
221 const views::Event& event) { 253 const views::Event& event) {
222 if (close_button_ != NULL && sender == close_button_) 254 if (close_button_ != NULL && sender == close_button_)
223 frame_->Close(); 255 frame_->Close();
224 } 256 }
225 257
226 } // namespace chromeos 258 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698