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

Unified Diff: mandoline/ui/desktop_ui/find_bar_view.cc

Issue 1371773003: mandoline: Add find in page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final documentation changes. Created 5 years, 2 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 | « mandoline/ui/desktop_ui/find_bar_view.h ('k') | mandoline/ui/phone_ui/phone_browser_application_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mandoline/ui/desktop_ui/find_bar_view.cc
diff --git a/mandoline/ui/desktop_ui/find_bar_view.cc b/mandoline/ui/desktop_ui/find_bar_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..112ace1e569d9bd24d472c101136ef8ce713a744
--- /dev/null
+++ b/mandoline/ui/desktop_ui/find_bar_view.cc
@@ -0,0 +1,68 @@
+// Copyright 2015 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 "mandoline/ui/desktop_ui/find_bar_view.h"
+
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "mandoline/ui/desktop_ui/find_bar_delegate.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace mandoline {
+
+FindBarView::FindBarView(FindBarDelegate* delegate)
+ : delegate_(delegate),
+ layout_(new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 5)),
+ text_field_(new views::Textfield),
+ match_count_label_(new views::Label),
+ close_button_(new views::LabelButton(this, base::ASCIIToUTF16("Close"))) {
+ SetLayoutManager(layout_);
+
+ text_field_->set_controller(this);
+
+ AddChildView(text_field_);
+ AddChildView(match_count_label_);
+ AddChildView(close_button_);
+
+ layout_->SetDefaultFlex(0);
+ layout_->SetFlexForView(text_field_, 1);
+
+ SetVisible(false);
+ SetMatchLabel(0, 0);
+}
+
+FindBarView::~FindBarView() {}
+
+void FindBarView::Show() {
+ SetVisible(true);
+ text_field_->RequestFocus();
+}
+
+void FindBarView::Hide() {
+ SetVisible(false);
+}
+
+void FindBarView::SetMatchLabel(int result, int total) {
+ std::string str = base::StringPrintf("%d of %d", result, total);
+ match_count_label_->SetVisible(true);
+ match_count_label_->SetText(base::UTF8ToUTF16(str));
+ Layout();
+}
+
+void FindBarView::ContentsChanged(views::Textfield* sender,
+ const base::string16& new_contents) {
+ std::string contents = base::UTF16ToUTF8(new_contents);
+ delegate_->OnDoFind(contents);
+}
+
+void FindBarView::ButtonPressed(views::Button* sender, const ui::Event& event) {
+ if (sender == close_button_)
+ delegate_->OnHideFindBar();
+ else
+ NOTREACHED();
+}
+
+} // namespace mandoline
« no previous file with comments | « mandoline/ui/desktop_ui/find_bar_view.h ('k') | mandoline/ui/phone_ui/phone_browser_application_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698