summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-18 07:39:47 +0000
committerjackhou@chromium.org <jackhou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-18 07:39:47 +0000
commitb64322872775e28dfe93acf0582d1c4ae986a354 (patch)
treec6611d908ec364f0aa6bbbdee1be7051a19b4db6 /ui
parentff7c73d89fed5d8f76ca4c8846fce18fab2bb197 (diff)
downloadchromium_src-b64322872775e28dfe93acf0582d1c4ae986a354.zip
chromium_src-b64322872775e28dfe93acf0582d1c4ae986a354.tar.gz
chromium_src-b64322872775e28dfe93acf0582d1c4ae986a354.tar.bz2
Revert of views: Move MenuButton from TextButton to LabelButton. (https://codereview.chromium.org/298813002/)
Reason for revert: This is causes ExtensionApiTest.Bookmarks to fail on Linux: http://build.chromium.org/p/chromium.linux/builders/Linux%20Tests%20%28dbg%29%281%29%2832%29/builds/5412 http://build.chromium.org/p/chromium.linux/builders/Linux%20Tests%20%28dbg%29%281%29/builds/32272 TBR=erg@chromium.org,msw@chromium.org,sky@chromium.org NOTRY=true NOTREECHECKS=true Original issue's description: > views: Move MenuButton from TextButton to LabelButton. > > This also converts the TextButtons in the BookmarkBarView to LabelButtons, since they need to have the same base class as MenuButton does. This also standardizes on fade eliding instead of fade eliding sometimes and ellipsis eliding in other cases. > > This patch has the effect that everything on the bookmark bar also renders with GTK+ borders in GTK theme mode on Linux. > > BUG=155363 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=277878 Review URL: https://codereview.chromium.org/340003002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/app_list/views/search_box_view.cc11
-rw-r--r--ui/message_center/views/notifier_settings_view.cc1
-rw-r--r--ui/views/button_drag_utils.cc24
-rw-r--r--ui/views/button_drag_utils.h13
-rw-r--r--ui/views/controls/button/custom_button.h4
-rw-r--r--ui/views/controls/button/label_button.cc12
-rw-r--r--ui/views/controls/button/label_button.h10
-rw-r--r--ui/views/controls/button/menu_button.cc26
-rw-r--r--ui/views/controls/button/menu_button.h11
-rw-r--r--ui/views/controls/button/radio_button.h2
-rw-r--r--ui/views/linux_ui/linux_ui.h3
11 files changed, 30 insertions, 87 deletions
diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc
index 2569942..a9b65a1 100644
--- a/ui/app_list/views/search_box_view.cc
+++ b/ui/app_list/views/search_box_view.cc
@@ -16,7 +16,6 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h"
-#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/image_view.h"
@@ -58,12 +57,10 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate,
#if !defined(OS_CHROMEOS)
menu_button_ = new views::MenuButton(NULL, base::string16(), this, false);
menu_button_->SetBorder(views::Border::NullBorder());
- menu_button_->SetImage(views::Button::STATE_NORMAL,
- *rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_NORMAL));
- menu_button_->SetImage(views::Button::STATE_HOVERED,
- *rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_HOVER));
- menu_button_->SetImage(views::Button::STATE_PRESSED,
- *rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_PRESSED));
+ menu_button_->SetIcon(*rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_NORMAL));
+ menu_button_->SetHoverIcon(*rb.GetImageSkiaNamed(IDR_APP_LIST_TOOLS_HOVER));
+ menu_button_->SetPushedIcon(*rb.GetImageSkiaNamed(
+ IDR_APP_LIST_TOOLS_PRESSED));
AddChildView(menu_button_);
#endif
diff --git a/ui/message_center/views/notifier_settings_view.cc b/ui/message_center/views/notifier_settings_view.cc
index a282ccb..5a46f48 100644
--- a/ui/message_center/views/notifier_settings_view.cc
+++ b/ui/message_center/views/notifier_settings_view.cc
@@ -28,7 +28,6 @@
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/controls/button/menu_button.h"
-#include "ui/views/controls/button/text_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
diff --git a/ui/views/button_drag_utils.cc b/ui/views/button_drag_utils.cc
index 2c4f25a..500c5e0 100644
--- a/ui/views/button_drag_utils.cc
+++ b/ui/views/button_drag_utils.cc
@@ -10,7 +10,6 @@
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
-#include "ui/gfx/geometry/point.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/button/text_button.h"
#include "ui/views/drag_utils.h"
@@ -19,25 +18,17 @@
namespace button_drag_utils {
// Maximum width of the link drag image in pixels.
-static const int kLinkDragImageMaxWidth = 150;
+static const int kLinkDragImageMaxWidth = 200;
void SetURLAndDragImage(const GURL& url,
const base::string16& title,
const gfx::ImageSkia& icon,
- const gfx::Point* press_pt,
ui::OSExchangeData* data,
views::Widget* widget) {
DCHECK(url.is_valid() && data);
+
data->SetURL(url, title);
- SetDragImage(url, title, icon, press_pt, data, widget);
-}
-void SetDragImage(const GURL& url,
- const base::string16& title,
- const gfx::ImageSkia& icon,
- const gfx::Point* press_pt,
- ui::OSExchangeData* data,
- views::Widget* widget) {
// Create a button to render the drag image for us.
views::TextButton button(NULL,
title.empty() ? base::UTF8ToUTF16(url.spec())
@@ -52,17 +43,14 @@ void SetDragImage(const GURL& url,
gfx::Size prefsize = button.GetPreferredSize();
button.SetBounds(0, 0, prefsize.width(), prefsize.height());
- gfx::Vector2d press_point;
- if (press_pt)
- press_point = press_pt->OffsetFromOrigin();
- else
- press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2);
-
// Render the image.
scoped_ptr<gfx::Canvas> canvas(
views::GetCanvasForDragImage(widget, prefsize));
button.PaintButton(canvas.get(), views::TextButton::PB_FOR_DRAG);
- drag_utils::SetDragImageOnDataObject(*canvas, press_point, data);
+ drag_utils::SetDragImageOnDataObject(
+ *canvas,
+ gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2),
+ data);
}
} // namespace button_drag_utils
diff --git a/ui/views/button_drag_utils.h b/ui/views/button_drag_utils.h
index 8f1a7ee..0570ff2 100644
--- a/ui/views/button_drag_utils.h
+++ b/ui/views/button_drag_utils.h
@@ -12,7 +12,6 @@ class GURL;
namespace gfx {
class ImageSkia;
-class Point;
}
namespace ui {
@@ -26,23 +25,13 @@ class Widget;
namespace button_drag_utils {
// Sets url and title on data as well as setting a suitable image for dragging.
-// The image looks like that of the bookmark buttons. |press_pt| is optional
-// offset; otherwise, it centers the drag image.
+// The image looks like that of the bookmark buttons.
VIEWS_EXPORT void SetURLAndDragImage(const GURL& url,
const base::string16& title,
const gfx::ImageSkia& icon,
- const gfx::Point* press_pt,
ui::OSExchangeData* data,
views::Widget* widget);
-// As above, but only sets the image.
-VIEWS_EXPORT void SetDragImage(const GURL& url,
- const base::string16& title,
- const gfx::ImageSkia& icon,
- const gfx::Point* press_pt,
- ui::OSExchangeData* data,
- views::Widget* widget);
-
} // namespace drag_utils
#endif // UI_VIEWS_BUTTON_DRAG_UTILS_H_
diff --git a/ui/views/controls/button/custom_button.h b/ui/views/controls/button/custom_button.h
index 4614a5c..930cc92 100644
--- a/ui/views/controls/button/custom_button.h
+++ b/ui/views/controls/button/custom_button.h
@@ -18,8 +18,8 @@ namespace views {
class CustomButtonStateChangedDelegate;
-// A button with custom rendering. The common base class of ImageButton,
-// LabelButton and TextButton.
+// A button with custom rendering. The common base class of ImageButton and
+// TextButton.
// Note that this type of button is not focusable by default and will not be
// part of the focus chain. Call SetFocusable(true) to make it part of the
// focus chain.
diff --git a/ui/views/controls/button/label_button.cc b/ui/views/controls/button/label_button.cc
index 860d1b1..d6647de 100644
--- a/ui/views/controls/button/label_button.cc
+++ b/ui/views/controls/button/label_button.cc
@@ -100,10 +100,6 @@ void LabelButton::SetTextColor(ButtonState for_state, SkColor color) {
explicitly_set_colors_[for_state] = true;
}
-void LabelButton::SetHaloColor(SkColor color) {
- label_->set_halo_color(color);
-}
-
bool LabelButton::GetTextMultiLine() const {
return label_->is_multi_line();
}
@@ -226,7 +222,7 @@ void LabelButton::Layout() {
adjusted_alignment = (adjusted_alignment == gfx::ALIGN_LEFT) ?
gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT;
- gfx::Rect child_area(GetChildAreaBounds());
+ gfx::Rect child_area(GetLocalBounds());
child_area.Inset(GetInsets());
gfx::Size image_size(image_->GetPreferredSize());
@@ -279,10 +275,6 @@ void LabelButton::SetBorder(scoped_ptr<Border> border) {
View::SetBorder(border.Pass());
}
-gfx::Rect LabelButton::GetChildAreaBounds() {
- return GetLocalBounds();
-}
-
void LabelButton::OnPaint(gfx::Canvas* canvas) {
View::OnPaint(canvas);
Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
@@ -374,7 +366,7 @@ void LabelButton::UpdateThemedBorder() {
views::LinuxUI* linux_ui = views::LinuxUI::instance();
if (linux_ui) {
SetBorder(linux_ui->CreateNativeBorder(
- this, label_button_border.Pass()));
+ this, label_button_border.PassAs<Border>()));
} else
#endif
{
diff --git a/ui/views/controls/button/label_button.h b/ui/views/controls/button/label_button.h
index 425f5c0..8e13ffc 100644
--- a/ui/views/controls/button/label_button.h
+++ b/ui/views/controls/button/label_button.h
@@ -38,14 +38,11 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
// Get or set the text shown on the button.
const base::string16& GetText() const;
- virtual void SetText(const base::string16& text);
+ void SetText(const base::string16& text);
// Set the text color shown for the specified button state.
void SetTextColor(ButtonState for_state, SkColor color);
- // Sets a halo color on the label.
- void SetHaloColor(SkColor color);
-
// Get or set the text's multi-line property to break on '\n', etc.
bool GetTextMultiLine() const;
void SetTextMultiLine(bool text_multi_line);
@@ -75,7 +72,6 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
void SetStyle(ButtonStyle style);
void SetFocusPainter(scoped_ptr<Painter> focus_painter);
- Painter* focus_painter() { return focus_painter_.get(); }
// View:
virtual void SetBorder(scoped_ptr<Border> border) OVERRIDE;
@@ -87,10 +83,6 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
ImageView* image() const { return image_; }
Label* label() const { return label_; }
- // Returns the available area for the label and image. Subclasses can change
- // these bounds if they need room to do manual painting.
- virtual gfx::Rect GetChildAreaBounds();
-
// View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnFocus() OVERRIDE;
diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc
index 29271ce..dcfed7e 100644
--- a/ui/views/controls/button/menu_button.cc
+++ b/ui/views/controls/button/menu_button.cc
@@ -16,7 +16,6 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/screen.h"
-#include "ui/gfx/text_constants.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/mouse_constants.h"
@@ -47,7 +46,7 @@ MenuButton::MenuButton(ButtonListener* listener,
const base::string16& text,
MenuButtonListener* menu_button_listener,
bool show_menu_marker)
- : LabelButton(listener, text),
+ : TextButton(listener, text),
menu_visible_(false),
menu_offset_(kDefaultMenuOffsetX, kDefaultMenuOffsetY),
listener_(menu_button_listener),
@@ -55,7 +54,7 @@ MenuButton::MenuButton(ButtonListener* listener,
menu_marker_(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_MENU_DROPARROW).ToImageSkia()),
destroyed_flag_(NULL) {
- SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ set_alignment(TextButton::ALIGN_LEFT);
}
MenuButton::~MenuButton() {
@@ -134,8 +133,8 @@ bool MenuButton::Activate() {
return true;
}
-void MenuButton::OnPaint(gfx::Canvas* canvas) {
- LabelButton::OnPaint(canvas);
+void MenuButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
+ TextButton::PaintButton(canvas, mode);
if (show_menu_marker_)
PaintMenuMarker(canvas);
@@ -148,7 +147,7 @@ void MenuButton::OnPaint(gfx::Canvas* canvas) {
////////////////////////////////////////////////////////////////////////////////
gfx::Size MenuButton::GetPreferredSize() const {
- gfx::Size prefsize = LabelButton::GetPreferredSize();
+ gfx::Size prefsize = TextButton::GetPreferredSize();
if (show_menu_marker_) {
prefsize.Enlarge(menu_marker_->width() + kMenuMarkerPaddingLeft +
kMenuMarkerPaddingRight,
@@ -187,7 +186,7 @@ void MenuButton::OnMouseReleased(const ui::MouseEvent& event) {
HitTestPoint(event.location())) {
Activate();
} else {
- LabelButton::OnMouseReleased(event);
+ TextButton::OnMouseReleased(event);
}
}
@@ -210,7 +209,7 @@ void MenuButton::OnGestureEvent(ui::GestureEvent* event) {
// the gesture event here.
return;
}
- LabelButton::OnGestureEvent(event);
+ TextButton::OnGestureEvent(event);
}
bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) {
@@ -266,17 +265,6 @@ void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) {
canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y());
}
-gfx::Rect MenuButton::GetChildAreaBounds() {
- gfx::Size s = size();
-
- if (show_menu_marker_) {
- s.set_width(s.width() - menu_marker_->width() - kMenuMarkerPaddingLeft -
- kMenuMarkerPaddingRight);
- }
-
- return gfx::Rect(s);
-}
-
int MenuButton::GetMaximumScreenXCoordinate() {
if (!GetWidget()) {
NOTREACHED();
diff --git a/ui/views/controls/button/menu_button.h b/ui/views/controls/button/menu_button.h
index 257d2f6..1ca6de0 100644
--- a/ui/views/controls/button/menu_button.h
+++ b/ui/views/controls/button/menu_button.h
@@ -10,7 +10,7 @@
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "ui/views/background.h"
-#include "ui/views/controls/button/label_button.h"
+#include "ui/views/controls/button/text_button.h"
namespace views {
@@ -23,7 +23,7 @@ class MenuButtonListener;
// A button that shows a menu when the left mouse button is pushed
//
////////////////////////////////////////////////////////////////////////////////
-class VIEWS_EXPORT MenuButton : public LabelButton {
+class VIEWS_EXPORT MenuButton : public TextButton {
public:
static const char kViewClassName[];
@@ -50,10 +50,12 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
// Activate the button (called when the button is pressed).
virtual bool Activate();
+ // Overridden from TextButton for the potential use of a drop marker.
+ virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE;
+
// Overridden from View:
virtual gfx::Size GetPreferredSize() const OVERRIDE;
virtual const char* GetClassName() const OVERRIDE;
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
@@ -66,9 +68,6 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
// Paint the menu marker image.
void PaintMenuMarker(gfx::Canvas* canvas);
- // Overridden from LabelButton:
- virtual gfx::Rect GetChildAreaBounds() OVERRIDE;
-
// True if the menu is currently visible.
bool menu_visible_;
diff --git a/ui/views/controls/button/radio_button.h b/ui/views/controls/button/radio_button.h
index edbb2c6..abffd60 100644
--- a/ui/views/controls/button/radio_button.h
+++ b/ui/views/controls/button/radio_button.h
@@ -30,7 +30,7 @@ class VIEWS_EXPORT RadioButton : public Checkbox {
// Overridden from Button:
virtual void NotifyClick(const ui::Event& event) OVERRIDE;
- // Overridden from LabelButton:
+ // Overridden from TextButtonBase:
virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE;
// Overridden from Checkbox:
diff --git a/ui/views/linux_ui/linux_ui.h b/ui/views/linux_ui/linux_ui.h
index b5466f5..504de81 100644
--- a/ui/views/linux_ui/linux_ui.h
+++ b/ui/views/linux_ui/linux_ui.h
@@ -35,7 +35,6 @@ class NativeTheme;
namespace views {
class Border;
class LabelButton;
-class LabelButtonBorder;
class View;
class WindowButtonOrderObserver;
@@ -126,7 +125,7 @@ class VIEWS_EXPORT LinuxUI : public ui::LinuxInputMethodContextFactory,
// Builds a Border which paints the native button style.
virtual scoped_ptr<Border> CreateNativeBorder(
views::LabelButton* owning_button,
- scoped_ptr<views::LabelButtonBorder> border) = 0;
+ scoped_ptr<views::Border> border) = 0;
// Notifies the observer about changes about how window buttons should be
// laid out. If the order is anything other than the default min,max,close on