Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // To make your location bar View named FooBlat extend itself into the | |
| 10 // padding around it to get an enlarged touch target, inherit from | |
| 11 // TouchableLocationBarView<FooBlat> and call | |
| 12 // TouchableLocationBarViewBase::Init() from your constructor. | |
| 13 | |
| 14 #include "ui/views/border.h" | |
| 15 | |
| 16 class TouchableLocationBarViewBase { | |
|
Peter Kasting
2012/06/12 22:03:52
I don't understand what splitting this class in tw
Jói
2012/06/13 11:29:39
Rolled it into one class as requested. This simpl
| |
| 17 public: | |
| 18 // Call this from the constructor (or during early initialization) | |
| 19 // of a class that inherits from TouchableLocationBarView<>. | |
| 20 void Init(); | |
| 21 | |
| 22 // Returns the number of pixels of built-in padding to the left and | |
| 23 // right of the image for this view. | |
| 24 int GetBuiltInHorizontalPadding() const; | |
| 25 | |
| 26 protected: | |
| 27 int touch_horizontal_padding() const; | |
|
Peter Kasting
2012/06/12 22:03:52
Nit: Should be camel-cased since implementation is
Jói
2012/06/13 11:29:39
This method went away with the simplification.
| |
| 28 virtual void SetBorder(int vertical_padding, int horizontal_padding) = 0; | |
| 29 }; | |
| 30 | |
| 31 // A mix-in for a class based on views::View and intended for the | |
| 32 // location bar. In a touch layout, the mix-in adds an empty border | |
| 33 // around the view to increase the size of the touch target. The | |
| 34 // border extends a few pixels up and down, which doesn't affect | |
| 35 // layout, and extends half of the padding used between items in the | |
| 36 // location bar to the left and right. | |
| 37 template<class Concrete> | |
| 38 class TouchableLocationBarView : public TouchableLocationBarViewBase { | |
| 39 private: | |
| 40 virtual void SetBorder(int vertical_padding, int horizontal_padding) OVERRIDE; | |
| 41 }; | |
| 42 | |
| 43 template<class Concrete> | |
| 44 void TouchableLocationBarView<Concrete>::SetBorder(int vertical_padding, | |
| 45 int horizontal_padding) { | |
| 46 static_cast<Concrete*>(this)->set_border(views::Border::CreateEmptyBorder( | |
| 47 vertical_padding, horizontal_padding, | |
| 48 vertical_padding, horizontal_padding)); | |
| 49 } | |
| 50 | |
| 51 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_TOUCHABLE_LOCATION_BAR_VIEW_H_ | |
| OLD | NEW |