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

Unified Diff: ui/views/controls/button/text_button.cc

Issue 10933085: Update ConstrainedWindowViews appearance according to mock (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review updates Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/button/text_button.cc
diff --git a/ui/views/controls/button/text_button.cc b/ui/views/controls/button/text_button.cc
index 1a4c4e700cadce959305fb9e01ea9af2caf37e65..19a67bd517edcc5920421e92255becda1fb7c2cc 100644
--- a/ui/views/controls/button/text_button.cc
+++ b/ui/views/controls/button/text_button.cc
@@ -13,6 +13,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/button/button.h"
+#include "ui/views/focus_border.h"
#include "ui/views/widget/widget.h"
#if defined(OS_WIN)
@@ -267,6 +268,8 @@ TextButtonBase::TextButtonBase(ButtonListener* listener, const string16& text)
inactive_text_shadow_color_(0),
has_shadow_(false),
shadow_offset_(gfx::Point(1, 1)),
+ min_width_(0),
+ min_height_(0),
max_width_(0),
show_multiple_icon_states_(true),
is_default_(false),
@@ -371,6 +374,9 @@ gfx::Size TextButtonBase::GetPreferredSize() {
if (max_width_ > 0)
prefsize.set_width(std::min(max_width_, prefsize.width()));
+ prefsize.set_width(std::max(prefsize.height(), min_width_));
+ prefsize.set_height(std::max(prefsize.height(), min_height_));
+
return prefsize;
}
@@ -383,7 +389,9 @@ int TextButtonBase::GetHeightForWidth(int w) {
gfx::Size text_size;
CalculateTextSize(&text_size, w);
- return text_size.height() + GetInsets().height();
+ int height = text_size.height() + GetInsets().height();
+
+ return std::max(height, min_height_);
}
void TextButtonBase::OnPaint(gfx::Canvas* canvas) {
@@ -670,6 +678,10 @@ TextButton::TextButton(ButtonListener* listener, const string16& text)
icon_text_spacing_(kDefaultIconTextSpacing),
ignore_minimum_size_(true) {
set_border(new TextButtonBorder);
+ set_focus_border(FocusBorder::CreateDashedFocusBorder(kFocusRectInset,
+ kFocusRectInset,
+ kFocusRectInset,
+ kFocusRectInset));
}
TextButton::~TextButton() {
@@ -718,6 +730,9 @@ gfx::Size TextButton::GetPreferredSize() {
}
#endif
+ prefsize.set_width(std::max(prefsize.height(), min_width_));
+ prefsize.set_height(std::max(prefsize.height(), min_height_));
+
return prefsize;
}
@@ -755,14 +770,6 @@ std::string TextButton::GetClassName() const {
return kViewClassName;
}
-void TextButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
- if (HasFocus() && (focusable() || IsAccessibilityFocusable())) {
- gfx::Rect rect(GetLocalBounds());
- rect.Inset(kFocusRectInset, kFocusRectInset);
- canvas->DrawFocusRect(rect);
- }
-}
-
ui::NativeTheme::Part TextButton::GetThemePart() const {
return ui::NativeTheme::kPushButton;
}
@@ -829,6 +836,11 @@ void NativeTextButton::Init() {
color_hover_ = color_ = color_enabled_;
#endif
set_border(new TextButtonNativeThemeBorder(this));
+#if !defined(OS_WIN)
+ // Paint nothing, focus will be indicated with a border highlight drawn by
+ // NativeThemeBase::PaintButton.
+ set_focus_border(NULL);
+#endif
set_ignore_minimum_size(false);
set_alignment(ALIGN_CENTER);
set_focusable(true);
@@ -842,19 +854,6 @@ std::string NativeTextButton::GetClassName() const {
return kViewClassName;
}
-void NativeTextButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
-#if defined(OS_WIN)
- if (HasFocus() && (focusable() || IsAccessibilityFocusable())) {
- gfx::Rect rect(GetLocalBounds());
- rect.Inset(kFocusRectInset, kFocusRectInset);
- canvas->DrawFocusRect(rect);
- }
-#else
- // Paint nothing, focus will be indicated with a border highlight drawn by
- // NativeThemeBase::PaintButton.
-#endif
-}
-
void NativeTextButton::GetExtraParams(
ui::NativeTheme::ExtraParams* params) const {
TextButton::GetExtraParams(params);

Powered by Google App Engine
This is Rietveld 408576698