summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2020-02-12 10:22:54 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2020-02-12 10:27:59 +0100
commitac5879e3e5c2ce86dc6166f0d7f669ea5ab063fa (patch)
tree8f9704eb40ec04ef2a905611d99b3133a04e5951
parentb694a830afe7fc32d7fd0bd0c30865c589d6572d (diff)
homescreen: Initial import from bu5hm4n code
Just removed custom Edje classes and tried to replace them with Efl.Ui classes (for simplicity).
-rw-r--r--apps/c/homescreen/meson.build13
-rw-r--r--apps/c/homescreen/src/Hills.edjbin0 -> 91069 bytes
-rw-r--r--apps/c/homescreen/src/homescreen.c240
-rw-r--r--apps/c/homescreen/src/meson.build11
4 files changed, 264 insertions, 0 deletions
diff --git a/apps/c/homescreen/meson.build b/apps/c/homescreen/meson.build
new file mode 100644
index 00000000..a6ac3bf2
--- /dev/null
+++ b/apps/c/homescreen/meson.build
@@ -0,0 +1,13 @@
1project(
2 'efl-example-homescreen', 'c',
3 version : '0.0.1',
4 default_options: [ 'c_std=gnu99', 'warning_level=2' ],
5 meson_version : '>= 0.38.0')
6
7eina = dependency('eina', version : '>=1.20.99')
8efl = dependency('efl-ui', version : '>=1.20.99')
9elm = dependency('elementary', version : '>=1.20.99')
10
11inc = include_directories('.')
12subdir('src')
13
diff --git a/apps/c/homescreen/src/Hills.edj b/apps/c/homescreen/src/Hills.edj
new file mode 100644
index 00000000..72c4d9b4
--- /dev/null
+++ b/apps/c/homescreen/src/Hills.edj
Binary files differ
diff --git a/apps/c/homescreen/src/homescreen.c b/apps/c/homescreen/src/homescreen.c
new file mode 100644
index 00000000..ff328175
--- /dev/null
+++ b/apps/c/homescreen/src/homescreen.c
@@ -0,0 +1,240 @@
1#define EFL_BETA_API_SUPPORT
2#include <Efl_Ui.h>
3#include <Efreet.h>
4
5static Efl_Ui_Spotlight_Container *over_container;
6
7#define SCALE 0.5
8
9typedef struct
10{
11 Eina_Position2D position;
12 const char *name;
13 const char *icon;
14 Efl_Event_Cb cb;
15} Icon;
16
17static void _fake_app_cb(void *data, const Efl_Event *ev);
18
19#define P "/usr/share/icons/hicolor/128x128/apps/"
20
21static Icon workspace1[] = {
22 { EINA_POSITION2D(0, 0), "Firefox", P"firefox.png", NULL},
23 { EINA_POSITION2D(0, 1), "Monodevelop", P"monodevelop.png", NULL},
24 { EINA_POSITION2D(0, 2), "Terminal", "utilities-terminal", NULL},
25 { EINA_POSITION2D(2, 0), NULL, NULL, NULL},
26};
27
28static Icon workspace2[] = {
29 { EINA_POSITION2D(0, 3), "web-browser", "web-browser", _fake_app_cb},
30 { EINA_POSITION2D(1, 3), "Emacs", P"emacs.png", _fake_app_cb},
31 { EINA_POSITION2D(2, 3), "etui", P"etui.png", _fake_app_cb},
32 { EINA_POSITION2D(3, 3), "CAD", P"librecad.png", _fake_app_cb},
33 { EINA_POSITION2D(4, 3), "Libreoffice", P"libreoffice-base.png", _fake_app_cb},
34 { EINA_POSITION2D(0, 4), "Riot", P"riot.png", _fake_app_cb},
35 { EINA_POSITION2D(1, 4), "Tex", P"texstudio.png", _fake_app_cb},
36 { EINA_POSITION2D(2, 4), "Telegram", P"telegram.png", _fake_app_cb},
37 { EINA_POSITION2D(3, 4), "Vlc", P"vlc.png", _fake_app_cb},
38 { EINA_POSITION2D(4, 4), "Mono", P"monodevelop.png", _fake_app_cb},
39 { EINA_POSITION2D(2, 0), NULL, NULL, NULL},
40};
41
42static Icon workspace3[] = {
43 { EINA_POSITION2D(0, 0), "bla", P"remmina.png", NULL},
44 { EINA_POSITION2D(1, 1), "bla", "ic2", NULL},
45 { EINA_POSITION2D(0, 2), "bla", "ic", NULL},
46 { EINA_POSITION2D(1, 3), "bla", "ic2", NULL},
47 { EINA_POSITION2D(0, 4), "bla", "ic", NULL},
48 { EINA_POSITION2D(2, 0), "bla", "ic", NULL},
49 { EINA_POSITION2D(3, 1), "bla", "ic2", NULL},
50 { EINA_POSITION2D(2, 2), "bla", "ic", NULL},
51 { EINA_POSITION2D(3, 3), "bla", "ic2", NULL},
52 { EINA_POSITION2D(2, 4), "bla", "ic", NULL},
53 { EINA_POSITION2D(4, 0), "bla", "ic", NULL},
54 { EINA_POSITION2D(4, 2), "bla", "ic", NULL},
55 { EINA_POSITION2D(4, 4), "bla", "ic", NULL},
56 { EINA_POSITION2D(0, 2), NULL, NULL, NULL},
57};
58
59static Icon* workspaces[] = {workspace1, workspace2, workspace3};
60
61static void _home_screen_cb(void *data, const Efl_Event *cb);
62
63static Icon start_line_config[] = {
64 { EINA_POSITION2D(0, 0), "Call", "call-start", _fake_app_cb},
65 { EINA_POSITION2D(0, 0), "Contact", "contact-new", _fake_app_cb},
66 { EINA_POSITION2D(0, 0), "Home", "applications-internet", _home_screen_cb},
67 { EINA_POSITION2D(0, 0), "Mail", "emblem-mail", _fake_app_cb},
68 { EINA_POSITION2D(0, 0), "Documents", "emblem-documents", _fake_app_cb},
69 { EINA_POSITION2D(0, 0), NULL, NULL, NULL},
70};
71
72static Eo *compositor;
73
74
75static Efl_Ui_Widget*
76_create_icon(Icon *icon, Eo *parent)
77{
78 Eo *box = efl_add(EFL_UI_BOX_CLASS, parent);
79 // Icon
80 Eo *ic = efl_add(EFL_UI_IMAGE_CLASS, box,
81 efl_ui_image_icon_set(efl_added, icon->icon),
82 efl_gfx_hint_weight_set(efl_added, 1.0, 1.0),
83 efl_gfx_entity_size_set(efl_added, EINA_SIZE2D(300, 300)),
84 efl_pack(box, efl_added));
85 if (icon->cb)
86 efl_event_callback_add(ic, EFL_INPUT_EVENT_CLICKED, icon->cb, icon);
87
88 // Label
89 efl_add(EFL_UI_TEXTBOX_CLASS, box,
90 efl_text_set(efl_added, icon->name),
91 efl_canvas_textblock_style_apply(efl_added, "effect_type=soft_shadow shadow_color=black"),
92 efl_text_horizontal_align_set(efl_added, 0.5),
93 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
94 efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
95 efl_pack(box, efl_added));
96
97 return box;
98}
99
100static Efl_Ui_Table*
101_hs_screen_new(Icon *icons)
102{
103 Efl_Ui_Table *table;
104
105 table = efl_add(EFL_UI_TABLE_CLASS, over_container);
106
107 for (int y = 0; y < 5; ++y)
108 {
109 for (int x = 0; x < 5; ++x)
110 {
111 Eo *obj = efl_add(EFL_CANVAS_RECTANGLE_CLASS, table, efl_gfx_color_set(efl_added, 0, 0, 0, 0));
112 efl_pack_table(table, obj, x, y, 1, 1);
113 }
114 }
115
116 for (int i = 0; icons[i].name; ++i)
117 {
118 Eo *icon = _create_icon(&icons[i], table);
119 efl_pack_table(table, icon, icons[i].position.x, icons[i].position.y, 1, 1);
120 }
121
122 return table;
123}
124
125static Efl_Ui_Widget*
126_build_homescreen(Efl_Ui_Win *win)
127{
128 Efl_Ui_Spotlight_Indicator *indicator = efl_new(EFL_UI_SPOTLIGHT_ICON_INDICATOR_CLASS);
129 Efl_Ui_Spotlight_Manager *scroll = efl_new(EFL_UI_SPOTLIGHT_SCROLL_MANAGER_CLASS);
130
131 over_container = efl_add(EFL_UI_SPOTLIGHT_CONTAINER_CLASS, win,
132 efl_ui_spotlight_manager_set(efl_added, scroll),
133 efl_ui_spotlight_indicator_set(efl_added, indicator)
134 );
135
136 for (int i = 0; i < 3; ++i)
137 {
138 Eo *screen = _hs_screen_new(workspaces[i]);
139
140 efl_pack_end(over_container, screen);
141 }
142 return over_container;
143}
144
145static Efl_Ui_Widget*
146_build_overall_structure(Efl_Ui_Win *win, Efl_Ui_Widget *homescreen)
147{
148 Efl_Ui_Widget *o, *start_line;
149
150 o = efl_add(EFL_UI_BOX_CLASS, win);
151 efl_pack_end(o, homescreen);
152
153 //start line
154 start_line = efl_add(EFL_UI_BOX_CLASS, win);
155 efl_gfx_hint_weight_set(start_line, 1.0, 0.0);
156 efl_ui_layout_orientation_set(start_line, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL);
157 efl_gfx_hint_size_min_set(start_line, EINA_SIZE2D(5*150*SCALE, 150*SCALE));
158 efl_gfx_hint_size_max_set(start_line, EINA_SIZE2D(-1, 150*SCALE));
159 efl_pack_end(o, start_line);
160
161 for (int i = 0; i < 5; ++i)
162 {
163 efl_pack_end(start_line, _create_icon(&start_line_config[i], start_line));
164 }
165
166 return o;
167}
168
169static Efl_Ui_Widget*
170_build_compositor(Efl_Ui_Win *win)
171{
172 Efl_Ui_Widget *comp;
173 Efl_Ui_Spotlight_Manager *stack;
174
175 stack = efl_new(EFL_UI_SPOTLIGHT_FADE_MANAGER_CLASS);
176 comp = efl_add(EFL_UI_SPOTLIGHT_CONTAINER_CLASS, win,
177 efl_ui_spotlight_manager_set(efl_added, stack));
178
179 return comp;
180}
181
182static void
183_home_screen_cb(void *data EINA_UNUSED, const Efl_Event *cb EINA_UNUSED)
184{
185 Efl_Canvas_Rectangle *rect;
186
187 rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, compositor);
188 efl_ui_spotlight_push(compositor, rect);
189}
190
191static void
192_fake_app_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
193{
194 Efl_Ui_Table *table = efl_add(EFL_UI_TABLE_CLASS, compositor);
195 Efl_Canvas_Rectangle *rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, compositor);
196 efl_gfx_color_set(rect, 50, 50, 50, 255);
197 efl_pack_table(table, rect, 0, 0, 1, 1);
198 Efl_Ui_Textbox *text = efl_add(EFL_UI_TEXTBOX_CLASS , table);
199 efl_text_interactive_editable_set(text, EINA_FALSE);
200 efl_text_multiline_set(text, EINA_FALSE);
201 efl_text_set(text, "This is a testing application");
202 efl_pack_table(table, text, 0, 0, 1, 1);
203 efl_ui_spotlight_push(compositor, table);
204}
205
206static void
207_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
208{
209 efl_exit(0);
210}
211
212EAPI_MAIN void
213efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
214{
215 Eo *win, *over_container, *desktop, *background;
216
217 efreet_init();
218
219 win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
220 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
221 // when the user clicks "close" on a window there is a request to delete
222 efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL);
223 efl_gfx_entity_size_set(win, EINA_SIZE2D(720*SCALE+15, 1280*SCALE));
224
225 over_container = _build_homescreen(win);
226 desktop = _build_overall_structure(win, over_container);
227
228 compositor = _build_compositor(win);
229 //efl_pack_end(compositor, desktop);
230 efl_ui_spotlight_push(compositor, desktop);
231 efl_gfx_entity_size_set(compositor, EINA_SIZE2D(720*SCALE, 1280*SCALE));
232
233 background = efl_add(EFL_UI_IMAGE_CLASS, win,
234 //efl_file_set(efl_added, "../src/wood_01.jpg"),
235 efl_file_key_set(efl_added, "e/desktop/background"),
236 efl_file_set(efl_added, "../src/Hills.edj"),
237 efl_gfx_image_scale_method_set(efl_added, EFL_GFX_IMAGE_SCALE_METHOD_EXPAND));
238 efl_content_set(win, background);
239}
240EFL_MAIN()
diff --git a/apps/c/homescreen/src/meson.build b/apps/c/homescreen/src/meson.build
new file mode 100644
index 00000000..c7312399
--- /dev/null
+++ b/apps/c/homescreen/src/meson.build
@@ -0,0 +1,11 @@
1src = files([
2 'homescreen.c',
3])
4
5deps = [eina, efl, elm]
6
7executable('efl_example_homescreen', src,
8 dependencies : deps,
9 include_directories : inc,
10 install : true
11)