mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-11 13:50:48 -05:00
[Icon] Add a squared option.
This commit is contained in:
parent
b69b846db1
commit
5cdfb378b0
3 changed files with 26 additions and 0 deletions
|
@ -1399,6 +1399,9 @@ This is an icon widget. The displayed icon can be set with \fB\fCfilename\fR and
|
||||||
If the property \fB\fCaction\fR is set, it acts as a button.
|
If the property \fB\fCaction\fR is set, it acts as a button.
|
||||||
\fB\fCaction\fR can be set to a keybinding name and completes that action. (see rofi \-show keys for a list).
|
\fB\fCaction\fR can be set to a keybinding name and completes that action. (see rofi \-show keys for a list).
|
||||||
|
|
||||||
|
.PP
|
||||||
|
If the \fB\fCsquared\fR property is set to \fBfalse\fP the widget height and width are not forced to be equal.
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
|
@ -869,6 +869,7 @@ This is an icon widget. The displayed icon can be set with `filename` and size w
|
||||||
If the property `action` is set, it acts as a button.
|
If the property `action` is set, it acts as a button.
|
||||||
`action` can be set to a keybinding name and completes that action. (see rofi -show keys for a list).
|
`action` can be set to a keybinding name and completes that action. (see rofi -show keys for a list).
|
||||||
|
|
||||||
|
If the `squared` property is set to **false** the widget height and width are not forced to be equal.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ struct _icon
|
||||||
// Size of the icon.
|
// Size of the icon.
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
|
int squared;
|
||||||
|
|
||||||
uint32_t icon_fetch_id;
|
uint32_t icon_fetch_id;
|
||||||
|
|
||||||
double yalign, xalign;
|
double yalign, xalign;
|
||||||
|
@ -56,6 +58,15 @@ static int icon_get_desired_height ( widget *widget )
|
||||||
{
|
{
|
||||||
icon *b = (icon *) widget;
|
icon *b = (icon *) widget;
|
||||||
int height = b->size;
|
int height = b->size;
|
||||||
|
if ( b->squared == FALSE ){
|
||||||
|
if( b->icon ) {
|
||||||
|
int iconh = cairo_image_surface_get_height ( b->icon );
|
||||||
|
int iconw = cairo_image_surface_get_width ( b->icon );
|
||||||
|
int icons = MAX ( iconh, iconw );
|
||||||
|
double scale = (double) b->size / icons;
|
||||||
|
height = iconh*scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
height += widget_padding_get_padding_height ( widget );
|
height += widget_padding_get_padding_height ( widget );
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
@ -63,6 +74,15 @@ static int icon_get_desired_width ( widget *widget )
|
||||||
{
|
{
|
||||||
icon *b = (icon *) widget;
|
icon *b = (icon *) widget;
|
||||||
int width = b->size;
|
int width = b->size;
|
||||||
|
if ( b->squared == FALSE ){
|
||||||
|
if( b->icon ) {
|
||||||
|
int iconh = cairo_image_surface_get_height ( b->icon );
|
||||||
|
int iconw = cairo_image_surface_get_width ( b->icon );
|
||||||
|
int icons = MAX ( iconh, iconw );
|
||||||
|
double scale = (double) b->size / icons;
|
||||||
|
width = iconw*scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
width += widget_padding_get_padding_width ( widget );
|
width += widget_padding_get_padding_width ( widget );
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
@ -152,6 +172,8 @@ icon * icon_create ( widget *parent, const char *name )
|
||||||
RofiDistance d = rofi_theme_get_distance ( WIDGET ( b ), "size", b->size );
|
RofiDistance d = rofi_theme_get_distance ( WIDGET ( b ), "size", b->size );
|
||||||
b->size = distance_get_pixel ( d, ROFI_ORIENTATION_VERTICAL );
|
b->size = distance_get_pixel ( d, ROFI_ORIENTATION_VERTICAL );
|
||||||
|
|
||||||
|
b->squared = rofi_theme_get_boolean ( WIDGET ( b ), "squared", TRUE );
|
||||||
|
|
||||||
const char * filename = rofi_theme_get_string ( WIDGET ( b ), "filename", NULL );
|
const char * filename = rofi_theme_get_string ( WIDGET ( b ), "filename", NULL );
|
||||||
if ( filename ) {
|
if ( filename ) {
|
||||||
b->icon_fetch_id = rofi_icon_fetcher_query ( filename, b->size );
|
b->icon_fetch_id = rofi_icon_fetcher_query ( filename, b->size );
|
||||||
|
|
Loading…
Reference in a new issue