summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2021-06-14 16:04:15 +0200
committerDave Davenport <qball@blame.services>2021-06-14 16:04:15 +0200
commit828aaa231a84f9ad23cf836a71b58290b5e217e8 (patch)
treeea06ac8d677f59a36a162ae4ecf2bd605cc39296
parent5c5428bd11b87a336174398194062f7d3901daf6 (diff)
[Theme] Add angle support to linear-gradient.
-rw-r--r--doc/rofi-theme.53
-rw-r--r--doc/rofi-theme.5.markdown2
-rw-r--r--include/rofi-types.h2
-rw-r--r--lexer/theme-parser.y8
-rw-r--r--source/theme.c9
5 files changed, 24 insertions, 0 deletions
diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5
index ec5d49ce..c089fdfe 100644
--- a/doc/rofi-theme.5
+++ b/doc/rofi-theme.5
@@ -370,6 +370,9 @@ Format: linear\-gradient(stop color,stop1, color, stop2 color, ...);
.IP \(bu 2
Format: linear\-gradient(to direction, stop color,stop1, color, stop2 color, ...);
where direction is: top,left,right,bottom.
+.IP \(bu 2
+Format: linear\-gradient(angle, stop color,stop1, color, stop2 color, ...);
+Angle in deg,rad,grad (as used in color).
.PP
Where the path is a string, and stop color is of type color.
diff --git a/doc/rofi-theme.5.markdown b/doc/rofi-theme.5.markdown
index 5dc72de9..336f4cc5 100644
--- a/doc/rofi-theme.5.markdown
+++ b/doc/rofi-theme.5.markdown
@@ -258,6 +258,8 @@ dynamic: false;
* Format: linear-gradient(stop color,stop1, color, stop2 color, ...);
* Format: linear-gradient(to direction, stop color,stop1, color, stop2 color, ...);
where direction is: top,left,right,bottom.
+* Format: linear-gradient(angle, stop color,stop1, color, stop2 color, ...);
+ Angle in deg,rad,grad (as used in color).
Where the path is a string, and stop color is of type color.
diff --git a/include/rofi-types.h b/include/rofi-types.h
index b7d57898..7e0794d3 100644
--- a/include/rofi-types.h
+++ b/include/rofi-types.h
@@ -185,6 +185,7 @@ typedef enum
ROFI_DIRECTION_RIGHT,
ROFI_DIRECTION_TOP,
ROFI_DIRECTION_BOTTOM,
+ ROFI_DIRECTION_ANGLE,
} RofiDirection;
@@ -194,6 +195,7 @@ typedef struct
char *url;
RofiDirection dir;
+ double angle;
/** colors */
GList *colors;
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index 5fb304c7..94bf3cd3 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -556,6 +556,14 @@ t_property_element
$$->value.image.dir = $4;
$$->value.image.colors = $6;
}
+| T_LINEAR_GRADIENT T_PARENT_LEFT t_property_color_value_angle T_COMMA t_color_list T_PARENT_RIGHT {
+ $$ = rofi_theme_property_create ( P_IMAGE );
+ $$->value.image.type = ROFI_IMAGE_LINEAR_GRADIENT;
+ $$->value.image.dir = ROFI_DIRECTION_ANGLE;
+ $$->value.image.angle = $3;
+ $$->value.image.colors = $5;
+}
+
;
t_property_direction
diff --git a/source/theme.c b/source/theme.c
index 219daf4f..f70f0c45 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -1015,6 +1015,15 @@ gboolean rofi_theme_get_image ( const widget *widget, const char *property, cair
case ROFI_DIRECTION_TOP:
pat = cairo_pattern_create_linear (0.0,widget->h, 0.0, 0.0);
break;
+ case ROFI_DIRECTION_ANGLE:
+ {
+ double offsety1 = sin(G_PI*2*p->value.image.angle)*(widget->h/2.0);
+ double offsetx1 = cos(G_PI*2*p->value.image.angle)*(widget->w/2.0);
+ pat = cairo_pattern_create_linear (
+ widget->w/2.0 - offsetx1, widget->h/2.0 - offsety1,
+ widget->w/2.0 + offsetx1, widget->h/2.0 + offsety1 );
+ break;
+ }
};
guint length = g_list_length ( p->value.image.colors );
if ( length > 1 ){