Commit a117eabd authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

Remove views::Combobox::STYLE_ACTION

It is unused, and was never updated to Harmony/MD style.

Bug: 822074
Change-Id: Ic12e4dc5ffa9f271e940090f6954a4a16f7dde84
Reviewed-on: https://chromium-review.googlesource.com/c/1298095
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603009}
parent 952ff9f9
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ui/base/ime/text_input_type.h" #include "ui/base/ime/text_input_type.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/combobox_model.h"
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
#include "ui/native_theme/native_theme.h" #include "ui/native_theme/native_theme.h"
#include "ui/views/border.h" #include "ui/views/border.h"
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/textfield_layout.h" #include "chrome/browser/ui/views/textfield_layout.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "ui/base/models/combobox_model.h"
#include "ui/views/controls/combobox/combobox.h" #include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h" #include "ui/views/controls/textfield/textfield.h"
......
...@@ -32,9 +32,12 @@ ...@@ -32,9 +32,12 @@
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
namespace views { namespace views {
namespace {
// The length of the hover fade animation.
constexpr int kHoverAnimationDurationMs = 170;
} // namespace
// static // static
const int LabelButton::kHoverAnimationDurationMs = 170;
const char LabelButton::kViewClassName[] = "LabelButton"; const char LabelButton::kViewClassName[] = "LabelButton";
LabelButton::LabelButton(ButtonListener* listener, LabelButton::LabelButton(ButtonListener* listener,
......
...@@ -28,9 +28,6 @@ class LabelButtonLabel; ...@@ -28,9 +28,6 @@ class LabelButtonLabel;
// LabelButton is a button with text and an icon, it's not focusable by default. // LabelButton is a button with text and an icon, it's not focusable by default.
class VIEWS_EXPORT LabelButton : public Button, public NativeThemeDelegate { class VIEWS_EXPORT LabelButton : public Button, public NativeThemeDelegate {
public: public:
// The length of the hover fade animation.
static const int kHoverAnimationDurationMs;
static const char kViewClassName[]; static const char kViewClassName[];
// Creates a LabelButton with ButtonPressed() events sent to |listener| and // Creates a LabelButton with ButtonPressed() events sent to |listener| and
......
This diff is collapsed.
...@@ -6,12 +6,9 @@ ...@@ -6,12 +6,9 @@
#define UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_ #define UI_VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/base/models/combobox_model.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/controls/prefix_delegate.h" #include "ui/views/controls/prefix_delegate.h"
namespace gfx { namespace gfx {
...@@ -19,6 +16,7 @@ class FontList; ...@@ -19,6 +16,7 @@ class FontList;
} }
namespace ui { namespace ui {
class ComboboxModel;
class MenuModel; class MenuModel;
} }
...@@ -28,40 +26,23 @@ class ComboboxTestApi; ...@@ -28,40 +26,23 @@ class ComboboxTestApi;
} }
class ComboboxListener; class ComboboxListener;
class Button; class FocusRing;
class MenuRunner; class MenuRunner;
class Painter;
class PrefixSelector; class PrefixSelector;
// A non-editable combobox (aka a drop-down list or selector). // A non-editable combobox (aka a drop-down list or selector).
// Combobox has two distinct parts, the drop down arrow and the text. Combobox // Combobox has two distinct parts, the drop down arrow and the text.
// offers two distinct behaviors:
// * STYLE_NORMAL: typical combobox, clicking on the text and/or button shows
// the drop down, arrow keys change selection or show the menu depending on
// the platform, selected index can be changed by the user to something other
// than the first item.
// * STYLE_ACTION: clicking on the text notifies the listener. The menu can be
// shown only by clicking on the arrow, except on Mac where it can be shown
// through the keyboard. The selected index is always reverted to 0 after the
// listener is notified.
class VIEWS_EXPORT Combobox : public View, class VIEWS_EXPORT Combobox : public View,
public PrefixDelegate, public PrefixDelegate,
public ButtonListener { public ButtonListener {
public: public:
// The style of the combobox.
enum Style {
STYLE_NORMAL,
STYLE_ACTION,
};
// The combobox's class name. // The combobox's class name.
static const char kViewClassName[]; static const char kViewClassName[];
// |model| is owned by the combobox when using this constructor. // |model| is owned by the combobox when using this constructor.
explicit Combobox(std::unique_ptr<ui::ComboboxModel> model, explicit Combobox(std::unique_ptr<ui::ComboboxModel> model);
Style style = STYLE_NORMAL);
// |model| is not owned by the combobox when using this constructor. // |model| is not owned by the combobox when using this constructor.
explicit Combobox(ui::ComboboxModel* model, Style style = STYLE_NORMAL); explicit Combobox(ui::ComboboxModel* model);
~Combobox() override; ~Combobox() override;
static const gfx::FontList& GetFontList(); static const gfx::FontList& GetFontList();
...@@ -99,7 +80,6 @@ class VIEWS_EXPORT Combobox : public View, ...@@ -99,7 +80,6 @@ class VIEWS_EXPORT Combobox : public View,
const char* GetClassName() const override; const char* GetClassName() const override;
bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) override; bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) override;
bool OnKeyPressed(const ui::KeyEvent& e) override; bool OnKeyPressed(const ui::KeyEvent& e) override;
bool OnKeyReleased(const ui::KeyEvent& e) override;
void OnPaint(gfx::Canvas* canvas) override; void OnPaint(gfx::Canvas* canvas) override;
void OnFocus() override; void OnFocus() override;
void OnBlur() override; void OnBlur() override;
...@@ -136,9 +116,6 @@ class VIEWS_EXPORT Combobox : public View, ...@@ -136,9 +116,6 @@ class VIEWS_EXPORT Combobox : public View,
// Draws the selected value of the drop down list // Draws the selected value of the drop down list
void PaintText(gfx::Canvas* canvas); void PaintText(gfx::Canvas* canvas);
// Draws the button images.
void PaintButtons(gfx::Canvas* canvas);
// Show the drop down list // Show the drop down list
void ShowDropDownMenu(ui::MenuSourceType source_type); void ShowDropDownMenu(ui::MenuSourceType source_type);
...@@ -148,14 +125,10 @@ class VIEWS_EXPORT Combobox : public View, ...@@ -148,14 +125,10 @@ class VIEWS_EXPORT Combobox : public View,
// Called when the selection is changed by the user. // Called when the selection is changed by the user.
void OnPerformAction(); void OnPerformAction();
int GetDisclosureArrowLeftPadding() const;
int GetDisclosureArrowRightPadding() const;
// Returns the size of the disclosure arrow. // Returns the size of the disclosure arrow.
gfx::Size ArrowSize() const; gfx::Size ArrowSize() const;
// Finds the size of the largest menu label or, for STYLE_ACTION, the size of // Finds the size of the largest menu label.
// the selected label.
gfx::Size GetContentSize() const; gfx::Size GetContentSize() const;
// Handles the clicking event. // Handles the clicking event.
...@@ -176,9 +149,6 @@ class VIEWS_EXPORT Combobox : public View, ...@@ -176,9 +149,6 @@ class VIEWS_EXPORT Combobox : public View,
// Reference to our model, which may be owned or not. // Reference to our model, which may be owned or not.
ui::ComboboxModel* model_; ui::ComboboxModel* model_;
// The visual style of this combobox.
const Style style_;
// Our listener. Not owned. Notified when the selected index change. // Our listener. Not owned. Notified when the selected index change.
ComboboxListener* listener_; ComboboxListener* listener_;
...@@ -208,29 +178,15 @@ class VIEWS_EXPORT Combobox : public View, ...@@ -208,29 +178,15 @@ class VIEWS_EXPORT Combobox : public View,
// The maximum dimensions of the content in the dropdown. // The maximum dimensions of the content in the dropdown.
gfx::Size content_size_; gfx::Size content_size_;
// The painters or images that are used when |style_| is STYLE_BUTTONS. The // A transparent button that handles events and holds button state. Placed on
// first index means the state of unfocused or focused. // top of the combobox as a child view. Doesn't paint itself, but serves as a
// The images are owned by ResourceBundle. // host for inkdrops.
std::unique_ptr<Painter> body_button_painters_[2][Button::STATE_COUNT];
std::vector<const gfx::ImageSkia*>
menu_button_images_[2][Button::STATE_COUNT];
// The transparent buttons to handle events and render buttons. These are
// placed on top of this combobox as child views, accept event and manage the
// button states. These are not rendered but when |style_| is
// STYLE_NOTIFY_ON_CLICK, a Combobox renders the button images according to
// these button states.
// The base View takes the ownerships of these as child views.
Button* text_button_;
Button* arrow_button_; Button* arrow_button_;
// Set while the dropdown is showing. Ensures the menu is closed if |this| is // Set while the dropdown is showing. Ensures the menu is closed if |this| is
// destroyed. // destroyed.
std::unique_ptr<MenuRunner> menu_runner_; std::unique_ptr<MenuRunner> menu_runner_;
// The image to be drawn for this combobox's arrow.
gfx::ImageSkia arrow_image_;
// When true, the size of contents is defined by the selected label. // When true, the size of contents is defined by the selected label.
// Otherwise, it's defined by the widest label in the menu. If this is set to // Otherwise, it's defined by the widest label in the menu. If this is set to
// true, the parent view must relayout in ChildPreferredSizeChanged(). // true, the parent view must relayout in ChildPreferredSizeChanged().
...@@ -239,9 +195,6 @@ class VIEWS_EXPORT Combobox : public View, ...@@ -239,9 +195,6 @@ class VIEWS_EXPORT Combobox : public View,
// The focus ring for this Combobox. // The focus ring for this Combobox.
std::unique_ptr<FocusRing> focus_ring_; std::unique_ptr<FocusRing> focus_ring_;
// Used for making calbacks.
base::WeakPtrFactory<Combobox> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(Combobox); DISALLOW_COPY_AND_ASSIGN(Combobox);
}; };
......
...@@ -16,12 +16,11 @@ class Combobox; ...@@ -16,12 +16,11 @@ class Combobox;
class VIEWS_EXPORT ComboboxListener { class VIEWS_EXPORT ComboboxListener {
public: public:
// Invoked when the user does the appropriate gesture that some action should // Invoked when the user does the appropriate gesture that some action should
// be performed. For both STYLE_NORMAL and STYLE_ACTION this is invoked if the // be performed. This is invoked if the user clicks on the menu button and
// user clicks on the menu button and then clicks an item. For STYLE_NORMAL // then clicks an item, and also when the menu is not showing and the does a
// this is also invoked when the menu is not showing and the does a gesture to // gesture to change the selection (for example, presses the home or end
// change the selection (for example, presses the home or end keys). This is // keys). This is not invoked when the menu is shown and the user changes the
// not invoked when the menu is shown and the user changes the selection // selection without closing the menu.
// without closing the menu.
virtual void OnPerformAction(Combobox* combobox) = 0; virtual void OnPerformAction(Combobox* combobox) = 0;
protected: protected:
......
...@@ -50,32 +50,17 @@ void ComboboxExample::CreateExampleView(View* container) { ...@@ -50,32 +50,17 @@ void ComboboxExample::CreateExampleView(View* container) {
disabled_combobox_->SetSelectedIndex(4); disabled_combobox_->SetSelectedIndex(4);
disabled_combobox_->SetEnabled(false); disabled_combobox_->SetEnabled(false);
action_combobox_ = new Combobox(std::make_unique<ComboboxModelExample>(),
Combobox::STYLE_ACTION);
action_combobox_->set_listener(this);
// Note: STYLE_ACTION comboboxes always have the first item selected by
// default.
container->SetLayoutManager( container->SetLayoutManager(
std::make_unique<BoxLayout>(BoxLayout::kVertical, gfx::Insets(10, 0), 5)); std::make_unique<BoxLayout>(BoxLayout::kVertical, gfx::Insets(10, 0), 5));
container->AddChildView(combobox_); container->AddChildView(combobox_);
container->AddChildView(disabled_combobox_); container->AddChildView(disabled_combobox_);
container->AddChildView(action_combobox_);
} }
void ComboboxExample::OnPerformAction(Combobox* combobox) { void ComboboxExample::OnPerformAction(Combobox* combobox) {
if (combobox == combobox_) { DCHECK_EQ(combobox, combobox_);
PrintStatus("Selected: %s", PrintStatus("Selected: %s", base::UTF16ToUTF8(combobox->model()->GetItemAt(
base::UTF16ToUTF8(
combobox->model()->GetItemAt(combobox->selected_index()))
.c_str());
} else if (combobox == action_combobox_) {
PrintStatus("Action: %s", base::UTF16ToUTF8(combobox->model()->GetItemAt(
combobox->selected_index())) combobox->selected_index()))
.c_str()); .c_str());
} else {
NOTREACHED() << "Surprising combobox.";
}
} }
} // namespace examples } // namespace examples
......
...@@ -28,7 +28,6 @@ class VIEWS_EXAMPLES_EXPORT ComboboxExample : public ExampleBase, ...@@ -28,7 +28,6 @@ class VIEWS_EXAMPLES_EXPORT ComboboxExample : public ExampleBase,
Combobox* combobox_ = nullptr; Combobox* combobox_ = nullptr;
Combobox* disabled_combobox_ = nullptr; Combobox* disabled_combobox_ = nullptr;
Combobox* action_combobox_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ComboboxExample); DISALLOW_COPY_AND_ASSIGN(ComboboxExample);
}; };
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment