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

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

Issue 59383003: Add the button style for combobox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 years, 1 month 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
Index: ui/views/controls/button/multi_target_button.cc
diff --git a/ui/views/controls/button/multi_target_button.cc b/ui/views/controls/button/multi_target_button.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c041f218430ec55be9c5ca5179f257e7dd00e704
--- /dev/null
+++ b/ui/views/controls/button/multi_target_button.cc
@@ -0,0 +1,52 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/controls/button/multi_target_button.h"
+
+#include "grit/ui_resources.h"
+#include "ui/base/models/menu_model.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/controls/button/label_button.h"
+#include "ui/views/controls/button/label_button_border.h"
+#include "ui/views/controls/button/menu_button.h"
+#include "ui/views/controls/menu/menu_runner.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace views {
+
+MultiTargetButton::MultiTargetButton(ui::MenuModel* menu_model)
+ : menu_model_(menu_model) {
+ SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, -4));
hajimehoshi 2013/11/05 10:10:26 -4 is to remove the space between two buttons. Wou
+
+ button_ = new views::LabelButton(this, menu_model->GetLabelAt(0));
sky 2013/11/05 16:29:37 Using two buttons side by side is problematic beca
+ button_->SetStyle(Button::STYLE_NATIVE_TEXTBUTTON);
+ AddChildView(button_);
+
+ drop_arrow_button_ = new MenuButton(NULL, string16(), this, true);
+ drop_arrow_button_->set_focusable(true);
+ drop_arrow_button_->set_border(
+ new views::LabelButtonBorder(Button::STYLE_BUTTON));
+ AddChildView(drop_arrow_button_);
+}
+
+MultiTargetButton::~MultiTargetButton() {
+}
+
+void MultiTargetButton::ButtonPressed(Button* sender, const ui::Event& event) {
+ menu_model_->ActivatedAt(0);
+}
+
+void MultiTargetButton::OnMenuButtonClicked(
+ View* source, const gfx::Point& point) {
+ DCHECK_EQ(drop_arrow_button_, source);
+ menu_runner_.reset(new MenuRunner(menu_model_));
+ ignore_result(menu_runner_->RunMenuAt(source->GetWidget(), drop_arrow_button_,
+ gfx::Rect(point, gfx::Size()),
+ MenuItemView::TOPRIGHT,
+ ui::MenuSourceType::MENU_SOURCE_MOUSE,
+ MenuRunner::HAS_MNEMONICS));
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698