Tooltip: get text color from style context (#1295)

* Tooltip: get text color from style context

* cache the math
This commit is contained in:
Danielle Foré 2021-11-09 22:27:45 -08:00 committed by GitHub
parent fee8ce43a3
commit 869aa70cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,17 +47,33 @@ public class Gala.Tooltip : Clutter.Actor {
public float max_width;
static construct {
var label_widget_path = new Gtk.WidgetPath ();
label_widget_path.append_type (GLib.Type.from_name ("label"));
label_widget_path.iter_set_object_name (-1, "tooltip");
var tooltip_widget_path = new Gtk.WidgetPath ();
var pos = tooltip_widget_path.append_type (typeof (Gtk.Window));
tooltip_widget_path.iter_set_object_name (pos, "tooltip");
tooltip_widget_path.iter_add_class (pos, Gtk.STYLE_CLASS_CSD);
tooltip_widget_path.iter_add_class (pos, Gtk.STYLE_CLASS_BACKGROUND);
style_context = new Gtk.StyleContext ();
style_context.add_class (Gtk.STYLE_CLASS_BACKGROUND);
style_context.set_path (label_widget_path);
style_context.set_path (tooltip_widget_path);
padding = style_context.get_padding (Gtk.StateFlags.NORMAL);
text_color = Clutter.Color.from_string ("#ffffff");
tooltip_widget_path.append_type (typeof (Gtk.Label));
var label_style_context = new Gtk.StyleContext ();
label_style_context.set_path (tooltip_widget_path);
var text_rgba = (Gdk.RGBA) label_style_context.get_property (
Gtk.STYLE_PROPERTY_COLOR,
Gtk.StateFlags.NORMAL
);
text_color = Clutter.Color () {
red = (uint8) text_rgba.red * uint8.MAX,
green = (uint8) text_rgba.green * uint8.MAX,
blue = (uint8) text_rgba.blue * uint8.MAX,
alpha = (uint8) text_rgba.alpha * uint8.MAX,
};
}
construct {