diff --git a/meson.build b/meson.build index d64bb8372c06927d8f893a5b1b89d544f2b1365e..36b20d94b389a5b3682a2e3246a9aa9ca0a0ba08 100644 --- a/meson.build +++ b/meson.build @@ -101,6 +101,9 @@ endif libipuz_dep = dependency('libipuz-0.5', version: '>= 0.5.1') +cc = meson.get_compiler('c') +m_dep = cc.find_library('m', required : true) + word_list_inc = include_directories('src') # Variables used to translate puzzle_sets diff --git a/src/meson.build b/src/meson.build index 75b1135382364ea4cadad35c4cde316bbbe6fa20..1da74a2c5d933d0344425f85bf35aef5d49a332f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -244,6 +244,7 @@ crosswords_deps = [ libadwaita_dep, librsvg_dep, libword_list_dep, + m_dep, ] crosswords_resource_file_config = configuration_data() diff --git a/src/svg.c b/src/svg.c index d149437e307ac5a8037ae8e3d5af8ec7daf58458..c9db6c19c4e1877bc749c4b25cd806c9fc6f7fac 100644 --- a/src/svg.c +++ b/src/svg.c @@ -21,6 +21,8 @@ #include "crosswords-config.h" #include "svg.h" +#include + /* appends src to dest and consumes src */ static void append (GString *dest, GString *src) @@ -97,8 +99,11 @@ overlay_definitions (LayoutGeometry *g) gchar buf_a[G_ASCII_DTOSTR_BUF_SIZE]; gchar buf_b[G_ASCII_DTOSTR_BUF_SIZE]; gchar buf_c[G_ASCII_DTOSTR_BUF_SIZE]; + gchar buf_d[G_ASCII_DTOSTR_BUF_SIZE]; + gchar buf_e[G_ASCII_DTOSTR_BUF_SIZE]; double half_border = (double) g->border_size / 2.0; + double quarter_border = (double) g->border_size / 4.0; double double_border = (double) g->border_size * 2.0; double corner_radius = (double) g->border_size; g_string_append (s, "\n"); @@ -180,15 +185,61 @@ overlay_definitions (LayoutGeometry *g) /* divided */ g_string_append_printf (s, - "\n", + "\n", g_ascii_dtostr (buf_a, sizeof (buf_a), g->cell_size/2.0), g->cell_size, - g_ascii_dtostr (buf_b, sizeof (buf_b), half_border)); + g_ascii_dtostr (buf_b, sizeof (buf_b), half_border), + g_ascii_dtostr (buf_c, sizeof (buf_c), - quarter_border)); g_string_append_printf (s, - "\n", + "\n", g_ascii_dtostr (buf_a, sizeof (buf_a), g->cell_size/2.0), g_ascii_dtostr (buf_b, sizeof (buf_b), half_border), - g->cell_size); + g->cell_size, + g_ascii_dtostr (buf_c, sizeof (buf_c), - quarter_border)); + g_string_append_printf (s, + "\n", + g_ascii_dtostr (buf_a, sizeof (buf_a), g->cell_size/2.0), + g_ascii_dtostr (buf_b, sizeof (buf_b), sqrt (2) * g->cell_size), + g_ascii_dtostr (buf_c, sizeof (buf_c), half_border), + buf_a, + buf_a, + g_ascii_dtostr (buf_d, sizeof (buf_d), - (sqrt (2) * g->cell_size - g->cell_size) / 2), + g_ascii_dtostr (buf_e, sizeof (buf_e), - quarter_border)); + g_string_append_printf (s, + "\n", + g_ascii_dtostr (buf_a, sizeof (buf_a), g->cell_size/2.0), + g_ascii_dtostr (buf_b, sizeof (buf_b), sqrt (2) * g->cell_size), + g_ascii_dtostr (buf_c, sizeof (buf_c), half_border), + buf_a, + buf_a, + g_ascii_dtostr (buf_d, sizeof (buf_d), - (sqrt (2) * g->cell_size - g->cell_size) / 2), + g_ascii_dtostr (buf_e, sizeof (buf_e), - quarter_border)); + g_string_append_printf (s, + "\n", + g_ascii_dtostr (buf_a, sizeof (buf_a), g->cell_size/2.0), + g->cell_size, + g_ascii_dtostr (buf_b, sizeof (buf_b), half_border), + g_ascii_dtostr (buf_c, sizeof (buf_c), - quarter_border), + buf_a, + buf_b, + g->cell_size, + buf_c); + g_string_append_printf (s, + "\n", + g_ascii_dtostr (buf_a, sizeof (buf_a), g->cell_size/2.0), + g_ascii_dtostr (buf_b, sizeof (buf_b), sqrt (2) * g->cell_size), + g_ascii_dtostr (buf_c, sizeof (buf_c), half_border), + buf_a, + buf_a, + g_ascii_dtostr (buf_d, sizeof (buf_d), - (sqrt (2) * g->cell_size - g->cell_size) / 2), + g_ascii_dtostr (buf_e, sizeof (buf_e), - quarter_border), + buf_a, + buf_b, + buf_c, + buf_a, + buf_a, + buf_d, + buf_e); /* The following arrows come from docs/arrows.svg */ g_ascii_dtostr (buf_a, sizeof (buf_a), scale_for_arrows (g)); @@ -553,6 +604,8 @@ divided (GridLayout *layout) { IpuzStyleDivided divided = IPUZ_STYLE_DIVIDED_NONE; LayoutItemKind kind; + LayoutItemCellStyle cell_style; + gchar *classes = ""; GridCoord coord = { .row = row, .column = column, @@ -564,11 +617,13 @@ divided (GridLayout *layout) { LayoutCell cell = grid_layout_get_cell (layout, coord); divided = cell.divided; + cell_style = cell.css_class; } else if (kind == LAYOUT_ITEM_KIND_CLUE_BLOCK_CELL) { LayoutClueBlockCell cell = grid_layout_get_clue_block_cell (layout, coord); divided = cell.divided; + cell_style = cell.css_class; } else continue; @@ -580,10 +635,25 @@ divided (GridLayout *layout) id = "divided_horiz"; else if (divided == IPUZ_STYLE_DIVIDED_VERT) id = "divided_vert"; - /* FIXME: handle the rest */ + else if (divided == IPUZ_STYLE_DIVIDED_UP_RIGHT) + id = "divided_up_right"; + else if (divided == IPUZ_STYLE_DIVIDED_UP_LEFT) + id = "divided_up_left"; + else if (divided == IPUZ_STYLE_DIVIDED_PLUS) + id = "divided_plus"; + else if (divided == IPUZ_STYLE_DIVIDED_CROSS) + id = "divided_cross"; + + if (cell_style == LAYOUT_ITEM_STYLE_FOCUSED + || cell_style == LAYOUT_ITEM_STYLE_FOCUSED_BLOCK + || cell_style == LAYOUT_ITEM_STYLE_SELECTED_FOCUSED + || cell_style == LAYOUT_ITEM_STYLE_SELECTED_FOCUSED_BLOCK) + classes = "divided-focused"; + else + classes = "divided"; if (id) - append (s, positioned_instance (id, NULL, xpos, ypos)); + append (s, positioned_instance (id, classes, xpos, ypos)); } } @@ -787,6 +857,8 @@ svg_overlays_from_layout (GridLayout *layout) static const char dark_stylesheet[] = ".barred-focused { fill: #1a5fb4; }\n" + ".divided { fill: black; }\n" + ".divided-focused { fill: #1a5fb4; }\n" ".border { fill: black; }\n" ".enumeration { fill: #888888; }\n" ".arrow { fill: black; }\n" @@ -794,6 +866,8 @@ static const char dark_stylesheet[] = static const char light_stylesheet[] = ".barred-focused { fill: #1a5fb4; }\n" + ".divided { fill: black; }\n" + ".divided-focused { fill: #1a5fb4; }\n" ".border { fill: black; }\n" ".enumeration { fill: #888888; }\n" ".arrow { fill: black; }\n" diff --git a/thumbnailer/meson.build b/thumbnailer/meson.build index 7c500fac3e43d1e43842d4ece3737d5954d9be70..4f5009391b9ccc8f4bbb9fda44d53e8e9c8f8634 100644 --- a/thumbnailer/meson.build +++ b/thumbnailer/meson.build @@ -23,6 +23,7 @@ thumbnailer_deps = [ libadwaita_dep, librsvg_dep, libword_list_dep, + m_dep, ] thumbnailer = executable(