OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/views/frame/opaque_browser_frame_view_layout.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
6 | 6 |
7 #include "base/command_line.h" | |
7 #include "chrome/browser/profiles/profiles_state.h" | 8 #include "chrome/browser/profiles/profiles_state.h" |
8 #include "chrome/browser/ui/views/avatar_menu_button.h" | 9 #include "chrome/browser/ui/views/avatar_menu_button.h" |
10 #include "chrome/common/chrome_switches.h" | |
9 #include "chrome/common/profile_management_switches.h" | 11 #include "chrome/common/profile_management_switches.h" |
10 #include "ui/gfx/font.h" | 12 #include "ui/gfx/font.h" |
11 #include "ui/views/controls/button/image_button.h" | 13 #include "ui/views/controls/button/image_button.h" |
12 #include "ui/views/controls/label.h" | 14 #include "ui/views/controls/label.h" |
13 | 15 |
14 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
15 #include "win8/util/win8_util.h" | 17 #include "win8/util/win8_util.h" |
16 #endif // OS_WIN | 18 #endif // OS_WIN |
17 | 19 |
18 namespace { | 20 namespace { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 | 53 |
52 // Space between the edge of the avatar and the tabstrip. | 54 // Space between the edge of the avatar and the tabstrip. |
53 const int kAvatarInnerSpacing = 4; | 55 const int kAvatarInnerSpacing = 4; |
54 | 56 |
55 // Space between the trailing edge of the avatar label and the tabstrip. | 57 // Space between the trailing edge of the avatar label and the tabstrip. |
56 const int kAvatarLabelInnerSpacing = 10; | 58 const int kAvatarLabelInnerSpacing = 10; |
57 | 59 |
58 // How far the new avatar button is from the closest caption button. | 60 // How far the new avatar button is from the closest caption button. |
59 const int kNewAvatarButtonOffset = 5; | 61 const int kNewAvatarButtonOffset = 5; |
60 | 62 |
61 // In restored mode, the New Tab button isn't at the same height as the caption | 63 // When the title bar is in its normal two row mode, the New Tab button isn't at |
James Cook
2013/12/20 22:23:51
nit: You might want to put the word "restored" in
Matt Giuca
2014/01/06 04:28:21
Done.
| |
62 // buttons, but the space will look cluttered if it actually slides under them, | 64 // the same height as the caption buttons, but the space will look cluttered if |
63 // so we stop it when the gap between the two is down to 5 px. | 65 // it actually slides under them, so we stop it when the gap between the two is |
64 const int kNewTabCaptionRestoredSpacing = 5; | 66 // down to 5 px. |
67 const int kNewTabCaptionNormalSpacing = 5; | |
65 | 68 |
66 // In maximized mode, where the New Tab button and the caption buttons are at | 69 // When the title bar is condensed to one row (as when maximized), the New Tab |
67 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 70 // button and the caption buttons are at similar vertical coordinates, so we |
68 // looking too cluttered. | 71 // need to reserve a larger, 16 px gap to avoid looking too cluttered. |
69 const int kNewTabCaptionMaximizedSpacing = 16; | 72 const int kNewTapCaptionCondensedSpacing = 16; |
70 | 73 |
71 // The top 3 px of the tabstrip is shadow; in maximized mode we push this off | 74 // The top 3 px of the tabstrip is shadow; in maximized mode we push this off |
72 // the top of the screen so the tabs appear flush against the screen edge. | 75 // the top of the screen so the tabs appear flush against the screen edge. |
73 const int kTabstripTopShadowThickness = 3; | 76 const int kTabstripTopShadowThickness = 3; |
74 | 77 |
75 // How far to indent the tabstrip from the left side of the screen when there | 78 // How far to indent the tabstrip from the left side of the screen when there |
76 // is no avatar icon. | 79 // is no avatar icon. |
77 const int kTabStripIndent = -6; | 80 const int kTabStripIndent = -6; |
78 | 81 |
79 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 82 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 | 139 |
137 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( | 140 gfx::Rect OpaqueBrowserFrameViewLayout::GetBoundsForTabStrip( |
138 const gfx::Size& tabstrip_preferred_size, | 141 const gfx::Size& tabstrip_preferred_size, |
139 int available_width) const { | 142 int available_width) const { |
140 available_width -= trailing_button_start_; | 143 available_width -= trailing_button_start_; |
141 available_width -= leading_button_start_; | 144 available_width -= leading_button_start_; |
142 | 145 |
143 if (delegate_->GetAdditionalReservedSpaceInTabStrip()) | 146 if (delegate_->GetAdditionalReservedSpaceInTabStrip()) |
144 available_width -= delegate_->GetAdditionalReservedSpaceInTabStrip(); | 147 available_width -= delegate_->GetAdditionalReservedSpaceInTabStrip(); |
145 | 148 |
146 const int caption_spacing = delegate_->IsMaximized() ? | 149 const int caption_spacing = IsTitleBarCondensed() ? |
147 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing; | 150 kNewTapCaptionCondensedSpacing : kNewTabCaptionNormalSpacing; |
148 const int tabstrip_width = available_width - caption_spacing; | 151 const int tabstrip_width = available_width - caption_spacing; |
149 gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false), | 152 gfx::Rect bounds(leading_button_start_, GetTabStripInsetsTop(false), |
150 std::max(0, tabstrip_width), | 153 std::max(0, tabstrip_width), |
151 tabstrip_preferred_size.height()); | 154 tabstrip_preferred_size.height()); |
152 | 155 |
153 int leading_tabstrip_indent = kTabStripIndent; | 156 int leading_tabstrip_indent = kTabStripIndent; |
154 if (delegate_->ShouldShowAvatar() && !ShouldAvatarBeOnRight()) { | 157 if (delegate_->ShouldShowAvatar() && !ShouldAvatarBeOnRight()) { |
155 if (avatar_label_ && avatar_label_->bounds().width()) | 158 if (avatar_label_ && avatar_label_->bounds().width()) |
156 leading_tabstrip_indent += kAvatarLabelInnerSpacing; | 159 leading_tabstrip_indent += kAvatarLabelInnerSpacing; |
157 else | 160 else |
(...skipping 11 matching lines...) Expand all Loading... | |
169 NonClientTopBorderHeight(false) + border_thickness); | 172 NonClientTopBorderHeight(false) + border_thickness); |
170 | 173 |
171 // Ensure that we can, at minimum, hold our window controls and avatar icon. | 174 // Ensure that we can, at minimum, hold our window controls and avatar icon. |
172 min_size.set_width(std::max(min_size.width(), minimum_size_for_buttons_)); | 175 min_size.set_width(std::max(min_size.width(), minimum_size_for_buttons_)); |
173 | 176 |
174 // Ensure that the minimum width is enough to hold a minimum width tab strip | 177 // Ensure that the minimum width is enough to hold a minimum width tab strip |
175 // at its usual insets. | 178 // at its usual insets. |
176 if (delegate_->IsTabStripVisible()) { | 179 if (delegate_->IsTabStripVisible()) { |
177 gfx::Size preferred_size = delegate_->GetTabstripPreferredSize(); | 180 gfx::Size preferred_size = delegate_->GetTabstripPreferredSize(); |
178 const int min_tabstrip_width = preferred_size.width(); | 181 const int min_tabstrip_width = preferred_size.width(); |
179 const int caption_spacing = delegate_->IsMaximized() ? | 182 const int caption_spacing = IsTitleBarCondensed() ? |
180 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing; | 183 kNewTapCaptionCondensedSpacing : kNewTabCaptionNormalSpacing; |
181 min_size.Enlarge(min_tabstrip_width + caption_spacing, 0); | 184 min_size.Enlarge(min_tabstrip_width + caption_spacing, 0); |
182 } | 185 } |
183 | 186 |
184 return min_size; | 187 return min_size; |
185 } | 188 } |
186 | 189 |
187 gfx::Rect OpaqueBrowserFrameViewLayout::GetWindowBoundsForClientBounds( | 190 gfx::Rect OpaqueBrowserFrameViewLayout::GetWindowBoundsForClientBounds( |
188 const gfx::Rect& client_bounds) const { | 191 const gfx::Rect& client_bounds) const { |
189 int top_height = NonClientTopBorderHeight(false); | 192 int top_height = NonClientTopBorderHeight(false); |
190 int border_thickness = NonClientBorderThickness(); | 193 int border_thickness = NonClientBorderThickness(); |
191 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 194 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
192 std::max(0, client_bounds.y() - top_height), | 195 std::max(0, client_bounds.y() - top_height), |
193 client_bounds.width() + (2 * border_thickness), | 196 client_bounds.width() + (2 * border_thickness), |
194 client_bounds.height() + top_height + border_thickness); | 197 client_bounds.height() + top_height + border_thickness); |
195 } | 198 } |
196 | 199 |
197 int OpaqueBrowserFrameViewLayout::FrameBorderThickness(bool restored) const { | 200 int OpaqueBrowserFrameViewLayout::FrameBorderThickness(bool restored) const { |
198 return (!restored && (delegate_->IsMaximized() || | 201 return (!restored && (IsTitleBarCondensed() || |
199 delegate_->IsFullscreen())) ? | 202 delegate_->IsFullscreen())) ? |
200 0 : kFrameBorderThickness; | 203 0 : kFrameBorderThickness; |
201 } | 204 } |
202 | 205 |
203 int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const { | 206 int OpaqueBrowserFrameViewLayout::NonClientBorderThickness() const { |
204 // When we fill the screen, we don't show a client edge. | 207 // When we fill the screen, we don't show a client edge. |
205 return FrameBorderThickness(false) + | 208 return FrameBorderThickness(false) + |
206 ((delegate_->IsMaximized() || delegate_->IsFullscreen()) ? | 209 ((IsTitleBarCondensed() || delegate_->IsFullscreen()) ? |
207 0 : views::NonClientFrameView::kClientEdgeThickness); | 210 0 : views::NonClientFrameView::kClientEdgeThickness); |
208 } | 211 } |
209 | 212 |
210 int OpaqueBrowserFrameViewLayout::NonClientTopBorderHeight( | 213 int OpaqueBrowserFrameViewLayout::NonClientTopBorderHeight( |
211 bool restored) const { | 214 bool restored) const { |
212 if (delegate_->ShouldShowWindowTitle()) { | 215 if (delegate_->ShouldShowWindowTitle()) { |
213 return std::max(FrameBorderThickness(restored) + delegate_->GetIconSize(), | 216 return std::max(FrameBorderThickness(restored) + delegate_->GetIconSize(), |
214 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) + | 217 CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) + |
215 TitlebarBottomThickness(restored); | 218 TitlebarBottomThickness(restored); |
216 } | 219 } |
217 | 220 |
218 return FrameBorderThickness(restored) - | 221 int thickness = FrameBorderThickness(restored); |
219 ((delegate_->IsTabStripVisible() && | 222 if (!restored && delegate_->IsTabStripVisible() && |
James Cook
2013/12/20 22:23:51
better, thanks
| |
220 !restored && !delegate_->ShouldLeaveOffsetNearTopBorder()) | 223 (!delegate_->ShouldLeaveOffsetNearTopBorder() || IsTitleBarCondensed())) { |
221 ? kTabstripTopShadowThickness : 0); | 224 thickness -= kTabstripTopShadowThickness; |
225 } | |
226 return thickness; | |
222 } | 227 } |
223 | 228 |
224 int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const { | 229 int OpaqueBrowserFrameViewLayout::GetTabStripInsetsTop(bool restored) const { |
225 return NonClientTopBorderHeight(restored) + ((!restored && | 230 return NonClientTopBorderHeight(restored) + ((!restored && |
226 (!delegate_->ShouldLeaveOffsetNearTopBorder() || | 231 (!delegate_->ShouldLeaveOffsetNearTopBorder() || |
232 IsTitleBarCondensed() || | |
227 delegate_->IsFullscreen())) ? | 233 delegate_->IsFullscreen())) ? |
228 0 : kNonClientRestoredExtraThickness); | 234 0 : kNonClientRestoredExtraThickness); |
229 } | 235 } |
230 | 236 |
231 int OpaqueBrowserFrameViewLayout::TitlebarBottomThickness(bool restored) const { | 237 int OpaqueBrowserFrameViewLayout::TitlebarBottomThickness(bool restored) const { |
232 return kTitlebarTopAndBottomEdgeThickness + | 238 return kTitlebarTopAndBottomEdgeThickness + |
233 ((!restored && delegate_->IsMaximized()) ? 0 : | 239 ((!restored && IsTitleBarCondensed()) ? 0 : |
234 views::NonClientFrameView::kClientEdgeThickness); | 240 views::NonClientFrameView::kClientEdgeThickness); |
235 } | 241 } |
236 | 242 |
237 int OpaqueBrowserFrameViewLayout::CaptionButtonY(bool restored) const { | 243 int OpaqueBrowserFrameViewLayout::CaptionButtonY(bool restored) const { |
238 // Maximized buttons start at window top, since the window has no border. This | 244 // Maximized buttons start at window top, since the window has no border. This |
239 // offset is for the image (the actual clickable bounds extend all the way to | 245 // offset is for the image (the actual clickable bounds extend all the way to |
240 // the top to take Fitts' Law into account). | 246 // the top to take Fitts' Law into account). |
241 return ((!restored && delegate_->IsMaximized()) ? | 247 return ((!restored && IsTitleBarCondensed()) ? |
242 FrameBorderThickness(false) : | 248 FrameBorderThickness(false) : |
243 views::NonClientFrameView::kFrameShadowThickness) + extra_caption_y_; | 249 views::NonClientFrameView::kFrameShadowThickness) + extra_caption_y_; |
244 } | 250 } |
245 | 251 |
246 gfx::Rect OpaqueBrowserFrameViewLayout::IconBounds() const { | 252 gfx::Rect OpaqueBrowserFrameViewLayout::IconBounds() const { |
247 return window_icon_bounds_; | 253 return window_icon_bounds_; |
248 } | 254 } |
249 | 255 |
250 gfx::Rect OpaqueBrowserFrameViewLayout::CalculateClientAreaBounds( | 256 gfx::Rect OpaqueBrowserFrameViewLayout::CalculateClientAreaBounds( |
251 int width, | 257 int width, |
252 int height) const { | 258 int height) const { |
253 int top_height = NonClientTopBorderHeight(false); | 259 int top_height = NonClientTopBorderHeight(false); |
254 int border_thickness = NonClientBorderThickness(); | 260 int border_thickness = NonClientBorderThickness(); |
255 return gfx::Rect(border_thickness, top_height, | 261 return gfx::Rect(border_thickness, top_height, |
256 std::max(0, width - (2 * border_thickness)), | 262 std::max(0, width - (2 * border_thickness)), |
257 std::max(0, height - top_height - border_thickness)); | 263 std::max(0, height - top_height - border_thickness)); |
258 } | 264 } |
259 | 265 |
266 bool OpaqueBrowserFrameViewLayout::IsTitleBarCondensed() const { | |
267 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
268 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseSystemTitleBar)) | |
269 return true; | |
270 #endif | |
271 | |
272 return delegate_->IsMaximized(); | |
273 } | |
274 | |
260 /////////////////////////////////////////////////////////////////////////////// | 275 /////////////////////////////////////////////////////////////////////////////// |
261 // OpaqueBrowserFrameView, private: | 276 // OpaqueBrowserFrameView, private: |
262 | 277 |
263 bool OpaqueBrowserFrameViewLayout::ShouldAvatarBeOnRight() const { | 278 bool OpaqueBrowserFrameViewLayout::ShouldAvatarBeOnRight() const { |
264 // The avatar should be shown either on the end of the left or the beginning | 279 // The avatar should be shown either on the end of the left or the beginning |
265 // of the right depending on which side has fewer buttons. | 280 // of the right depending on which side has fewer buttons. |
266 return trailing_buttons_.size() < leading_buttons_.size(); | 281 return trailing_buttons_.size() < leading_buttons_.size(); |
267 } | 282 } |
268 | 283 |
269 void OpaqueBrowserFrameViewLayout::LayoutWindowControls(views::View* host) { | 284 void OpaqueBrowserFrameViewLayout::LayoutWindowControls(views::View* host) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 use_hidden_icon_location = false; | 329 use_hidden_icon_location = false; |
315 | 330 |
316 // Our frame border has a different "3D look" than Windows'. Theirs has | 331 // Our frame border has a different "3D look" than Windows'. Theirs has |
317 // a more complex gradient on the top that they push their icon/title | 332 // a more complex gradient on the top that they push their icon/title |
318 // below; then the maximized window cuts this off and the icon/title are | 333 // below; then the maximized window cuts this off and the icon/title are |
319 // centered in the remaining space. Because the apparent shape of our | 334 // centered in the remaining space. Because the apparent shape of our |
320 // border is simpler, using the same positioning makes things look | 335 // border is simpler, using the same positioning makes things look |
321 // slightly uncentered with restored windows, so when the window is | 336 // slightly uncentered with restored windows, so when the window is |
322 // restored, instead of calculating the remaining space from below the | 337 // restored, instead of calculating the remaining space from below the |
323 // frame border, we calculate from below the 3D edge. | 338 // frame border, we calculate from below the 3D edge. |
324 int unavailable_px_at_top = delegate_->IsMaximized() ? | 339 int unavailable_px_at_top = IsTitleBarCondensed() ? |
325 frame_thickness : kTitlebarTopAndBottomEdgeThickness; | 340 frame_thickness : kTitlebarTopAndBottomEdgeThickness; |
326 // When the icon is shorter than the minimum space we reserve for the | 341 // When the icon is shorter than the minimum space we reserve for the |
327 // caption button, we vertically center it. We want to bias rounding to | 342 // caption button, we vertically center it. We want to bias rounding to |
328 // put extra space above the icon, since the 3D edge (+ client edge, for | 343 // put extra space above the icon, since the 3D edge (+ client edge, for |
329 // restored windows) below looks (to the eye) more like additional space | 344 // restored windows) below looks (to the eye) more like additional space |
330 // than does the 3D edge (or nothing at all, for maximized windows) | 345 // than does the 3D edge (or nothing at all, for maximized windows) |
331 // above; hence the +1. | 346 // above; hence the +1. |
332 int y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - | 347 int y = unavailable_px_at_top + (NonClientTopBorderHeight(false) - |
333 unavailable_px_at_top - size - | 348 unavailable_px_at_top - size - |
334 TitlebarBottomThickness(false) + 1) / 2; | 349 TitlebarBottomThickness(false) + 1) / 2; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 gfx::ImageSkia incognito_icon = delegate_->GetOTRAvatarIcon(); | 415 gfx::ImageSkia incognito_icon = delegate_->GetOTRAvatarIcon(); |
401 | 416 |
402 bool avatar_on_right = ShouldAvatarBeOnRight(); | 417 bool avatar_on_right = ShouldAvatarBeOnRight(); |
403 int avatar_bottom = GetTabStripInsetsTop(false) + | 418 int avatar_bottom = GetTabStripInsetsTop(false) + |
404 delegate_->GetTabStripHeight() - kAvatarBottomSpacing; | 419 delegate_->GetTabStripHeight() - kAvatarBottomSpacing; |
405 int avatar_restored_y = avatar_bottom - incognito_icon.height(); | 420 int avatar_restored_y = avatar_bottom - incognito_icon.height(); |
406 int avatar_x = avatar_on_right ? | 421 int avatar_x = avatar_on_right ? |
407 host->width() - trailing_button_start_ - kAvatarOuterSpacing - | 422 host->width() - trailing_button_start_ - kAvatarOuterSpacing - |
408 incognito_icon.width() : | 423 incognito_icon.width() : |
409 leading_button_start_ + kAvatarOuterSpacing; | 424 leading_button_start_ + kAvatarOuterSpacing; |
410 int avatar_y = delegate_->IsMaximized() ? | 425 int avatar_y = IsTitleBarCondensed() ? |
411 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : | 426 (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) : |
412 avatar_restored_y; | 427 avatar_restored_y; |
413 avatar_bounds_.SetRect( | 428 avatar_bounds_.SetRect( |
414 avatar_x, | 429 avatar_x, |
415 avatar_y, | 430 avatar_y, |
416 incognito_icon.width(), | 431 incognito_icon.width(), |
417 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); | 432 delegate_->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0); |
418 if (avatar_button_) { | 433 if (avatar_button_) { |
419 avatar_button_->set_button_on_right(avatar_on_right); | 434 avatar_button_->set_button_on_right(avatar_on_right); |
420 avatar_button_->SetBoundsRect(avatar_bounds_); | 435 avatar_button_->SetBoundsRect(avatar_bounds_); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 | 521 |
507 button->SetImageAlignment( | 522 button->SetImageAlignment( |
508 (alignment == ALIGN_LEADING) ? | 523 (alignment == ALIGN_LEADING) ? |
509 views::ImageButton::ALIGN_RIGHT : views::ImageButton::ALIGN_LEFT, | 524 views::ImageButton::ALIGN_RIGHT : views::ImageButton::ALIGN_LEFT, |
510 views::ImageButton::ALIGN_BOTTOM); | 525 views::ImageButton::ALIGN_BOTTOM); |
511 | 526 |
512 // There should always be the same number of non-shadow pixels visible to the | 527 // There should always be the same number of non-shadow pixels visible to the |
513 // side of the caption buttons. In maximized mode we extend buttons to the | 528 // side of the caption buttons. In maximized mode we extend buttons to the |
514 // screen top and the rightmost button to the screen right (or leftmost button | 529 // screen top and the rightmost button to the screen right (or leftmost button |
515 // to the screen left, for left-aligned buttons) to obey Fitts' Law. | 530 // to the screen left, for left-aligned buttons) to obey Fitts' Law. |
516 bool is_maximized = delegate_->IsMaximized(); | 531 bool title_bar_condensed = IsTitleBarCondensed(); |
517 | 532 |
518 // When we are the first button on the leading side and are the close | 533 // When we are the first button on the leading side and are the close |
519 // button, we must flip ourselves, because the close button assets have | 534 // button, we must flip ourselves, because the close button assets have |
520 // a little notch to fit in the rounded frame. | 535 // a little notch to fit in the rounded frame. |
521 button->SetDrawImageMirrored(alignment == ALIGN_LEADING && | 536 button->SetDrawImageMirrored(alignment == ALIGN_LEADING && |
522 !has_leading_buttons_ && | 537 !has_leading_buttons_ && |
523 button == close_button_); | 538 button == close_button_); |
524 // If the window is maximized, align the buttons to its upper edge. | 539 // If the window is maximized, align the buttons to its upper edge. |
525 int extra_height = is_maximized ? extra_caption_y_ : 0; | 540 int extra_height = title_bar_condensed ? extra_caption_y_ : 0; |
526 | 541 |
527 switch (alignment) { | 542 switch (alignment) { |
528 case ALIGN_LEADING: { | 543 case ALIGN_LEADING: { |
529 if (has_leading_buttons_) | 544 if (has_leading_buttons_) |
530 leading_button_start_ += window_caption_spacing_; | 545 leading_button_start_ += window_caption_spacing_; |
531 | 546 |
532 // If we're the first button on the left and maximized, add width to the | 547 // If we're the first button on the left and maximized, add width to the |
533 // right hand side of the screen. | 548 // right hand side of the screen. |
534 int extra_width = (is_maximized && !has_leading_buttons_) ? | 549 int extra_width = (title_bar_condensed && !has_leading_buttons_) ? |
535 (kFrameBorderThickness - | 550 (kFrameBorderThickness - |
536 views::NonClientFrameView::kFrameShadowThickness) : 0; | 551 views::NonClientFrameView::kFrameShadowThickness) : 0; |
537 | 552 |
538 button->SetBounds( | 553 button->SetBounds( |
539 leading_button_start_, | 554 leading_button_start_, |
540 caption_y - extra_height, | 555 caption_y - extra_height, |
541 button_size.width() + extra_width, | 556 button_size.width() + extra_width, |
542 button_size.height() + extra_height); | 557 button_size.height() + extra_height); |
543 | 558 |
544 leading_button_start_ += extra_width + button_size.width(); | 559 leading_button_start_ += extra_width + button_size.width(); |
545 minimum_size_for_buttons_ += extra_width + button_size.width(); | 560 minimum_size_for_buttons_ += extra_width + button_size.width(); |
546 has_leading_buttons_ = true; | 561 has_leading_buttons_ = true; |
547 break; | 562 break; |
548 } | 563 } |
549 case ALIGN_TRAILING: { | 564 case ALIGN_TRAILING: { |
550 if (has_trailing_buttons_) | 565 if (has_trailing_buttons_) |
551 trailing_button_start_ += window_caption_spacing_; | 566 trailing_button_start_ += window_caption_spacing_; |
552 | 567 |
553 // If we're the first button on the right and maximized, add width to the | 568 // If we're the first button on the right and maximized, add width to the |
554 // right hand side of the screen. | 569 // right hand side of the screen. |
555 int extra_width = (is_maximized && !has_trailing_buttons_) ? | 570 int extra_width = (title_bar_condensed && !has_trailing_buttons_) ? |
556 (kFrameBorderThickness - | 571 (kFrameBorderThickness - |
557 views::NonClientFrameView::kFrameShadowThickness) : 0; | 572 views::NonClientFrameView::kFrameShadowThickness) : 0; |
558 | 573 |
559 button->SetBounds( | 574 button->SetBounds( |
560 host->width() - trailing_button_start_ - extra_width - | 575 host->width() - trailing_button_start_ - extra_width - |
561 button_size.width(), | 576 button_size.width(), |
562 caption_y - extra_height, | 577 caption_y - extra_height, |
563 button_size.width() + extra_width, | 578 button_size.width() + extra_width, |
564 button_size.height() + extra_height); | 579 button_size.height() + extra_height); |
565 | 580 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 | 688 |
674 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, | 689 void OpaqueBrowserFrameViewLayout::ViewAdded(views::View* host, |
675 views::View* view) { | 690 views::View* view) { |
676 SetView(view->id(), view); | 691 SetView(view->id(), view); |
677 } | 692 } |
678 | 693 |
679 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, | 694 void OpaqueBrowserFrameViewLayout::ViewRemoved(views::View* host, |
680 views::View* view) { | 695 views::View* view) { |
681 SetView(view->id(), NULL); | 696 SetView(view->id(), NULL); |
682 } | 697 } |
OLD | NEW |