Compare commits
1 Commits
css-light-
...
css-render
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1050ca63a6 |
34
NEWS
34
NEWS
@@ -1,40 +1,6 @@
|
||||
Overview of Changes in 4.15.2, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
* GtkFileChooserWidget:
|
||||
- Plug some memory leaks
|
||||
- Make Ctrl-Shift-N create a new folder
|
||||
|
||||
* CSS:
|
||||
- Support color(), oklab(), etc (https://www.w3.org/TR/css-color-4/)
|
||||
- Support color-mix() (https://www.w3.org/TR/css-color-5/)
|
||||
- Support relative colors (https://www.w3.org/TR/css-color-5/)
|
||||
|
||||
* Accessibility:
|
||||
- Avoid markup when reading labels
|
||||
|
||||
* GSK:
|
||||
- Subset fonts when serializing node trees
|
||||
|
||||
* Wayland:
|
||||
- Use xdg-dialog protocol for attached dialogs
|
||||
|
||||
* Windows:
|
||||
- Build with UNICODE
|
||||
|
||||
* Debugging:
|
||||
- Add GTK_DEBUG=css for warning about deprecated css syntax
|
||||
|
||||
* Tools:
|
||||
- nodeparser: Add an extract command for data urls
|
||||
|
||||
* Deprecations:
|
||||
- CSS Color functions shade(), lighter(), darker(), alpha(), mix()
|
||||
|
||||
* Translation updates:
|
||||
Hebrew
|
||||
|
||||
|
||||
Overview of Changes in 4.15.1, 21-05-2024
|
||||
=========================================
|
||||
|
||||
|
||||
@@ -93,12 +93,11 @@ Colors can be expressed in numerous ways in CSS (see the
|
||||
many (but not all) of these.
|
||||
|
||||
You can use rgb(), rgba(), hsl() with both the legacy or the modern CSS
|
||||
syntax, and calc() can be used as well in color expressions. hwb(), oklab(),
|
||||
oklch(), color(), color-mix() and relative colors are supported as well.
|
||||
syntax, and calc() can be used as well in color expressions.
|
||||
|
||||
### Non-CSS Colors
|
||||
|
||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||
|
||||
These extensions are deprecated and should be replaced by the equivalent
|
||||
standard CSS notions.
|
||||
|
||||
@@ -18,7 +18,6 @@ SYNOPSIS
|
||||
|
|
||||
| **gtk4-rendernode-tool** benchmark [OPTIONS...] <FILE>
|
||||
| **gtk4-rendernode-tool** compare [OPTIONS...] <FILE1> <FILE2>
|
||||
| **gtk4-rendernode-tool** extract [OPTIONS...] <FILE>
|
||||
| **gtk4-rendernode-tool** info [OPTIONS...] <FILE>
|
||||
| **gtk4-rendernode-tool** render [OPTIONS...] <FILE> [<FILE>]
|
||||
| **gtk4-rendernode-tool** show [OPTIONS...] <FILE>
|
||||
@@ -100,15 +99,3 @@ exit code is 1. If the images are identical, it is 0.
|
||||
``--quiet``
|
||||
|
||||
Don't write results to stdout.
|
||||
|
||||
|
||||
Extract
|
||||
^^^^^^^
|
||||
|
||||
The ``extract`` command saves all the data urls found in a node file to a given
|
||||
directory. The file names for the extracted files are derived from the mimetype
|
||||
of the url.
|
||||
|
||||
``--dir=DIRECTORY``
|
||||
|
||||
Save extracted files in ``DIRECTORY`` (defaults to the current directory).
|
||||
|
||||
@@ -77,7 +77,6 @@ content_files = [
|
||||
"section-tree-widget.md",
|
||||
"migrating-2to4.md",
|
||||
"migrating-3to4.md",
|
||||
"migrating-4to5.md",
|
||||
"broadway.md",
|
||||
"osx.md",
|
||||
"wayland.md",
|
||||
|
||||
@@ -14,7 +14,6 @@ expand_content_md_files = [
|
||||
'running.md',
|
||||
'migrating-2to4.md',
|
||||
'migrating-3to4.md',
|
||||
'migrating-4to5.md',
|
||||
'actions.md',
|
||||
'input-handling.md',
|
||||
'drawing-model.md',
|
||||
|
||||
@@ -58,7 +58,7 @@ use a GtkLabel.
|
||||
If you have a need for custom drawing that fits into the current
|
||||
(dark or light) theme, e.g. for rendering a graph, you can still
|
||||
get the current style foreground color, using
|
||||
[method@Gtk.Widget.get_color].
|
||||
[method@Gtk.Widget.get_style_color].
|
||||
|
||||
## Local stylesheets are going away
|
||||
|
||||
@@ -73,103 +73,6 @@ GTK 5 will no longer provide this functionality. The recommendations
|
||||
is to use a global stylesheet (i.e. gtk_style_context_add_provider_for_display())
|
||||
and rely on style classes to make your CSS apply only where desired.
|
||||
|
||||
## Non-standard CSS extensions are going away
|
||||
|
||||
GTK's CSS machinery has a some non-standard extensions around colors:
|
||||
named colors with \@define-color and color functions: lighter(), darker(),
|
||||
shade(), alpha(), mix().
|
||||
|
||||
GTK now implements equivalent functionality from the CSS specs.
|
||||
|
||||
### \@define-color is going away
|
||||
|
||||
\@define-color should be replaced by custom properties in the :root scope.
|
||||
|
||||
Instead of
|
||||
|
||||
```
|
||||
@define-color fg_color #2e3436
|
||||
|
||||
...
|
||||
|
||||
box {
|
||||
color: @fg_color;
|
||||
}
|
||||
```
|
||||
|
||||
use
|
||||
|
||||
```
|
||||
:root {
|
||||
--fg-color: #2e3436;
|
||||
}
|
||||
|
||||
...
|
||||
|
||||
box {
|
||||
color: var(--fg-color);
|
||||
}
|
||||
```
|
||||
|
||||
For more information about custom CSS properties and variables, see the
|
||||
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1/)
|
||||
spec.
|
||||
|
||||
### Color expressions are going away
|
||||
|
||||
The color functions can all be replaced by combinations of calc() and color-mix().
|
||||
|
||||
ligher(c) and darker(c) are just shade(c, 1.3) or shade(c, 0.7), respectively, and
|
||||
thus can be handled the same way as shade in the examples below.
|
||||
|
||||
Replace
|
||||
|
||||
```
|
||||
a {
|
||||
color: mix(red, green, 0.8);
|
||||
}
|
||||
|
||||
b {
|
||||
color: alpha(green, 0.6);
|
||||
}
|
||||
|
||||
c {
|
||||
color: shade(red, 1.3);
|
||||
}
|
||||
|
||||
d {
|
||||
color: shade(red, 0.7);
|
||||
}
|
||||
```
|
||||
|
||||
with
|
||||
|
||||
```
|
||||
a {
|
||||
color: color-mix(in srgb, red, green 80%);
|
||||
}
|
||||
|
||||
b {
|
||||
color: rgb(from green, r g b / calc(alpha * 0.6));
|
||||
}
|
||||
|
||||
c {
|
||||
color: hsl(from red, h calc(s * 1.3) calc(l * 1.3));
|
||||
}
|
||||
|
||||
d {
|
||||
color: hsl(from red, h calc(s * 0.7) calc(l * 0.7));
|
||||
}
|
||||
```
|
||||
|
||||
Variations of these replacements are possible.
|
||||
|
||||
Note that GTK has historically computed mix() and shade() values in the SRGB and HSL
|
||||
colorspaces, but using OKLAB instead might yield slightly better results.
|
||||
|
||||
For more information about color-mix(), see the
|
||||
[CSS Color](https://drafts.csswg.org/css-color-5) spec.
|
||||
|
||||
## Chooser interfaces are going away
|
||||
|
||||
The GtkColorChooser, GtkFontChooser, GtkFileChooser and GtkAppChooser
|
||||
|
||||
@@ -3866,25 +3866,9 @@ pointer_surface_leave (void *data,
|
||||
pointer_surface_update_scale (device);
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_surface_preferred_buffer_scale (void *data,
|
||||
struct wl_surface *wl_surface,
|
||||
int32_t factor)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_surface_preferred_buffer_transform (void *data,
|
||||
struct wl_surface *wl_surface,
|
||||
uint32_t transform)
|
||||
{
|
||||
}
|
||||
|
||||
static const struct wl_surface_listener pointer_surface_listener = {
|
||||
pointer_surface_enter,
|
||||
pointer_surface_leave,
|
||||
pointer_surface_preferred_buffer_scale,
|
||||
pointer_surface_preferred_buffer_transform,
|
||||
pointer_surface_leave
|
||||
};
|
||||
|
||||
static void
|
||||
|
||||
@@ -679,16 +679,9 @@ vulkan_supported_platform (GdkSurface *surface,
|
||||
if (props.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU)
|
||||
{
|
||||
if (!as_fallback)
|
||||
GSK_DEBUG (RENDERER, "Not using '%s': device is CPU", g_type_name (renderer_type));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gdk_display_init_dmabuf (display);
|
||||
if (!display->vk_dmabuf_formats ||
|
||||
gdk_dmabuf_formats_get_n_formats (display->vk_dmabuf_formats) == 0)
|
||||
{
|
||||
if (!as_fallback)
|
||||
GSK_DEBUG (RENDERER, "Not using '%s': no dmabuf support", g_type_name (renderer_type));
|
||||
GSK_DEBUG (RENDERER,
|
||||
"Not using '%s': device is CPU",
|
||||
g_type_name (renderer_type));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,6 @@
|
||||
#include <pango/pangofc-fontmap.h>
|
||||
#endif
|
||||
|
||||
#include <hb-subset.h>
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
typedef struct _Context Context;
|
||||
@@ -948,22 +946,23 @@ create_ascii_glyphs (PangoFont *font)
|
||||
PangoGlyphString *result, *glyph_string;
|
||||
guint i;
|
||||
|
||||
result = pango_glyph_string_new ();
|
||||
|
||||
coverage = pango_font_get_coverage (font, language);
|
||||
for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++)
|
||||
{
|
||||
if (!pango_coverage_get (coverage, i))
|
||||
break;
|
||||
}
|
||||
g_object_unref (coverage);
|
||||
if (i < MAX_ASCII_GLYPH)
|
||||
return NULL;
|
||||
|
||||
result = pango_glyph_string_new ();
|
||||
pango_glyph_string_set_size (result, N_ASCII_GLYPHS);
|
||||
glyph_string = pango_glyph_string_new ();
|
||||
for (i = MIN_ASCII_GLYPH; i < MAX_ASCII_GLYPH; i++)
|
||||
{
|
||||
const char text[2] = { i, 0 };
|
||||
|
||||
if (!pango_coverage_get (coverage, i))
|
||||
{
|
||||
result->glyphs[i - MIN_ASCII_GLYPH].glyph = PANGO_GLYPH_INVALID_INPUT;
|
||||
continue;
|
||||
}
|
||||
|
||||
pango_shape_with_flags (text, 1,
|
||||
text, 1,
|
||||
¬_a_hack,
|
||||
@@ -971,13 +970,14 @@ create_ascii_glyphs (PangoFont *font)
|
||||
PANGO_SHAPE_NONE);
|
||||
|
||||
if (glyph_string->num_glyphs != 1)
|
||||
result->glyphs[i - MIN_ASCII_GLYPH].glyph = PANGO_GLYPH_INVALID_INPUT;
|
||||
else
|
||||
result->glyphs[i - MIN_ASCII_GLYPH] = glyph_string->glyphs[0];
|
||||
{
|
||||
pango_glyph_string_free (glyph_string);
|
||||
pango_glyph_string_free (result);
|
||||
return NULL;
|
||||
}
|
||||
result->glyphs[i - MIN_ASCII_GLYPH] = glyph_string->glyphs[0];
|
||||
}
|
||||
|
||||
g_object_unref (coverage);
|
||||
|
||||
pango_glyph_string_free (glyph_string);
|
||||
|
||||
return result;
|
||||
@@ -1113,70 +1113,81 @@ parse_font (GtkCssParser *parser,
|
||||
if (font_name == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (context->fontmap)
|
||||
font = font_from_string (context->fontmap, font_name, FALSE);
|
||||
|
||||
if (gtk_css_parser_has_url (parser))
|
||||
{
|
||||
char *url;
|
||||
char *scheme;
|
||||
GBytes *bytes;
|
||||
GError *error = NULL;
|
||||
GtkCssLocation start_location;
|
||||
gboolean success = FALSE;
|
||||
|
||||
start_location = *gtk_css_parser_get_start_location (parser);
|
||||
url = gtk_css_parser_consume_url (parser);
|
||||
|
||||
if (url != NULL)
|
||||
if (font != NULL)
|
||||
{
|
||||
scheme = g_uri_parse_scheme (url);
|
||||
if (scheme && g_ascii_strcasecmp (scheme, "data") == 0)
|
||||
{
|
||||
bytes = gtk_css_data_url_parse (url, NULL, &error);
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = g_file_new_for_uri (url);
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, &error);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_free (scheme);
|
||||
gtk_css_parser_error_value (parser, "A font with this name already exists.");
|
||||
/* consume the url to avoid more errors */
|
||||
url = gtk_css_parser_consume_url (parser);
|
||||
g_free (url);
|
||||
if (bytes != NULL)
|
||||
{
|
||||
success = add_font_from_bytes (context, bytes, &error);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
gtk_css_parser_emit_error (parser,
|
||||
&start_location,
|
||||
gtk_css_parser_get_end_location (parser),
|
||||
error);
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
else
|
||||
{
|
||||
font = font_from_string (context->fontmap, font_name, FALSE);
|
||||
if (!font)
|
||||
char *scheme;
|
||||
GBytes *bytes;
|
||||
GError *error = NULL;
|
||||
GtkCssLocation start_location;
|
||||
gboolean success = FALSE;
|
||||
|
||||
start_location = *gtk_css_parser_get_start_location (parser);
|
||||
url = gtk_css_parser_consume_url (parser);
|
||||
|
||||
if (url != NULL)
|
||||
{
|
||||
gtk_css_parser_error (parser,
|
||||
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
|
||||
&start_location,
|
||||
gtk_css_parser_get_end_location (parser),
|
||||
"The given url does not define a font named \"%s\"",
|
||||
font_name);
|
||||
scheme = g_uri_parse_scheme (url);
|
||||
if (scheme && g_ascii_strcasecmp (scheme, "data") == 0)
|
||||
{
|
||||
bytes = gtk_css_data_url_parse (url, NULL, &error);
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
file = g_file_new_for_uri (url);
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, &error);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_free (scheme);
|
||||
g_free (url);
|
||||
if (bytes != NULL)
|
||||
{
|
||||
success = add_font_from_bytes (context, bytes, &error);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
gtk_css_parser_emit_error (parser,
|
||||
&start_location,
|
||||
gtk_css_parser_get_end_location (parser),
|
||||
error);
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
font = font_from_string (context->fontmap, font_name, FALSE);
|
||||
if (!font)
|
||||
{
|
||||
gtk_css_parser_error (parser,
|
||||
GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE,
|
||||
&start_location,
|
||||
gtk_css_parser_get_end_location (parser),
|
||||
"The given url does not define a font named \"%s\"",
|
||||
font_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context->fontmap)
|
||||
font = font_from_string (context->fontmap, font_name, FALSE);
|
||||
|
||||
if (!font)
|
||||
font = font_from_string (pango_cairo_font_map_get_default (), font_name, TRUE);
|
||||
|
||||
@@ -2244,12 +2255,6 @@ unpack_glyphs (PangoFont *font,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ascii->glyphs[idx].glyph == PANGO_GLYPH_INVALID_INPUT)
|
||||
{
|
||||
g_clear_pointer (&ascii, pango_glyph_string_free);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gi->glyph = ascii->glyphs[idx].glyph;
|
||||
gi->geometry.width = ascii->glyphs[idx].geometry.width;
|
||||
}
|
||||
@@ -2941,7 +2946,7 @@ typedef struct
|
||||
gsize named_node_counter;
|
||||
GHashTable *named_textures;
|
||||
gsize named_texture_counter;
|
||||
GHashTable *fonts;
|
||||
GHashTable *serialized_fonts;
|
||||
} Printer;
|
||||
|
||||
static void
|
||||
@@ -2956,59 +2961,6 @@ printer_init_check_texture (Printer *printer,
|
||||
g_hash_table_insert (printer->named_textures, texture, g_strdup (""));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
hb_face_t *face;
|
||||
hb_subset_input_t *input;
|
||||
gboolean serialized;
|
||||
} FontInfo;
|
||||
|
||||
static void
|
||||
font_info_free (gpointer data)
|
||||
{
|
||||
FontInfo *info = (FontInfo *) data;
|
||||
|
||||
hb_face_destroy (info->face);
|
||||
if (info->input)
|
||||
hb_subset_input_destroy (info->input);
|
||||
g_free (info);
|
||||
}
|
||||
|
||||
static void
|
||||
printer_init_collect_font_info (Printer *printer,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
PangoFont *font;
|
||||
FontInfo *info;
|
||||
|
||||
font = gsk_text_node_get_font (node);
|
||||
|
||||
info = (FontInfo *) g_hash_table_lookup (printer->fonts, hb_font_get_face (pango_font_get_hb_font (font)));
|
||||
if (!info)
|
||||
{
|
||||
info = g_new0 (FontInfo, 1);
|
||||
|
||||
info->face = hb_face_reference (hb_font_get_face (pango_font_get_hb_font (font)));
|
||||
if (!g_object_get_data (G_OBJECT (pango_font_get_font_map (font)), "font-files"))
|
||||
{
|
||||
info->input = hb_subset_input_create_or_fail ();
|
||||
hb_subset_input_set_flags (info->input, HB_SUBSET_FLAGS_RETAIN_GIDS);
|
||||
}
|
||||
|
||||
g_hash_table_insert (printer->fonts, info->face, info);
|
||||
}
|
||||
|
||||
if (info->input)
|
||||
{
|
||||
const PangoGlyphInfo *glyphs;
|
||||
guint n_glyphs;
|
||||
|
||||
glyphs = gsk_text_node_get_glyphs (node, &n_glyphs);
|
||||
|
||||
for (guint i = 0; i < n_glyphs; i++)
|
||||
hb_set_add (hb_subset_input_glyph_set (info->input), glyphs[i].glyph);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
printer_init_duplicates_for_node (Printer *printer,
|
||||
GskRenderNode *node)
|
||||
@@ -3024,9 +2976,6 @@ printer_init_duplicates_for_node (Printer *printer,
|
||||
{
|
||||
case GSK_CAIRO_NODE:
|
||||
case GSK_TEXT_NODE:
|
||||
printer_init_collect_font_info (printer, node);
|
||||
break;
|
||||
|
||||
case GSK_COLOR_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
@@ -3150,7 +3099,7 @@ printer_init (Printer *self,
|
||||
self->named_node_counter = 0;
|
||||
self->named_textures = g_hash_table_new_full (NULL, NULL, NULL, g_free);
|
||||
self->named_texture_counter = 0;
|
||||
self->fonts = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, font_info_free);
|
||||
self->serialized_fonts = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
printer_init_duplicates_for_node (self, node);
|
||||
}
|
||||
@@ -3162,7 +3111,7 @@ printer_clear (Printer *self)
|
||||
g_string_free (self->str, TRUE);
|
||||
g_hash_table_unref (self->named_nodes);
|
||||
g_hash_table_unref (self->named_textures);
|
||||
g_hash_table_unref (self->fonts);
|
||||
g_hash_table_unref (self->serialized_fonts);
|
||||
}
|
||||
|
||||
#define IDENT_LEVEL 2 /* Spaces per level */
|
||||
@@ -3622,46 +3571,14 @@ append_texture_param (Printer *p,
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
static void
|
||||
print_font (PangoFont *font)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
char *s;
|
||||
hb_face_t *face;
|
||||
hb_blob_t *blob;
|
||||
const char *data;
|
||||
unsigned int length;
|
||||
char *csum;
|
||||
|
||||
desc = pango_font_describe_with_absolute_size (font);
|
||||
s = pango_font_description_to_string (desc);
|
||||
|
||||
face = hb_font_get_face (pango_font_get_hb_font (font));
|
||||
blob = hb_face_reference_blob (face);
|
||||
|
||||
data = hb_blob_get_data (blob, &length);
|
||||
csum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, (const guchar *)data, length);
|
||||
|
||||
g_print ("%s, face %p, sha %s\n", s, face, csum);
|
||||
|
||||
g_free (csum);
|
||||
hb_blob_destroy (blob);
|
||||
g_free (s);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_text_node_serialize_font (GskRenderNode *node,
|
||||
Printer *p)
|
||||
{
|
||||
PangoFont *font = gsk_text_node_get_font (node);
|
||||
PangoFontMap *fontmap = pango_font_get_font_map (font);
|
||||
PangoFontDescription *desc;
|
||||
char *s;
|
||||
FontInfo *info;
|
||||
hb_face_t *face;
|
||||
hb_blob_t *blob;
|
||||
const char *data;
|
||||
guint length;
|
||||
char *b64;
|
||||
|
||||
desc = pango_font_describe_with_absolute_size (font);
|
||||
s = pango_font_description_to_string (desc);
|
||||
@@ -3669,31 +3586,42 @@ gsk_text_node_serialize_font (GskRenderNode *node,
|
||||
g_free (s);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
g_print ("serializing ");
|
||||
print_font (font);
|
||||
info = g_hash_table_lookup (p->fonts, hb_font_get_face (pango_font_get_hb_font (font)));
|
||||
if (info->serialized)
|
||||
/* Check if this is a custom font that we created from a url */
|
||||
if (!g_object_get_data (G_OBJECT (fontmap), "font-files"))
|
||||
return;
|
||||
|
||||
if (info->input)
|
||||
face = hb_subset_or_fail (info->face, info->input);
|
||||
else
|
||||
face = hb_face_reference (info->face);
|
||||
#ifdef HAVE_PANGOFT
|
||||
{
|
||||
FcPattern *pat;
|
||||
FcResult res;
|
||||
const char *file;
|
||||
char *data;
|
||||
gsize len;
|
||||
char *b64;
|
||||
|
||||
blob = hb_face_reference_blob (face);
|
||||
data = hb_blob_get_data (blob, &length);
|
||||
pat = pango_fc_font_get_pattern (PANGO_FC_FONT (font));
|
||||
res = FcPatternGetString (pat, FC_FILE, 0, (FcChar8 **)&file);
|
||||
if (res != FcResultMatch)
|
||||
return;
|
||||
|
||||
b64 = base64_encode_with_linebreaks ((const guchar *) data, length);
|
||||
if (g_hash_table_contains (p->serialized_fonts, file))
|
||||
return;
|
||||
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n");
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_string_append (p->str, "\")");
|
||||
if (!g_file_get_contents (file, &data, &len, NULL))
|
||||
return;
|
||||
|
||||
g_free (b64);
|
||||
hb_blob_destroy (blob);
|
||||
hb_face_destroy (face);
|
||||
g_hash_table_add (p->serialized_fonts, (gpointer) file);
|
||||
|
||||
info->serialized = TRUE;
|
||||
b64 = base64_encode_with_linebreaks ((const guchar *) data, len);
|
||||
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n");
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_string_append (p->str, "\")");
|
||||
|
||||
g_free (b64);
|
||||
g_free (data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -778,20 +778,13 @@ gtk_style_context_resolve_color (GtkStyleContext *context,
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
GtkCssValue *val;
|
||||
GtkCssComputeContext ctx = { NULL, };
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
ctx.provider = GTK_STYLE_PROVIDER (priv->cascade);
|
||||
ctx.style = gtk_css_node_get_style (priv->cssnode);
|
||||
if (gtk_css_node_get_parent (priv->cssnode))
|
||||
ctx.parent_style = gtk_css_node_get_style (gtk_css_node_get_parent (priv->cssnode));
|
||||
|
||||
val = gtk_css_color_value_resolve (color,
|
||||
GTK_CSS_PROPERTY_COLOR,
|
||||
&ctx,
|
||||
GTK_STYLE_PROVIDER (priv->cascade),
|
||||
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
|
||||
|
||||
if (val == NULL)
|
||||
|
||||
@@ -21,14 +21,12 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
GtkCssValue * gtk_css_calc_value_parse_sum (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx);
|
||||
GtkCssValue * gtk_css_calc_value_parse_sum (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags);
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_calc_value_parse_value (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx)
|
||||
gtk_css_calc_value_parse_value (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags)
|
||||
{
|
||||
if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_OPEN_PARENS))
|
||||
{
|
||||
@@ -36,7 +34,7 @@ gtk_css_calc_value_parse_value (GtkCssParser *parser,
|
||||
|
||||
gtk_css_parser_start_block (parser);
|
||||
|
||||
result = gtk_css_calc_value_parse_sum (parser, flags, ctx);
|
||||
result = gtk_css_calc_value_parse_sum (parser, flags);
|
||||
if (result == NULL)
|
||||
{
|
||||
gtk_css_parser_end_block (parser);
|
||||
@@ -62,7 +60,7 @@ gtk_css_calc_value_parse_value (GtkCssParser *parser,
|
||||
return result;
|
||||
}
|
||||
|
||||
return gtk_css_number_value_parse_with_context (parser, flags, ctx);
|
||||
return gtk_css_number_value_parse (parser, flags);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -73,9 +71,8 @@ is_number (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx)
|
||||
gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags)
|
||||
{
|
||||
GtkCssValue *result, *value, *temp;
|
||||
GtkCssNumberParseFlags actual_flags;
|
||||
@@ -84,7 +81,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
actual_flags = flags | GTK_CSS_PARSE_NUMBER;
|
||||
gtk_css_parser_get_token (parser);
|
||||
start = *gtk_css_parser_get_start_location (parser);
|
||||
result = gtk_css_calc_value_parse_value (parser, actual_flags, ctx);
|
||||
result = gtk_css_calc_value_parse_value (parser, actual_flags);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -95,7 +92,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
|
||||
if (gtk_css_parser_try_delim (parser, '*'))
|
||||
{
|
||||
value = gtk_css_calc_value_parse_product (parser, actual_flags, ctx);
|
||||
value = gtk_css_calc_value_parse_product (parser, actual_flags);
|
||||
if (value == NULL)
|
||||
goto fail;
|
||||
if (is_number (value))
|
||||
@@ -108,7 +105,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
}
|
||||
else if (gtk_css_parser_try_delim (parser, '/'))
|
||||
{
|
||||
value = gtk_css_calc_value_parse_product (parser, GTK_CSS_PARSE_NUMBER, ctx);
|
||||
value = gtk_css_calc_value_parse_product (parser, GTK_CSS_PARSE_NUMBER);
|
||||
if (value == NULL)
|
||||
goto fail;
|
||||
temp = gtk_css_number_value_multiply (result, 1.0 / gtk_css_number_value_get (value, 100));
|
||||
@@ -140,13 +137,12 @@ fail:
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_calc_value_parse_sum (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx)
|
||||
gtk_css_calc_value_parse_sum (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = gtk_css_calc_value_parse_product (parser, flags, ctx);
|
||||
result = gtk_css_calc_value_parse_product (parser, flags);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -156,13 +152,13 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
|
||||
|
||||
if (gtk_css_parser_try_delim (parser, '+'))
|
||||
{
|
||||
next = gtk_css_calc_value_parse_product (parser, flags, ctx);
|
||||
next = gtk_css_calc_value_parse_product (parser, flags);
|
||||
if (next == NULL)
|
||||
goto fail;
|
||||
}
|
||||
else if (gtk_css_parser_try_delim (parser, '-'))
|
||||
{
|
||||
temp = gtk_css_calc_value_parse_product (parser, flags, ctx);
|
||||
temp = gtk_css_calc_value_parse_product (parser, flags);
|
||||
if (temp == NULL)
|
||||
goto fail;
|
||||
next = gtk_css_number_value_multiply (temp, -1);
|
||||
@@ -197,7 +193,6 @@ fail:
|
||||
typedef struct
|
||||
{
|
||||
GtkCssNumberParseFlags flags;
|
||||
GtkCssNumberParseContext *ctx;
|
||||
GtkCssValue *value;
|
||||
} ParseCalcData;
|
||||
|
||||
@@ -208,7 +203,7 @@ gtk_css_calc_value_parse_arg (GtkCssParser *parser,
|
||||
{
|
||||
ParseCalcData *data = data_;
|
||||
|
||||
data->value = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx);
|
||||
data->value = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (data->value == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -216,16 +211,14 @@ gtk_css_calc_value_parse_arg (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_calc_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx)
|
||||
gtk_css_calc_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags)
|
||||
{
|
||||
ParseCalcData data;
|
||||
|
||||
/* This can only be handled at compute time, we allow '-' after all */
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.value = NULL;
|
||||
data.ctx = ctx;
|
||||
|
||||
if (!gtk_css_parser_has_function (parser, "calc"))
|
||||
{
|
||||
@@ -242,7 +235,6 @@ gtk_css_calc_value_parse (GtkCssParser *parser,
|
||||
typedef struct
|
||||
{
|
||||
GtkCssNumberParseFlags flags;
|
||||
GtkCssNumberParseContext *ctx;
|
||||
GPtrArray *values;
|
||||
} ParseArgnData;
|
||||
|
||||
@@ -254,7 +246,7 @@ gtk_css_argn_value_parse_arg (GtkCssParser *parser,
|
||||
ParseArgnData *data = data_;
|
||||
GtkCssValue *value;
|
||||
|
||||
value = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx);
|
||||
value = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -266,7 +258,6 @@ gtk_css_argn_value_parse_arg (GtkCssParser *parser,
|
||||
typedef struct
|
||||
{
|
||||
GtkCssNumberParseFlags flags;
|
||||
GtkCssNumberParseContext *ctx;
|
||||
GtkCssValue *values[3];
|
||||
} ParseClampData;
|
||||
|
||||
@@ -286,7 +277,7 @@ gtk_css_clamp_value_parse_arg (GtkCssParser *parser,
|
||||
}
|
||||
}
|
||||
|
||||
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx);
|
||||
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (data->values[arg] == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -294,10 +285,9 @@ gtk_css_clamp_value_parse_arg (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_clamp_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
guint type)
|
||||
gtk_css_clamp_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint type)
|
||||
{
|
||||
ParseClampData data;
|
||||
GtkCssValue *result = NULL;
|
||||
@@ -310,7 +300,6 @@ gtk_css_clamp_value_parse (GtkCssParser *parser,
|
||||
|
||||
/* This can only be handled at compute time, we allow '-' after all */
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.ctx = ctx;
|
||||
data.values[0] = NULL;
|
||||
data.values[1] = NULL;
|
||||
data.values[2] = NULL;
|
||||
@@ -337,7 +326,6 @@ gtk_css_clamp_value_parse (GtkCssParser *parser,
|
||||
|
||||
typedef struct {
|
||||
GtkCssNumberParseFlags flags;
|
||||
GtkCssNumberParseContext *ctx;
|
||||
guint mode;
|
||||
gboolean has_mode;
|
||||
GtkCssValue *values[2];
|
||||
@@ -364,13 +352,13 @@ gtk_css_round_value_parse_arg (GtkCssParser *parser,
|
||||
}
|
||||
}
|
||||
|
||||
data->values[0] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx);
|
||||
data->values[0] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (data->values[0] == NULL)
|
||||
return 0;
|
||||
}
|
||||
else if (arg == 1)
|
||||
{
|
||||
GtkCssValue *value = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx);
|
||||
GtkCssValue *value = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
@@ -388,7 +376,7 @@ gtk_css_round_value_parse_arg (GtkCssParser *parser,
|
||||
return 0;
|
||||
}
|
||||
|
||||
data->values[1] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx);
|
||||
data->values[1] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
|
||||
if (data->values[1] == NULL)
|
||||
return 0;
|
||||
@@ -398,10 +386,9 @@ gtk_css_round_value_parse_arg (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_round_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
guint type)
|
||||
gtk_css_round_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint type)
|
||||
{
|
||||
ParseRoundData data;
|
||||
GtkCssValue *result = NULL;
|
||||
@@ -413,7 +400,6 @@ gtk_css_round_value_parse (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.ctx = ctx;
|
||||
data.mode = ROUND_NEAREST;
|
||||
data.has_mode = FALSE;
|
||||
data.values[0] = NULL;
|
||||
@@ -444,7 +430,6 @@ gtk_css_round_value_parse (GtkCssParser *parser,
|
||||
|
||||
typedef struct {
|
||||
GtkCssNumberParseFlags flags;
|
||||
GtkCssNumberParseContext *ctx;
|
||||
GtkCssValue *values[2];
|
||||
} ParseArg2Data;
|
||||
|
||||
@@ -455,7 +440,7 @@ gtk_css_arg2_value_parse_arg (GtkCssParser *parser,
|
||||
{
|
||||
ParseArg2Data *data = data_;
|
||||
|
||||
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags, data->ctx);
|
||||
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (data->values[arg] == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -463,13 +448,12 @@ gtk_css_arg2_value_parse_arg (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_arg2_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
guint min_args,
|
||||
guint max_args,
|
||||
const char *function,
|
||||
guint type)
|
||||
gtk_css_arg2_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint min_args,
|
||||
guint max_args,
|
||||
const char *function,
|
||||
guint type)
|
||||
{
|
||||
ParseArg2Data data;
|
||||
GtkCssValue *result = NULL;
|
||||
@@ -483,7 +467,6 @@ gtk_css_arg2_value_parse (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.ctx = ctx;
|
||||
data.values[0] = NULL;
|
||||
data.values[1] = NULL;
|
||||
|
||||
@@ -507,11 +490,10 @@ gtk_css_arg2_value_parse (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_argn_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
const char *function,
|
||||
guint type)
|
||||
gtk_css_argn_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
const char *function,
|
||||
guint type)
|
||||
{
|
||||
ParseArgnData data;
|
||||
GtkCssValue *result = NULL;
|
||||
@@ -525,7 +507,6 @@ gtk_css_argn_value_parse (GtkCssParser *parser,
|
||||
/* This can only be handled at compute time, we allow '-' after all */
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.values = g_ptr_array_new ();
|
||||
data.ctx = ctx;
|
||||
|
||||
if (gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_argn_value_parse_arg, &data))
|
||||
{
|
||||
@@ -554,3 +535,4 @@ gtk_css_argn_value_parse (GtkCssParser *parser,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,26 +22,21 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * gtk_css_calc_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx);
|
||||
GtkCssNumberParseFlags flags);
|
||||
GtkCssValue * gtk_css_clamp_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
guint type);
|
||||
GtkCssValue * gtk_css_round_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
guint type);
|
||||
GtkCssValue * gtk_css_arg2_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
guint min_args,
|
||||
guint max_args,
|
||||
const char *function,
|
||||
guint type);
|
||||
GtkCssValue * gtk_css_argn_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx,
|
||||
const char *function,
|
||||
guint type);
|
||||
|
||||
|
||||
@@ -73,54 +73,46 @@ append_color_component (GString *string,
|
||||
g_string_append_printf (string, "%g", gtk_css_color_get_component (color, idx));
|
||||
}
|
||||
|
||||
static void
|
||||
print_as_rgb (const GtkCssColor *color,
|
||||
GString *string)
|
||||
{
|
||||
GtkCssColor tmp;
|
||||
|
||||
gtk_css_color_convert (color, GTK_CSS_COLOR_SPACE_SRGB, &tmp);
|
||||
if (tmp.values[3] > 0.999)
|
||||
{
|
||||
g_string_append_printf (string, "rgb(%d,%d,%d)",
|
||||
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.));
|
||||
}
|
||||
else
|
||||
{
|
||||
char alpha[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (tmp.values[3], 0, 1));
|
||||
|
||||
g_string_append_printf (string, "rgba(%d,%d,%d,%s)",
|
||||
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.),
|
||||
alpha);
|
||||
}
|
||||
}
|
||||
|
||||
GString *
|
||||
gtk_css_color_print (const GtkCssColor *color,
|
||||
gboolean serialize_as_rgb,
|
||||
GString *string)
|
||||
{
|
||||
GtkCssColorSpace print_color_space = color->color_space;
|
||||
GtkCssColor tmp;
|
||||
|
||||
switch (color->color_space)
|
||||
{
|
||||
case GTK_CSS_COLOR_SPACE_SRGB:
|
||||
case GTK_CSS_COLOR_SPACE_HSL:
|
||||
case GTK_CSS_COLOR_SPACE_HWB:
|
||||
if (serialize_as_rgb)
|
||||
{
|
||||
print_as_rgb (color, string);
|
||||
return string;
|
||||
}
|
||||
print_rgb:
|
||||
{
|
||||
GtkCssColor tmp;
|
||||
|
||||
gtk_css_color_convert (color, GTK_CSS_COLOR_SPACE_SRGB, &tmp);
|
||||
if (tmp.values[3] > 0.999)
|
||||
{
|
||||
g_string_append_printf (string, "rgb(%d,%d,%d)",
|
||||
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.));
|
||||
}
|
||||
else
|
||||
{
|
||||
char alpha[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
g_ascii_formatd (alpha, G_ASCII_DTOSTR_BUF_SIZE, "%g", CLAMP (tmp.values[3], 0, 1));
|
||||
|
||||
g_string_append_printf (string, "rgba(%d,%d,%d,%s)",
|
||||
(int)(0.5 + CLAMP (tmp.values[0], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[1], 0., 1.) * 255.),
|
||||
(int)(0.5 + CLAMP (tmp.values[2], 0., 1.) * 255.),
|
||||
alpha);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
|
||||
case GTK_CSS_COLOR_SPACE_SRGB:
|
||||
if (serialize_as_rgb)
|
||||
goto print_rgb;
|
||||
|
||||
print_color_space = GTK_CSS_COLOR_SPACE_SRGB;
|
||||
g_string_append (string, "color(srgb ");
|
||||
break;
|
||||
|
||||
@@ -140,23 +132,18 @@ gtk_css_color_print (const GtkCssColor *color,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (print_color_space != color->color_space)
|
||||
gtk_css_color_convert (color, print_color_space, &tmp);
|
||||
else
|
||||
tmp = *color;
|
||||
|
||||
for (guint i = 0; i < 3; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append_c (string, ' ');
|
||||
append_color_component (string, &tmp, i);
|
||||
append_color_component (string, color, i);
|
||||
}
|
||||
|
||||
if (gtk_css_color_component_missing (&tmp, 3) ||
|
||||
tmp.values[3] < 0.999)
|
||||
if (gtk_css_color_component_missing (color, 3) ||
|
||||
color->values[3] < 0.999)
|
||||
{
|
||||
g_string_append (string, " / ");
|
||||
append_color_component (string, &tmp, 3);
|
||||
append_color_component (string, color, 3);
|
||||
}
|
||||
|
||||
g_string_append_c (string, ')');
|
||||
@@ -225,24 +212,6 @@ gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
color_space_is_polar (GtkCssColorSpace color_space)
|
||||
{
|
||||
switch (color_space)
|
||||
{
|
||||
case GTK_CSS_COLOR_SPACE_SRGB:
|
||||
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
|
||||
case GTK_CSS_COLOR_SPACE_OKLAB:
|
||||
return FALSE;
|
||||
case GTK_CSS_COLOR_SPACE_HSL:
|
||||
case GTK_CSS_COLOR_SPACE_HWB:
|
||||
case GTK_CSS_COLOR_SPACE_OKLCH:
|
||||
return TRUE;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Color conversion */
|
||||
|
||||
@@ -750,157 +719,5 @@ gtk_css_color_interpolate (const GtkCssColor *from,
|
||||
unpremultiply (output);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_hue_interpolation (GtkCssParser *parser,
|
||||
GtkCssHueInterpolation *interp)
|
||||
{
|
||||
const GtkCssToken *token = gtk_css_parser_get_token (parser);
|
||||
|
||||
if (gtk_css_token_is_ident (token, "shorter"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*interp = GTK_CSS_HUE_INTERPOLATION_SHORTER;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "longer"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*interp = GTK_CSS_HUE_INTERPOLATION_LONGER;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "increasing"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*interp = GTK_CSS_HUE_INTERPOLATION_INCREASING;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "decreasing"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*interp = GTK_CSS_HUE_INTERPOLATION_DECREASING;
|
||||
}
|
||||
else
|
||||
{
|
||||
*interp = GTK_CSS_HUE_INTERPOLATION_SHORTER;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!gtk_css_parser_try_ident (parser, "hue"))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected 'hue'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
|
||||
GtkCssColorSpace *in,
|
||||
GtkCssHueInterpolation *interp)
|
||||
{
|
||||
const GtkCssToken *token;
|
||||
|
||||
if (!gtk_css_parser_try_ident (parser, "in"))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected 'in'");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
token = gtk_css_parser_get_token (parser);
|
||||
|
||||
if (gtk_css_token_is_ident (token, "srgb"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*in = GTK_CSS_COLOR_SPACE_SRGB;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "srgb-linear"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*in = GTK_CSS_COLOR_SPACE_SRGB_LINEAR;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "hsl"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*in = GTK_CSS_COLOR_SPACE_HSL;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "hwb"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*in = GTK_CSS_COLOR_SPACE_HWB;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "oklch"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*in = GTK_CSS_COLOR_SPACE_OKLCH;
|
||||
}
|
||||
else if (gtk_css_token_is_ident (token, "oklab"))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
*in = GTK_CSS_COLOR_SPACE_OKLAB;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Invalid color space");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (color_space_is_polar (*in))
|
||||
return parse_hue_interpolation (parser, interp);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gtk_css_color_interpolation_method_print (GtkCssColorSpace in,
|
||||
GtkCssHueInterpolation interp,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, "in ");
|
||||
|
||||
switch (in)
|
||||
{
|
||||
case GTK_CSS_COLOR_SPACE_SRGB:
|
||||
g_string_append (string, "srgb");
|
||||
break;
|
||||
case GTK_CSS_COLOR_SPACE_SRGB_LINEAR:
|
||||
g_string_append (string, "srgb-linear");
|
||||
break;
|
||||
case GTK_CSS_COLOR_SPACE_HSL:
|
||||
g_string_append (string, "hsl");
|
||||
break;
|
||||
case GTK_CSS_COLOR_SPACE_HWB:
|
||||
g_string_append (string, "hwb");
|
||||
break;
|
||||
case GTK_CSS_COLOR_SPACE_OKLCH:
|
||||
g_string_append (string, "oklch");
|
||||
break;
|
||||
case GTK_CSS_COLOR_SPACE_OKLAB:
|
||||
g_string_append (string, "oklab");
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (!color_space_is_polar (in))
|
||||
return;
|
||||
|
||||
switch (interp)
|
||||
{
|
||||
case GTK_CSS_HUE_INTERPOLATION_SHORTER:
|
||||
/* shorter is the default mode, don't print it */
|
||||
break;
|
||||
case GTK_CSS_HUE_INTERPOLATION_LONGER:
|
||||
g_string_append (string, " longer hue");
|
||||
break;
|
||||
case GTK_CSS_HUE_INTERPOLATION_INCREASING:
|
||||
g_string_append (string, " increasing hue");
|
||||
break;
|
||||
case GTK_CSS_HUE_INTERPOLATION_DECREASING:
|
||||
g_string_append (string, " decreasing hue");
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "gtk/css/gtkcssparserprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
@@ -114,12 +112,4 @@ void gtk_css_color_interpolate (const GtkCssColor *from,
|
||||
const char * gtk_css_color_space_get_coord_name (GtkCssColorSpace color_space,
|
||||
guint coord);
|
||||
|
||||
gboolean gtk_css_color_interpolation_method_parse (GtkCssParser *parser,
|
||||
GtkCssColorSpace *in,
|
||||
GtkCssHueInterpolation *interp);
|
||||
|
||||
void gtk_css_color_interpolation_method_print (GtkCssColorSpace in,
|
||||
GtkCssHueInterpolation interp,
|
||||
GString *string);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,11 +33,9 @@ GtkCssValue * gtk_css_color_value_new_name (const char *name) G
|
||||
gboolean gtk_css_color_value_can_parse (GtkCssParser *parser);
|
||||
GtkCssValue * gtk_css_color_value_parse (GtkCssParser *parser);
|
||||
|
||||
GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context,
|
||||
GtkCssValue *current);
|
||||
|
||||
GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssValue *current);
|
||||
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST;
|
||||
|
||||
GtkCssValue * gtk_css_color_value_new_color (GtkCssColorSpace color_space,
|
||||
@@ -48,10 +46,6 @@ GtkCssValue * gtk_css_color_value_new_color (GtkCssColorSpace color_
|
||||
const GtkCssColor *
|
||||
gtk_css_color_value_get_color (const GtkCssValue *color) G_GNUC_CONST;
|
||||
|
||||
float gtk_css_color_value_get_coord (const GtkCssValue *color,
|
||||
GtkCssColorSpace color_space,
|
||||
gboolean legacy_srgb,
|
||||
guint coord);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "gtkcsscalcvalueprivate.h"
|
||||
#include "gtkcssenumvalueprivate.h"
|
||||
#include "gtkcssdimensionvalueprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
@@ -70,7 +69,6 @@ typedef enum {
|
||||
TYPE_EXP,
|
||||
TYPE_LOG,
|
||||
TYPE_HYPOT,
|
||||
TYPE_COLOR_COORD,
|
||||
} NumberValueType;
|
||||
|
||||
static const char *function_name[] = {
|
||||
@@ -112,12 +110,6 @@ struct _GtkCssValue {
|
||||
guint n_terms;
|
||||
GtkCssValue *terms[1];
|
||||
} calc;
|
||||
struct {
|
||||
GtkCssValue *color;
|
||||
GtkCssColorSpace color_space;
|
||||
guint coord : 16;
|
||||
guint legacy_rgb_scale : 1;
|
||||
} color_coord;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -148,11 +140,7 @@ gtk_css_calc_value_new (guint type,
|
||||
static void
|
||||
gtk_css_value_number_free (GtkCssValue *number)
|
||||
{
|
||||
if (number->type == TYPE_COLOR_COORD)
|
||||
{
|
||||
gtk_css_value_unref (number->color_coord.color);
|
||||
}
|
||||
else if (number->type != TYPE_DIMENSION)
|
||||
if (number->type != TYPE_DIMENSION)
|
||||
{
|
||||
for (guint i = 0; i < number->calc.n_terms; i++)
|
||||
{
|
||||
@@ -322,21 +310,7 @@ gtk_css_value_number_compute (GtkCssValue *number,
|
||||
GtkCssStyle *style = context->style;
|
||||
GtkCssStyle *parent_style = context->parent_style;
|
||||
|
||||
if (number->type == TYPE_COLOR_COORD)
|
||||
{
|
||||
GtkCssValue *color;
|
||||
float v;
|
||||
|
||||
color = gtk_css_value_compute (number->color_coord.color, property_id, context);
|
||||
v = gtk_css_color_value_get_coord (color,
|
||||
number->color_coord.color_space,
|
||||
number->color_coord.legacy_rgb_scale,
|
||||
number->color_coord.coord);
|
||||
gtk_css_value_unref (color);
|
||||
|
||||
return gtk_css_number_value_new (v, GTK_CSS_NUMBER);
|
||||
}
|
||||
else if (number->type != TYPE_DIMENSION)
|
||||
if (number->type != TYPE_DIMENSION)
|
||||
{
|
||||
const guint n_terms = number->calc.n_terms;
|
||||
GtkCssValue *result;
|
||||
@@ -546,10 +520,6 @@ gtk_css_value_number_print (const GtkCssValue *value,
|
||||
g_string_append_c (string, ')');
|
||||
break;
|
||||
|
||||
case TYPE_COLOR_COORD:
|
||||
g_string_append (string, gtk_css_color_space_get_coord_name (value->color_coord.color_space, value->color_coord.coord));
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
const char *sep = value->type == TYPE_CALC ? " + " : (value->type == TYPE_PRODUCT ? " * " : ", ");
|
||||
@@ -901,7 +871,6 @@ gtk_css_number_value_get_dimension (const GtkCssValue *value)
|
||||
case TYPE_SQRT:
|
||||
case TYPE_POW:
|
||||
case TYPE_LOG:
|
||||
case TYPE_COLOR_COORD:
|
||||
return GTK_CSS_DIMENSION_NUMBER;
|
||||
|
||||
case TYPE_ASIN:
|
||||
@@ -918,11 +887,7 @@ gtk_css_number_value_get_dimension (const GtkCssValue *value)
|
||||
gboolean
|
||||
gtk_css_number_value_has_percent (const GtkCssValue *value)
|
||||
{
|
||||
if (value->type == TYPE_COLOR_COORD)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else if (value->type == TYPE_DIMENSION)
|
||||
if (value->type == TYPE_DIMENSION)
|
||||
{
|
||||
return gtk_css_unit_get_dimension (value->dimension.unit) == GTK_CSS_DIMENSION_PERCENTAGE;
|
||||
}
|
||||
@@ -1361,7 +1326,6 @@ gtk_css_math_value_new (guint type,
|
||||
switch ((NumberValueType) type)
|
||||
{
|
||||
case TYPE_DIMENSION:
|
||||
case TYPE_COLOR_COORD:
|
||||
g_assert_not_reached ();
|
||||
|
||||
case TYPE_ROUND:
|
||||
@@ -1443,16 +1407,6 @@ gtk_css_number_value_can_parse (GtkCssParser *parser)
|
||||
GtkCssValue *
|
||||
gtk_css_number_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags)
|
||||
{
|
||||
GtkCssNumberParseContext ctx = { NULL, 0, FALSE };
|
||||
|
||||
return gtk_css_number_value_parse_with_context (parser, flags, &ctx);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_number_value_parse_with_context (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *ctx)
|
||||
{
|
||||
const GtkCssToken *token = gtk_css_parser_get_token (parser);
|
||||
|
||||
@@ -1461,47 +1415,47 @@ gtk_css_number_value_parse_with_context (GtkCssParser *parser,
|
||||
const char *name = gtk_css_token_get_string (token);
|
||||
|
||||
if (g_ascii_strcasecmp (name, "calc") == 0)
|
||||
return gtk_css_calc_value_parse (parser, flags, ctx);
|
||||
return gtk_css_calc_value_parse (parser, flags);
|
||||
else if (g_ascii_strcasecmp (name, "min") == 0)
|
||||
return gtk_css_argn_value_parse (parser, flags, ctx, "min", TYPE_MIN);
|
||||
return gtk_css_argn_value_parse (parser, flags, "min", TYPE_MIN);
|
||||
else if (g_ascii_strcasecmp (name, "max") == 0)
|
||||
return gtk_css_argn_value_parse (parser, flags, ctx, "max", TYPE_MAX);
|
||||
return gtk_css_argn_value_parse (parser, flags, "max", TYPE_MAX);
|
||||
else if (g_ascii_strcasecmp (name, "hypot") == 0)
|
||||
return gtk_css_argn_value_parse (parser, flags, ctx, "hypot", TYPE_HYPOT);
|
||||
return gtk_css_argn_value_parse (parser, flags, "hypot", TYPE_HYPOT);
|
||||
else if (g_ascii_strcasecmp (name, "clamp") == 0)
|
||||
return gtk_css_clamp_value_parse (parser, flags, ctx, TYPE_CLAMP);
|
||||
return gtk_css_clamp_value_parse (parser, flags, TYPE_CLAMP);
|
||||
else if (g_ascii_strcasecmp (name, "round") == 0)
|
||||
return gtk_css_round_value_parse (parser, flags, ctx, TYPE_ROUND);
|
||||
return gtk_css_round_value_parse (parser, flags, TYPE_ROUND);
|
||||
else if (g_ascii_strcasecmp (name, "mod") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, flags, ctx, 2, 2, "mod", TYPE_MOD);
|
||||
return gtk_css_arg2_value_parse (parser, flags, 2, 2, "mod", TYPE_MOD);
|
||||
else if (g_ascii_strcasecmp (name, "rem") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, flags, ctx, 2, 2, "rem", TYPE_REM);
|
||||
return gtk_css_arg2_value_parse (parser, flags, 2, 2, "rem", TYPE_REM);
|
||||
else if (g_ascii_strcasecmp (name, "abs") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, flags, ctx, 1, 1, "abs", TYPE_ABS);
|
||||
return gtk_css_arg2_value_parse (parser, flags, 1, 1, "abs", TYPE_ABS);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sign") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, ctx, 1, 1, "sign", TYPE_SIGN);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, 1, 1, "sign", TYPE_SIGN);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sin") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, ctx, 1, 1, "sin", TYPE_SIN);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, 1, 1, "sin", TYPE_SIN);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "cos") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, ctx, 1, 1, "cos", TYPE_COS);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, 1, 1, "cos", TYPE_COS);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "tan") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, ctx, 1, 1, "tan", TYPE_TAN);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_ANGLE, 1, 1, "tan", TYPE_TAN);
|
||||
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "asin") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "asin", TYPE_ASIN);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "asin", TYPE_ASIN);
|
||||
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "acos") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "acos", TYPE_ACOS);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "acos", TYPE_ACOS);
|
||||
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "atan") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "atan", TYPE_ATAN);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "atan", TYPE_ATAN);
|
||||
else if ((flags & GTK_CSS_PARSE_ANGLE) && g_ascii_strcasecmp (name, "atan2") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, ctx, 2, 2, "atan2", TYPE_ATAN2);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER|GTK_CSS_PARSE_DIMENSION|GTK_CSS_PARSE_PERCENT, 2, 2, "atan2", TYPE_ATAN2);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "pow") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 2, 2, "pow", TYPE_POW);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 2, 2, "pow", TYPE_POW);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "sqrt") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "sqrt", TYPE_SQRT);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "sqrt", TYPE_SQRT);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "exp") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 1, "exp", TYPE_EXP);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 1, "exp", TYPE_EXP);
|
||||
else if ((flags & GTK_CSS_PARSE_NUMBER) && g_ascii_strcasecmp (name, "log") == 0)
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, ctx, 1, 2, "log", TYPE_LOG);
|
||||
return gtk_css_arg2_value_parse (parser, GTK_CSS_PARSE_NUMBER, 1, 2, "log", TYPE_LOG);
|
||||
}
|
||||
else if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
|
||||
{
|
||||
@@ -1525,18 +1479,6 @@ gtk_css_number_value_parse_with_context (GtkCssParser *parser,
|
||||
return gtk_css_number_value_new (constants[i].value, GTK_CSS_NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->color)
|
||||
{
|
||||
for (guint i = 0; i < 4; i++)
|
||||
{
|
||||
if (g_ascii_strcasecmp (name, gtk_css_color_space_get_coord_name (ctx->color_space, i)) == 0)
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
return gtk_css_number_value_new_color_component (ctx->color, ctx->color_space, ctx->legacy_rgb_scale, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return gtk_css_dimension_value_parse (parser, flags);
|
||||
@@ -1768,12 +1710,6 @@ gtk_css_number_value_get (const GtkCssValue *value,
|
||||
return sqrt (acc);
|
||||
}
|
||||
|
||||
case TYPE_COLOR_COORD:
|
||||
return gtk_css_color_value_get_coord (value->color_coord.color,
|
||||
value->color_coord.color_space,
|
||||
value->color_coord.legacy_rgb_scale,
|
||||
value->color_coord.coord);
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
@@ -1885,33 +1821,3 @@ _sign (double a)
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_number_value_new_color_component (GtkCssValue *color,
|
||||
GtkCssColorSpace color_space,
|
||||
gboolean legacy_rgb_scale,
|
||||
guint coord)
|
||||
{
|
||||
if (gtk_css_value_is_computed (color))
|
||||
{
|
||||
float v;
|
||||
|
||||
v = gtk_css_color_value_get_coord (color, color_space, legacy_rgb_scale, coord);
|
||||
|
||||
return gtk_css_number_value_new (v, GTK_CSS_NUMBER);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_NUMBER);
|
||||
result->type = TYPE_COLOR_COORD;
|
||||
result->color_coord.color_space = color_space;
|
||||
result->color_coord.color = gtk_css_value_ref (color);
|
||||
result->color_coord.coord = coord;
|
||||
result->color_coord.legacy_rgb_scale = legacy_rgb_scale;
|
||||
result->is_computed = FALSE;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include "gtk/css/gtkcssparserprivate.h"
|
||||
#include "gtkcsstypesprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
#include "gtkcsscolorprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -37,14 +36,6 @@ typedef enum /*< skip >*/ {
|
||||
GTK_CSS_PARSE_TIME = (1 << 5)
|
||||
} GtkCssNumberParseFlags;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Context needed when parsing numbers */
|
||||
GtkCssValue *color;
|
||||
GtkCssColorSpace color_space;
|
||||
gboolean legacy_rgb_scale; /* r, g, b must be scaled to 255 */
|
||||
} GtkCssNumberParseContext;
|
||||
|
||||
#define GTK_CSS_PARSE_DIMENSION (GTK_CSS_PARSE_LENGTH|GTK_CSS_PARSE_ANGLE|GTK_CSS_PARSE_TIME)
|
||||
|
||||
GtkCssValue * gtk_css_dimension_value_new (double value,
|
||||
@@ -56,10 +47,6 @@ gboolean gtk_css_number_value_can_parse (GtkCssParser *par
|
||||
GtkCssValue * gtk_css_number_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags);
|
||||
|
||||
GtkCssValue * gtk_css_number_value_parse_with_context (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
GtkCssNumberParseContext *context);
|
||||
|
||||
GtkCssDimension gtk_css_number_value_get_dimension (const GtkCssValue *value) G_GNUC_PURE;
|
||||
gboolean gtk_css_number_value_has_percent (const GtkCssValue *value) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_number_value_multiply (GtkCssValue *value,
|
||||
@@ -75,11 +62,6 @@ double gtk_css_number_value_get_canonical (GtkCssValue *num
|
||||
|
||||
gboolean gtk_css_dimension_value_is_zero (const GtkCssValue *value) G_GNUC_PURE;
|
||||
|
||||
GtkCssValue * gtk_css_number_value_new_color_component (GtkCssValue *color,
|
||||
GtkCssColorSpace color_space,
|
||||
gboolean legacy_srgb,
|
||||
guint coord);
|
||||
|
||||
enum {
|
||||
ROUND_NEAREST,
|
||||
ROUND_UP,
|
||||
|
||||
@@ -1245,8 +1245,7 @@ typedef enum {
|
||||
GTK_SYSTEM_SETTING_FONT_NAME,
|
||||
GTK_SYSTEM_SETTING_FONT_CONFIG,
|
||||
GTK_SYSTEM_SETTING_DISPLAY,
|
||||
GTK_SYSTEM_SETTING_ICON_THEME,
|
||||
GTK_SYSTEM_SETTING_COLOR_SCHEME,
|
||||
GTK_SYSTEM_SETTING_ICON_THEME
|
||||
} GtkSystemSetting;
|
||||
|
||||
/**
|
||||
@@ -1881,22 +1880,4 @@ typedef enum {
|
||||
GTK_FONT_RENDERING_MANUAL,
|
||||
} GtkFontRendering;
|
||||
|
||||
/**
|
||||
* GtkColorScheme:
|
||||
* @GTK_COLOR_SCHEME_LIGHT: A light color scheme is used
|
||||
* @GTK_COLOR_SCHEME_DARK: A dark color scheme is used
|
||||
*
|
||||
* Values for the [property@Gtk.Settings:gtk-color-scheme] property
|
||||
* that indicate what color scheme is used.
|
||||
*
|
||||
* This information can be used inside CSS to select appropriate colors
|
||||
* with the light-dark() function.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
typedef enum {
|
||||
GTK_COLOR_SCHEME_LIGHT,
|
||||
GTK_COLOR_SCHEME_DARK
|
||||
} GtkColorScheme;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -203,7 +203,6 @@ enum {
|
||||
PROP_KEYNAV_USE_CARET,
|
||||
PROP_OVERLAY_SCROLLING,
|
||||
PROP_FONT_RENDERING,
|
||||
PROP_COLOR_SCHEME,
|
||||
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
@@ -978,24 +977,6 @@ gtk_settings_class_init (GtkSettingsClass *class)
|
||||
GTK_FONT_RENDERING_AUTOMATIC,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
/**
|
||||
* GtkSettings:gtk-color-scheme:
|
||||
*
|
||||
* The used color scheme.
|
||||
*
|
||||
* GTK can not determine this on its own and relies on application or
|
||||
* platform libraries to set this property appropriately.
|
||||
*
|
||||
* The used color scheme can affect color selection inside CSS with
|
||||
* the light-dark() function.
|
||||
*
|
||||
* Since: 4.16
|
||||
*/
|
||||
pspecs[PROP_COLOR_SCHEME] = g_param_spec_enum ("gtk-color-scheme", NULL, NULL,
|
||||
GTK_TYPE_COLOR_SCHEME,
|
||||
GTK_COLOR_SCHEME_LIGHT,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (gobject_class, NUM_PROPERTIES, pspecs);
|
||||
}
|
||||
|
||||
@@ -1311,8 +1292,6 @@ gtk_settings_notify (GObject *object,
|
||||
case PROP_CURSOR_THEME_SIZE:
|
||||
settings_update_cursor_theme (settings);
|
||||
break;
|
||||
case PROP_COLOR_SCHEME:
|
||||
gtk_system_setting_changed (settings->display, GTK_SYSTEM_SETTING_COLOR_SCHEME);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
217
gtk/gtkwidget.c
217
gtk/gtkwidget.c
@@ -2322,6 +2322,10 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
|
||||
priv->alloc_needed = TRUE;
|
||||
priv->alloc_needed_on_child = TRUE;
|
||||
priv->draw_needed = TRUE;
|
||||
priv->background_draw_needed = TRUE;
|
||||
priv->border_draw_needed = TRUE;
|
||||
priv->content_draw_needed = TRUE;
|
||||
priv->outline_draw_needed = TRUE;
|
||||
priv->focus_on_click = TRUE;
|
||||
priv->can_focus = TRUE;
|
||||
priv->focusable = FALSE;
|
||||
@@ -3489,6 +3493,64 @@ gtk_widget_unrealize (GtkWidget *widget)
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_WIDGET_DRAW_BACKGROUND = 1 << 0,
|
||||
GTK_WIDGET_DRAW_BORDER = 1 << 1,
|
||||
GTK_WIDGET_DRAW_CONTENT = 1 << 2,
|
||||
GTK_WIDGET_DRAW_OUTLINE = 1 << 3
|
||||
} GtkWidgetDrawFlags;
|
||||
|
||||
static void
|
||||
gtk_widget_queue_draw_node (GtkWidget *widget,
|
||||
GtkWidgetDrawFlags flags)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
/* Just return if the widget isn't mapped */
|
||||
if (!_gtk_widget_get_mapped (widget))
|
||||
return;
|
||||
|
||||
if (flags & GTK_WIDGET_DRAW_BACKGROUND)
|
||||
{
|
||||
g_clear_pointer (&priv->background_node, gsk_render_node_unref);
|
||||
priv->background_draw_needed = TRUE;
|
||||
}
|
||||
if (flags & GTK_WIDGET_DRAW_BORDER)
|
||||
{
|
||||
g_clear_pointer (&priv->border_node, gsk_render_node_unref);
|
||||
priv->border_draw_needed = TRUE;
|
||||
}
|
||||
if (flags & GTK_WIDGET_DRAW_CONTENT)
|
||||
{
|
||||
g_clear_pointer (&priv->content_node, gsk_render_node_unref);
|
||||
priv->content_draw_needed = TRUE;
|
||||
}
|
||||
if (flags & GTK_WIDGET_DRAW_OUTLINE)
|
||||
{
|
||||
g_clear_pointer (&priv->outline_node, gsk_render_node_unref);
|
||||
priv->outline_draw_needed = TRUE;
|
||||
}
|
||||
|
||||
for (GtkWidget *w = widget; w; w = _gtk_widget_get_parent (w))
|
||||
{
|
||||
priv = gtk_widget_get_instance_private (w);
|
||||
|
||||
if (priv->draw_needed)
|
||||
break;
|
||||
|
||||
priv->draw_needed = TRUE;
|
||||
g_clear_pointer (&priv->render_node, gsk_render_node_unref);
|
||||
if (w != widget)
|
||||
{
|
||||
g_clear_pointer (&priv->content_node, gsk_render_node_unref);
|
||||
priv->content_draw_needed = TRUE;
|
||||
}
|
||||
if (GTK_IS_NATIVE (w) && _gtk_widget_get_realized (w))
|
||||
gdk_surface_queue_render (gtk_native_get_surface (GTK_NATIVE (w)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_queue_draw:
|
||||
* @widget: a `GtkWidget`
|
||||
@@ -3504,22 +3566,7 @@ gtk_widget_queue_draw (GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
/* Just return if the widget isn't mapped */
|
||||
if (!_gtk_widget_get_mapped (widget))
|
||||
return;
|
||||
|
||||
for (; widget; widget = _gtk_widget_get_parent (widget))
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
if (priv->draw_needed)
|
||||
break;
|
||||
|
||||
priv->draw_needed = TRUE;
|
||||
g_clear_pointer (&priv->render_node, gsk_render_node_unref);
|
||||
if (GTK_IS_NATIVE (widget) && _gtk_widget_get_realized (widget))
|
||||
gdk_surface_queue_render (gtk_native_get_surface (GTK_NATIVE (widget)));
|
||||
}
|
||||
gtk_widget_queue_draw_node (widget, GTK_WIDGET_DRAW_CONTENT);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -5001,7 +5048,19 @@ gtk_widget_real_css_changed (GtkWidget *widget,
|
||||
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_REDRAW) ||
|
||||
(has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_CONTENT)))
|
||||
{
|
||||
gtk_widget_queue_draw (widget);
|
||||
GtkWidgetDrawFlags flags = 0;
|
||||
|
||||
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_CONTENT) ||
|
||||
(has_text && gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_CONTENT)))
|
||||
flags |= GTK_WIDGET_DRAW_CONTENT;
|
||||
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_BACKGROUND))
|
||||
flags |= GTK_WIDGET_DRAW_BACKGROUND;
|
||||
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_BORDER))
|
||||
flags |= GTK_WIDGET_DRAW_BORDER;
|
||||
if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_OUTLINE))
|
||||
flags |= GTK_WIDGET_DRAW_OUTLINE;
|
||||
|
||||
gtk_widget_queue_draw_node (widget, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5018,7 +5077,6 @@ static void
|
||||
gtk_widget_real_system_setting_changed (GtkWidget *widget,
|
||||
GtkSystemSetting setting)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkWidget *child;
|
||||
|
||||
if (setting == GTK_SYSTEM_SETTING_DPI ||
|
||||
@@ -5030,11 +5088,6 @@ gtk_widget_real_system_setting_changed (GtkWidget *widget,
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
|
||||
if (setting == GTK_SYSTEM_SETTING_COLOR_SCHEME)
|
||||
{
|
||||
gtk_css_node_invalidate (priv->cssnode, GTK_CSS_CHANGE_SOURCE);
|
||||
}
|
||||
|
||||
for (child = _gtk_widget_get_first_child (widget);
|
||||
child != NULL;
|
||||
child = _gtk_widget_get_next_sibling (child))
|
||||
@@ -11850,11 +11903,106 @@ gtk_widget_list_controllers (GtkWidget *widget,
|
||||
return (GtkEventController **)g_ptr_array_free (controllers, FALSE);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_widget_ensure_background_node (GtkWidget *widget,
|
||||
GtkCssBoxes *boxes)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
if (priv->background_draw_needed)
|
||||
{
|
||||
GtkSnapshot *snapshot;
|
||||
|
||||
g_clear_pointer (&priv->background_node, gsk_render_node_unref);
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gtk_css_style_snapshot_background (boxes, snapshot);
|
||||
priv->background_node = gtk_snapshot_free_to_node (snapshot);
|
||||
}
|
||||
|
||||
return priv->background_node;
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_widget_ensure_border_node (GtkWidget *widget,
|
||||
GtkCssBoxes *boxes)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
if (priv->border_draw_needed)
|
||||
{
|
||||
GtkSnapshot *snapshot;
|
||||
|
||||
g_clear_pointer (&priv->border_node, gsk_render_node_unref);
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gtk_css_style_snapshot_border (boxes, snapshot);
|
||||
priv->border_node = gtk_snapshot_free_to_node (snapshot);
|
||||
}
|
||||
|
||||
return priv->border_node;
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_widget_ensure_content_node (GtkWidget *widget,
|
||||
GtkCssBoxes *boxes)
|
||||
{
|
||||
GtkWidgetClass *klass = GTK_WIDGET_GET_CLASS (widget);
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
if (priv->content_draw_needed)
|
||||
{
|
||||
GtkSnapshot *snapshot;
|
||||
|
||||
g_clear_pointer (&priv->content_node, gsk_render_node_unref);
|
||||
snapshot = gtk_snapshot_new ();
|
||||
|
||||
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
||||
{
|
||||
gtk_snapshot_push_rounded_clip (snapshot, gtk_css_boxes_get_padding_box (boxes));
|
||||
klass->snapshot (widget, snapshot);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
klass->snapshot (widget, snapshot);
|
||||
}
|
||||
|
||||
priv->content_node = gtk_snapshot_free_to_node (snapshot);
|
||||
}
|
||||
|
||||
return priv->content_node;
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_widget_ensure_outline_node (GtkWidget *widget,
|
||||
GtkCssBoxes *boxes)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
if (priv->outline_draw_needed)
|
||||
{
|
||||
GtkSnapshot *snapshot;
|
||||
|
||||
g_clear_pointer (&priv->outline_node, gsk_render_node_unref);
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gtk_css_style_snapshot_outline (boxes, snapshot);
|
||||
priv->outline_node = gtk_snapshot_free_to_node (snapshot);
|
||||
}
|
||||
|
||||
return priv->outline_node;
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_append (GtkSnapshot *snapshot,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
if (node)
|
||||
gtk_snapshot_append_node (snapshot, node);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
gtk_widget_create_render_node (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkWidgetClass *klass = GTK_WIDGET_GET_CLASS (widget);
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkCssBoxes boxes;
|
||||
GtkCssValue *filter_value;
|
||||
@@ -11882,21 +12030,10 @@ gtk_widget_create_render_node (GtkWidget *widget,
|
||||
if (opacity < 1.0)
|
||||
gtk_snapshot_push_opacity (snapshot, opacity);
|
||||
|
||||
gtk_css_style_snapshot_background (&boxes, snapshot);
|
||||
gtk_css_style_snapshot_border (&boxes, snapshot);
|
||||
|
||||
if (priv->overflow == GTK_OVERFLOW_HIDDEN)
|
||||
{
|
||||
gtk_snapshot_push_rounded_clip (snapshot, gtk_css_boxes_get_padding_box (&boxes));
|
||||
klass->snapshot (widget, snapshot);
|
||||
gtk_snapshot_pop (snapshot);
|
||||
}
|
||||
else
|
||||
{
|
||||
klass->snapshot (widget, snapshot);
|
||||
}
|
||||
|
||||
gtk_css_style_snapshot_outline (&boxes, snapshot);
|
||||
maybe_append (snapshot, gtk_widget_ensure_background_node (widget, &boxes));
|
||||
maybe_append (snapshot, gtk_widget_ensure_border_node (widget, &boxes));
|
||||
maybe_append (snapshot, gtk_widget_ensure_content_node (widget, &boxes));
|
||||
maybe_append (snapshot, gtk_widget_ensure_outline_node (widget, &boxes));
|
||||
|
||||
if (opacity < 1.0)
|
||||
gtk_snapshot_pop (snapshot);
|
||||
@@ -11909,7 +12046,7 @@ gtk_widget_create_render_node (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_do_snapshot (GtkWidget *widget,
|
||||
gtk_widget_do_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
|
||||
@@ -88,7 +88,12 @@ struct _GtkWidgetPrivate
|
||||
guint alloc_needed_on_child : 1; /* 0 or more children - or this widget - need a size_allocate() call */
|
||||
|
||||
/* Queue-draw related flags */
|
||||
guint draw_needed : 1;
|
||||
guint draw_needed : 1;
|
||||
guint background_draw_needed : 1;
|
||||
guint border_draw_needed : 1;
|
||||
guint content_draw_needed : 1;
|
||||
guint outline_draw_needed : 1;
|
||||
|
||||
/* Expand-related flags */
|
||||
guint need_compute_expand : 1; /* Need to recompute computed_[hv]_expand */
|
||||
guint computed_hexpand : 1; /* computed results (composite of child flags) */
|
||||
@@ -166,6 +171,10 @@ struct _GtkWidgetPrivate
|
||||
|
||||
/* The render node we draw or %NULL if not yet created.*/
|
||||
GskRenderNode *render_node;
|
||||
GskRenderNode *background_node;
|
||||
GskRenderNode *border_node;
|
||||
GskRenderNode *content_node;
|
||||
GskRenderNode *outline_node;
|
||||
|
||||
/* The layout manager, or %NULL */
|
||||
GtkLayoutManager *layout_manager;
|
||||
|
||||
@@ -1002,7 +1002,6 @@ gtk_deps = [
|
||||
platform_gio_dep,
|
||||
pangocairo_dep,
|
||||
harfbuzz_dep,
|
||||
hb_subset_dep,
|
||||
fribidi_dep,
|
||||
cairogobj_dep,
|
||||
fontconfig_dep,
|
||||
|
||||
@@ -93,22 +93,22 @@ $_wm_highlight: if($variant=='light', $top_hilight, // Sass gets mad if this is
|
||||
/*
|
||||
these colors are exported for the window manager and shouldn't be used in applications,
|
||||
read if you used those and something break with a version upgrade you're on your own... */
|
||||
@define-color wm_title hsl(from #{$fg_color} h calc(s * 1.8) calc(l * 1.8));
|
||||
@define-color wm_title shade(#{$fg_color}, 1.8);
|
||||
@define-color wm_unfocused_title #{$backdrop_fg_color};
|
||||
@define-color wm_highlight #{"" + $_wm_highlight};
|
||||
@define-color wm_borders_edge #{"" + $borders_edge};
|
||||
|
||||
@define-color wm_bg_a hsl(from #{$bg_color} h calc(s * 1.2) calc(l * 1.2));
|
||||
@define-color wm_bg_a shade(#{$bg_color}, 1.2);
|
||||
@define-color wm_bg_b #{$bg_color};
|
||||
|
||||
@define-color wm_shadow rgb(from black r g b / calc(alpha * 0.35));
|
||||
@define-color wm_border rgb(from black r g b / calc(alpha * 0.18));
|
||||
@define-color wm_shadow alpha(black, 0.35);
|
||||
@define-color wm_border alpha(black, 0.18);
|
||||
|
||||
@define-color wm_button_hover_color_a hsl(from #{$bg_color} h calc(s * 1.3) calc(l * 1.3));
|
||||
@define-color wm_button_hover_color_a shade(#{$bg_color}, 1.3);
|
||||
@define-color wm_button_hover_color_b #{$bg_color};
|
||||
@define-color wm_button_active_color_a hsl(from #{$bg_color} h calc(s * 0.85) calc(l * 0.85));
|
||||
@define-color wm_button_active_color_b hsl(from #{$bg_color} h calc(s * 0.89) calc(l * 0.89));
|
||||
@define-color wm_button_active_color_c hsl(from #{$bg_color} h calc(s * 0.9) calc(l * 0.9));
|
||||
@define-color wm_button_active_color_a shade(#{$bg_color}, 0.85);
|
||||
@define-color wm_button_active_color_b shade(#{$bg_color}, 0.89);
|
||||
@define-color wm_button_active_color_c shade(#{$bg_color}, 0.9);
|
||||
|
||||
//FIXME this is really an API
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@function gtkalpha($c,$a) {
|
||||
@return unquote("rgb(from #{$c} r g b / calc(alpha * #{$a}))");
|
||||
@return unquote("alpha(#{$c},#{$a})");
|
||||
}
|
||||
|
||||
$ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
|
||||
|
||||
@@ -71,17 +71,6 @@
|
||||
<property name="tooltip-text" translatable="yes">Create Folder</property>
|
||||
<property name="popover">new_folder_popover</property>
|
||||
<property name="icon-name">folder-new-symbolic</property>
|
||||
<child>
|
||||
<object class="GtkShortcutController">
|
||||
<property name="scope">managed</property>
|
||||
<child>
|
||||
<object class="GtkShortcut">
|
||||
<property name="trigger"><Control><Shift>N</property>
|
||||
<property name="action">activate</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -399,7 +399,6 @@ fribidi_dep = dependency('fribidi', version: fribidi_req,
|
||||
default_options: ['docs=false'])
|
||||
harfbuzz_dep = dependency('harfbuzz', version: harfbuzz_req,
|
||||
default_options: ['coretext=enabled'])
|
||||
hb_subset_dep = dependency('harfbuzz-subset', version: harfbuzz_req)
|
||||
|
||||
# Require PangoFT2 if on X11 or wayland
|
||||
pangoft_dep = dependency('pangoft2', version: pango_req,
|
||||
|
||||
27
po/sl.po
27
po/sl.po
@@ -11,8 +11,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: gtk+ master\n"
|
||||
"Report-Msgid-Bugs-To: https://gitlab.gnome.org/GNOME/gtk/-/issues/\n"
|
||||
"POT-Creation-Date: 2024-06-03 12:48+0000\n"
|
||||
"PO-Revision-Date: 2024-06-04 09:27+0200\n"
|
||||
"POT-Creation-Date: 2024-05-31 21:05+0000\n"
|
||||
"PO-Revision-Date: 2024-06-01 10:53+0200\n"
|
||||
"Last-Translator: Martin Srebotnjak <miles@filmsi.net>\n"
|
||||
"Language-Team: Slovenian GNOME Translation Team <gnome-si@googlegroups.com>\n"
|
||||
"Language: sl_SI\n"
|
||||
@@ -1295,7 +1295,7 @@ msgstr ""
|
||||
#. * translated on keyboards used for your language, don't translate
|
||||
#. * this.
|
||||
#.
|
||||
#: gtk/gtkaccelgroup.c:839 gtk/gtkshortcutlabel.c:101
|
||||
#: gtk/gtkaccelgroup.c:837 gtk/gtkshortcutlabel.c:101
|
||||
#: gtk/gtkshortcutlabel.c:137
|
||||
msgctxt "keyboard label"
|
||||
msgid "Shift"
|
||||
@@ -1306,7 +1306,7 @@ msgstr "Shift"
|
||||
#. * translated on keyboards used for your language, don't translate
|
||||
#. * this.
|
||||
#.
|
||||
#: gtk/gtkaccelgroup.c:858 gtk/gtkshortcutlabel.c:104
|
||||
#: gtk/gtkaccelgroup.c:856 gtk/gtkshortcutlabel.c:104
|
||||
#: gtk/gtkshortcutlabel.c:139
|
||||
msgctxt "keyboard label"
|
||||
msgid "Ctrl"
|
||||
@@ -1317,7 +1317,7 @@ msgstr "Ctrl"
|
||||
#. * translated on keyboards used for your language, don't translate
|
||||
#. * this.
|
||||
#.
|
||||
#: gtk/gtkaccelgroup.c:877 gtk/gtkshortcutlabel.c:107
|
||||
#: gtk/gtkaccelgroup.c:875 gtk/gtkshortcutlabel.c:107
|
||||
#: gtk/gtkshortcutlabel.c:141
|
||||
msgctxt "keyboard label"
|
||||
msgid "Alt"
|
||||
@@ -1328,7 +1328,7 @@ msgstr "Alt"
|
||||
#. * translated on keyboards used for your language, don't translate
|
||||
#. * this.
|
||||
#.
|
||||
#: gtk/gtkaccelgroup.c:895 gtk/gtkshortcutlabel.c:113
|
||||
#: gtk/gtkaccelgroup.c:893 gtk/gtkshortcutlabel.c:113
|
||||
#: gtk/gtkshortcutlabel.c:143
|
||||
msgctxt "keyboard label"
|
||||
msgid "Super"
|
||||
@@ -1339,7 +1339,7 @@ msgstr "Super"
|
||||
#. * translated on keyboards used for your language, don't translate
|
||||
#. * this.
|
||||
#.
|
||||
#: gtk/gtkaccelgroup.c:909 gtk/gtkshortcutlabel.c:116
|
||||
#: gtk/gtkaccelgroup.c:907 gtk/gtkshortcutlabel.c:116
|
||||
#: gtk/gtkshortcutlabel.c:145
|
||||
msgctxt "keyboard label"
|
||||
msgid "Hyper"
|
||||
@@ -1350,7 +1350,7 @@ msgstr "Hiper"
|
||||
#. * translated on keyboards used for your language, don't translate
|
||||
#. * this.
|
||||
#.
|
||||
#: gtk/gtkaccelgroup.c:924 gtk/gtkshortcutlabel.c:110
|
||||
#: gtk/gtkaccelgroup.c:922 gtk/gtkshortcutlabel.c:110
|
||||
#: gtk/gtkshortcutlabel.c:148
|
||||
msgctxt "keyboard label"
|
||||
msgid "Meta"
|
||||
@@ -1360,17 +1360,17 @@ msgstr "Meta"
|
||||
#. * be used in accelerators such as "Ctrl+Shift+KP 1" in menus,
|
||||
#. * and therefore the translation needs to be very short.
|
||||
#.
|
||||
#: gtk/gtkaccelgroup.c:944
|
||||
#: gtk/gtkaccelgroup.c:942
|
||||
msgctxt "keyboard label"
|
||||
msgid "KP"
|
||||
msgstr "KP"
|
||||
|
||||
#: gtk/gtkaccelgroup.c:951
|
||||
#: gtk/gtkaccelgroup.c:949
|
||||
msgctxt "keyboard label"
|
||||
msgid "Space"
|
||||
msgstr "Preslednica"
|
||||
|
||||
#: gtk/gtkaccelgroup.c:954 gtk/gtkshortcutlabel.c:176
|
||||
#: gtk/gtkaccelgroup.c:952 gtk/gtkshortcutlabel.c:176
|
||||
msgctxt "keyboard label"
|
||||
msgid "Backslash"
|
||||
msgstr "Leva poševnica"
|
||||
@@ -2482,7 +2482,6 @@ msgid "Yesterday"
|
||||
msgstr "Včeraj"
|
||||
|
||||
#: gtk/gtkfilechooserwidget.c:3777
|
||||
#, c-format
|
||||
msgid "%-e %b"
|
||||
msgstr "%-e %b"
|
||||
|
||||
@@ -4219,7 +4218,7 @@ msgstr "Vir:"
|
||||
msgid "Defined At"
|
||||
msgstr "Določeno pri"
|
||||
|
||||
#: gtk/inspector/recorder.c:1951
|
||||
#: gtk/inspector/recorder.c:1950
|
||||
#, c-format
|
||||
msgid "Saving RenderNode failed"
|
||||
msgstr "Shranjevanje izrisovanja vozlišča je spodletelo"
|
||||
@@ -7822,7 +7821,6 @@ msgid ""
|
||||
"Commands:\n"
|
||||
" benchmark Benchmark rendering of a node\n"
|
||||
" compare Compare nodes or images\n"
|
||||
" extract Extract data urls\n"
|
||||
" info Provide information about the node\n"
|
||||
" show Show the node\n"
|
||||
" render Take a screenshot of the node\n"
|
||||
@@ -7836,7 +7834,6 @@ msgstr ""
|
||||
"Ukazi:\n"
|
||||
" benchmark Preizkusno izrisovanje vozlišča\n"
|
||||
" compare Primerja vozlišča ali slike\n"
|
||||
" extract Izvleče url-je podatkov\n"
|
||||
" info Izpiše podatke o vozlišču\n"
|
||||
" show Pokaže vozlišče\n"
|
||||
" render Izdela zaslonsko sliko vozlišča\n"
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
a {
|
||||
color: color-mix(in srgb, red, blue);
|
||||
}
|
||||
|
||||
b {
|
||||
color: color-mix(in srgb, red 50%, blue 50%);
|
||||
}
|
||||
|
||||
c {
|
||||
color: color-mix(in srgb, red 25%, blue);
|
||||
}
|
||||
|
||||
d {
|
||||
color: color-mix(in srgb, red, blue 25%);
|
||||
}
|
||||
|
||||
e {
|
||||
color: color-mix(in srgb, red 20%, blue 30%);
|
||||
}
|
||||
|
||||
f {
|
||||
color: color-mix(in srgb, red 60%, blue 90%);
|
||||
}
|
||||
|
||||
g {
|
||||
color: color-mix(in srgb-linear, red, blue);
|
||||
}
|
||||
|
||||
h {
|
||||
color: color-mix(in hsl, red, blue);
|
||||
}
|
||||
|
||||
i {
|
||||
color: color-mix(in hsl shorter hue, red, blue);
|
||||
}
|
||||
|
||||
j {
|
||||
color: color-mix(in hsl longer hue, red, blue);
|
||||
}
|
||||
|
||||
k {
|
||||
color: color-mix(in hsl increasing hue, red, blue);
|
||||
}
|
||||
|
||||
l {
|
||||
color: color-mix(in hsl decreasing hue, red, blue);
|
||||
}
|
||||
|
||||
m {
|
||||
color: color-mix(in hwb shorter hue, red, blue);
|
||||
}
|
||||
|
||||
n {
|
||||
color: color-mix(in oklch shorter hue, red, blue);
|
||||
}
|
||||
|
||||
o {
|
||||
color: color-mix(in oklab, red, blue);
|
||||
}
|
||||
|
||||
p {
|
||||
color: color-mix(in);
|
||||
}
|
||||
|
||||
q {
|
||||
color: color-mix(in srgb);
|
||||
}
|
||||
|
||||
r {
|
||||
color: color-mix(in srgb longer hue, red, blue);
|
||||
}
|
||||
|
||||
s {
|
||||
color: color-mix(in hsl wider hue, red, blue);
|
||||
}
|
||||
|
||||
t {
|
||||
color: color-mix(in hsl, red);
|
||||
}
|
||||
|
||||
u {
|
||||
color: color-mix(in hsl, red, 50%);
|
||||
}
|
||||
|
||||
v {
|
||||
color: color-mix(in hsl, white, black calc(20% + 30%));
|
||||
}
|
||||
|
||||
w {
|
||||
color: color-mix(in srgb, currentColor 50%, transparent 50%);
|
||||
}
|
||||
|
||||
x {
|
||||
color: color-mix(in srgb-linear, currentColor 25%, transparent);
|
||||
}
|
||||
|
||||
y {
|
||||
color: color-mix(in hsl, currentColor, transparent 25%);
|
||||
}
|
||||
|
||||
z {
|
||||
color: color-mix(in srgb-linear, currentColor 50%, transparent);
|
||||
}
|
||||
|
||||
aa {
|
||||
color: color-mix(in hsl, currentColor, transparent 50%);
|
||||
}
|
||||
|
||||
ab {
|
||||
color: color-mix(in hsl longer hue, currentColor 20%, transparent 30%);
|
||||
}
|
||||
|
||||
ac {
|
||||
color: color-mix(in hwb, currentColor 60%, transparent 90%);
|
||||
}
|
||||
|
||||
ad {
|
||||
color: color-mix(in oklch, currentColor 60%, transparent 90%);
|
||||
}
|
||||
|
||||
ae {
|
||||
color: color-mix(in oklab, currentColor 60%, transparent 90%);
|
||||
}
|
||||
|
||||
af {
|
||||
color: color-mix(in srgb, 30% red, 70% blue);
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
color-mix.css:62:22-23: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
color-mix.css:66:27-28: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
color-mix.css:70:28-34: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
color-mix.css:74:27-32: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
color-mix.css:78:31-32: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
color-mix.css:82:36-37: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
@@ -1,103 +0,0 @@
|
||||
a {
|
||||
color: color(srgb 0.5 0 0.5);
|
||||
}
|
||||
|
||||
b {
|
||||
color: color(srgb 0.5 0 0.5);
|
||||
}
|
||||
|
||||
c {
|
||||
color: color(srgb 0.25 0 0.75);
|
||||
}
|
||||
|
||||
d {
|
||||
color: color(srgb 0.75 0 0.25);
|
||||
}
|
||||
|
||||
e {
|
||||
color: color(srgb 0.4 0 0.6 / 0.5);
|
||||
}
|
||||
|
||||
f {
|
||||
color: color(srgb 0.4 0 0.6);
|
||||
}
|
||||
|
||||
g {
|
||||
color: color(srgb-linear 0.5 0 0.5);
|
||||
}
|
||||
|
||||
h {
|
||||
color: color(srgb 1 0 1);
|
||||
}
|
||||
|
||||
i {
|
||||
color: color(srgb 1 0 1);
|
||||
}
|
||||
|
||||
j {
|
||||
color: color(srgb 0 1 0);
|
||||
}
|
||||
|
||||
k {
|
||||
color: color(srgb 0 1 0);
|
||||
}
|
||||
|
||||
l {
|
||||
color: color(srgb 1 0 1);
|
||||
}
|
||||
|
||||
m {
|
||||
color: color(srgb 1 0 1);
|
||||
}
|
||||
|
||||
n {
|
||||
color: oklch(0.539985 0.285449 326.643);
|
||||
}
|
||||
|
||||
o {
|
||||
color: oklab(0.539985 0.096203 -0.0928409);
|
||||
}
|
||||
|
||||
v {
|
||||
color: color(srgb 0.5 0.5 0.5);
|
||||
}
|
||||
|
||||
w {
|
||||
color: color-mix(in srgb, currentcolor, rgba(0,0,0,0));
|
||||
}
|
||||
|
||||
x {
|
||||
color: color-mix(in srgb-linear, currentcolor 25%, rgba(0,0,0,0));
|
||||
}
|
||||
|
||||
y {
|
||||
color: color-mix(in hsl, currentcolor 75%, rgba(0,0,0,0));
|
||||
}
|
||||
|
||||
z {
|
||||
color: color-mix(in srgb-linear, currentcolor, rgba(0,0,0,0));
|
||||
}
|
||||
|
||||
aa {
|
||||
color: color-mix(in hsl, currentcolor, rgba(0,0,0,0));
|
||||
}
|
||||
|
||||
ab {
|
||||
color: color-mix(in hsl longer hue, currentcolor 20%, rgba(0,0,0,0) 30%);
|
||||
}
|
||||
|
||||
ac {
|
||||
color: color-mix(in hwb, currentcolor 60%, rgba(0,0,0,0) 90%);
|
||||
}
|
||||
|
||||
ad {
|
||||
color: color-mix(in oklch, currentcolor 60%, rgba(0,0,0,0) 90%);
|
||||
}
|
||||
|
||||
ae {
|
||||
color: color-mix(in oklab, currentcolor 60%, rgba(0,0,0,0) 90%);
|
||||
}
|
||||
|
||||
af {
|
||||
color: color(srgb 0.3 0 0.7);
|
||||
}
|
||||
@@ -204,9 +204,6 @@ test_data = [
|
||||
'colors-errors.css',
|
||||
'colors-errors.errors',
|
||||
'colors-errors.ref.css',
|
||||
'color-mix.css',
|
||||
'color-mix.errors',
|
||||
'color-mix.ref.css',
|
||||
'colors-red.css',
|
||||
'colors-red.ref.css',
|
||||
'comment-detection.css',
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
a {
|
||||
color: color(from rgb(100, 200, 10) srgb g g calc(b * 2));
|
||||
}
|
||||
|
||||
b {
|
||||
color: oklab(from white l 0.1 0.2);
|
||||
}
|
||||
|
||||
c {
|
||||
color: red;
|
||||
background-color: hsl(from currentcolor calc(h + 60) s l);
|
||||
}
|
||||
|
||||
d {
|
||||
color: oklab(from white r g b);
|
||||
}
|
||||
|
||||
e {
|
||||
color: rgb(from darkgoldenrod r g 100 / 50%);
|
||||
}
|
||||
|
||||
e {
|
||||
color: rgb(from rgba(30,40,50,60) r g 100 / alpha);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
relative-color.css:15:27-28: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||
@@ -1,20 +0,0 @@
|
||||
a {
|
||||
color: color(srgb 0.784314 0.784314 0.0784314);
|
||||
}
|
||||
|
||||
b {
|
||||
color: oklab(1 0.1 0.2);
|
||||
}
|
||||
|
||||
c {
|
||||
background-color: hsl(from currentcolor calc(h + 60) s l / alpha);
|
||||
color: rgb(255,0,0);
|
||||
}
|
||||
|
||||
e {
|
||||
color: color(from rgb(184,134,11) srgb 184 134 100 / 50%);
|
||||
}
|
||||
|
||||
e {
|
||||
color: rgb(30,40,100);
|
||||
}
|
||||
@@ -10,7 +10,6 @@ common_env = [
|
||||
'G_ENABLE_DIAGNOSTIC=0',
|
||||
'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
|
||||
'GDK_DEBUG=default-settings',
|
||||
'GTK_DEBUG=css',
|
||||
]
|
||||
exclude_unstable = ['flaky', 'failing']
|
||||
|
||||
|
||||
@@ -48,6 +48,22 @@ usage (void)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* A simplified version of g_log_writer_default_would_drop(), to avoid
|
||||
* bumping up the required version of GLib to 2.68
|
||||
*/
|
||||
static gboolean
|
||||
would_drop (GLogLevelFlags level,
|
||||
const char *domain)
|
||||
{
|
||||
#if GLIB_CHECK_VERSION (2, 68, 0)
|
||||
return g_log_writer_default_would_drop (level, domain);
|
||||
#else
|
||||
return (level & (G_LOG_LEVEL_ERROR |
|
||||
G_LOG_LEVEL_CRITICAL |
|
||||
G_LOG_LEVEL_WARNING)) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static GLogWriterOutput
|
||||
log_writer_func (GLogLevelFlags level,
|
||||
const GLogField *fields,
|
||||
@@ -66,7 +82,7 @@ log_writer_func (GLogLevelFlags level,
|
||||
message = fields[i].value;
|
||||
}
|
||||
|
||||
if (message != NULL && !g_log_writer_default_would_drop (level, domain))
|
||||
if (message != NULL && !would_drop (level, domain))
|
||||
{
|
||||
const char *prefix;
|
||||
switch (level & G_LOG_LEVEL_MASK)
|
||||
|
||||
@@ -1,326 +0,0 @@
|
||||
/* Copyright 2023 Red Hat, Inc.
|
||||
*
|
||||
* GTK is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* GTK is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with GTK; see the file COPYING. If not,
|
||||
* see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Matthias Clasen
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <glib/gprintf.h>
|
||||
#include <glib/gstdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "gtk-rendernode-tool.h"
|
||||
|
||||
static gboolean verbose;
|
||||
static char *directory = NULL;
|
||||
|
||||
static guint texture_count;
|
||||
static guint font_count;
|
||||
|
||||
static GHashTable *fonts;
|
||||
|
||||
static void
|
||||
extract_texture (GskRenderNode *node)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
char *filename;
|
||||
char *path;
|
||||
|
||||
if (gsk_render_node_get_node_type (node) == GSK_TEXTURE_NODE)
|
||||
texture = gsk_texture_node_get_texture (node);
|
||||
else
|
||||
texture = gsk_texture_scale_node_get_texture (node);
|
||||
|
||||
do {
|
||||
filename = g_strdup_printf ("gtk-texture-%u.ttf", texture_count);
|
||||
path = g_build_path ("/", directory, filename, NULL);
|
||||
|
||||
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
break;
|
||||
|
||||
g_free (path);
|
||||
g_free (filename);
|
||||
texture_count++;
|
||||
} while (TRUE);
|
||||
|
||||
if (verbose)
|
||||
g_print ("Writing %dx%d texture to %s\n",
|
||||
gdk_texture_get_width (texture),
|
||||
gdk_texture_get_height (texture),
|
||||
filename);
|
||||
|
||||
if (!gdk_texture_save_to_png (texture, path))
|
||||
{
|
||||
g_printerr (_("Failed to write %s\n"), filename);
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
g_free (filename);
|
||||
|
||||
texture_count++;
|
||||
}
|
||||
|
||||
static void
|
||||
extract_font (GskRenderNode *node)
|
||||
{
|
||||
PangoFont *font;
|
||||
hb_font_t *hb_font;
|
||||
hb_face_t *hb_face;
|
||||
hb_blob_t *hb_blob;
|
||||
const char *data;
|
||||
unsigned int length;
|
||||
char *filename;
|
||||
char *path;
|
||||
char *sum;
|
||||
|
||||
font = gsk_text_node_get_font (node);
|
||||
hb_font = pango_font_get_hb_font (font);
|
||||
hb_face = hb_font_get_face (hb_font);
|
||||
hb_blob = hb_face_reference_blob (hb_face);
|
||||
|
||||
if (hb_blob == hb_blob_get_empty ())
|
||||
{
|
||||
hb_blob_destroy (hb_blob);
|
||||
g_warning ("Failed to extract font data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
data = hb_blob_get_data (hb_blob, &length);
|
||||
|
||||
sum = g_compute_checksum_for_data (G_CHECKSUM_SHA256, (const guchar *)data, length);
|
||||
|
||||
if (!fonts)
|
||||
fonts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
|
||||
if (g_hash_table_contains (fonts, sum))
|
||||
{
|
||||
g_free (sum);
|
||||
hb_blob_destroy (hb_blob);
|
||||
return;
|
||||
}
|
||||
|
||||
g_hash_table_add (fonts, sum);
|
||||
|
||||
do {
|
||||
filename = g_strdup_printf ("gtk-font-%u.ttf", font_count);
|
||||
path = g_build_path ("/", directory, filename, NULL);
|
||||
|
||||
if (!g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
break;
|
||||
|
||||
g_free (path);
|
||||
g_free (filename);
|
||||
font_count++;
|
||||
} while (TRUE);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
|
||||
desc = pango_font_describe (font);
|
||||
g_print ("Writing font %s to %s\n",
|
||||
pango_font_description_get_family (desc),
|
||||
filename);
|
||||
pango_font_description_free (desc);
|
||||
}
|
||||
|
||||
if (!g_file_set_contents (path, data, length, NULL))
|
||||
{
|
||||
g_printerr (_("Failed to write %s\n"), filename);
|
||||
}
|
||||
|
||||
hb_blob_destroy (hb_blob);
|
||||
|
||||
g_free (path);
|
||||
g_free (filename);
|
||||
|
||||
font_count++;
|
||||
}
|
||||
|
||||
#define N_NODE_TYPES (GSK_SUBSURFACE_NODE + 1)
|
||||
static void
|
||||
extract_from_node (GskRenderNode *node)
|
||||
{
|
||||
g_assert (gsk_render_node_get_node_type (node) < N_NODE_TYPES);
|
||||
|
||||
switch (gsk_render_node_get_node_type (node))
|
||||
{
|
||||
case GSK_CONTAINER_NODE:
|
||||
for (unsigned int i = 0; i < gsk_container_node_get_n_children (node); i++)
|
||||
extract_from_node (gsk_container_node_get_child (node, i));
|
||||
break;
|
||||
|
||||
case GSK_CAIRO_NODE:
|
||||
case GSK_COLOR_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
case GSK_RADIAL_GRADIENT_NODE:
|
||||
case GSK_REPEATING_RADIAL_GRADIENT_NODE:
|
||||
case GSK_CONIC_GRADIENT_NODE:
|
||||
case GSK_BORDER_NODE:
|
||||
case GSK_INSET_SHADOW_NODE:
|
||||
case GSK_OUTSET_SHADOW_NODE:
|
||||
break;
|
||||
|
||||
case GSK_TEXTURE_NODE:
|
||||
case GSK_TEXTURE_SCALE_NODE:
|
||||
extract_texture (node);
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_NODE:
|
||||
extract_from_node (gsk_transform_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_OPACITY_NODE:
|
||||
extract_from_node (gsk_opacity_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_COLOR_MATRIX_NODE:
|
||||
extract_from_node (gsk_color_matrix_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_REPEAT_NODE:
|
||||
extract_from_node (gsk_repeat_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_CLIP_NODE:
|
||||
extract_from_node (gsk_clip_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_ROUNDED_CLIP_NODE:
|
||||
extract_from_node (gsk_rounded_clip_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_SHADOW_NODE:
|
||||
extract_from_node (gsk_shadow_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_BLEND_NODE:
|
||||
extract_from_node (gsk_blend_node_get_bottom_child (node));
|
||||
extract_from_node (gsk_blend_node_get_top_child (node));
|
||||
break;
|
||||
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
extract_from_node (gsk_cross_fade_node_get_start_child (node));
|
||||
extract_from_node (gsk_cross_fade_node_get_end_child (node));
|
||||
break;
|
||||
|
||||
case GSK_TEXT_NODE:
|
||||
extract_font (node);
|
||||
break;
|
||||
|
||||
case GSK_BLUR_NODE:
|
||||
extract_from_node (gsk_blur_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_DEBUG_NODE:
|
||||
extract_from_node (gsk_debug_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_GL_SHADER_NODE:
|
||||
for (unsigned int i = 0; i < gsk_gl_shader_node_get_n_children (node); i++)
|
||||
extract_from_node (gsk_gl_shader_node_get_child (node, i));
|
||||
break;
|
||||
|
||||
case GSK_MASK_NODE:
|
||||
extract_from_node (gsk_mask_node_get_source (node));
|
||||
extract_from_node (gsk_mask_node_get_mask (node));
|
||||
break;
|
||||
|
||||
case GSK_FILL_NODE:
|
||||
extract_from_node (gsk_fill_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_STROKE_NODE:
|
||||
extract_from_node (gsk_stroke_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_SUBSURFACE_NODE:
|
||||
extract_from_node (gsk_subsurface_node_get_child (node));
|
||||
break;
|
||||
|
||||
case GSK_NOT_A_RENDER_NODE:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
file_extract (const char *filename)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
|
||||
node = load_node_file (filename);
|
||||
|
||||
extract_from_node (node);
|
||||
|
||||
gsk_render_node_unref (node);
|
||||
}
|
||||
|
||||
void
|
||||
do_extract (int *argc,
|
||||
const char ***argv)
|
||||
{
|
||||
GOptionContext *context;
|
||||
char **filenames = NULL;
|
||||
const GOptionEntry entries[] = {
|
||||
{ "dir", 0, 0, G_OPTION_ARG_FILENAME, &directory, N_("Directory to use"), N_("DIRECTORY") },
|
||||
{ "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, N_("Be verbose"), NULL },
|
||||
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, N_("FILE") },
|
||||
{ NULL, }
|
||||
};
|
||||
GError *error = NULL;
|
||||
|
||||
g_set_prgname ("gtk4-rendernode-tool extract");
|
||||
context = g_option_context_new (NULL);
|
||||
g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
|
||||
g_option_context_add_main_entries (context, entries, NULL);
|
||||
g_option_context_set_summary (context, _("Extract data urls from the render node."));
|
||||
|
||||
if (!g_option_context_parse (context, argc, (char ***)argv, &error))
|
||||
{
|
||||
g_printerr ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
g_option_context_free (context);
|
||||
|
||||
if (filenames == NULL)
|
||||
{
|
||||
g_printerr (_("No .node file specified\n"));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (g_strv_length (filenames) > 1)
|
||||
{
|
||||
g_printerr (_("Can only accept a single .node file\n"));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (directory == NULL)
|
||||
directory = g_strdup (".");
|
||||
|
||||
file_extract (filenames[0]);
|
||||
|
||||
g_strfreev (filenames);
|
||||
g_free (directory);
|
||||
}
|
||||
@@ -40,7 +40,6 @@ usage (void)
|
||||
"Commands:\n"
|
||||
" benchmark Benchmark rendering of a node\n"
|
||||
" compare Compare nodes or images\n"
|
||||
" extract Extract data urls\n"
|
||||
" info Provide information about the node\n"
|
||||
" show Show the node\n"
|
||||
" render Take a screenshot of the node\n"
|
||||
@@ -120,8 +119,6 @@ main (int argc, const char *argv[])
|
||||
do_benchmark (&argc, &argv);
|
||||
else if (strcmp (argv[0], "compare") == 0)
|
||||
do_compare (&argc, &argv);
|
||||
else if (strcmp (argv[0], "extract") == 0)
|
||||
do_extract (&argc, &argv);
|
||||
else
|
||||
usage ();
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ void do_compare (int *argc, const char ***argv);
|
||||
void do_info (int *argc, const char ***argv);
|
||||
void do_show (int *argc, const char ***argv);
|
||||
void do_render (int *argc, const char ***argv);
|
||||
void do_extract (int *argc, const char ***argv);
|
||||
|
||||
GskRenderNode *load_node_file (const char *filename);
|
||||
GskRenderer *create_renderer (const char *name, GError **error);
|
||||
|
||||
@@ -43,7 +43,6 @@ gtk_tools = [
|
||||
['gtk4-rendernode-tool', ['gtk-rendernode-tool.c',
|
||||
'gtk-rendernode-tool-benchmark.c',
|
||||
'gtk-rendernode-tool-compare.c',
|
||||
'gtk-rendernode-tool-extract.c',
|
||||
'gtk-rendernode-tool-info.c',
|
||||
'gtk-rendernode-tool-render.c',
|
||||
'gtk-rendernode-tool-show.c',
|
||||
|
||||
Reference in New Issue
Block a user