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

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

Issue 298813002: views: Move MenuButton from TextButton to LabelButton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable DragDirectlyToSecondWindow. Created 6 years, 6 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 | « ui/views/controls/button/menu_button.h ('k') | ui/views/controls/button/radio_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/menu_button.cc
diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc
index dcfed7ee0f138d102be6150909cb8a4a4e01e193..29271cea51f3d5d9f9ac96ae61759a2452267a07 100644
--- a/ui/views/controls/button/menu_button.cc
+++ b/ui/views/controls/button/menu_button.cc
@@ -16,6 +16,7 @@
#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"
@@ -46,7 +47,7 @@ MenuButton::MenuButton(ButtonListener* listener,
const base::string16& text,
MenuButtonListener* menu_button_listener,
bool show_menu_marker)
- : TextButton(listener, text),
+ : LabelButton(listener, text),
menu_visible_(false),
menu_offset_(kDefaultMenuOffsetX, kDefaultMenuOffsetY),
listener_(menu_button_listener),
@@ -54,7 +55,7 @@ MenuButton::MenuButton(ButtonListener* listener,
menu_marker_(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_MENU_DROPARROW).ToImageSkia()),
destroyed_flag_(NULL) {
- set_alignment(TextButton::ALIGN_LEFT);
+ SetHorizontalAlignment(gfx::ALIGN_LEFT);
}
MenuButton::~MenuButton() {
@@ -133,8 +134,8 @@ bool MenuButton::Activate() {
return true;
}
-void MenuButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
- TextButton::PaintButton(canvas, mode);
+void MenuButton::OnPaint(gfx::Canvas* canvas) {
+ LabelButton::OnPaint(canvas);
if (show_menu_marker_)
PaintMenuMarker(canvas);
@@ -147,7 +148,7 @@ void MenuButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
////////////////////////////////////////////////////////////////////////////////
gfx::Size MenuButton::GetPreferredSize() const {
- gfx::Size prefsize = TextButton::GetPreferredSize();
+ gfx::Size prefsize = LabelButton::GetPreferredSize();
if (show_menu_marker_) {
prefsize.Enlarge(menu_marker_->width() + kMenuMarkerPaddingLeft +
kMenuMarkerPaddingRight,
@@ -186,7 +187,7 @@ void MenuButton::OnMouseReleased(const ui::MouseEvent& event) {
HitTestPoint(event.location())) {
Activate();
} else {
- TextButton::OnMouseReleased(event);
+ LabelButton::OnMouseReleased(event);
}
}
@@ -209,7 +210,7 @@ void MenuButton::OnGestureEvent(ui::GestureEvent* event) {
// the gesture event here.
return;
}
- TextButton::OnGestureEvent(event);
+ LabelButton::OnGestureEvent(event);
}
bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) {
@@ -265,6 +266,17 @@ 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();
« no previous file with comments | « ui/views/controls/button/menu_button.h ('k') | ui/views/controls/button/radio_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698