Skip to content

Commit

Permalink
Merge branch 'master' into tintou/color
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin Noël authored Sep 8, 2021
2 parents a2ac0db + 5f26f2f commit 8c0df16
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions src/Widgets/Tooltip.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
*/
public class Gala.Tooltip : Clutter.Actor {
private static Clutter.Color text_color;
private static Gdk.RGBA bg_color;
private static Gtk.Border padding;
private static int border_radius;
private static Gtk.StyleContext style_context;

/**
* Canvas to draw the Tooltip background.
Expand Down Expand Up @@ -52,21 +51,11 @@ public class Gala.Tooltip : Clutter.Actor {
label_widget_path.append_type (GLib.Type.from_name ("label"));
label_widget_path.iter_set_object_name (-1, "tooltip");

var tooltip_style_context = new Gtk.StyleContext ();
tooltip_style_context.add_class (Gtk.STYLE_CLASS_BACKGROUND);
tooltip_style_context.set_path (label_widget_path);
style_context = new Gtk.StyleContext ();
style_context.add_class (Gtk.STYLE_CLASS_BACKGROUND);
style_context.set_path (label_widget_path);

bg_color = (Gdk.RGBA) tooltip_style_context.get_property (
Gtk.STYLE_PROPERTY_BACKGROUND_COLOR,
Gtk.StateFlags.NORMAL
);

border_radius = (int) tooltip_style_context.get_property (
Gtk.STYLE_PROPERTY_BORDER_RADIUS,
Gtk.StateFlags.NORMAL
);

padding = tooltip_style_context.get_padding (Gtk.StateFlags.NORMAL);
padding = style_context.get_padding (Gtk.StateFlags.NORMAL);

text_color = Clutter.Color.from_string ("#ffffff");
}
Expand Down Expand Up @@ -132,15 +121,13 @@ public class Gala.Tooltip : Clutter.Actor {
background_canvas.invalidate ();
}

private static bool draw_background (Cairo.Context cr, int width, int height) {
cr.save ();
cr.set_operator (Cairo.Operator.CLEAR);
cr.paint ();
cr.restore ();
private static bool draw_background (Cairo.Context ctx, int width, int height) {
ctx.save ();

style_context.render_background (ctx, 0, 0, width, height);
style_context.render_frame (ctx, 0, 0, width, height);

Granite.Drawing.Utilities.cairo_rounded_rectangle (cr, 0, 0, width, height, border_radius);
cr.set_source_rgba (bg_color.red, bg_color.green, bg_color.blue, bg_color.alpha);
cr.fill ();
ctx.restore ();

return false;
}
Expand Down

0 comments on commit 8c0df16

Please sign in to comment.