Chromium Code Reviews

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: Remove body margins of two internal pages(due to the changes in tabs.css file). Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 130 matching lines...)
141 141
142 void BubbleFrameView::UpdateWindowIcon() { 142 void BubbleFrameView::UpdateWindowIcon() {
143 } 143 }
144 144
145 gfx::Insets BubbleFrameView::GetInsets() const { 145 gfx::Insets BubbleFrameView::GetInsets() const {
146 return (style_ & STYLE_FLUSH) ? 146 return (style_ & STYLE_FLUSH) ?
147 gfx::Insets() : 147 gfx::Insets() :
148 gfx::Insets(kTitleTopPadding, 148 gfx::Insets(kTitleTopPadding,
149 kHorizontalPadding, 149 kHorizontalPadding,
150 0, 150 0,
151 kHorizontalPadding); 151 kHorizontalPadding);
flackr 2011/11/21 20:43:31 I think the Insets you return here should not incl
bshe 2011/11/22 16:26:24 I was thinking that I can use offset_insets to off
152 } 152 }
153 153
154 gfx::Insets BubbleFrameView::GetOffsetInsets() const {
155 return (style_ & STYLE_FLUSH_CONTENT) ?
156 gfx::Insets(0,
157 -kHorizontalPadding,
158 0,
159 -kHorizontalPadding) :
160 gfx::Insets();
161 }
162
154 gfx::Size BubbleFrameView::GetPreferredSize() { 163 gfx::Size BubbleFrameView::GetPreferredSize() {
155 gfx::Size pref = frame_->client_view()->GetPreferredSize(); 164 gfx::Size pref = frame_->client_view()->GetPreferredSize();
156 gfx::Rect bounds(0, 0, pref.width(), pref.height()); 165 gfx::Rect bounds(0, 0, pref.width(), pref.height());
157 return frame_->non_client_view()->GetWindowBoundsForClientBounds( 166 return frame_->non_client_view()->GetWindowBoundsForClientBounds(
158 bounds).size(); 167 bounds).size();
159 } 168 }
160 169
161 void BubbleFrameView::Layout() { 170 void BubbleFrameView::Layout() {
162 gfx::Insets insets = GetInsets(); 171 gfx::Insets insets = GetInsets();
163 172
164 gfx::Size title_size; 173 gfx::Size title_size;
165 if (title_) 174 if (title_)
166 title_size = title_->GetPreferredSize(); 175 title_size = title_->GetPreferredSize();
167 gfx::Size close_button_size; 176 gfx::Size close_button_size;
168 if (close_button_) 177 if (close_button_)
169 close_button_size = close_button_->GetPreferredSize(); 178 close_button_size = close_button_->GetPreferredSize();
170 gfx::Size throbber_size; 179 gfx::Size throbber_size;
171 if (throbber_) 180 if (throbber_)
172 throbber_size = throbber_->GetPreferredSize(); 181 throbber_size = throbber_->GetPreferredSize();
173 182
183 // Need to center elements which are shorter.
184 int max_height = std::max(title_size.height(),
185 std::max(close_button_size.height(),
186 throbber_size.height()));
187
174 if (title_) { 188 if (title_) {
175 title_->SetBounds( 189 title_->SetBounds(
176 insets.left(), insets.top(), 190 insets.left(),
191 insets.top() + (static_cast<int>(
flackr 2011/11/21 20:43:31 Remove static_cast, integer division results in an
bshe 2011/11/22 16:26:24 Done. A stupid mistake...
192 (max_height - title_size.height()) / 2)), // Center
177 std::max(0, width() - insets.width() - close_button_size.width()), 193 std::max(0, width() - insets.width() - close_button_size.width()),
178 title_size.height()); 194 title_size.height());
179 } 195 }
180 196
181 if (close_button_) { 197 if (close_button_) {
182 close_button_->SetBounds( 198 close_button_->SetBounds(
183 width() - insets.right() - close_button_size.width(), insets.top(), 199 width() - insets.right() - close_button_size.width(),
200 insets.top() + (static_cast<int>(
flackr 2011/11/21 20:43:31 ditto
bshe 2011/11/22 16:26:24 Done.
201 (max_height - close_button_size.height()) / 2)),
184 close_button_size.width(), close_button_size.height()); 202 close_button_size.width(), close_button_size.height());
185 } 203 }
186 204
187 if (throbber_) { 205 if (throbber_) {
188 throbber_->SetBounds( 206 throbber_->SetBounds(
189 insets.left(), insets.top(), 207 insets.left(),
208 insets.top() + (static_cast<int> (
flackr 2011/11/21 20:43:31 ditto
bshe 2011/11/22 16:26:24 Done.
209 (max_height - throbber_size.height()) / 2)),
190 std::min(throbber_size.width(), width()), 210 std::min(throbber_size.width(), width()),
191 throbber_size.height()); 211 throbber_size.height());
192 } 212 }
193 213
194 int top_height = insets.top(); 214 int top_height = insets.top();
195 if (title_size.height() > 0 || 215 if (title_size.height() > 0 ||
196 close_button_size.height() > 0 || 216 close_button_size.height() > 0 ||
197 throbber_size.height() > 0) { 217 throbber_size.height() > 0) {
198 top_height += kTitleContentPadding + std::max( 218 top_height += kTitleContentPadding + std::max(
199 std::max(title_size.height(), close_button_size.height()), 219 std::max(title_size.height(), close_button_size.height()),
200 throbber_size.height()); 220 throbber_size.height());
201 } 221 }
202 client_view_bounds_.SetRect(insets.left(), top_height, 222
203 std::max(0, width() - insets.width()), 223 gfx::Insets offset_insets = GetOffsetInsets();
flackr 2011/11/21 20:43:31 As per my above comment, my preference would be if
bshe 2011/11/22 16:26:24 Done.
204 std::max(0, height() - top_height - insets.bottom())); 224 client_view_bounds_.SetRect(insets.left() + offset_insets.left(), top_height,
225 std::max(0, width() - insets.width() - offset_insets.width()),
226 std::max(0, height() - top_height - insets.bottom()
227 - offset_insets.bottom()));
205 } 228 }
206 229
207 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) { 230 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) {
208 SkPaint paint; 231 SkPaint paint;
209 paint.setStyle(SkPaint::kFill_Style); 232 paint.setStyle(SkPaint::kFill_Style);
210 paint.setColor(kBubbleWindowBackgroundColor); 233 paint.setColor(kBubbleWindowBackgroundColor);
211 gfx::Path path; 234 gfx::Path path;
212 gfx::Rect bounds(GetContentsBounds()); 235 gfx::Rect bounds(GetContentsBounds());
213 SkRect rect; 236 SkRect rect;
214 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), 237 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()),
215 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); 238 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom()));
216 path.addRect(rect); 239 path.addRect(rect);
217 canvas->GetSkCanvas()->drawPath(path, paint); 240 canvas->GetSkCanvas()->drawPath(path, paint);
218 } 241 }
219 242
220 void BubbleFrameView::ButtonPressed(views::Button* sender, 243 void BubbleFrameView::ButtonPressed(views::Button* sender,
221 const views::Event& event) { 244 const views::Event& event) {
222 if (close_button_ != NULL && sender == close_button_) 245 if (close_button_ != NULL && sender == close_button_)
223 frame_->Close(); 246 frame_->Close();
224 } 247 }
225 248
226 } // namespace chromeos 249 } // namespace chromeos
OLDNEW

Powered by Google App Engine