OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/rounded_window.h" | 5 #include "chrome/browser/ui/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/gtk_signal_registrar.h" | |
11 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
12 #include "base/logging.h" | 11 #include "base/logging.h" |
13 #include "chrome/browser/ui/gtk/gtk_util.h" | 12 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 13 #include "ui/base/gtk/gtk_signal_registrar.h" |
14 | 14 |
15 namespace gtk_util { | 15 namespace gtk_util { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char* kRoundedData = "rounded-window-data"; | 19 const char* kRoundedData = "rounded-window-data"; |
20 | 20 |
21 // If the border radius is less than |kMinRoundedBorderSize|, we don't actually | 21 // If the border radius is less than |kMinRoundedBorderSize|, we don't actually |
22 // round the corners, we just truncate the corner. | 22 // round the corners, we just truncate the corner. |
23 const int kMinRoundedBorderSize = 8; | 23 const int kMinRoundedBorderSize = 8; |
24 | 24 |
25 struct RoundedWindowData { | 25 struct RoundedWindowData { |
26 // Expected window size. Used to detect when we need to reshape the window. | 26 // Expected window size. Used to detect when we need to reshape the window. |
27 int expected_width; | 27 int expected_width; |
28 int expected_height; | 28 int expected_height; |
29 | 29 |
30 // Color of the border. | 30 // Color of the border. |
31 GdkColor border_color; | 31 GdkColor border_color; |
32 | 32 |
33 // Radius of the edges in pixels. | 33 // Radius of the edges in pixels. |
34 int corner_size; | 34 int corner_size; |
35 | 35 |
36 // Which corners should be rounded? | 36 // Which corners should be rounded? |
37 int rounded_edges; | 37 int rounded_edges; |
38 | 38 |
39 // Which sides of the window should have an internal border? | 39 // Which sides of the window should have an internal border? |
40 int drawn_borders; | 40 int drawn_borders; |
41 | 41 |
42 // Keeps track of attached signal handlers. | 42 // Keeps track of attached signal handlers. |
43 GtkSignalRegistrar signals; | 43 ui::GtkSignalRegistrar signals; |
44 }; | 44 }; |
45 | 45 |
46 // Callback from GTK to release allocated memory. | 46 // Callback from GTK to release allocated memory. |
47 void FreeRoundedWindowData(gpointer data) { | 47 void FreeRoundedWindowData(gpointer data) { |
48 delete static_cast<RoundedWindowData*>(data); | 48 delete static_cast<RoundedWindowData*>(data); |
49 } | 49 } |
50 | 50 |
51 enum FrameType { | 51 enum FrameType { |
52 FRAME_MASK, | 52 FRAME_MASK, |
53 FRAME_STROKE, | 53 FRAME_STROKE, |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 312 |
313 void SetRoundedWindowBorderColor(GtkWidget* widget, GdkColor color) { | 313 void SetRoundedWindowBorderColor(GtkWidget* widget, GdkColor color) { |
314 DCHECK(widget); | 314 DCHECK(widget); |
315 RoundedWindowData* data = static_cast<RoundedWindowData*>( | 315 RoundedWindowData* data = static_cast<RoundedWindowData*>( |
316 g_object_get_data(G_OBJECT(widget), kRoundedData)); | 316 g_object_get_data(G_OBJECT(widget), kRoundedData)); |
317 DCHECK(data); | 317 DCHECK(data); |
318 data->border_color = color; | 318 data->border_color = color; |
319 } | 319 } |
320 | 320 |
321 } // namespace gtk_util | 321 } // namespace gtk_util |
OLD | NEW |