@@ -9,14 +9,25 @@ namespace Gala.Drawing {
99 * A class containing an RGBA color and methods for more powerful color manipulation.
1010 */
1111 public class Color : GLib .Object {
12- public const Gdk . RGBA LIGHT_BACKGROUND = { (250f / 255f ), (250f / 255f ), (250f / 255f ), 1 };
13- public const Gdk . RGBA DARK_BACKGROUND = { (51 / 255f ), (51 / 255f ), (51 / 255f ), 1 };
14- public const Gdk . RGBA LIGHT_BORDER = { 0 , 0 , 0 , 0.2f };
15- public const Gdk . RGBA DARK_BORDER = { 0 , 0 , 0 , 0.75f };
16- public const Gdk . RGBA LIGHT_HIGHLIGHT = { 255 , 255 , 255 , 1 };
17- public const Gdk . RGBA DARK_HIGHLIGHT = { 255 , 255 , 255 , 0.05f };
18- public const Gdk . RGBA TOOLTIP_BACKGROUND = { 0 , 0 , 0 , 1 };
19- public const Gdk . RGBA TOOLTIP_TEXT_COLOR = { 1 , 1 , 1 , 1 };
12+ #if ! HAS_MUTTER47
13+ public const Clutter . Color LIGHT_BACKGROUND = { 250 , 250 , 250 , 255 };
14+ public const Clutter . Color DARK_BACKGROUND = { 51 , 51 , 51 , 255 };
15+ public const Clutter . Color LIGHT_BORDER = { 0 , 0 , 0 , 51 };
16+ public const Clutter . Color DARK_BORDER = { 0 , 0 , 0 , 191 };
17+ public const Clutter . Color LIGHT_HIGHLIGHT = { 255 , 255 , 255 , 255 };
18+ public const Clutter . Color DARK_HIGHLIGHT = { 255 , 255 , 255 , 13 };
19+ public const Clutter . Color TOOLTIP_BACKGROUND = { 0 , 0 , 0 , 255 };
20+ public const Clutter . Color TOOLTIP_TEXT_COLOR = { 255 , 255 , 255 , 255 };
21+ #else
22+ public const Cogl . Color LIGHT_BACKGROUND = { 250 , 250 , 250 , 255 };
23+ public const Cogl . Color DARK_BACKGROUND = { 51 , 51 , 51 , 255 };
24+ public const Cogl . Color LIGHT_BORDER = { 0 , 0 , 0 , 51 };
25+ public const Cogl . Color DARK_BORDER = { 0 , 0 , 0 , 191 };
26+ public const Cogl . Color LIGHT_HIGHLIGHT = { 255 , 255 , 255 , 255 };
27+ public const Cogl . Color DARK_HIGHLIGHT = { 255 , 255 , 255 , 13 };
28+ public const Cogl . Color TOOLTIP_BACKGROUND = { 0 , 0 , 0 , 255 };
29+ public const Cogl . Color TOOLTIP_TEXT_COLOR = { 255 , 255 , 255 , 255 };
30+ #endif
2031
2132 /**
2233 * The value of the red channel, with 0 being the lowest value and 1.0 being the greatest value.
@@ -93,15 +104,6 @@ namespace Gala.Drawing {
93104 this . A = A ;
94105 }
95106
96- /**
97- * Constructs a new {@link Gala.Drawing.Color} from a {@link Gdk.RGBA}.
98- *
99- * @param color the {@link Gdk.RGBA}
100- */
101- public Color.from_rgba (Gdk .RGBA color ) {
102- set_from_rgba (color);
103- }
104-
105107 /**
106108 * Constructs a new {@link Gala.Drawing.Color} from a string.
107109 *
@@ -112,14 +114,20 @@ namespace Gala.Drawing {
112114 * * A RGB color in the form “rgb(r,g,b)” (In this case the color will have full opacity)
113115 * * A RGBA color in the form “rgba(r,g,b,a)”
114116 *
115- * For more details on formatting and how this function works see {@link Gdk.RGBA.parse }
117+ * For more details on formatting and how this function works see {@link Clutter.Color.from_string }
116118 *
117119 * @param color the string specifying the color
118120 */
119121 public Color.from_string (string color ) {
120- Gdk . RGBA rgba = Gdk . RGBA ();
121- rgba. parse (color);
122- set_from_rgba (rgba);
122+ #if ! HAS_MUTTER47
123+ var parsed_color = Clutter . Color . from_string (color);
124+ #else
125+ var parsed_color = Cogl . Color . from_string (color);
126+ #endif
127+ R = parsed_color. red / 255.0 ;
128+ G = parsed_color. green / 255.0 ;
129+ B = parsed_color. blue / 255.0 ;
130+ A = parsed_color. alpha / 255.0 ;
123131 }
124132
125133 /**
@@ -508,13 +516,17 @@ namespace Gala.Drawing {
508516 * Note: that this string representation may lose some precision, since r, g and b are represented
509517 * as 8-bit integers. If this is a concern, you should use a different representation.
510518 *
511- * This returns the same string as a {@link Gdk.RGBA } would return in {@link Gdk.RGBA .to_string}
519+ * This returns the same string as a {@link Clutter.Color } would return in {@link Clutter.Color .to_string}
512520 *
513521 * @return the text string
514522 */
515523 public string to_string () {
516- Gdk . RGBA rgba = {(float )R , (float )G , (float )B , (float )A };
517- return rgba. to_string ();
524+ #if ! HAS_MUTTER47
525+ Clutter . Color color = { (uint8 ) (R * 255 ), (uint8 ) (G * 255 ), (uint8 ) (B * 255 ), (uint8 ) (A * 255 ) };
526+ #else
527+ Cogl . Color color = { (uint8 ) (R * 255 ), (uint8 ) (G * 255 ), (uint8 ) (B * 255 ), (uint8 ) (A * 255 ) };
528+ #endif
529+ return color. to_string ();
518530 }
519531
520532 /**
@@ -546,12 +558,5 @@ namespace Gala.Drawing {
546558
547559 return (alpha << 24 ) | (red << 16 ) | (green << 8 ) | blue;
548560 }
549-
550- private void set_from_rgba (Gdk .RGBA color ) {
551- R = color. red;
552- G = color. green;
553- B = color. blue;
554- A = color. alpha;
555- }
556561 }
557562}
0 commit comments