OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef VIEWS_VIEW_H_ | 5 #ifndef VIEWS_VIEW_H_ |
6 #define VIEWS_VIEW_H_ | 6 #define VIEWS_VIEW_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 // Following are a few examples of the values returned by this function for | 339 // Following are a few examples of the values returned by this function for |
340 // a View with the bounds {0, 0, 100, 100} and a right-to-left layout: | 340 // a View with the bounds {0, 0, 100, 100} and a right-to-left layout: |
341 // | 341 // |
342 // MirroredXCoordinateInsideView(0) -> 100 | 342 // MirroredXCoordinateInsideView(0) -> 100 |
343 // MirroredXCoordinateInsideView(20) -> 80 | 343 // MirroredXCoordinateInsideView(20) -> 80 |
344 // MirroredXCoordinateInsideView(99) -> 1 | 344 // MirroredXCoordinateInsideView(99) -> 1 |
345 int MirroredXCoordinateInsideView(int x) const { | 345 int MirroredXCoordinateInsideView(int x) const { |
346 return UILayoutIsRightToLeft() ? width() - x : x; | 346 return UILayoutIsRightToLeft() ? width() - x : x; |
347 } | 347 } |
348 | 348 |
| 349 // Given a X coordinate and a width inside the View, this function returns |
| 350 // the mirrored X coordinate if the View's UI layout is right-to-left. If the |
| 351 // layout is left-to-right, the same X coordinate is returned. |
| 352 // |
| 353 // Following are a few examples of the values returned by this function for |
| 354 // a View with the bounds {0, 0, 100, 100} and a right-to-left layout: |
| 355 // |
| 356 // MirroredXCoordinateInsideView(0, 10) -> 90 |
| 357 // MirroredXCoordinateInsideView(20, 20) -> 60 |
| 358 int MirroredXWithWidthInsideView(int x, int w) const { |
| 359 return UILayoutIsRightToLeft() ? width() - x - w : x; |
| 360 } |
| 361 |
349 // Painting functions | 362 // Painting functions |
350 | 363 |
351 // Mark the specified rectangle as dirty (needing repaint). If |urgent| is | 364 // Mark the specified rectangle as dirty (needing repaint). If |urgent| is |
352 // true, the view will be repainted when the current event processing is | 365 // true, the view will be repainted when the current event processing is |
353 // done. Otherwise, painting will take place as soon as possible. | 366 // done. Otherwise, painting will take place as soon as possible. |
354 virtual void SchedulePaint(const gfx::Rect& r, bool urgent); | 367 virtual void SchedulePaint(const gfx::Rect& r, bool urgent); |
355 | 368 |
356 // Mark the entire View's bounds as dirty. Painting will occur as soon as | 369 // Mark the entire View's bounds as dirty. Painting will occur as soon as |
357 // possible. | 370 // possible. |
358 virtual void SchedulePaint(); | 371 virtual void SchedulePaint(); |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 // is going to be flipped horizontally (using the appropriate transform) on | 1216 // is going to be flipped horizontally (using the appropriate transform) on |
1204 // right-to-left locales for this View. | 1217 // right-to-left locales for this View. |
1205 bool flip_canvas_on_paint_for_rtl_ui_; | 1218 bool flip_canvas_on_paint_for_rtl_ui_; |
1206 | 1219 |
1207 DISALLOW_COPY_AND_ASSIGN(View); | 1220 DISALLOW_COPY_AND_ASSIGN(View); |
1208 }; | 1221 }; |
1209 | 1222 |
1210 } // namespace views | 1223 } // namespace views |
1211 | 1224 |
1212 #endif // VIEWS_VIEW_H_ | 1225 #endif // VIEWS_VIEW_H_ |
OLD | NEW |