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

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

Issue 15071002: WIP - loop in LayoutManager for preferred size changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: scoped layouter Created 7 years, 7 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/message_center/views/message_popup_bubble.cc ('k') | ui/views/controls/menu/submenu_view.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/controls/button/label_button.h" 5 #include "ui/views/controls/button/label_button.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/base/animation/throb_animation.h" 9 #include "ui/base/animation/throb_animation.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 void LabelButton::SetFont(const gfx::Font& font) { 104 void LabelButton::SetFont(const gfx::Font& font) {
105 label_->SetFont(font); 105 label_->SetFont(font);
106 } 106 }
107 107
108 gfx::HorizontalAlignment LabelButton::GetHorizontalAlignment() const { 108 gfx::HorizontalAlignment LabelButton::GetHorizontalAlignment() const {
109 return label_->horizontal_alignment(); 109 return label_->horizontal_alignment();
110 } 110 }
111 111
112 void LabelButton::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) { 112 void LabelButton::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) {
113 label_->SetHorizontalAlignment(alignment); 113 label_->SetHorizontalAlignment(alignment);
114 InvalidateLayout(); 114 Layout();
115 } 115 }
116 116
117 void LabelButton::SetIsDefault(bool is_default) { 117 void LabelButton::SetIsDefault(bool is_default) {
118 if (is_default == is_default_) 118 if (is_default == is_default_)
119 return; 119 return;
120 is_default_ = is_default; 120 is_default_ = is_default;
121 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE); 121 ui::Accelerator accel(ui::VKEY_RETURN, ui::EF_NONE);
122 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel); 122 is_default_ ? AddAccelerator(accel) : RemoveAccelerator(accel);
123 123
124 // STYLE_BUTTON uses bold text to indicate default buttons. 124 // STYLE_BUTTON uses bold text to indicate default buttons.
(...skipping 20 matching lines...) Expand all
145 set_focusable(true); 145 set_focusable(true);
146 } 146 }
147 if (style == STYLE_BUTTON) { 147 if (style == STYLE_BUTTON) {
148 set_min_size(gfx::Size(70, 31)); 148 set_min_size(gfx::Size(70, 31));
149 const SkColor color = GetNativeTheme()->GetSystemColor( 149 const SkColor color = GetNativeTheme()->GetSystemColor(
150 ui::NativeTheme::kColorId_WindowBackground); 150 ui::NativeTheme::kColorId_WindowBackground);
151 label_->SetShadowColors(color, color); 151 label_->SetShadowColors(color, color);
152 label_->SetShadowOffset(0, 1); 152 label_->SetShadowOffset(0, 1);
153 } 153 }
154 // Invalidate the layout to pickup the new insets from the border. 154 // Invalidate the layout to pickup the new insets from the border.
155 InvalidateLayout(); 155 Layout();
156 ResetColorsFromNativeTheme(); 156 ResetColorsFromNativeTheme();
157 } 157 }
158 158
159 gfx::Size LabelButton::GetPreferredSize() { 159 gfx::Size LabelButton::GetPreferredSize() {
160 const gfx::Font font = label_->font(); 160 const gfx::Font font = label_->font();
161 // Use a temporary label copy for sizing to avoid calculation side-effects. 161 // Use a temporary label copy for sizing to avoid calculation side-effects.
162 // Use bold text for STYLE_BUTTON to avoid changing size when made default. 162 // Use bold text for STYLE_BUTTON to avoid changing size when made default.
163 Label label(label_->text(), style_ == STYLE_BUTTON ? 163 Label label(label_->text(), style_ == STYLE_BUTTON ?
164 font.DeriveFont(0, font.GetStyle() | gfx::Font::BOLD) : font); 164 font.DeriveFont(0, font.GetStyle() | gfx::Font::BOLD) : font);
165 label.SetMultiLine(GetTextMultiLine()); 165 label.SetMultiLine(GetTextMultiLine());
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return ui::NativeTheme::kNormal; 339 return ui::NativeTheme::kNormal;
340 } 340 }
341 341
342 ui::NativeTheme::State LabelButton::GetForegroundThemeState( 342 ui::NativeTheme::State LabelButton::GetForegroundThemeState(
343 ui::NativeTheme::ExtraParams* params) const { 343 ui::NativeTheme::ExtraParams* params) const {
344 GetExtraParams(params); 344 GetExtraParams(params);
345 return ui::NativeTheme::kHovered; 345 return ui::NativeTheme::kHovered;
346 } 346 }
347 347
348 } // namespace views 348 } // namespace views
OLDNEW
« no previous file with comments | « ui/message_center/views/message_popup_bubble.cc ('k') | ui/views/controls/menu/submenu_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698