1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

Change PixelWidth to RofiPixelUnit.

This commit is contained in:
Dave Davenport 2017-06-02 16:21:05 +02:00
parent 48bf1709b6
commit 7352f1c2ba
5 changed files with 67 additions and 67 deletions

View file

@ -56,10 +56,10 @@ typedef enum
typedef enum typedef enum
{ {
/** Solid line */ /** Solid line */
SOLID, ROFI_HL_SOLID,
/** Dashed line */ /** Dashed line */
DASH ROFI_HL_DASH
} LineStyle; } RofiLineStyle;
/** /**
* Distance unit type. * Distance unit type.
@ -67,12 +67,12 @@ typedef enum
typedef enum typedef enum
{ {
/** PixelWidth in pixels. */ /** PixelWidth in pixels. */
PW_PX, ROFI_PU_PX,
/** PixelWidth in EM. */ /** PixelWidth in EM. */
PW_EM, ROFI_PU_EM,
/** PixelWidget in percentage */ /** PixelWidget in percentage */
PW_PERCENT, ROFI_PU_PERCENT,
} PixelWidth; } RofiPixelUnit;
/** /**
* Structure representing a distance. * Structure representing a distance.
@ -82,9 +82,9 @@ typedef struct
/** Distance */ /** Distance */
double distance; double distance;
/** Unit type of the distance */ /** Unit type of the distance */
PixelWidth type; RofiPixelUnit type;
/** Style of the line */ /** Style of the line */
LineStyle style; RofiLineStyle style;
} Distance; } Distance;
/** /**

View file

@ -447,18 +447,18 @@ t_property_distance
/** distance unit. px, em, % */ /** distance unit. px, em, % */
t_property_unit t_property_unit
: T_UNIT_PX { $$ = PW_PX; } : T_UNIT_PX { $$ = ROFI_PU_PX; }
| T_UNIT_EM { $$ = PW_EM; } | T_UNIT_EM { $$ = ROFI_PU_EM; }
| T_PERCENT { $$ = PW_PERCENT; } | T_PERCENT { $$ = ROFI_PU_PERCENT; }
; ;
/****** /******
* Line style * Line style
* If not set, solid. * If not set, solid.
*/ */
t_property_line_style t_property_line_style
: %empty { $$ = SOLID; } : %empty { $$ = ROFI_HL_SOLID; }
| T_SOLID { $$ = SOLID; } | T_SOLID { $$ = ROFI_HL_SOLID; }
| T_DASH { $$ = DASH; } | T_DASH { $$ = ROFI_HL_DASH; }
; ;
/** /**

View file

@ -131,16 +131,16 @@ void rofi_theme_free ( ThemeWidget *widget )
*/ */
static void rofi_theme_print_distance ( Distance d ) static void rofi_theme_print_distance ( Distance d )
{ {
if ( d.type == PW_PX ) { if ( d.type == ROFI_PU_PX ) {
printf ( "%upx ", (unsigned int) d.distance ); printf ( "%upx ", (unsigned int) d.distance );
} }
else if ( d.type == PW_PERCENT ) { else if ( d.type == ROFI_PU_PERCENT ) {
printf ( "%f%% ", d.distance ); printf ( "%f%% ", d.distance );
} }
else { else {
printf ( "%fem ", d.distance ); printf ( "%fem ", d.distance );
} }
if ( d.style == DASH ) { if ( d.style == ROFI_HL_DASH ) {
printf ( "dash " ); printf ( "dash " );
} }
} }
@ -511,14 +511,14 @@ static Distance _rofi_theme_get_distance ( const widget *widget, const char *pro
Property *p = rofi_theme_find_property ( wid, P_PADDING, property, exact ); Property *p = rofi_theme_find_property ( wid, P_PADDING, property, exact );
if ( p ) { if ( p ) {
if ( p->type == P_INTEGER ) { if ( p->type == P_INTEGER ) {
return (Distance){ p->value.i, PW_PX, SOLID }; return (Distance){ p->value.i, ROFI_PU_PX, ROFI_HL_SOLID };
} }
else { else {
return p->value.padding.left; return p->value.padding.left;
} }
} }
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property ); g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
return (Distance){ def, PW_PX, SOLID }; return (Distance){ def, ROFI_PU_PX, ROFI_HL_SOLID };
} }
@ -597,7 +597,7 @@ Padding rofi_theme_get_padding ( const widget *widget, const char *property, Pad
pad = p->value.padding; pad = p->value.padding;
} }
else { else {
Distance d = (Distance){ p->value.i, PW_PX, SOLID }; Distance d = (Distance){ p->value.i, ROFI_PU_PX, ROFI_HL_SOLID };
return (Padding){ d, d, d, d }; return (Padding){ d, d, d, d };
} }
} }
@ -639,10 +639,10 @@ ThemeHighlight rofi_theme_get_highlight ( widget *widget, const char *property,
int distance_get_pixel ( Distance d, Orientation ori ) int distance_get_pixel ( Distance d, Orientation ori )
{ {
if ( d.type == PW_EM ) { if ( d.type == ROFI_PU_EM ) {
return d.distance * textbox_get_estimated_char_height (); return d.distance * textbox_get_estimated_char_height ();
} }
else if ( d.type == PW_PERCENT ) { else if ( d.type == ROFI_PU_PERCENT ) {
if ( ori == ORIENTATION_VERTICAL ) { if ( ori == ORIENTATION_VERTICAL ) {
int height = 0; int height = 0;
rofi_view_get_current_monitor ( NULL, &height ); rofi_view_get_current_monitor ( NULL, &height );
@ -659,7 +659,7 @@ int distance_get_pixel ( Distance d, Orientation ori )
void distance_get_linestyle ( Distance d, cairo_t *draw ) void distance_get_linestyle ( Distance d, cairo_t *draw )
{ {
if ( d.style == DASH ) { if ( d.style == ROFI_HL_DASH ) {
const double dashes[1] = { 4 }; const double dashes[1] = { 4 };
cairo_set_dash ( draw, dashes, 1, 0.0 ); cairo_set_dash ( draw, dashes, 1, 0.0 );
} }

View file

@ -38,10 +38,10 @@ void widget_init ( widget *widget, WidgetType type, const char *name )
{ {
widget->type = type; widget->type = type;
widget->name = g_strdup ( name ); widget->name = g_strdup ( name );
widget->def_padding = (Padding){ { WIDGET_DEFAULT_PADDING, PW_PX, SOLID }, { WIDGET_DEFAULT_PADDING, PW_PX, SOLID }, { WIDGET_DEFAULT_PADDING, PW_PX, SOLID }, { WIDGET_DEFAULT_PADDING, PW_PX, SOLID } }; widget->def_padding = (Padding){ { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID }, { WIDGET_DEFAULT_PADDING, ROFI_PU_PX, ROFI_HL_SOLID } };
widget->def_border = (Padding){ { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID } }; widget->def_border = (Padding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
widget->def_border_radius = (Padding){ { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID } }; widget->def_border_radius = (Padding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
widget->def_margin = (Padding){ { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID }, { 0, PW_PX, SOLID } }; widget->def_margin = (Padding){ { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID }, { 0, ROFI_PU_PX, ROFI_HL_SOLID } };
widget->padding = rofi_theme_get_padding ( widget, "padding", widget->def_padding ); widget->padding = rofi_theme_get_padding ( widget, "padding", widget->def_padding );
widget->border = rofi_theme_get_padding ( widget, "border", widget->def_border ); widget->border = rofi_theme_get_padding ( widget, "border", widget->def_border );

View file

@ -222,12 +222,12 @@ START_TEST ( test_properties_distance_em)
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { test: 10em;}"); rofi_theme_parse_string ( "* { test: 10em;}");
ck_assert_ptr_nonnull ( rofi_theme ); ck_assert_ptr_nonnull ( rofi_theme );
Distance d = (Distance){ 1, PW_PX, SOLID}; Distance d = (Distance){ 1, ROFI_PU_PX, ROFI_HL_SOLID};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "test", pi); Padding p = rofi_theme_get_padding ( &wid, "test", pi);
ck_assert_int_eq ( p.left.distance , 10 ); ck_assert_int_eq ( p.left.distance , 10 );
ck_assert_int_eq( p.left.type , PW_EM ); ck_assert_int_eq( p.left.type , ROFI_PU_EM );
ck_assert_int_eq( p.left.style, SOLID); ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
} }
END_TEST END_TEST
@ -238,17 +238,17 @@ START_TEST ( test_properties_distance_em_linestyle)
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { sol: 1.3em solid; dash: 1.5em dash;}"); rofi_theme_parse_string ( "* { sol: 1.3em solid; dash: 1.5em dash;}");
ck_assert_ptr_nonnull ( rofi_theme ); ck_assert_ptr_nonnull ( rofi_theme );
Distance d = (Distance){ 1, PW_PX, SOLID}; Distance d = (Distance){ 1, ROFI_PU_PX, ROFI_HL_SOLID};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "sol", pi); Padding p = rofi_theme_get_padding ( &wid, "sol", pi);
ck_assert_double_eq ( p.left.distance , 1.3 ); ck_assert_double_eq ( p.left.distance , 1.3 );
ck_assert_int_eq( p.left.type , PW_EM ); ck_assert_int_eq( p.left.type , ROFI_PU_EM );
ck_assert_int_eq( p.left.style, SOLID); ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding ( &wid, "dash", pi); p = rofi_theme_get_padding ( &wid, "dash", pi);
ck_assert_double_eq ( p.left.distance , 1.5 ); ck_assert_double_eq ( p.left.distance , 1.5 );
ck_assert_int_eq( p.left.type , PW_EM ); ck_assert_int_eq( p.left.type , ROFI_PU_EM );
ck_assert_int_eq( p.left.style, DASH); ck_assert_int_eq( p.left.style, ROFI_HL_DASH);
} }
END_TEST END_TEST
START_TEST ( test_properties_distance_px) START_TEST ( test_properties_distance_px)
@ -258,12 +258,12 @@ START_TEST ( test_properties_distance_px)
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { test: 10px;}"); rofi_theme_parse_string ( "* { test: 10px;}");
ck_assert_ptr_nonnull ( rofi_theme ); ck_assert_ptr_nonnull ( rofi_theme );
Distance d = (Distance){ 1, PW_EM, DASH}; Distance d = (Distance){ 1, ROFI_PU_EM, ROFI_HL_DASH};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "test", pi); Padding p = rofi_theme_get_padding ( &wid, "test", pi);
ck_assert_double_eq ( p.left.distance , 10.0 ); ck_assert_double_eq ( p.left.distance , 10.0 );
ck_assert_int_eq( p.left.type , PW_PX ); ck_assert_int_eq( p.left.type , ROFI_PU_PX );
ck_assert_int_eq( p.left.style, SOLID); ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
} }
END_TEST END_TEST
START_TEST ( test_properties_distance_px_linestyle) START_TEST ( test_properties_distance_px_linestyle)
@ -273,16 +273,16 @@ START_TEST ( test_properties_distance_px_linestyle)
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { sol: 10px solid; dash: 14px dash;}"); rofi_theme_parse_string ( "* { sol: 10px solid; dash: 14px dash;}");
ck_assert_ptr_nonnull ( rofi_theme ); ck_assert_ptr_nonnull ( rofi_theme );
Distance d = (Distance){ 1, PW_EM, DASH}; Distance d = (Distance){ 1, ROFI_PU_EM, ROFI_HL_DASH};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "sol", pi); Padding p = rofi_theme_get_padding ( &wid, "sol", pi);
ck_assert_double_eq ( p.left.distance , 10.0 ); ck_assert_double_eq ( p.left.distance , 10.0 );
ck_assert_int_eq( p.left.type , PW_PX ); ck_assert_int_eq( p.left.type , ROFI_PU_PX );
ck_assert_int_eq( p.left.style, SOLID); ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding ( &wid, "dash", pi); p = rofi_theme_get_padding ( &wid, "dash", pi);
ck_assert_double_eq ( p.left.distance , 14.0 ); ck_assert_double_eq ( p.left.distance , 14.0 );
ck_assert_int_eq( p.left.type , PW_PX ); ck_assert_int_eq( p.left.type , ROFI_PU_PX );
ck_assert_int_eq( p.left.style, DASH); ck_assert_int_eq( p.left.style, ROFI_HL_DASH);
} }
END_TEST END_TEST
START_TEST ( test_properties_distance_percent) START_TEST ( test_properties_distance_percent)
@ -292,12 +292,12 @@ START_TEST ( test_properties_distance_percent)
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { test: 10%;}"); rofi_theme_parse_string ( "* { test: 10%;}");
ck_assert_ptr_nonnull ( rofi_theme ); ck_assert_ptr_nonnull ( rofi_theme );
Distance d = (Distance){ 1, PW_EM, DASH}; Distance d = (Distance){ 1, ROFI_PU_EM, ROFI_HL_DASH};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "test", pi); Padding p = rofi_theme_get_padding ( &wid, "test", pi);
ck_assert_double_eq ( p.left.distance , 10.0 ); ck_assert_double_eq ( p.left.distance , 10.0 );
ck_assert_int_eq( p.left.type , PW_PERCENT); ck_assert_int_eq( p.left.type , ROFI_PU_PERCENT);
ck_assert_int_eq( p.left.style, SOLID); ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
} }
END_TEST END_TEST
START_TEST ( test_properties_distance_percent_linestyle) START_TEST ( test_properties_distance_percent_linestyle)
@ -307,16 +307,16 @@ START_TEST ( test_properties_distance_percent_linestyle)
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { sol: 10% solid; dash: 10% dash;}"); rofi_theme_parse_string ( "* { sol: 10% solid; dash: 10% dash;}");
ck_assert_ptr_nonnull ( rofi_theme ); ck_assert_ptr_nonnull ( rofi_theme );
Distance d = (Distance){ 1, PW_EM, DASH}; Distance d = (Distance){ 1, ROFI_PU_EM, ROFI_HL_DASH};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "sol", pi); Padding p = rofi_theme_get_padding ( &wid, "sol", pi);
ck_assert_double_eq ( p.left.distance , 10.0 ); ck_assert_double_eq ( p.left.distance , 10.0 );
ck_assert_int_eq( p.left.type , PW_PERCENT); ck_assert_int_eq( p.left.type , ROFI_PU_PERCENT);
ck_assert_int_eq( p.left.style, SOLID); ck_assert_int_eq( p.left.style, ROFI_HL_SOLID);
p = rofi_theme_get_padding ( &wid, "dash", pi); p = rofi_theme_get_padding ( &wid, "dash", pi);
ck_assert_double_eq ( p.left.distance , 10 ); ck_assert_double_eq ( p.left.distance , 10 );
ck_assert_int_eq( p.left.type , PW_PERCENT); ck_assert_int_eq( p.left.type , ROFI_PU_PERCENT);
ck_assert_int_eq( p.left.style, DASH); ck_assert_int_eq( p.left.style, ROFI_HL_DASH);
} }
END_TEST END_TEST
START_TEST ( test_properties_position) START_TEST ( test_properties_position)
@ -961,17 +961,17 @@ START_TEST ( test_properties_padding_2 )
wid.name = "blaat"; wid.name = "blaat";
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { test: 10px 20px;}"); rofi_theme_parse_string ( "* { test: 10px 20px;}");
Distance d = (Distance){ 1, PW_PX, SOLID}; Distance d = (Distance){ 1, ROFI_PU_PX, ROFI_HL_SOLID};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "test", pi); Padding p = rofi_theme_get_padding ( &wid, "test", pi);
ck_assert_double_eq ( p.left.distance , 20 ); ck_assert_double_eq ( p.left.distance , 20 );
ck_assert_int_eq ( p.left.type , PW_PX ); ck_assert_int_eq ( p.left.type , ROFI_PU_PX );
ck_assert_double_eq ( p.right.distance , 20 ); ck_assert_double_eq ( p.right.distance , 20 );
ck_assert_int_eq ( p.right.type , PW_PX ); ck_assert_int_eq ( p.right.type , ROFI_PU_PX );
ck_assert_double_eq ( p.top.distance , 10 ); ck_assert_double_eq ( p.top.distance , 10 );
ck_assert_int_eq ( p.top.type , PW_PX ); ck_assert_int_eq ( p.top.type , ROFI_PU_PX );
ck_assert_double_eq ( p.bottom.distance , 10 ); ck_assert_double_eq ( p.bottom.distance , 10 );
ck_assert_int_eq ( p.bottom.type , PW_PX ); ck_assert_int_eq ( p.bottom.type , ROFI_PU_PX );
} }
END_TEST END_TEST
@ -981,17 +981,17 @@ START_TEST ( test_properties_padding_3 )
wid.name = "blaat"; wid.name = "blaat";
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { test: 10px 30px 20px;}"); rofi_theme_parse_string ( "* { test: 10px 30px 20px;}");
Distance d = (Distance){ 1, PW_PX, SOLID}; Distance d = (Distance){ 1, ROFI_PU_PX, ROFI_HL_SOLID};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "test", pi); Padding p = rofi_theme_get_padding ( &wid, "test", pi);
ck_assert_double_eq ( p.left.distance , 30 ); ck_assert_double_eq ( p.left.distance , 30 );
ck_assert_int_eq ( p.left.type , PW_PX ); ck_assert_int_eq ( p.left.type , ROFI_PU_PX );
ck_assert_double_eq ( p.right.distance , 30 ); ck_assert_double_eq ( p.right.distance , 30 );
ck_assert_int_eq ( p.right.type , PW_PX ); ck_assert_int_eq ( p.right.type , ROFI_PU_PX );
ck_assert_double_eq ( p.top.distance , 10 ); ck_assert_double_eq ( p.top.distance , 10 );
ck_assert_int_eq ( p.top.type , PW_PX ); ck_assert_int_eq ( p.top.type , ROFI_PU_PX );
ck_assert_double_eq ( p.bottom.distance , 20 ); ck_assert_double_eq ( p.bottom.distance , 20 );
ck_assert_int_eq ( p.bottom.type , PW_PX ); ck_assert_int_eq ( p.bottom.type , ROFI_PU_PX );
} }
END_TEST END_TEST
@ -1001,17 +1001,17 @@ START_TEST ( test_properties_padding_4 )
wid.name = "blaat"; wid.name = "blaat";
wid.state = NULL; wid.state = NULL;
rofi_theme_parse_string ( "* { test: 10px 30px 20px 40px;}"); rofi_theme_parse_string ( "* { test: 10px 30px 20px 40px;}");
Distance d = (Distance){ 1, PW_PX, SOLID}; Distance d = (Distance){ 1, ROFI_PU_PX, ROFI_HL_SOLID};
Padding pi = (Padding){d,d,d,d}; Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "test", pi); Padding p = rofi_theme_get_padding ( &wid, "test", pi);
ck_assert_double_eq ( p.left.distance , 40 ); ck_assert_double_eq ( p.left.distance , 40 );
ck_assert_int_eq ( p.left.type , PW_PX ); ck_assert_int_eq ( p.left.type , ROFI_PU_PX );
ck_assert_double_eq ( p.right.distance , 30 ); ck_assert_double_eq ( p.right.distance , 30 );
ck_assert_int_eq ( p.right.type , PW_PX ); ck_assert_int_eq ( p.right.type , ROFI_PU_PX );
ck_assert_double_eq ( p.top.distance , 10 ); ck_assert_double_eq ( p.top.distance , 10 );
ck_assert_int_eq ( p.top.type , PW_PX ); ck_assert_int_eq ( p.top.type , ROFI_PU_PX );
ck_assert_double_eq ( p.bottom.distance , 20 ); ck_assert_double_eq ( p.bottom.distance , 20 );
ck_assert_int_eq ( p.bottom.type , PW_PX ); ck_assert_int_eq ( p.bottom.type , ROFI_PU_PX );
} }
END_TEST END_TEST