1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Millimeter support for distance (#1144)

This commit is contained in:
nick87720z 2020-06-10 01:19:43 +05:00 committed by GitHub
parent 2da2a1f4dc
commit fb2ba8ada3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View file

@ -80,6 +80,8 @@ typedef enum
{
/** PixelWidth in pixels. */
ROFI_PU_PX,
/** PixelWidth in millimeters. */
ROFI_PU_MM,
/** PixelWidth in EM. */
ROFI_PU_EM,
/** PixelWidget in percentage */

View file

@ -174,6 +174,7 @@ HEX [[:xdigit:]]
NUMBER [[:digit:]]
PNNUMBER [-+]?[[:digit:]]+
PX (px)
MM (mm)
EM (em)
CH (ch)
PERCENT (\%)
@ -452,6 +453,7 @@ if ( queue == NULL ){
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{EM} { return T_UNIT_EM; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CH} { return T_UNIT_CH; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{PX} { return T_UNIT_PX; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{MM} { return T_UNIT_MM; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{PERCENT} { return T_PERCENT; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{LS_SOLID} { return T_SOLID; }
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{LS_DASH} { return T_DASH; }

View file

@ -187,6 +187,7 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%token T_SOLID "Solid"
%token T_UNIT_PX "pixels"
%token T_UNIT_MM "mm"
%token T_UNIT_EM "em"
%token T_UNIT_CH "ch"
%token T_UNIT_PERCENT "%"
@ -738,9 +739,10 @@ t_property_distance
/** distance unit. px, em, % */
t_property_unit
: T_UNIT_PX { $$ = ROFI_PU_PX; }
| T_UNIT_MM { $$ = ROFI_PU_MM; }
| T_UNIT_EM { $$ = ROFI_PU_EM; }
| T_UNIT_CH { $$ = ROFI_PU_CH; }
| T_PERCENT { $$ = ROFI_PU_PERCENT; }
| T_PERCENT { $$ = ROFI_PU_PERCENT; }
;
/******
* Line style

View file

@ -301,6 +301,10 @@ static void rofi_theme_print_distance_unit ( RofiDistanceUnit *unit )
if ( unit->type == ROFI_PU_PX ) {
printf ( "%upx ", (unsigned int) unit->distance );
}
else if ( unit->type == ROFI_PU_MM ) {
printf_double ( unit->distance );
fputs ( "mm ", stdout );
}
else if ( unit->type == ROFI_PU_PERCENT ) {
printf_double ( unit->distance );
fputs ( "% ", stdout );
@ -942,6 +946,9 @@ static int get_pixels ( RofiDistanceUnit *unit, RofiOrientation ori )
val = ( unit->distance * width ) / ( 100.0 );
}
}
else if ( unit->type == ROFI_PU_MM ) {
val = unit->distance * config.dpi / 25.4;
}
return val;
}