2016-01-19 21:09:01 +01:00
|
|
|
diff --git controls/button/menu_button.cc controls/button/menu_button.cc
|
2017-01-23 18:36:54 +01:00
|
|
|
index c4e986b..02fb9f3 100644
|
2016-01-19 21:09:01 +01:00
|
|
|
--- controls/button/menu_button.cc
|
|
|
|
+++ controls/button/menu_button.cc
|
2017-01-23 18:36:54 +01:00
|
|
|
@@ -193,7 +193,7 @@ void MenuButton::OnPaint(gfx::Canvas* canvas) {
|
2016-01-19 21:09:01 +01:00
|
|
|
gfx::Size MenuButton::GetPreferredSize() const {
|
|
|
|
gfx::Size prefsize = LabelButton::GetPreferredSize();
|
|
|
|
if (show_menu_marker_) {
|
|
|
|
- prefsize.Enlarge(menu_marker_->width() + kMenuMarkerPaddingLeft +
|
|
|
|
+ prefsize.Enlarge(menu_marker_->width() + GetMarkerPaddingLeft() +
|
|
|
|
kMenuMarkerPaddingRight,
|
|
|
|
0);
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
@@ -323,7 +323,7 @@ gfx::Rect MenuButton::GetChildAreaBounds() {
|
2016-01-19 21:09:01 +01:00
|
|
|
gfx::Size s = size();
|
|
|
|
|
|
|
|
if (show_menu_marker_) {
|
|
|
|
- s.set_width(s.width() - menu_marker_->width() - kMenuMarkerPaddingLeft -
|
|
|
|
+ s.set_width(s.width() - menu_marker_->width() - GetMarkerPaddingLeft() -
|
|
|
|
kMenuMarkerPaddingRight);
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
@@ -412,4 +412,10 @@ int MenuButton::GetMaximumScreenXCoordinate() {
|
2016-01-19 21:09:01 +01:00
|
|
|
return monitor_bounds.right() - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
+int MenuButton::GetMarkerPaddingLeft() const {
|
|
|
|
+ if (!image()->GetImage().isNull() || !label()->text().empty())
|
|
|
|
+ return kMenuMarkerPaddingLeft;
|
|
|
|
+ return kMenuMarkerPaddingRight;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
} // namespace views
|
|
|
|
diff --git controls/button/menu_button.h controls/button/menu_button.h
|
2016-11-23 21:54:29 +01:00
|
|
|
index c232cc1..cc207f9 100644
|
2016-01-19 21:09:01 +01:00
|
|
|
--- controls/button/menu_button.h
|
|
|
|
+++ controls/button/menu_button.h
|
|
|
|
@@ -54,6 +54,9 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
|
|
|
|
~MenuButton() override;
|
|
|
|
|
|
|
|
bool show_menu_marker() const { return show_menu_marker_; }
|
|
|
|
+ void set_show_menu_marker(bool show_menu_marker) {
|
|
|
|
+ show_menu_marker_ = show_menu_marker;
|
|
|
|
+ }
|
|
|
|
void set_menu_marker(const gfx::ImageSkia* menu_marker) {
|
|
|
|
menu_marker_ = menu_marker;
|
|
|
|
}
|
|
|
|
@@ -116,6 +119,9 @@ class VIEWS_EXPORT MenuButton : public LabelButton {
|
|
|
|
// use this to make sure a menu is never shown off screen.
|
|
|
|
int GetMaximumScreenXCoordinate();
|
|
|
|
|
|
|
|
+ // Only apply left padding if there's an image or label.
|
|
|
|
+ int GetMarkerPaddingLeft() const;
|
|
|
|
+
|
|
|
|
// We use a time object in order to keep track of when the menu was closed.
|
|
|
|
// The time is used for simulating menu behavior for the menu button; that
|
|
|
|
// is, if the menu is shown and the button is pressed, we need to close the
|
|
|
|
diff --git view.h view.h
|
2017-01-23 18:36:54 +01:00
|
|
|
index 147785c..5d413a1 100644
|
2016-01-19 21:09:01 +01:00
|
|
|
--- view.h
|
|
|
|
+++ view.h
|
|
|
|
@@ -18,6 +18,7 @@
|
2016-05-25 01:35:43 +02:00
|
|
|
#include "base/i18n/rtl.h"
|
2016-01-19 21:09:01 +01:00
|
|
|
#include "base/logging.h"
|
|
|
|
#include "base/macros.h"
|
|
|
|
+#include "base/supports_user_data.h"
|
|
|
|
#include "build/build_config.h"
|
|
|
|
#include "ui/accessibility/ax_enums.h"
|
|
|
|
#include "ui/base/accelerators/accelerator.h"
|
2017-01-23 18:36:54 +01:00
|
|
|
@@ -114,7 +115,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
|
2016-01-19 21:09:01 +01:00
|
|
|
public ui::LayerOwner,
|
|
|
|
public ui::AcceleratorTarget,
|
|
|
|
public ui::EventTarget,
|
|
|
|
- public ui::EventHandler {
|
|
|
|
+ public ui::EventHandler,
|
|
|
|
+ public base::SupportsUserData {
|
|
|
|
public:
|
|
|
|
typedef std::vector<View*> Views;
|
|
|
|
|