30#define G_LOG_DOMAIN "Widgets.Icon"
62 int iconh = cairo_image_surface_get_height(b->
icon);
63 int iconw = cairo_image_surface_get_width(b->
icon);
64 int icons = MAX(iconh, iconw);
65 double scale = (double)b->
size / icons;
66 height = iconh * scale;
77 int iconh = cairo_image_surface_get_height(b->
icon);
78 int iconw = cairo_image_surface_get_width(b->
icon);
79 int icons = MAX(iconh, iconw);
80 double scale = (double)b->
size / icons;
81 width = iconw * scale;
94 cairo_surface_reference(b->
icon);
97 if (b->
icon == NULL) {
100 int iconh = cairo_image_surface_get_height(b->
icon);
101 int iconw = cairo_image_surface_get_width(b->
icon);
106 double scalex = (double)(b->
widget.
w - lpad - rpad) / iconw;
107 double scaley = (double)(b->
widget.
h - tpad - bpad) / iconh;
108 double scale = MIN(scalex, scaley);
113 draw, lpad + (b->
widget.
w - iconw * scale - lpad - rpad) * b->
xalign,
114 tpad + (b->
widget.
h - iconh * scale - tpad - bpad) * b->
yalign);
115 cairo_scale(draw, scale, scale);
117 cairo_pattern_t *pat = cairo_pattern_create_for_surface(b->
icon);
118 cairo_set_source_rgb(draw, 0, 0, 0);
120 cairo_mask(draw, pat);
121 cairo_set_operator(draw, CAIRO_OPERATOR_HSL_LUMINOSITY);
122 cairo_pattern_destroy(pat);
124 cairo_set_source_surface(draw, b->
icon, 0, 0);
133 cairo_surface_destroy(b->
icon);
150 if (icon_widget->
icon) {
151 cairo_surface_destroy(icon_widget->
icon);
152 icon_widget->
icon = NULL;
155 cairo_surface_reference(surf);
156 icon_widget->
icon = surf;
cairo_surface_t * rofi_icon_fetcher_get(const uint32_t uid)
uint32_t rofi_icon_fetcher_query(const char *name, const int size)
void icon_set_surface(icon *icon_widget, cairo_surface_t *surf)
icon * icon_create(widget *parent, const char *name)
static int icon_get_desired_width(widget *wid, G_GNUC_UNUSED const int height)
static void icon_free(widget *wid)
static void icon_resize(widget *wid, short w, short h)
static int icon_get_desired_height(widget *wid, G_GNUC_UNUSED const int width)
static void icon_draw(widget *wid, cairo_t *draw)
@ ROFI_ORIENTATION_VERTICAL
int distance_get_pixel(RofiDistance d, RofiOrientation ori)
double rofi_theme_get_double(const widget *wid, const char *property, double def)
int rofi_theme_get_boolean(const widget *wid, const char *property, int def)
gboolean rofi_theme_has_property(const widget *wid_in, const PropertyType type, const char *property)
RofiDistance rofi_theme_get_distance(const widget *wid, const char *property, int def)
void rofi_theme_get_color(const widget *wid, const char *property, cairo_t *d)
const char * rofi_theme_get_string(const widget *wid, const char *property, const char *def)