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

Unified Diff: chrome/browser/ui/views/location_bar/touchable_location_bar_view.h

Issue 10519008: Enlarge size of touch target for several location bar buttons without affecting visual layout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary .cc file Created 8 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 | « chrome/browser/ui/views/location_bar/star_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/location_bar/touchable_location_bar_view.h
diff --git a/chrome/browser/ui/views/location_bar/touchable_location_bar_view.h b/chrome/browser/ui/views/location_bar/touchable_location_bar_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..207155d41d010a7a32f568f7b76a61e8387d8d34
--- /dev/null
+++ b/chrome/browser/ui/views/location_bar/touchable_location_bar_view.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2012 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.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_TOUCHABLE_LOCATION_BAR_VIEW_H_
+#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_TOUCHABLE_LOCATION_BAR_VIEW_H_
+#pragma once
+
+#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
+#include "ui/base/layout.h"
+#include "ui/views/border.h"
+
+// A mix-in for a class based on views::View and intended for the
+// location bar. In a touch layout, the mix-in adds an empty border
+// around the view to increase the size of the touch target. The
+// border extends a few pixels up and down, which doesn't affect
+// layout, and extends half of the padding used between items in the
+// location bar to the left and right.
+//
+// To make your location bar View named FooBlat extend itself into the
+// padding around it to get an enlarged touch target, inherit from
+// TouchableLocationBarView<FooBlat> and call
+// TouchableLocationBarView<FooBlat>::Init() from your constructor.
+template<class Concrete>
+class TouchableLocationBarView {
+ public:
+ // Call this from the constructor (or during early initialization)
+ // of a class that inherits from TouchableLocationBarView<>.
+ void Init();
+
+ // Returns the number of pixels of built-in padding to the left and
+ // right of the image for this view.
+ int GetBuiltInHorizontalPadding() const;
+};
+
+template<class Concrete>
+int TouchableLocationBarView<Concrete>::GetBuiltInHorizontalPadding() const {
+ return ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?
+ LocationBarView::GetItemPadding() / 2 : 0;
+}
+
+template<class Concrete>
+void TouchableLocationBarView<Concrete>::Init() {
Peter Kasting 2012/06/13 17:09:16 Nit: Order definitions the same as the declaration
Jói 2012/06/13 17:18:01 Done.
+ int horizontal_padding = GetBuiltInHorizontalPadding();
+ if (horizontal_padding != 0) {
+ static_cast<Concrete*>(this)->set_border(views::Border::CreateEmptyBorder(
+ 3, horizontal_padding, 3, horizontal_padding));
+ }
+}
+
+#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_TOUCHABLE_LOCATION_BAR_VIEW_H_
« no previous file with comments | « chrome/browser/ui/views/location_bar/star_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698