[gtk/css-overline] css: Support overline
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/css-overline] css: Support overline
- Date: Tue, 26 Jan 2021 05:05:05 +0000 (UTC)
commit 65a4118d507838d00f95099007a2c8b9d1609967
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 26 00:04:04 2021 -0500
css: Support overline
We can support text-decoration-line: overline,
since pango supports it now.
docs/reference/gtk/css-properties.md | 2 +-
gtk/gtkcssenumvalue.c | 1 +
gtk/gtkcssstyle.c | 13 +++++++++++++
gtk/gtkcsstypesprivate.h | 1 +
4 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/gtk/css-properties.md b/docs/reference/gtk/css-properties.md
index e50f577650..96fb3be0e0 100644
--- a/docs/reference/gtk/css-properties.md
+++ b/docs/reference/gtk/css-properties.md
@@ -151,7 +151,7 @@ done with
|caret-color|[CSS Basic User Interface Level 3](https://www.w3.org/TR/css3-ui/#caret-color) | CSS allows an
auto value |
|-gtk-secondary-caret-color|[Color](https://www.w3.org/TR/css-color-3/#valuea-def-color) | used for the
secondary caret in bidirectional text |
|letter-spacing| [CSS Text Level 3](https://www.w3.org/TR/css3-text/#letter-spacing) | |
-|text-decoration-line| [CSS Text Decoration Level
3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | CSS allows overline |
+|text-decoration-line| [CSS Text Decoration Level
3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-line-property) | |
|text-decoration-color| [CSS Text Decoration Level
3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-color-property) | |
|text-decoration-style| [CSS Text Decoration Level
3](https://www.w3.org/TR/css-text-decor-3/#text-decoration-style-property) | CSS allows dashed and dotted |
|text-shadow| [CSS Text Decoration Level 3](https://www.w3.org/TR/css-text-decor-3/#text-shadow-property) | |
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index 9bd29e3742..6a9b4bfec7 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -561,6 +561,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_LINE = {
static GtkCssValue text_decoration_line_values[] = {
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_NONE, "none" },
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE, "underline" },
+ { >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_OVERLINE, "overline" },
{ >K_CSS_VALUE_TEXT_DECORATION_LINE, 1, TRUE, GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH, "line-through"
},
};
diff --git a/gtk/gtkcssstyle.c b/gtk/gtkcssstyle.c
index 5d5fc2b44f..ee6f9c44c5 100644
--- a/gtk/gtkcssstyle.c
+++ b/gtk/gtkcssstyle.c
@@ -397,6 +397,12 @@ get_pango_underline_from_style (GtkTextDecorationStyle style)
g_return_val_if_reached (PANGO_UNDERLINE_SINGLE);
}
+static PangoOverline
+get_pango_overline_from_style (GtkTextDecorationStyle style)
+{
+ return PANGO_OVERLINE_SINGLE;
+}
+
static PangoAttrList *
add_pango_attr (PangoAttrList *attrs,
PangoAttribute *attr)
@@ -454,6 +460,13 @@ gtk_css_style_get_pango_attributes (GtkCssStyle *style)
decoration_color->green * 65535. +
0.5,
decoration_color->blue * 65535. +
0.5));
break;
+ case GTK_CSS_TEXT_DECORATION_LINE_OVERLINE:
+ attrs = add_pango_attr (attrs, pango_attr_overline_new (get_pango_overline_from_style
(decoration_style)));
+ if (!gdk_rgba_equal (color, decoration_color))
+ attrs = add_pango_attr (attrs, pango_attr_overline_color_new (decoration_color->red * 65535. + 0.5,
+ decoration_color->green * 65535. + 0.5,
+ decoration_color->blue * 65535. +
0.5));
+ break;
case GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH:
attrs = add_pango_attr (attrs, pango_attr_strikethrough_new (TRUE));
if (!gdk_rgba_equal (color, decoration_color))
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index fe30beaae1..efb54a5561 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -327,6 +327,7 @@ typedef enum /*< skip >*/ {
typedef enum /*< skip >*/ {
GTK_CSS_TEXT_DECORATION_LINE_NONE,
GTK_CSS_TEXT_DECORATION_LINE_UNDERLINE,
+ GTK_CSS_TEXT_DECORATION_LINE_OVERLINE,
GTK_CSS_TEXT_DECORATION_LINE_LINE_THROUGH
} GtkTextDecorationLine;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]