summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Poole <netstar@gmail.com>2017-11-26 12:36:42 +0000
committerAl Poole <netstar@gmail.com>2017-11-26 12:36:42 +0000
commit5abeeb980a9fb82136a70c24f822cdc3eb633dd0 (patch)
treed96a9af1559a899b49cef45e6ec5a83117688970
parent047141fc908f3457ef43f333df603914b2676047 (diff)
elm_code: set the color scheme from the default edc.
This allows us to override in the application also. Work from myself and @ajwillia.ms.
-rw-r--r--data/elementary/themes/edc/elm/code.edc38
-rw-r--r--src/lib/elementary/elm_code_widget.c132
2 files changed, 95 insertions, 75 deletions
diff --git a/data/elementary/themes/edc/elm/code.edc b/data/elementary/themes/edc/elm/code.edc
index fc589b8..608b16f 100644
--- a/data/elementary/themes/edc/elm/code.edc
+++ b/data/elementary/themes/edc/elm/code.edc
@@ -18,3 +18,41 @@ group { name: "elm/code/layout/default";
18 } 18 }
19 } 19 }
20} 20}
21
22color_classes {
23 color_class { name: "elm/code/status/default"; color: 36 36 36 255; }
24 color_class { name: "elm/code/status/current"; color: 12 12 12 255; }
25 color_class { name: "elm/code/status/ignored"; color: 36 36 36 255; }
26 color_class { name: "elm/code/status/note"; color: 221 119 17 255; }
27 color_class { name: "elm/code/status/warning"; color: 221 119 17 255; }
28 color_class { name: "elm/code/status/error"; color: 204 17 17 255; }
29 color_class { name: "elm/code/status/fatal"; color: 204 17 17 255; }
30 color_class { name: "elm/code/status/added"; color: 36 96 36 255; }
31 color_class { name: "elm/code/status/removed"; color: 96 36 36 255; }
32 color_class { name: "elm/code/status/changed"; color: 36 36 96 255; }
33 color_class { name: "elm/code/status/passed"; color: 54 96 54 255; }
34 color_class { name: "elm/code/status/failed"; color: 96 54 54 255; }
35 color_class { name: "elm/code/status/todo"; color: 51 85 187 255; }
36
37 color_class { name: "elm/code/token/default"; color: 187 187 187 255; }
38 color_class { name: "elm/code/token/comment"; color: 85 85 85 255; }
39 color_class { name: "elm/code/token/string"; color: 255 136 119 255; }
40 color_class { name: "elm/code/token/number"; color: 170 153 34 255; }
41 color_class { name: "elm/code/token/brace"; color: 170 102 170 255; }
42 color_class { name: "elm/code/token/type"; color: 255 255 255 255; }
43 color_class { name: "elm/code/token/class"; color: 255 255 255 255; }
44 color_class { name: "elm/code/token/function"; color: 255 255 255 255; }
45 color_class { name: "elm/code/token/param"; color: 187 187 187 255; }
46 color_class { name: "elm/code/token/keyword"; color: 68 136 204 255; }
47 color_class { name: "elm/code/token/preprocessor"; color: 102 255 85 255; }
48 color_class { name: "elm/code/token/added"; color: 54 255 54 255; }
49 color_class { name: "elm/code/token/removed"; color: 255 54 54 255; }
50 color_class { name: "elm/code/token/changed"; color: 54 54 255 255; }
51 color_class { name: "elm/code/token/match"; color: 187 187 51 255; }
52
53 color_class { name: "elm/code/widget/color/selection"; color: 51 153 255 255; }
54 color_class { name: "elm/code/widget/color/gutter/bg"; color: 75 75 75 255; }
55 color_class { name: "elm/code/widget/color/gutter/fg"; color: 139 139 139 255; }
56 color_class { name: "elm/code/widget/color/gutter/scope/bg"; color: 54 54 54 255; }
57 color_class { name: "elm/code/widget/color/whitespace"; color: 50 50 50 127; }
58}
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index ce42ab5..e61aa6a 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -1782,87 +1782,64 @@ _elm_code_widget_elm_widget_widget_event(Eo *obj EINA_UNUSED, Elm_Code_Widget_Da
1782 return EINA_FALSE; 1782 return EINA_FALSE;
1783} 1783}
1784 1784
1785// load a named colour class from the theme and apply it to the grid's specified palette
1785static void 1786static void
1786_elm_code_widget_setup_palette(Evas_Object *o) 1787_elm_code_widget_setup_palette_item(Evas_Object *grid, int type, const char *name, Evas_Object *edje)
1787{ 1788{
1788 double feint = 0.5; 1789 int r, g, b, a;
1790
1791 if (!edje_object_color_class_get(edje, name, &r, &g, &b, &a,
1792 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
1793 return;
1794
1795 evas_object_textgrid_palette_set(grid, EVAS_TEXTGRID_PALETTE_STANDARD, type, r, g, b, a);
1796}
1797
1798static void
1799_elm_code_widget_setup_palette(Evas_Object *o, Evas_Object *layout)
1800{
1801 Evas_Object *edje;
1802
1803 edje = elm_layout_edje_get(layout);
1789 1804
1790 // setup status colors 1805 // setup status colors
1791 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_DEFAULT, 1806 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_DEFAULT, "elm/code/status/default", edje);
1792 36, 36, 36, 255); 1807 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_CURRENT, "elm/code/status/current", edje);
1793 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_CURRENT, 1808 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_IGNORED, "elm/code/status/ignored", edje);
1794 12, 12, 12, 255); 1809 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_NOTE, "elm/code/status/note", edje);
1795 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_IGNORED, 1810 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_WARNING, "elm/code/status/warning", edje);
1796 36, 36, 36, 255); 1811 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_ERROR, "elm/code/status/error", edje);
1797 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_NOTE, 1812 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_FATAL, "elm/code/status/fatal", edje);
1798 221, 119, 17, 255); 1813 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_ADDED, "elm/code/status/added", edje);
1799 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_WARNING, 1814 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_REMOVED, "elm/code/status/removed", edje);
1800 221, 119, 17, 255); 1815 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_CHANGED, "elm/code/status/changed", edje);
1801 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_ERROR, 1816 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_PASSED, "elm/code/status/passed", edje);
1802 204, 17, 17, 255); 1817 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_FAILED, "elm/code/status/failed", edje);
1803 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_FATAL, 1818 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_TODO, "elm/code/status/todo", edje);
1804 204, 17, 17, 255);
1805
1806 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_ADDED,
1807 36, 96, 36, 255);
1808 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_REMOVED,
1809 96, 36, 36, 255);
1810 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_CHANGED,
1811 36, 36, 96, 255);
1812
1813 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_PASSED,
1814 54, 96, 54, 255);
1815 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_FAILED,
1816 96, 54, 54, 255);
1817
1818 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_TODO,
1819 51, 85, 187, 255);
1820 1819
1821 // setup token colors 1820 // setup token colors
1822 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_DEFAULT, 1821 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_DEFAULT, "elm/code/token/default", edje);
1823 187, 187, 187, 255); 1822 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_COMMENT, "elm/code/token/comment", edje);
1824 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_COMMENT, 1823 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_STRING, "elm/code/token/string", edje);
1825 85, 85, 85, 255); 1824 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_NUMBER, "elm/code/token/number", edje);
1826 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_STRING, 1825 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_BRACE, "elm/code/token/brace", edje);
1827 255, 136, 119, 255); 1826 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_TYPE, "elm/code/token/type", edje);
1828 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_NUMBER, 1827 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_CLASS, "elm/code/token/class", edje);
1829 170, 153, 34, 255); 1828 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_FUNCTION, "elm/code/token/function", edje);
1830 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_BRACE, 1829 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_PARAM, "elm/code/token/param", edje);
1831 170, 102, 170, 255); 1830 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_KEYWORD, "elm/code/token/keyword", edje);
1832 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_TYPE, 1831 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_PREPROCESSOR, "elm/code/token/preprocessor", edje);
1833 255, 255, 255, 255); 1832 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_ADDED, "elm/code/token/added", edje);
1834 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CLASS, 1833 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_REMOVED, "elm/code/token/removed", edje);
1835 255, 255, 255, 255); 1834 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_CHANGED, "elm/code/token/changed", edje);
1836 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_FUNCTION, 1835 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_MATCH, "elm/code/token/match", edje);
1837 255, 255, 255, 255);
1838 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_PARAM,
1839 187, 187, 187, 255);
1840 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_KEYWORD,
1841 68, 136, 204, 255);
1842 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_PREPROCESSOR,
1843 102, 255, 85, 255);
1844
1845 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_ADDED,
1846 54, 255, 54, 255);
1847 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_REMOVED,
1848 255, 54, 54, 255);
1849 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CHANGED,
1850 54, 54, 255, 255);
1851
1852 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_MATCH,
1853 187, 187, 51, 255);
1854 1836
1855 // other styles that the widget uses 1837 // other styles that the widget uses
1856 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_SELECTION, 1838 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_SELECTION, "elm/code/widget/color/selection", edje);
1857 51, 153, 255, 255); 1839 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_BG, "elm/code/widget/color/gutter/bg", edje);
1858 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_GUTTER_BG, 1840 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_FG, "elm/code/widget/color/gutter/fg", edje);
1859 75, 75, 75, 255); 1841 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_SCOPE_BG, "elm/code/widget/color/scope/bg", edje);
1860 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_GUTTER_SCOPE_BG, 1842 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_WHITESPACE, "elm/code/widget/color/whitespace", edje);
1861 54, 54, 54, 255);
1862 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_GUTTER_FG,
1863 139, 139, 139, 255);
1864 evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_WHITESPACE,
1865 101 * feint, 101 * feint, 101 * feint, 255 * feint);
1866} 1843}
1867 1844
1868static void 1845static void
@@ -1897,7 +1874,7 @@ _elm_code_widget_ensure_n_grid_rows(Elm_Code_Widget *widget, int rows)
1897 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, 0.0); 1874 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, 0.0);
1898 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, 0.0); 1875 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, 0.0);
1899 evas_object_show(grid); 1876 evas_object_show(grid);
1900 _elm_code_widget_setup_palette(grid); 1877 _elm_code_widget_setup_palette(grid, efl_parent_get(pd->scroller));
1901 1878
1902 elm_box_pack_end(pd->gridbox, grid); 1879 elm_box_pack_end(pd->gridbox, grid);
1903 pd->grids = eina_list_append(pd->grids, grid); 1880 pd->grids = eina_list_append(pd->grids, grid);
@@ -2220,6 +2197,8 @@ _elm_code_widget_efl_canvas_group_group_add(Eo *obj, Elm_Code_Widget_Data *pd)
2220{ 2197{
2221 Evas_Object *background, *gridrows, *scroller; 2198 Evas_Object *background, *gridrows, *scroller;
2222 const char *fontname, *fontsize; 2199 const char *fontname, *fontsize;
2200 Eo *edje;
2201 int r, g, b, a;
2223 2202
2224 efl_canvas_group_add(efl_super(obj, ELM_CODE_WIDGET_CLASS)); 2203 efl_canvas_group_add(efl_super(obj, ELM_CODE_WIDGET_CLASS));
2225 elm_object_focus_allow_set(obj, EINA_TRUE); 2204 elm_object_focus_allow_set(obj, EINA_TRUE);
@@ -2235,8 +2214,11 @@ _elm_code_widget_efl_canvas_group_group_add(Eo *obj, Elm_Code_Widget_Data *pd)
2235 elm_object_focus_allow_set(scroller, EINA_FALSE); 2214 elm_object_focus_allow_set(scroller, EINA_FALSE);
2236 pd->scroller = scroller; 2215 pd->scroller = scroller;
2237 2216
2217 edje = elm_layout_edje_get(efl_parent_get(pd->scroller));
2218 edje_object_color_class_get(edje, "elm/code/status/default", &r, &g, &b, &a, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
2219
2238 background = elm_bg_add(scroller); 2220 background = elm_bg_add(scroller);
2239 evas_object_color_set(background, 36, 36, 36, 255); 2221 evas_object_color_set(background, r, g, b, a);
2240 evas_object_size_hint_weight_set(background, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 2222 evas_object_size_hint_weight_set(background, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2241 evas_object_size_hint_align_set(background, EVAS_HINT_FILL, EVAS_HINT_FILL); 2223 evas_object_size_hint_align_set(background, EVAS_HINT_FILL, EVAS_HINT_FILL);
2242 evas_object_show(background); 2224 evas_object_show(background);