OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/gtk/rounded_window.h" | 5 #include "chrome/browser/gtk/rounded_window.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <math.h> | 8 #include <math.h> |
9 | 9 |
10 #include "app/l10n_util.h" | 10 #include "base/i18n/rtl.h" |
11 #include "chrome/browser/gtk/gtk_util.h" | 11 #include "chrome/browser/gtk/gtk_util.h" |
12 | 12 |
13 namespace gtk_util { | 13 namespace gtk_util { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const char* kRoundedData = "rounded-window-data"; | 17 const char* kRoundedData = "rounded-window-data"; |
18 | 18 |
19 // If the border radius is less than |kMinRoundedBorderSize|, we don't actually | 19 // If the border radius is less than |kMinRoundedBorderSize|, we don't actually |
20 // round the corners, we just truncate the corner. | 20 // round the corners, we just truncate the corner. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // (|type| == FRAME_STROKE). | 53 // (|type| == FRAME_STROKE). |
54 std::vector<GdkPoint> MakeFramePolygonPoints(RoundedWindowData* data, | 54 std::vector<GdkPoint> MakeFramePolygonPoints(RoundedWindowData* data, |
55 FrameType type) { | 55 FrameType type) { |
56 using gtk_util::MakeBidiGdkPoint; | 56 using gtk_util::MakeBidiGdkPoint; |
57 int width = data->expected_width; | 57 int width = data->expected_width; |
58 int height = data->expected_height; | 58 int height = data->expected_height; |
59 int corner_size = data->corner_size; | 59 int corner_size = data->corner_size; |
60 | 60 |
61 std::vector<GdkPoint> points; | 61 std::vector<GdkPoint> points; |
62 | 62 |
63 bool ltr = l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT; | 63 bool ltr = !base::i18n::IsRTL(); |
64 // If we have a stroke, we have to offset some of our points by 1 pixel. | 64 // If we have a stroke, we have to offset some of our points by 1 pixel. |
65 // We have to inset by 1 pixel when we draw horizontal lines that are on the | 65 // We have to inset by 1 pixel when we draw horizontal lines that are on the |
66 // bottom or when we draw vertical lines that are closer to the end (end is | 66 // bottom or when we draw vertical lines that are closer to the end (end is |
67 // right for ltr). | 67 // right for ltr). |
68 int y_off = (type == FRAME_MASK) ? 0 : -1; | 68 int y_off = (type == FRAME_MASK) ? 0 : -1; |
69 // We use this one for LTR. | 69 // We use this one for LTR. |
70 int x_off_l = ltr ? y_off : 0; | 70 int x_off_l = ltr ? y_off : 0; |
71 // We use this one for RTL. | 71 // We use this one for RTL. |
72 int x_off_r = !ltr ? -y_off : 0; | 72 int x_off_r = !ltr ? -y_off : 0; |
73 | 73 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 void SetRoundedWindowBorderColor(GtkWidget* widget, GdkColor color) { | 303 void SetRoundedWindowBorderColor(GtkWidget* widget, GdkColor color) { |
304 DCHECK(widget); | 304 DCHECK(widget); |
305 RoundedWindowData* data = static_cast<RoundedWindowData*>( | 305 RoundedWindowData* data = static_cast<RoundedWindowData*>( |
306 g_object_get_data(G_OBJECT(widget), kRoundedData)); | 306 g_object_get_data(G_OBJECT(widget), kRoundedData)); |
307 DCHECK(data); | 307 DCHECK(data); |
308 data->border_color = color; | 308 data->border_color = color; |
309 } | 309 } |
310 | 310 |
311 } // namespace gtk_util | 311 } // namespace gtk_util |
OLD | NEW |