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

Side by Side Diff: ui/views/controls/button/label_button.cc

Issue 1645013004: Views - dialog button defaultness shouldn't follow focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win compile Created 4 years, 10 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
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | ui/views/window/dialog_client_view.h » ('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/controls/button/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 if (is_default == is_default_) 174 if (is_default == is_default_)
175 return; 175 return;
176 is_default_ = is_default; 176 is_default_ = is_default;
177 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE); 177 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE);
178 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel); 178 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel);
179 179
180 // STYLE_BUTTON uses bold text to indicate default buttons. 180 // STYLE_BUTTON uses bold text to indicate default buttons.
181 if (style_ == STYLE_BUTTON) { 181 if (style_ == STYLE_BUTTON) {
182 label_->SetFontList( 182 label_->SetFontList(
183 is_default ? cached_bold_font_list_ : cached_normal_font_list_); 183 is_default ? cached_bold_font_list_ : cached_normal_font_list_);
184 // Usually this function is called before |this| is attached to a widget, 184 InvalidateLayout();
185 // but in the cases where |this| is already shown, we need to re-layout
186 // because font boldness affects the label's size.
187 if (GetWidget())
188 Layout();
189 } 185 }
190 } 186 }
191 187
192 void LabelButton::SetStyle(ButtonStyle style) { 188 void LabelButton::SetStyle(ButtonStyle style) {
193 // All callers currently pass STYLE_BUTTON, and should only call this once, to 189 // All callers currently pass STYLE_BUTTON, and should only call this once, to
194 // change from the default style. 190 // change from the default style.
195 DCHECK_EQ(style, STYLE_BUTTON); 191 DCHECK_EQ(style, STYLE_BUTTON);
196 DCHECK_EQ(style_, STYLE_TEXTBUTTON); 192 DCHECK_EQ(style_, STYLE_TEXTBUTTON);
197 DCHECK(!GetWidget()) << "Can't change button style after adding to a Widget."; 193 DCHECK(!GetWidget()) << "Can't change button style after adding to a Widget.";
198 194
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 GetExtraParams(params); 505 GetExtraParams(params);
510 return ui::NativeTheme::kHovered; 506 return ui::NativeTheme::kHovered;
511 } 507 }
512 508
513 void LabelButton::ResetCachedPreferredSize() { 509 void LabelButton::ResetCachedPreferredSize() {
514 cached_preferred_size_valid_ = false; 510 cached_preferred_size_valid_ = false;
515 cached_preferred_size_ = gfx::Size(); 511 cached_preferred_size_ = gfx::Size();
516 } 512 }
517 513
518 } // namespace views 514 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/custom_button.cc ('k') | ui/views/window/dialog_client_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698