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

Side by Side Diff: ui/views/bubble/bubble_frame_view.cc

Issue 20871003: Fix BubbleFrameView title and close button patterns. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge; add OVERRIDE mark. Created 7 years, 4 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
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/window/dialog_delegate.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/views/bubble/bubble_frame_view.h" 5 #include "ui/views/bubble/bubble_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/hit_test.h" 10 #include "ui/base/hit_test.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 gfx::Insets border_insets = bubble_border_->GetInsets(); 122 gfx::Insets border_insets = bubble_border_->GetInsets();
123 const SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize), 123 const SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize),
124 SkIntToScalar(border_insets.top() - kBorderStrokeSize), 124 SkIntToScalar(border_insets.top() - kBorderStrokeSize),
125 SkIntToScalar(size.width() - border_insets.right() + 125 SkIntToScalar(size.width() - border_insets.right() +
126 kBorderStrokeSize), 126 kBorderStrokeSize),
127 SkIntToScalar(size.height() - border_insets.bottom() + 127 SkIntToScalar(size.height() - border_insets.bottom() +
128 kBorderStrokeSize) }; 128 kBorderStrokeSize) };
129 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius); 129 window_mask->addRoundRect(rect, kCornerRadius, kCornerRadius);
130 } 130 }
131 131
132 void BubbleFrameView::ResetWindowControls() {} 132 void BubbleFrameView::ResetWindowControls() {
133 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton());
134 }
133 135
134 void BubbleFrameView::UpdateWindowIcon() {} 136 void BubbleFrameView::UpdateWindowIcon() {}
135 137
136 void BubbleFrameView::UpdateWindowTitle() {} 138 void BubbleFrameView::UpdateWindowTitle() {
139 title_->SetText(GetWidget()->widget_delegate()->ShouldShowWindowTitle() ?
140 GetWidget()->widget_delegate()->GetWindowTitle() : string16());
141 // Update the close button visibility too, otherwise it's not intialized.
142 ResetWindowControls();
143 }
137 144
138 gfx::Insets BubbleFrameView::GetInsets() const { 145 gfx::Insets BubbleFrameView::GetInsets() const {
139 gfx::Insets insets = content_margins_; 146 gfx::Insets insets = content_margins_;
140 const int title_height = title_->text().empty() ? 0 : 147 const int title_height = title_->text().empty() ? 0 :
141 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset; 148 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset;
142 const int close_height = close_->visible() ? close_->height() : 0; 149 const int close_height = close_->visible() ? close_->height() : 0;
143 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); 150 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0);
144 return insets; 151 return insets;
145 } 152 }
146 153
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 210 }
204 211
205 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { 212 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) {
206 bubble_border_ = border; 213 bubble_border_ = border;
207 set_border(bubble_border_); 214 set_border(bubble_border_);
208 215
209 // Update the background, which relies on the border. 216 // Update the background, which relies on the border.
210 set_background(new views::BubbleBackground(border)); 217 set_background(new views::BubbleBackground(border));
211 } 218 }
212 219
213 void BubbleFrameView::SetTitle(const string16& title) {
214 title_->SetText(title);
215 }
216
217 void BubbleFrameView::SetShowCloseButton(bool show) {
218 close_->SetVisible(show);
219 }
220
221 void BubbleFrameView::SetTitlebarExtraView(View* view) { 220 void BubbleFrameView::SetTitlebarExtraView(View* view) {
222 DCHECK(view); 221 DCHECK(view);
223 DCHECK(!titlebar_extra_view_); 222 DCHECK(!titlebar_extra_view_);
224 AddChildView(view); 223 AddChildView(view);
225 titlebar_extra_view_ = view; 224 titlebar_extra_view_ = view;
226 } 225 }
227 226
228 gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, 227 gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect,
229 gfx::Size client_size, 228 gfx::Size client_size,
230 bool adjust_if_offscreen) { 229 bool adjust_if_offscreen) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble 312 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble
314 // window needs to be moved to the right and that means we need to move arrow 313 // window needs to be moved to the right and that means we need to move arrow
315 // to the left, and that means negative offset. 314 // to the left, and that means negative offset.
316 bubble_border_->set_arrow_offset( 315 bubble_border_->set_arrow_offset(
317 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); 316 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust);
318 if (offscreen_adjust) 317 if (offscreen_adjust)
319 SchedulePaint(); 318 SchedulePaint();
320 } 319 }
321 320
322 } // namespace views 321 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/window/dialog_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698