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

Unified Diff: ui/views/bubble/bubble_frame_view.cc

Issue 2667903002: The close button for bubbles should be an ImageButton, not a LabelButton. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/bubble/bubble_frame_view.cc
diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc
index c22d511771c21b1b10e67ae4e89b91b281ee2adc..d27aa9d253f7b0d796eaeb133668c989600bfb06 100644
--- a/ui/views/bubble/bubble_frame_view.cc
+++ b/ui/views/bubble/bubble_frame_view.cc
@@ -25,9 +25,9 @@
#include "ui/resources/grit/ui_resources.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/bubble/bubble_border.h"
-#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/vector_icon_button.h"
#include "ui/views/controls/image_view.h"
+#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/resources/grit/views_resources.h"
@@ -46,7 +46,7 @@ const SkColor kFootnoteBackgroundColor = SkColorSetRGB(245, 245, 245);
const SkColor kFootnoteBorderColor = SkColorSetRGB(229, 229, 229);
constexpr int kClosePaddingRight = 7;
-constexpr int kClosePaddingTop = 6;
+constexpr int kClosePaddingTop = 7;
// The MD spec states that the center of the "x" should be 16x16 from the top
// right of the dialog.
@@ -116,26 +116,25 @@ BubbleFrameView::~BubbleFrameView() {}
// static
Button* BubbleFrameView::CreateCloseButton(VectorIconButtonDelegate* delegate) {
- Button* close_button = nullptr;
+ ImageButton* close_button = nullptr;
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
VectorIconButton* close = new VectorIconButton(delegate);
close->SetIcon(gfx::VectorIconId::BAR_CLOSE);
- close->SetSize(close->GetPreferredSize());
close_button = close;
} else {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- LabelButton* close = new LabelButton(delegate, base::string16());
- close->SetImage(CustomButton::STATE_NORMAL,
- *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia());
- close->SetImage(CustomButton::STATE_HOVERED,
- *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia());
- close->SetImage(CustomButton::STATE_PRESSED,
- *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia());
- close->SetBorder(nullptr);
- close->SetSize(close->GetPreferredSize());
- close_button = close;
+ ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
+ close_button = new ImageButton(delegate);
+ close_button->SetImage(CustomButton::STATE_NORMAL,
+ *rb->GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia());
+ close_button->SetImage(
+ CustomButton::STATE_HOVERED,
+ *rb->GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia());
+ close_button->SetImage(
+ CustomButton::STATE_PRESSED,
+ *rb->GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia());
}
close_button->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
+ close_button->SizeToPreferredSize();
return close_button;
}
@@ -315,13 +314,14 @@ void BubbleFrameView::Layout() {
// there's no title.
DCHECK(!title_margins_.IsEmpty() || !title_->visible());
- gfx::Rect bounds(GetContentsBounds());
+ const gfx::Rect contents_bounds = GetContentsBounds();
+ gfx::Rect bounds = contents_bounds;
bounds.Inset(title_margins_);
if (bounds.IsEmpty())
return;
// The close button is positioned somewhat closer to the edge of the bubble.
- gfx::Point close_position = GetContentsBounds().top_right();
+ gfx::Point close_position = contents_bounds.top_right();
if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
msw 2017/01/31 17:53:16 q: did you remember to test MD and non-MD?
Peter Kasting 2017/01/31 21:31:01 The Harmony close button is a VectorIconButton ins
close_position += gfx::Vector2d(-close_->width() - kClosePaddingRightMd,
kClosePaddingTopMd);
@@ -353,11 +353,10 @@ void BubbleFrameView::Layout() {
bounds.set_height(title_height);
if (footnote_container_) {
- gfx::Rect local_bounds = GetContentsBounds();
- int height = footnote_container_->GetHeightForWidth(local_bounds.width());
- footnote_container_->SetBounds(local_bounds.x(),
- local_bounds.bottom() - height,
- local_bounds.width(), height);
+ const int width = contents_bounds.width();
+ const int height = footnote_container_->GetHeightForWidth(width);
+ footnote_container_->SetBounds(
+ contents_bounds.x(), contents_bounds.bottom() - height, width, height);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698