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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_TOUCHABLE_LOCATION_BAR_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_TOUCHABLE_LOCATION_BAR_VIEW_H_
7 #pragma once
8
9 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
10 #include "ui/base/layout.h"
11 #include "ui/views/border.h"
12
13 // A mix-in for a class based on views::View and intended for the
14 // location bar. In a touch layout, the mix-in adds an empty border
15 // around the view to increase the size of the touch target. The
16 // border extends a few pixels up and down, which doesn't affect
17 // layout, and extends half of the padding used between items in the
18 // location bar to the left and right.
19 //
20 // To make your location bar View named FooBlat extend itself into the
21 // padding around it to get an enlarged touch target, inherit from
22 // TouchableLocationBarView<FooBlat> and call
23 // TouchableLocationBarView<FooBlat>::Init() from your constructor.
24 template<class Concrete>
25 class TouchableLocationBarView {
26 public:
27 // Call this from the constructor (or during early initialization)
28 // of a class that inherits from TouchableLocationBarView<>.
29 void Init();
30
31 // Returns the number of pixels of built-in padding to the left and
32 // right of the image for this view.
33 int GetBuiltInHorizontalPadding() const;
34 };
35
36 template<class Concrete>
37 int TouchableLocationBarView<Concrete>::GetBuiltInHorizontalPadding() const {
38 return ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ?
39 LocationBarView::GetItemPadding() / 2 : 0;
40 }
41
42 template<class Concrete>
43 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.
44 int horizontal_padding = GetBuiltInHorizontalPadding();
45 if (horizontal_padding != 0) {
46 static_cast<Concrete*>(this)->set_border(views::Border::CreateEmptyBorder(
47 3, horizontal_padding, 3, horizontal_padding));
48 }
49 }
50
51 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_TOUCHABLE_LOCATION_BAR_VIEW_H_
OLDNEW
« 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