mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
[Widget] with background image, draw background-color first.
This commit is contained in:
parent
1e25ae03b7
commit
beccfe4178
4 changed files with 21 additions and 6 deletions
|
@ -260,6 +260,18 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doub
|
|||
*/
|
||||
void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t *d );
|
||||
|
||||
|
||||
/**
|
||||
* @param widget The widget to query
|
||||
* @param property The property to query.
|
||||
* @param d The drawable to apply color.
|
||||
*
|
||||
* Obtain the image of the widget and applies this to the drawable d.
|
||||
*
|
||||
* @return true if image is set.
|
||||
*/
|
||||
gboolean rofi_theme_get_image ( const widget *widget, const char *property, cairo_t *d );
|
||||
|
||||
/**
|
||||
* @param widget The widget to query
|
||||
* @param property The property to query.
|
||||
|
|
|
@ -347,7 +347,5 @@ int widget_get_absolute_xpos ( widget *wid );
|
|||
* @returns the absolute y-position of widget of the widget in pixels.
|
||||
*/
|
||||
int widget_get_absolute_ypos ( widget *wid );
|
||||
|
||||
void rofi_theme_get_image ( const widget *widget, const char *property, cairo_t *d );
|
||||
/**@}*/
|
||||
#endif // ROFI_WIDGET_H
|
||||
|
|
|
@ -918,16 +918,16 @@ void rofi_theme_get_color ( const widget *widget, const char *property, cairo_t
|
|||
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
|
||||
}
|
||||
}
|
||||
void rofi_theme_get_image ( const widget *widget, const char *property, cairo_t *d )
|
||||
gboolean rofi_theme_get_image ( const widget *widget, const char *property, cairo_t *d )
|
||||
{
|
||||
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );
|
||||
Property *p = rofi_theme_find_property ( wid, P_IMAGE , property, FALSE );
|
||||
if ( p ) {
|
||||
if ( p->type == P_INHERIT ) {
|
||||
if ( widget->parent ) {
|
||||
rofi_theme_get_image ( widget->parent, property, d );
|
||||
return rofi_theme_get_image ( widget->parent, property, d );
|
||||
}
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
if ( p->value.image.type == ROFI_IMAGE_URL ) {
|
||||
if ( p->value.image.surface_id == 0 ) {
|
||||
|
@ -940,6 +940,7 @@ void rofi_theme_get_image ( const widget *widget, const char *property, cairo_t
|
|||
cairo_pattern_set_extend ( pat, CAIRO_EXTEND_REPEAT );
|
||||
cairo_set_source ( d, pat );
|
||||
cairo_pattern_destroy ( pat );
|
||||
return TRUE;
|
||||
}
|
||||
} else if ( p->value.image.type == ROFI_IMAGE_LINEAR_GRADIENT ) {
|
||||
cairo_pattern_t * pat = cairo_pattern_create_linear (0.0,0.0, widget->w, 0.0);
|
||||
|
@ -951,11 +952,13 @@ void rofi_theme_get_image ( const widget *widget, const char *property, cairo_t
|
|||
p->value.image.stop.blue, p->value.image.stop.alpha);
|
||||
cairo_set_source ( d, pat );
|
||||
cairo_pattern_destroy ( pat );
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
RofiPadding rofi_theme_get_padding ( const widget *widget, const char *property, RofiPadding pad )
|
||||
{
|
||||
|
|
|
@ -267,8 +267,10 @@ void widget_draw ( widget *widget, cairo_t *d )
|
|||
|
||||
cairo_set_source_rgba ( d, 1.0, 1.0, 1.0, 1.0 );
|
||||
rofi_theme_get_color ( widget, "background-color", d );
|
||||
rofi_theme_get_image ( widget, "background-image", d );
|
||||
cairo_fill_preserve ( d );
|
||||
if ( rofi_theme_get_image ( widget, "background-image", d ) ) {
|
||||
cairo_fill_preserve ( d );
|
||||
}
|
||||
cairo_clip ( d );
|
||||
|
||||
widget->draw ( widget, d );
|
||||
|
|
Loading…
Reference in a new issue