summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-12-05 23:21:11 +0000
committerAndy Williams <andy@andywilliams.me>2017-12-07 23:39:49 +0000
commit1a5d6fa93ad35de94ddb19664336eee1050d980c (patch)
treea8eb5536ea0fb957920fddf106212638446f9bd1 /src
parent535fa0e8f139a0939e2e1c6deaf26f9aee54dcde (diff)
elm_code: Adding initial support for alpha channel
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test_code.c2
-rw-r--r--src/lib/elementary/elm_code_widget.c100
-rw-r--r--src/lib/elementary/elm_code_widget.eo10
-rw-r--r--src/lib/elementary/elm_code_widget_private.h1
4 files changed, 74 insertions, 39 deletions
diff --git a/src/bin/elementary/test_code.c b/src/bin/elementary/test_code.c
index b05240c1af..81b68812a8 100644
--- a/src/bin/elementary/test_code.c
+++ b/src/bin/elementary/test_code.c
@@ -10,6 +10,7 @@ static Evas_Object *_test_code_win_create(const char *id, const char *name)
10 win = elm_win_add(NULL, id, ELM_WIN_BASIC); 10 win = elm_win_add(NULL, id, ELM_WIN_BASIC);
11 elm_win_title_set(win, name); 11 elm_win_title_set(win, name);
12 elm_win_autodel_set(win, EINA_TRUE); 12 elm_win_autodel_set(win, EINA_TRUE);
13 elm_win_alpha_set(win, EINA_TRUE);
13 14
14 evas_object_resize(win, 360 * elm_config_scale_get(), 220 * elm_config_scale_get()); 15 evas_object_resize(win, 360 * elm_config_scale_get(), 220 * elm_config_scale_get());
15 return win; 16 return win;
@@ -95,6 +96,7 @@ _elm_code_test_editor_setup(Evas_Object *parent, Eina_Bool log)
95 elm_obj_code_widget_editable_set(widget, EINA_TRUE); 96 elm_obj_code_widget_editable_set(widget, EINA_TRUE);
96 elm_obj_code_widget_show_whitespace_set(widget, EINA_TRUE); 97 elm_obj_code_widget_show_whitespace_set(widget, EINA_TRUE);
97 elm_obj_code_widget_line_numbers_set(widget, EINA_TRUE); 98 elm_obj_code_widget_line_numbers_set(widget, EINA_TRUE);
99 elm_obj_code_widget_alpha_set(widget, 200);
98 100
99 if (!log) 101 if (!log)
100 { 102 {
diff --git a/src/lib/elementary/elm_code_widget.c b/src/lib/elementary/elm_code_widget.c
index eb4a83800e..927ebc9941 100644
--- a/src/lib/elementary/elm_code_widget.c
+++ b/src/lib/elementary/elm_code_widget.c
@@ -1786,7 +1786,8 @@ _elm_code_widget_elm_widget_widget_event(Eo *obj EINA_UNUSED, Elm_Code_Widget_Da
1786 1786
1787// load a named colour class from the theme and apply it to the grid's specified palette 1787// load a named colour class from the theme and apply it to the grid's specified palette
1788static void 1788static void
1789_elm_code_widget_setup_palette_item(Evas_Object *grid, int type, const char *name, Evas_Object *edje) 1789_elm_code_widget_setup_palette_item(Evas_Object *grid, int type, const char *name,
1790 double fade, Evas_Object *edje)
1790{ 1791{
1791 int r, g, b, a; 1792 int r, g, b, a;
1792 1793
@@ -1794,54 +1795,55 @@ _elm_code_widget_setup_palette_item(Evas_Object *grid, int type, const char *nam
1794 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) 1795 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
1795 return; 1796 return;
1796 1797
1797 evas_object_textgrid_palette_set(grid, EVAS_TEXTGRID_PALETTE_STANDARD, type, r, g, b, a); 1798 evas_object_textgrid_palette_set(grid, EVAS_TEXTGRID_PALETTE_STANDARD, type,
1799 r * fade, g * fade, b * fade, a * fade);
1798} 1800}
1799 1801
1800static void 1802static void
1801_elm_code_widget_setup_palette(Evas_Object *o, Evas_Object *layout) 1803_elm_code_widget_setup_palette(Evas_Object *o, Evas_Object *layout, float fade)
1802{ 1804{
1803 Evas_Object *edje; 1805 Evas_Object *edje;
1804 1806
1805 edje = elm_layout_edje_get(layout); 1807 edje = elm_layout_edje_get(layout);
1806 1808
1807 // setup status colors 1809 // setup status colors
1808 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_DEFAULT, "elm/code/status/default", edje); 1810 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_DEFAULT, "elm/code/status/default", fade, edje);
1809 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_CURRENT, "elm/code/status/current", edje); 1811 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_CURRENT, "elm/code/status/current", fade, edje);
1810 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_IGNORED, "elm/code/status/ignored", edje); 1812 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_IGNORED, "elm/code/status/ignored", fade, edje);
1811 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_NOTE, "elm/code/status/note", edje); 1813 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_NOTE, "elm/code/status/note", fade, edje);
1812 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_WARNING, "elm/code/status/warning", edje); 1814 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_WARNING, "elm/code/status/warning", fade, edje);
1813 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_ERROR, "elm/code/status/error", edje); 1815 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_ERROR, "elm/code/status/error", fade, edje);
1814 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_FATAL, "elm/code/status/fatal", edje); 1816 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_FATAL, "elm/code/status/fatal", fade, edje);
1815 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_ADDED, "elm/code/status/added", edje); 1817 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_ADDED, "elm/code/status/added", fade, edje);
1816 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_REMOVED, "elm/code/status/removed", edje); 1818 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_REMOVED, "elm/code/status/removed", fade, edje);
1817 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_CHANGED, "elm/code/status/changed", edje); 1819 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_CHANGED, "elm/code/status/changed", fade, edje);
1818 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_PASSED, "elm/code/status/passed", edje); 1820 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_PASSED, "elm/code/status/passed", fade, edje);
1819 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_FAILED, "elm/code/status/failed", edje); 1821 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_FAILED, "elm/code/status/failed", fade, edje);
1820 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_TODO, "elm/code/status/todo", edje); 1822 _elm_code_widget_setup_palette_item(o, ELM_CODE_STATUS_TYPE_TODO, "elm/code/status/todo", fade, edje);
1821 1823
1822 // setup token colors 1824 // setup token colors
1823 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_DEFAULT, "elm/code/token/default", edje); 1825 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_DEFAULT, "elm/code/token/default", fade, edje);
1824 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_COMMENT, "elm/code/token/comment", edje); 1826 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_COMMENT, "elm/code/token/comment", fade, edje);
1825 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_STRING, "elm/code/token/string", edje); 1827 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_STRING, "elm/code/token/string", fade, edje);
1826 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_NUMBER, "elm/code/token/number", edje); 1828 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_NUMBER, "elm/code/token/number", fade, edje);
1827 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_BRACE, "elm/code/token/brace", edje); 1829 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_BRACE, "elm/code/token/brace", fade, edje);
1828 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_TYPE, "elm/code/token/type", edje); 1830 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_TYPE, "elm/code/token/type", fade, edje);
1829 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_CLASS, "elm/code/token/class", edje); 1831 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_CLASS, "elm/code/token/class", fade, edje);
1830 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_FUNCTION, "elm/code/token/function", edje); 1832 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_FUNCTION, "elm/code/token/function", fade, edje);
1831 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_PARAM, "elm/code/token/param", edje); 1833 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_PARAM, "elm/code/token/param", fade, edje);
1832 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_KEYWORD, "elm/code/token/keyword", edje); 1834 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_KEYWORD, "elm/code/token/keyword", fade, edje);
1833 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_PREPROCESSOR, "elm/code/token/preprocessor", edje); 1835 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_PREPROCESSOR, "elm/code/token/preprocessor", fade, edje);
1834 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_ADDED, "elm/code/token/added", edje); 1836 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_ADDED, "elm/code/token/added", fade, edje);
1835 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_REMOVED, "elm/code/token/removed", edje); 1837 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_REMOVED, "elm/code/token/removed", fade, edje);
1836 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_CHANGED, "elm/code/token/changed", edje); 1838 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_CHANGED, "elm/code/token/changed", fade, edje);
1837 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_MATCH, "elm/code/token/match", edje); 1839 _elm_code_widget_setup_palette_item(o, ELM_CODE_TOKEN_TYPE_MATCH, "elm/code/token/match", fade, edje);
1838 1840
1839 // other styles that the widget uses 1841 // other styles that the widget uses
1840 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_SELECTION, "elm/code/widget/color/selection", edje); 1842 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_SELECTION, "elm/code/widget/color/selection", fade, edje);
1841 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_BG, "elm/code/widget/color/gutter/bg", edje); 1843 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_BG, "elm/code/widget/color/gutter/bg", fade, edje);
1842 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_FG, "elm/code/widget/color/gutter/fg", edje); 1844 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_FG, "elm/code/widget/color/gutter/fg", fade, edje);
1843 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_SCOPE_BG, "elm/code/widget/color/scope/bg", edje); 1845 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_GUTTER_SCOPE_BG, "elm/code/widget/color/scope/bg", fade, edje);
1844 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_WHITESPACE, "elm/code/widget/color/whitespace", edje); 1846 _elm_code_widget_setup_palette_item(o, ELM_CODE_WIDGET_COLOR_WHITESPACE, "elm/code/widget/color/whitespace", fade, edje);
1845} 1847}
1846 1848
1847static void 1849static void
@@ -1876,7 +1878,7 @@ _elm_code_widget_ensure_n_grid_rows(Elm_Code_Widget *widget, int rows)
1876 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, 0.0); 1878 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, 0.0);
1877 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, 0.0); 1879 evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, 0.0);
1878 evas_object_show(grid); 1880 evas_object_show(grid);
1879 _elm_code_widget_setup_palette(grid, widget); 1881 _elm_code_widget_setup_palette(grid, widget, (double) pd->alpha / 255);
1880 1882
1881 elm_box_pack_end(pd->gridbox, grid); 1883 elm_box_pack_end(pd->gridbox, grid);
1882 pd->grids = eina_list_append(pd->grids, grid); 1884 pd->grids = eina_list_append(pd->grids, grid);
@@ -2199,6 +2201,7 @@ _elm_code_widget_elm_widget_theme_apply(Eo *obj, Elm_Code_Widget_Data *pd)
2199{ 2201{
2200 Eo *edje; 2202 Eo *edje;
2201 int r, g, b, a; 2203 int r, g, b, a;
2204 double fade;
2202 unsigned int i; 2205 unsigned int i;
2203 Evas_Object *grid, *background; 2206 Evas_Object *grid, *background;
2204 2207
@@ -2206,18 +2209,36 @@ _elm_code_widget_elm_widget_theme_apply(Eo *obj, Elm_Code_Widget_Data *pd)
2206 edje_object_color_class_get(edje, "elm/code/status/default", &r, &g, &b, &a, 2209 edje_object_color_class_get(edje, "elm/code/status/default", &r, &g, &b, &a,
2207 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 2210 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
2208 2211
2212 fade = (double) pd->alpha / 255;
2209 background = elm_object_part_content_get(pd->scroller, "elm.swallow.background"); 2213 background = elm_object_part_content_get(pd->scroller, "elm.swallow.background");
2210 evas_object_color_set(background, r, g, b, a); 2214 evas_object_color_set(background, r * fade, g * fade, b * fade, a * fade);
2215
2216 if (fade < 1.0)
2217 evas_object_color_set(obj, 1, 1, 1, 1); // setting 0 alpha is not working
2211 2218
2212 for (i = 0; i < eina_list_count(pd->grids); i++) 2219 for (i = 0; i < eina_list_count(pd->grids); i++)
2213 { 2220 {
2214 grid = eina_list_nth(pd->grids, i); 2221 grid = eina_list_nth(pd->grids, i);
2215 _elm_code_widget_setup_palette(grid, obj); 2222 _elm_code_widget_setup_palette(grid, obj, fade);
2216 } 2223 }
2217 2224
2218 return EFL_UI_THEME_APPLY_SUCCESS; 2225 return EFL_UI_THEME_APPLY_SUCCESS;
2219} 2226}
2220 2227
2228EOLIAN static int
2229_elm_code_widget_alpha_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd)
2230{
2231 return pd->alpha;
2232}
2233
2234EOLIAN static void
2235_elm_code_widget_alpha_set(Eo *obj, Elm_Code_Widget_Data *pd, int alpha)
2236{
2237 pd->alpha = alpha;
2238
2239 _elm_code_widget_elm_widget_theme_apply(obj, pd);
2240}
2241
2221EOLIAN static void 2242EOLIAN static void
2222_elm_code_widget_efl_canvas_group_group_add(Eo *obj, Elm_Code_Widget_Data *pd) 2243_elm_code_widget_efl_canvas_group_group_add(Eo *obj, Elm_Code_Widget_Data *pd)
2223{ 2244{
@@ -2226,6 +2247,7 @@ _elm_code_widget_efl_canvas_group_group_add(Eo *obj, Elm_Code_Widget_Data *pd)
2226 2247
2227 efl_canvas_group_add(efl_super(obj, ELM_CODE_WIDGET_CLASS)); 2248 efl_canvas_group_add(efl_super(obj, ELM_CODE_WIDGET_CLASS));
2228 elm_object_focus_allow_set(obj, EINA_TRUE); 2249 elm_object_focus_allow_set(obj, EINA_TRUE);
2250 pd->alpha = 255;
2229 2251
2230 if (!elm_layout_theme_set(obj, "code", "layout", elm_widget_style_get(obj))) 2252 if (!elm_layout_theme_set(obj, "code", "layout", elm_widget_style_get(obj)))
2231 CRI("Failed to set layout!"); 2253 CRI("Failed to set layout!");
diff --git a/src/lib/elementary/elm_code_widget.eo b/src/lib/elementary/elm_code_widget.eo
index c896e4e3ef..026e7cc815 100644
--- a/src/lib/elementary/elm_code_widget.eo
+++ b/src/lib/elementary/elm_code_widget.eo
@@ -149,6 +149,16 @@ class Elm.Code_Widget (Efl.Ui.Layout, Efl.Access.Text)
149 show_whitespace: bool; [[Whether or not we show whitespace characters]] 149 show_whitespace: bool; [[Whether or not we show whitespace characters]]
150 } 150 }
151 } 151 }
152 @property alpha {
153 [[Set an alpha color value for this widget (0 - 255) default is fully opaque (255).]]
154 set {
155 }
156 get {
157 }
158 values {
159 alpha: int;
160 }
161 }
152 @property syntax_enabled { 162 @property syntax_enabled {
153 set { 163 set {
154 [[Set whether syntax highlighting should be use for this widget.]] 164 [[Set whether syntax highlighting should be use for this widget.]]
diff --git a/src/lib/elementary/elm_code_widget_private.h b/src/lib/elementary/elm_code_widget_private.h
index 4e050a799b..8ff71becbf 100644
--- a/src/lib/elementary/elm_code_widget_private.h
+++ b/src/lib/elementary/elm_code_widget_private.h
@@ -28,6 +28,7 @@ typedef struct
28 Eina_Bool show_line_numbers; 28 Eina_Bool show_line_numbers;
29 unsigned int line_width_marker, tabstop; 29 unsigned int line_width_marker, tabstop;
30 Eina_Bool show_whitespace, tab_inserts_spaces; 30 Eina_Bool show_whitespace, tab_inserts_spaces;
31 int alpha;
31 32
32 Elm_Code_Widget_Selection_Data *selection; 33 Elm_Code_Widget_Selection_Data *selection;
33 34