88 * Clutter actor to display text in a tooltip-like component.
99 */
1010public class Gala.Tooltip : Clutter .Actor {
11+ private const int TEXT_MARGIN = 6 ;
12+ private const int CORNER_RADIUS = 3 ;
13+
1114 public float monitor_scale { get ; construct set ; }
1215
1316 private Gala . Text text_actor;
@@ -18,25 +21,29 @@ public class Gala.Tooltip : Clutter.Actor {
1821
1922 construct {
2023 text_actor = new Gala .Text () {
21- margin_left = 6 ,
22- margin_top = 6 ,
23- margin_bottom = 6 ,
24- margin_right = 6 ,
2524 ellipsize = Pango . EllipsizeMode . MIDDLE ,
2625 color = Drawing . Color . TOOLTIP_TEXT_COLOR
2726 };
28-
29- add_child (text_actor);
27+ bind_property (" monitor-scale" , text_actor, " margin-left" , SYNC_CREATE , transform_monitor_scale_to_margin);
28+ bind_property (" monitor-scale" , text_actor, " margin-top" , SYNC_CREATE , transform_monitor_scale_to_margin);
29+ bind_property (" monitor-scale" , text_actor, " margin-right" , SYNC_CREATE , transform_monitor_scale_to_margin);
30+ bind_property (" monitor-scale" , text_actor, " margin-bottom" , SYNC_CREATE , transform_monitor_scale_to_margin);
3031
3132 layout_manager = new Clutter .BinLayout ();
3233 background_color = Drawing . Color . TOOLTIP_BACKGROUND ;
34+ add_child (text_actor);
3335
34- var rounded_corners_effect = new RoundedCornersEffect (3 , monitor_scale);
36+ var rounded_corners_effect = new RoundedCornersEffect (CORNER_RADIUS , monitor_scale);
3537 bind_property (" monitor-scale" , rounded_corners_effect, " monitor-scale" );
3638 add_effect (rounded_corners_effect);
3739 }
3840
3941 public void set_text (string new_text) {
4042 text_actor. text = new_text;
4143 }
44+
45+ private static bool transform_monitor_scale_to_margin (Binding binding, Value from_value, ref Value to_value) {
46+ to_value. set_float (Utils . scale_to_int (TEXT_MARGIN , from_value. get_float ()));
47+ return true ;
48+ }
4249}
0 commit comments