Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/Widgets/MultitaskingView/Tooltip.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* Clutter actor to display text in a tooltip-like component.
*/
public class Gala.Tooltip : Clutter.Actor {
private const int TEXT_MARGIN = 6;
private const int CORNER_RADIUS = 3;

public float monitor_scale { get; construct set; }

private Gala.Text text_actor;
Expand All @@ -18,25 +21,29 @@ public class Gala.Tooltip : Clutter.Actor {

construct {
text_actor = new Gala.Text () {
margin_left = 6,
margin_top = 6,
margin_bottom = 6,
margin_right = 6,
ellipsize = Pango.EllipsizeMode.MIDDLE,
color = Drawing.Color.TOOLTIP_TEXT_COLOR
};

add_child (text_actor);
bind_property ("monitor-scale", text_actor, "margin-left", SYNC_CREATE, transform_monitor_scale_to_margin);
bind_property ("monitor-scale", text_actor, "margin-top", SYNC_CREATE, transform_monitor_scale_to_margin);
bind_property ("monitor-scale", text_actor, "margin-right", SYNC_CREATE, transform_monitor_scale_to_margin);
bind_property ("monitor-scale", text_actor, "margin-bottom", SYNC_CREATE, transform_monitor_scale_to_margin);

layout_manager = new Clutter.BinLayout ();
background_color = Drawing.Color.TOOLTIP_BACKGROUND;
add_child (text_actor);

var rounded_corners_effect = new RoundedCornersEffect (3, monitor_scale);
var rounded_corners_effect = new RoundedCornersEffect (CORNER_RADIUS, monitor_scale);
bind_property ("monitor-scale", rounded_corners_effect, "monitor-scale");
add_effect (rounded_corners_effect);
}

public void set_text (string new_text) {
text_actor.text = new_text;
}

private static bool transform_monitor_scale_to_margin (Binding binding, Value from_value, ref Value to_value) {
to_value.set_float (Utils.scale_to_int (TEXT_MARGIN, from_value.get_float ()));
return true;
}
}