diff options
author | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2014-12-09 16:41:16 -0200 |
---|---|---|
committer | Felipe Magno de Almeida <felipe@expertisesolutions.com.br> | 2015-12-23 22:23:46 -0200 |
commit | 9dbba7412358ac31af2f8e962d30438681b0f097 (patch) | |
tree | 91d4a92a3d9e89c8fffad6766b6c8e1b0e85b5f2 /src/examples | |
parent | b2ad8058c7e56dc2f0942b5291a630ea03a3202d (diff) | |
download | elementary-9dbba7412358ac31af2f8e962d30438681b0f097.tar.gz |
efl-js: JavaScript Eolian binding
To configure elementary sources with bindings to use in nodejs add
––with-js=nodejs in configure flags in EFL compilation to generate
node files, then compile elementary normally:
path/to/efl$ configure --with-js=nodejs
path/to/efl$ make
path/to/efl$ make install
path/to/elm$ configure
path/to/efl$ make
path/to/efl$ make install
To use, you have to require elm:
elm = require('elm')
The bindings is divided in two parts: generated and manually
written. The generation uses the Eolian library for parsing Eo files
and generate C++ code that is compiled against V8 interpreter library
to create a elm.node file that can be required in a node.js instance.
@feature
Diffstat (limited to 'src/examples')
27 files changed, 1317 insertions, 3 deletions
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am index dc18ec719..112dbeb0e 100644 --- a/src/examples/Makefile.am +++ b/src/examples/Makefile.am @@ -145,7 +145,8 @@ evas3d_scene_on_button_example.c \ evas3d_object_on_button_example.c \ evas3d_map_example.edc \ evas3d_map_example.c \ -track_example_01.c +track_example_01.c \ +twitter_example_01.edc if HAVE_CXX11 SRCS += \ @@ -197,7 +198,8 @@ files_DATA += \ theme_example.edj \ layout_example.edj\ codegen_example.edj \ - evas3d_map_example.edj + evas3d_map_example.edj \ + twitter_example_01.edj clean-local: rm -f *.edj *.epb *.cfg *.cfg.bkp @@ -528,4 +530,4 @@ screenshots: endif -EXTRA_DIST = dict.txt layout_example.edc theme_example.edc codegen_example.edc evas3d_map_example.edc +EXTRA_DIST = dict.txt layout_example.edc theme_example.edc codegen_example.edc evas3d_map_example.edc twitter_example_01.edc diff --git a/src/examples/bg_example_01.js b/src/examples/bg_example_01.js new file mode 100644 index 000000000..227259b63 --- /dev/null +++ b/src/examples/bg_example_01.js @@ -0,0 +1,15 @@ + +var elm = require('elm') + +win = new elm.Elm.WinStandard(null); +win.setTitle("Bg Plain"); +win.setAutohide(true); + +bg = new elm.Elm.Bg(win); +bg.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bg); +bg.setVisible(true); + +win.setSize(320,320); +win.setVisible(true); + diff --git a/src/examples/bg_example_02.js b/src/examples/bg_example_02.js new file mode 100644 index 000000000..e8e1a63e0 --- /dev/null +++ b/src/examples/bg_example_02.js @@ -0,0 +1,19 @@ + +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Bg Image"); +win.setAutohide(true); + +bg = new elm.Elm.Bg(win); +bg.setLoadSize(20,20); +bg.setOption(elm.Elm.Bg.Option.CENTER); + +//TODO: elm_app_data_dir_get +bg.setFile('../../data/images/plant_01.jpg', null); +bg.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bg); +bg.setVisible(true); + +win.setSize(320, 320); +win.setVisible(true); diff --git a/src/examples/box_js_example_01.js b/src/examples/box_js_example_01.js new file mode 100644 index 000000000..ba7761da5 --- /dev/null +++ b/src/examples/box_js_example_01.js @@ -0,0 +1,34 @@ + +var elm = require('elm') + +win = new elm.Elm.WinStandard(null); +win.setTitle('title'); +win.setAutohide(true); + +bg = new elm.Elm.Bg(win); +bg.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bg); +bg.setVisible(true); + +bx = new elm.Elm.Box(win); +bx.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bx); + +entry = new elm.Elm.Label(win); +entry.setSize(100, 100); +entry.setText(null, "Texto"); + +console.log('Texto: ', entry.getText(null)); + +entry.setSizeHintWeight(1.0, 1.0); +entry.setSizeHintAlign(-1.0, -1.0); +entry.setWrapWidth(50); +bx.packEnd(entry); +entry.setVisible(true); + +bx.setVisible(true); + +win.setSize(300, 320); +win.setVisible(true); + +console.log("Going to wait now\n"); diff --git a/src/examples/box_js_example_02.js b/src/examples/box_js_example_02.js new file mode 100644 index 000000000..6e76bd11a --- /dev/null +++ b/src/examples/box_js_example_02.js @@ -0,0 +1,86 @@ + +var efl = require('efl') +var elm = require('elm') + +_add_cb = function(){ + var btn = new elm.Elm.Button(win); + btn.setText("elm.text", "I do nothing"); + bx.packEnd(btn); + btn.setVisible(true); +} + +_clear_cb = function(){ + bx.clear(); +} + +_unpack_cb = function(btn){ + bx.unpack(btn); + btn.setColor(128, 64, 0, 128) +} + +win = new elm.Elm.WinStandard(null); +win.setTitle("Box example"); +win.setAutohide(true); + +bg = new elm.Elm.Bg(win); +bg.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bg); +bg.setVisible(true); + +bigbox = new elm.Elm.Box(win) +bigbox.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bigbox); + +bx = new elm.Elm.Box(win) +bx.setSizeHintWeight(1.0, 1.0); +bx.setHorizontal(true); +bigbox.packEnd(bx); +bx.setVisible(true); + +bt = new elm.Elm.Button(win); +bt.textSet("elm.text", "Add"); +bx.packEnd(bt); +bt.setVisible(true); +bt.on('clicked', _add_cb); + +bt = new elm.Elm.Button(win); +bt.textSet("elm.text", "Clear"); +bx.packEnd(bt); +bt.setVisible(true); +bt.on('clicked', _clear_cb); + +bx = new elm.Elm.Box(win) +bx.setSizeHintWeight(1.0, 1.0); +bx.setSizeHintAlign(-1.0, -1.0); +bx.setHorizontal(true); +bigbox.packEnd(bx); +bx.setVisible(true); + +bt = new elm.Elm.Button(win); +bt.textSet("elm.text", "Button 1"); +bx.packEnd(bt); +bt.setSizeHintWeight(1.0, 1.0); +bt.setSizeHintAlign(-1.0, -1.0); +bt.setVisible(true); +bt.on('clicked', _unpack_cb); + +bt = new elm.Elm.Button(win); +bt.textSet("elm.text", "Button 2"); +bx.packEnd(bt); +bt.setSizeHintWeight(1.0, 0.0); +bt.setSizeHintAlign(1.0, 0.5); +bt.setVisible(true); +bt.on('clicked', _unpack_cb); + +bt = new elm.Elm.Button(win); +bt.textSet("elm.text", "Button 3"); +bx.packEnd(bt); +bt.setVisible(true); +bt.on('clicked', _unpack_cb); + +bigbox.setVisible(true); + +win.setSize(300, 320); +win.setVisible(true); + +console.log("Going to wait now\n"); diff --git a/src/examples/bubble_example_01.js b/src/examples/bubble_example_01.js new file mode 100644 index 000000000..89ee4737b --- /dev/null +++ b/src/examples/bubble_example_01.js @@ -0,0 +1,54 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Bg Plain"); +win.setAutohide(true); + +bg = new elm.Elm.Bg(win); +bg.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bg); +bg.setVisible(true); + +label1 = new elm.Elm.Label(win); +label1.setText(null, "Bubble with no icon, info or label"); +label1.setVisible(true); + +console.log(efl); + +icon = new efl.Evas.Rectangle(win); +icon.setColor( 0, 0, 255, 255); +icon.setVisible(true); + +bubble1 = new elm.Elm.Bubble(win); +bubble1.contentSet("icon", icon); +bubble1.setText("info", "INFO"); +bubble1.setText(null, "LABEL"); +bubble1.contentSet(null, label1); +bubble1.setSize(300, 100); +bubble1.setVisible(true); + +corner = 0; +bubble1.on('clicked', + function() + { + ++corner; + if (corner > 3) + bubble1.pos_set(corner = 0); + else + bubble1.pos_set(corner); + }); + +label2 = new elm.Elm.Label(win); +label2.setText(null, "Bubble with no icon, info or label"); +label2.setVisible(true); + +bubble2 = new elm.Elm.Bubble(win); +bubble2.contentSet(null, label2); +bubble2.setSize(200, 50); +bubble2.setPosition(0, 110); +bubble2.setVisible(true); + +win.setSize(300, 200); +win.setVisible(true); diff --git a/src/examples/button_example_00.js b/src/examples/button_example_00.js new file mode 100644 index 000000000..64d7c8f6f --- /dev/null +++ b/src/examples/button_example_00.js @@ -0,0 +1,21 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Hello, World!"); +win.setAutohide(true); + +btn = new elm.Elm.Button(win); +btn.setText(null, "Good-Bye, World!"); +btn.setSize(120, 30); +btn.setPosition(60, 15); +btn.setSizeHintWeight(1.0, 1.0); +btn.setSizeHintAlign(1.0, 1.0); +btn.setVisible(true); + +btn.on('clicked', function () { console.log('clicked'); } ); + +win.setSize(240, 60); +win.setVisible(true); + diff --git a/src/examples/button_example_01.js b/src/examples/button_example_01.js new file mode 100644 index 000000000..5f34c112a --- /dev/null +++ b/src/examples/button_example_01.js @@ -0,0 +1,208 @@ +efl = require('efl'); +elm = require('elm'); + +_btn_options_cb = function(_btn) { + var text = _btn.textGet("elm.text"); + var lbl = text.split(": "); + + var t = parseFloat(lbl[1]); + if (lbl[0] === "Initial") + { + console.log ("Initial: " + lbl[1]); + up.setAutorepeatInitialTimeout(t); + down.setAutorepeatInitialTimeout(t); + left.setAutorepeatInitialTimeout(t); + right.setAutorepeatInitialTimeout(t); + } + else if (lbl[0] === "Gap") + { + console.log ("Gap: " + lbl[1]); + up.setAutorepeatGapTimeout(t); + down.setAutorepeatGapTimeout(t); + left.setAutorepeatGapTimeout(t); + right.setAutorepeatGapTimeout(t); + } +} + +_btn_cursors_move = function(_btn) { + var size = mid.getSizeHintAlign(); + var ax = size[0]; + var ay = size[1]; + console.log ("cursor move: ", size[0], size[1]); + + if (!icon_still) { + var icon = new elm.Elm.Icon(mid); + var icon_still_p = mid.contentUnset("icon"); + if (icon_still_p) { + icon_still_p.setVisible(false); + } + icon.setStandard("chat"); + mid.contentSet("icon", icon); + } + + if (_btn.getPosition()[1] == up.getPosition()[1]) { + ay -= 0.05; + if (ay < 0.0) ay = 0.0; + } + else if (_btn.getPosition()[1] == down.getPosition()[1]) { + ay += 0.05; + if (ay > 1.0) ay = 1.0; + } + else if (_btn.getPosition()[0] == left.getPosition()[0]) { + ax -= 0.05; + if (ax < 0.0) ax = 0.0; + } + else if (_btn.getPosition()[0] == right.getPosition()[0]) { + ax += 0.05; + if (ax > 1.0) ax = 1.0; + } + mid.setSizeHintAlign(ax, ay); +} + + +win = new elm.Elm.WinStandard(null); +win.setTitle("Button example"); +win.setAutohide(true); + +icon_still = new elm.Elm.Icon(win); +mid = new elm.Elm.Button(win); +up = new elm.Elm.Button(win); +down = new elm.Elm.Button(win); +left = new elm.Elm.Button(win); +right = new elm.Elm.Button(win); + +_btn_cursors_release = function() { + if (icon_still) + { + mid.contentSet("icon", icon_still); + icon_still = null; + } +} + +box = new elm.Elm.Box(win); +box.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(box); +box.setVisible(true); + +box_initial = new elm.Elm.Box(win); +box_initial.setHorizontal(true); +box_initial.setSizeHintWeight(1.0, 0.0); +box.packEnd(box_initial); +box_initial.setVisible(true); + +btn = new elm.Elm.Button(win); +btn.setText("elm.text", "Initial: 0.0"); +box_initial.packEnd(btn); +btn.setVisible(true); + +btn.on('clicked', _btn_options_cb); + +btn2 = new elm.Elm.Button(win); +btn2.setText("elm.text", "Initial: 1.0"); +box_initial.packEnd(btn2); +btn2.setVisible(true); +btn2.on('clicked', _btn_options_cb); + +btn3 = new elm.Elm.Button(win); +btn3.setText("elm.text", "Initial: 5.0"); +box_initial.packEnd(btn3); +btn3.setVisible(true); +btn3.on('clicked', _btn_options_cb); + +box_gap = new elm.Elm.Box(win); +box_gap.setHorizontal(true); +box_gap.setSizeHintWeight(1.0, 0.0); +box.packEnd(box_gap); +box_gap.setVisible(true); + +btn4 = new elm.Elm.Button(win); +btn4.setText("elm.text", "Gap: 0.1"); +box_gap.packEnd(btn4); +btn4.setVisible(true); +btn4.on('clicked', _btn_options_cb); + +btn5 = new elm.Elm.Button(win); +btn5.setText("elm.text", "Gap: 0.5"); +box_gap.packEnd(btn5); +btn5.setVisible(true); +btn5.on('clicked', _btn_options_cb); + +btn6 = new elm.Elm.Button(win); +btn6.setText("elm.text", "Gap: 1.0"); +box_gap.packEnd(btn6); +btn6.setVisible(true); +btn6.on('clicked', _btn_options_cb); + +up.setAutorepeat(true); +up.setAutorepeatInitialTimeout(1.0); +up.setAutorepeatGapTimeout(0.5); +up.setSizeHintWeight(1.0, 0.0); +up.setSizeHintAlign(-1.0, 0.0); +box.packEnd(up); +up.setVisible(true); +up.on('repeated', _btn_cursors_move) +up.on('unpressed', _btn_cursors_release); +icon_up = new elm.Elm.Icon(win); +icon_up.setStandard("arrow_up"); +up.contentSet("icon", icon_up); + +box_inferior = new elm.Elm.Box(win); +box_inferior.setHorizontal(true); +box_inferior.setSizeHintWeight(1.0, 1.0); +box_inferior.setSizeHintAlign(-1.0, -1.0); +box.packEnd(box_inferior); +box_inferior.setVisible(true); + +left.setAutorepeat(true); +left.setAutorepeatInitialTimeout(1.0); +left.setAutorepeatGapTimeout(0.5); +left.setSizeHintWeight(0.0, 1.0); +left.setSizeHintAlign(0.0, -1.0); +box_inferior.packEnd(left); +left.setVisible(true); +left.on('repeated', _btn_cursors_move) +left.on('unpressed', _btn_cursors_release); + +icon_left = new elm.Elm.Icon(win); +icon_left.setStandard("arrow_left"); +left.contentSet("icon", icon_left); + +mid.setSizeHintWeight(1.0, 1.0); +box_inferior.packEnd(mid); +mid.setVisible(true); + +icon_mid = new elm.Elm.Icon(win); +icon_mid.setStandard("close"); +mid.contentSet("icon", icon_mid); + +right.setAutorepeat(true); +right.setAutorepeatInitialTimeout(1.0); +right.setAutorepeatGapTimeout(0.5); +right.setSizeHintWeight(0.0, 1.0); +right.setSizeHintAlign(0.0, -1.0); +box_inferior.packEnd(right); +right.setVisible(true); +right.on('repeated', _btn_cursors_move); +right.on('unpressed', _btn_cursors_release); + +icon_right = new elm.Elm.Icon(win); +icon_right.setStandard("arrow_right"); +right.contentSet("icon", icon_right); + +down.setAutorepeat(true); +down.setAutorepeatInitialTimeout(1.0); +down.setAutorepeatGapTimeout(0.5); +down.setSizeHintWeight(1.0, 0.0); +down.setSizeHintAlign(-1.0, 0.0); +box.packEnd(down); +down.setVisible(true); +down.on('repeated', _btn_cursors_move); +down.on('unpressed', _btn_cursors_release); + +icon_down = new elm.Elm.Icon(win); +icon_down.setStandard("arrow_down"); +down.contentSet("icon", icon_down); + +win.setSize(300, 320); +win.setVisible(true); + diff --git a/src/examples/calendar_example_01.js b/src/examples/calendar_example_01.js new file mode 100644 index 000000000..980bf83a2 --- /dev/null +++ b/src/examples/calendar_example_01.js @@ -0,0 +1,14 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Calendar Creation Example"); +win.setAutohide(true); + +cal = new elm.Elm.Calendar(win); +cal.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(cal); +cal.setVisible(true); + +win.setVisible(true); diff --git a/src/examples/calendar_example_02.js b/src/examples/calendar_example_02.js new file mode 100644 index 000000000..c8b53fd75 --- /dev/null +++ b/src/examples/calendar_example_02.js @@ -0,0 +1,17 @@ +elm = require('elm'); + +//var weekdays = ["S", "M", "T", "W", "T", "F", "S"]; + +win = new elm.Elm.WinStandard(null); +win.setTitle("Calendar Layout Formatting Example"); +win.setAutohide(true); + +cal = new elm.Elm.Calendar(win); +cal.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(cal); + +//cal.format_function_set(funtion); +//cal.weekdays_names_set(weekdays); + +cal.setVisible(true); +win.setVisible(true); diff --git a/src/examples/calendar_example_03.js b/src/examples/calendar_example_03.js new file mode 100644 index 000000000..481079fc6 --- /dev/null +++ b/src/examples/calendar_example_03.js @@ -0,0 +1,15 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Calendar Min/Max Year Example"); +win.setAutohide(true); + +cal = new elm.Elm.Calendar(win); +cal.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(cal); +cal.setMinMaxYear(2020,2022); +cal.setVisible(true); + +win.setVisible(true); diff --git a/src/examples/calendar_example_04.js b/src/examples/calendar_example_04.js new file mode 100644 index 000000000..7f1094149 --- /dev/null +++ b/src/examples/calendar_example_04.js @@ -0,0 +1,32 @@ + +elm = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Calendar Day Selection Example"); +win.setAutohide(true); + +box = new elm.Elm.Box(win); +box.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(box); +box.setVisible(true); + +cal = new elm.Elm.Calendar(win); +cal.setSizeHintWeight(1.0, 1.0); +cal.setSizeHintAlign(-1.0, -1.0); +cal.setSelectMode(elm.Elm.Calendar.Select.Mode.NONE); +win.resizeObjectAdd(cal); +cal.setVisible(true); +box.packEnd(cal); + +cal2 = new elm.Elm.Calendar(win); +cal2.setSizeHintWeight(1.0, 1.0); +cal2.setSizeHintAlign(-1.0, -1.0); +// selected_time_set uses tm* struct +//dateCurrent = new Date(); +//dateSelected = dateCurrent.getSeconds() + 2 * 3600 * 24; +//cal2.selected_time_set(dateSelected); +cal2.setVisible(true); +box.packEnd(cal2); + +win.setVisible(true); diff --git a/src/examples/calendar_example_05.js b/src/examples/calendar_example_05.js new file mode 100644 index 000000000..7759b2da8 --- /dev/null +++ b/src/examples/calendar_example_05.js @@ -0,0 +1,29 @@ + +elm = require('elm'); + +_print_cal_info_cb = function () +{ + //var sel_time = cal.selected_time_get() + + var interval = cal.getInterval(); + var mm_yr = cal.getMinMaxYear(); + var sel_enable = cal.getSelectMode() != elm.Elm.Calendar.Select.Mode.NONE; + var wds = cal.getWeekdaysNames(); + + console.log("weekdays= " + wds + ", interval= " + interval + + "\nYear_Min: "+mm_yr[0]+ ", Year_Max: "+mm_yr[1]+", Sel Enabled: "+sel_enable); +} + + +win = new elm.Elm.WinStandard(null); +win.setTitle("Calendar Getters Example"); +win.setAutohide(true); + +cal = new elm.Elm.Calendar(win); +cal.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(cal); + +cal.on('changed', _print_cal_info_cb); + +cal.setVisible(true); +win.setVisible(true); diff --git a/src/examples/clock_example.js b/src/examples/clock_example.js new file mode 100644 index 000000000..f13c07e72 --- /dev/null +++ b/src/examples/clock_example.js @@ -0,0 +1,43 @@ +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Clock Example"); +win.setAutohide(true); + +bx = new elm.Elm.Box(win); +bx.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bx); +bx.setVisible(true); + +ck = new elm.Elm.Clock(win); +bx.packEnd(ck); +ck.setVisible(true); + +ck2 = new elm.Elm.Clock(win); +ck2.setShowAmPm(true); +bx.packEnd(ck2); +ck2.setVisible(true); + +ck3 = new elm.Elm.Clock(win); +ck3.setShowSeconds(true); +ck3.setTime(10, 11, 12); +bx.packEnd(ck3); +ck3.setVisible(true); + +ck4 = new elm.Elm.Clock(win); +ck4.setEdit(true); +ck4.setShowSeconds(true); +ck4.setShowAmPm(true); +ck4.setTime(10, 11, 12); +bx.packEnd(ck4); +ck4.setVisible(true); + +ck5 = new elm.Elm.Clock(win); +ck5.setShowSeconds(true); +ck5.setEdit(true); +digedit = elm.Elm.Clock.EditMode.HOUR_UNIT | elm.Elm.Clock.EditMode.MIN_UNIT | elm.Elm.Clock.EditMode.SEC_UNIT; +ck5.setEditMode(digedit); +bx.packEnd(ck5); +ck5.setVisible(true); + +win.setVisible(true); diff --git a/src/examples/datetime_example.js b/src/examples/datetime_example.js new file mode 100644 index 000000000..92b361ec8 --- /dev/null +++ b/src/examples/datetime_example.js @@ -0,0 +1,42 @@ + +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Datetime"); +win.setAutohide(true); + +bg = new elm.Elm.Bg(win); +bg.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bg); +bg.setVisible(true); + +bx = new elm.Elm.Box(win); +bx.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bx); +bx.setVisible(true); + +datetime = new elm.Elm.Datetime(bx); +datetime.setSizeHintWeight(1.0, 1.0); +datetime.setSizeHintAlign(-1.0, 0.5); +datetime.fieldVisibleSet(elm.Elm.Datetime.FieldType.HOUR, false); +datetime.fieldVisibleSet(elm.Elm.Datetime.FieldType.MINUTE, false); +datetime.fieldVisibleSet(elm.Elm.Datetime.FieldType.AMPM, false); +bx.packEnd(datetime); +datetime.setVisible(true); + +datetime = new elm.Elm.Datetime(bx); +datetime.setSizeHintWeight(1.0, 1.0); +datetime.setSizeHintAlign(-1.0, 0.5); +datetime.fieldVisibleSet(elm.Elm.Datetime.FieldType.YEAR, false); +datetime.fieldVisibleSet(elm.Elm.Datetime.FieldType.MONTH, false); +datetime.fieldVisibleSet(elm.Elm.Datetime.FieldType.DATE, false); +bx.packEnd(datetime); +datetime.setVisible(true); + +datetime = new elm.Elm.Datetime(bx); +datetime.setSizeHintWeight(1.0, 1.0); +datetime.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(datetime); +datetime.setVisible(true); + +win.setVisible(true); diff --git a/src/examples/icon_example_01.js b/src/examples/icon_example_01.js new file mode 100644 index 000000000..a1689349c --- /dev/null +++ b/src/examples/icon_example_01.js @@ -0,0 +1,33 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Icon Plain"); +win.setAutohide(true); + +icon = new elm.Elm.Icon(win); +//icon.order_lookup_set(ELM_ICON_LOOKUP_THEME_FDO); Ja eh o default +icon.setStandard("home"); + +var path, group; +r = icon.getFile(path, group); +path = r[0]; +gruop = r[1]; +console.log("path = " + path + ", group = " + group); + +var name; +name = icon.getStandard(); +console.log("name = " + name); + +icon.setNoScale(true); +icon.setResizable(false, true); +icon.setSmooth(false); +icon.setFillOutside(true); + +icon.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(icon); +icon.setVisible(true); + +win.setSize(320, 320); +win.setVisible(true); diff --git a/src/examples/menu_example_01.js b/src/examples/menu_example_01.js new file mode 100644 index 000000000..9e3170fe8 --- /dev/null +++ b/src/examples/menu_example_01.js @@ -0,0 +1,37 @@ +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Menu"); +win.setAutohide(true); + +rect = new efl.Evas.Rectangle(win); +win.resizeObjectAdd(rect); +rect.setSizeHintMin( 0, 0); +rect.setColor( 0, 0, 0, 0); +rect.setVisible(true); + +menu = new elm.Elm.Menu(win); +menu.itemAdd(null, null, "first item", null, null); // item_add nao implementado +menu_it = menu.itemAdd(null, "mail-reply-all", "second intem", null, null); + +menu.itemAdd(menu_it, "object-rotate-left", "menu 1", null, null); +button = new elm.Elm.Button(win); +button.textSet("elm.text", "button - delete items"); +menu_it1 = menu.itemAdd(menu_it, null, null, null, null); +menu_it1.setPartContent(null, button); + +//button.event_clicked(del_it); + +menu.itemSeparatorAdd(menu_it); +menu.itemAdd(menu_it, null, "third item", null, null); +menu.itemAdd(menu_it, null, "fourth item", null, null); +menu.itemAdd(menu_it, "window-new", "sub menu", null, null); + +menu_it = menu.itemAdd(null, null, "third item", null, null); +menu_it.setDisabled(true); + +menu.setVisible(true); +rect.on('mouse_down', function(){menu.visible_set(true)}); +win.setSize(250, 350); +win.setVisible(true); diff --git a/src/examples/popup_example_01.js b/src/examples/popup_example_01.js new file mode 100644 index 000000000..2e39763c0 --- /dev/null +++ b/src/examples/popup_example_01.js @@ -0,0 +1,32 @@ +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Popup"); +win.setAutohide(true); + +content = new elm.Elm.Label(win); +content.setText("elm.text", "<align=center>Content</align>"); + +popup = new elm.Elm.Popup(win); +popup.setTimeout(3); + +popup.on('timeout', function() + { + console.log("timeout"); + popup.setVisible(false); + }); + +popup.contentSet("elm.swallow.content", content); + +popup.setText("title,text", "Title"); +popup.setVisible(true); + +popup.on('block_clicked', function() + { + console.log("clicked") + popup.setVisible(false); + }); + +win.setSize(480, 800); +win.setVisible(true); diff --git a/src/examples/radio_example_01.js b/src/examples/radio_example_01.js new file mode 100644 index 000000000..ac91c2c41 --- /dev/null +++ b/src/examples/radio_example_01.js @@ -0,0 +1,65 @@ + +elm = require('elm'); + +_cb = function(obj){ + console.log(obj.textGet("elm.text"), "state value:", obj.getStateValue()); +} + +win = new elm.Elm.WinStandard(null); +win.setTitle("Radio"); +win.setAutohide(true); + +bx = new elm.Elm.Box(win); +bx.setHorizontal(true); +bx.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bx); +bx.setVisible(true); + +radio_g = new elm.Elm.Radio(win); +radio_g.textSet("elm.text", "Radio 1"); +radio_g.setStateValue(1); +radio_g.setValue(1); +ic = new elm.Elm.Icon(win); +ic.setStandard("home"); +radio_g.contentSet("icon", ic); +bx.packEnd(radio_g); +radio_g.setSizeHintWeight(1.0, 1.0); +radio_g.setSizeHintAlign(-1.0, -1.0); +radio_g.on('changed', _cb); +radio_g.setVisible(true); + +radio = new elm.Elm.Radio(win); +radio.textSet("elm.text", "Radio 2"); +radio.setStateValue(2); +radio.groupAdd(radio_g); +ic = new elm.Elm.Icon(win); +ic.setStandard("file"); +radio.contentSet("icon", ic); +bx.packEnd(radio); +radio.setSizeHintWeight(1.0, 1.0); +radio.setSizeHintAlign(-1.0, -1.0); +radio.on('changed', _cb); +radio.setVisible(true); + +radio = new elm.Elm.Radio(win); +radio.textSet("elm.text", "Radio 3"); +radio.setStateValue(3); +radio.groupAdd(radio_g); +bx.packEnd(radio); +radio.setSizeHintWeight(1.0, 1.0); +radio.setSizeHintAlign(-1.0, -1.0); +radio.on('changed', _cb); +radio.setVisible(true); + +radio = new elm.Elm.Radio(win); +radio.textSet("elm.text", "Radio 4"); +radio.setStateValue(4); +radio.groupAdd(radio_g); +bx.packEnd(radio); +radio.setSizeHintWeight(1.0, 1.0); +radio.setSizeHintAlign(-1.0, -1.0); +radio.on('changed', _cb); +radio.setVisible(true); + + +win.setVisible(true); diff --git a/src/examples/separator_example_01.js b/src/examples/separator_example_01.js new file mode 100644 index 000000000..53fc3cafa --- /dev/null +++ b/src/examples/separator_example_01.js @@ -0,0 +1,41 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Separator"); +win.setAutohide(true); + +bg = new elm.Elm.Bg(win); +bg.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bg); +bg.setVisible(true); + +bx = new elm.Elm.Box(win); +bx.setHorizontal(true); +bx.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bx); +bx.setVisible(true); + +rect = new efl.Evas.Rectangle(win); +rect.setColor( 0, 255, 0, 255) +rect.setSizeHintMin( 90, 200); +rect.setSizeHintWeight(1.0, 1.0); +rect.setSizeHintAlign(-1.0, -1.0); +rect.setVisible(true); +bx.packEnd(rect); + +separator = new elm.Elm.Separator(win); +separator.setHorizontal(true); +separator.setVisible(true); +bx.packEnd(separator); + +rect2 = new efl.Evas.Rectangle(win); +rect2.setColor( 0, 0, 255, 255); +rect2.setSizeHintMin( 90, 200); +rect2.setSizeHintWeight(1.0, 1.0); +rect2.setSizeHintAlign(-1.0, -1.0); +rect2.setVisible(true); +bx.packEnd(rect2); + +win.setVisible(true); diff --git a/src/examples/slider_example.js b/src/examples/slider_example.js new file mode 100644 index 000000000..e585119d9 --- /dev/null +++ b/src/examples/slider_example.js @@ -0,0 +1,104 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Slider Example"); +win.setAutohide(true); + +bx = new elm.Elm.Box(win); +//bx.setHorizontal(true); +bx.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bx); +bx.setVisible(true); + +sl = new elm.Elm.Slider(win); +sl.setSizeHintAlign(-1.0, 0.5); +sl.setSizeHintWeight(1.0, 1.0); +bx.packEnd(sl); +sl.setVisible(true); + +/* with icon, end and label */ +sl = new elm.Elm.Slider(win); +sl.textSet("elm.text", "Counter"); + +ic = new elm.Elm.Icon(win); +ic.setStandard("home"); +ic.setResizable(false, false); +sl.contentSet("icon", ic); + +ic = new elm.Elm.Icon(win); +ic.setStandard("folder"); +ic.setResizable(false, false); +sl.contentSet("end", ic); + +sl.setSizeHintAlign(-1.0, 0.5); +sl.setSizeHintWeight(1.0, 1.0); +bx.packEnd(sl); +sl.setVisible(true); + +/* value set and span size */ +sl = new elm.Elm.Slider(win); +sl.setValue(1); +sl.setSpanSize(200); +sl.setSizeHintAlign(-1.0, 0.5); +sl.setSizeHintWeight(1.0, 1.0); +bx.packEnd(sl); +sl.setVisible(true); + +/* with unit label and min - max */ +sl = new elm.Elm.Slider(win); +sl.setUnitFormat("%1.0f units"); +sl.setMinMax(0, 100); +sl.setSizeHintAlign(-1.0, 0.5); +sl.setSizeHintWeight(1.0, 1.0); +bx.packEnd(sl); +sl.setVisible(true); + +/* with indicator label and inverted */ +sl = new elm.Elm.Slider(win); +sl.setIndicatorFormat("%1.2f"); +sl.setInverted(true); +sl.setSizeHintAlign(-1.0, 0.5); +sl.setSizeHintWeight(1.0, 1.0); +bx.packEnd(sl); +sl.setVisible(true); + +/* vertical with indicator format func */ +sl = new elm.Elm.Slider(win); +sl.setHorizontal(false); +//indicator_format = function() +// { +// indicator = new char[32]; +// nprintf(indicator, 32, "%1.2f u", val); +// return indicator; +// } +//indicator_free = function() {console.log("free")} +//sl.indicator_format_function_set(indicator_format, indicator_free); + +sl.setSizeHintAlign(0.5, -1.0); +sl.setSizeHintWeight(0.0, 1.0); +bx.packEnd(sl); +sl.setVisible(true); + +/* callbacks */ +sl = new elm.Elm.Slider(win); +sl.setUnitFormat("%1.3f units"); +sl.setSizeHintAlign(-1.0, 0.5); +sl.setSizeHintWeight(1.0, 1.0); +bx.packEnd(sl); +sl.setVisible(true); + +sl.on('changed', function(obj) + { + val = obj.value_get(); + console.log("Changed to " + val); + }); + +sl.on('delay_changed', function(obj) + { + val = obj.value_get(); + console.log("Delay changed to " + val); + }); + +win.setVisible(true); diff --git a/src/examples/spinner_example.js b/src/examples/spinner_example.js new file mode 100644 index 000000000..c9d2917da --- /dev/null +++ b/src/examples/spinner_example.js @@ -0,0 +1,90 @@ + +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Spinner Example"); +win.setAutohide(true); + +bx = new elm.Elm.Box(win); +bx.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(bx); +bx.setVisible(true); + +sp = new elm.Elm.Spinner(win); +sp.setSizeHintWeight(1.0, 1.0); +sp.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(sp); +sp.setVisible(true); + +sp2 = new elm.Elm.Spinner(win); +sp2.setLabelFormat("Percentage %%%1.2f something"); +sp2.setSizeHintWeight(1.0, 1.0); +sp2.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(sp2); +sp2.setVisible(true); + +sp3 = new elm.Elm.Spinner(win); +sp3.setLabelFormat("%1.1f units"); +sp3.setStep(1.5); +sp3.setWrap(true); +sp3.setMinMax(-50.0, 250.0); +sp3.setSizeHintWeight(1.0, 1.0); +sp3.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(sp3); +sp3.setVisible(true); + +sp4 = new elm.Elm.Spinner(win); +sp4.setStyle("vertical"); +sp4.setInterval(0.2); +sp4.setSizeHintWeight(1.0, 1.0); +sp4.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(sp4); +sp4.setVisible(true); + +sp5 = new elm.Elm.Spinner(win); +sp5.setEditable(false); +sp5.setSizeHintWeight(1.0, 1.0); +sp5.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(sp5); +sp5.setVisible(true); + +sp6 = new elm.Elm.Spinner(win); +sp6.setEditable(false); +sp6.setMinMax(1, 12); +sp6.specialValueAdd(1, "January"); +sp6.specialValueAdd(2, "February"); +sp6.specialValueAdd(3, "March"); +sp6.specialValueAdd(4, "April"); +sp6.specialValueAdd(5, "May"); +sp6.specialValueAdd(6, "June"); +sp6.specialValueAdd(7, "July"); +sp6.specialValueAdd(8, "August"); +sp6.specialValueAdd(9, "September"); +sp6.specialValueAdd(10, "October"); +sp6.specialValueAdd(11, "November"); +sp6.specialValueAdd(12, "December"); +sp6.setSizeHintWeight(1.0, 1.0); +sp6.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(sp6); +sp6.setVisible(true); + +sp7 = new elm.Elm.Spinner(win); +sp7.setSizeHintWeight(1.0, 1.0); +sp7.setSizeHintAlign(-1.0, 0.5); +bx.packEnd(sp7); +sp7.setVisible(true); +sp7.setEditable(true); + +sp7.on('changed', + function(obj) + { + console.log("Value changed to " + obj.value_get()); + }); + +sp7.on('delay_changed', + function(obj) + { + console.log("Value delay changed to " + obj.value_get()); + }); + +win.setVisible(true); diff --git a/src/examples/table_example_01.js b/src/examples/table_example_01.js new file mode 100644 index 000000000..928f25494 --- /dev/null +++ b/src/examples/table_example_01.js @@ -0,0 +1,34 @@ + +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Table"); +win.setAutohide(true); + +table = new elm.Elm.Table(win); +win.resizeObjectAdd(table); +table.setVisible(true); +table.setPadding(5, 5); +table.setHomogeneous(true); + +label = new elm.Elm.Label(win); +label.setText("elm.text", "label 0"); +label.setVisible(true); +table.pack(label, 0, 0, 1, 1); + +label = new elm.Elm.Label(win); +label.setText("elm.text", "label 1"); +label.setVisible(true); +table.pack(label, 1, 0, 1, 1); + +label = new elm.Elm.Label(win); +label.setText("elm.text", "label 2"); +label.setVisible(true); +table.pack(label, 0, 1, 1, 1); + +label = new elm.Elm.Label(win); +label.setText("elm.text", "label 3"); +label.setVisible(true); +table.pack(label, 1, 1, 1, 1); + +win.setVisible(true); diff --git a/src/examples/table_example_02.js b/src/examples/table_example_02.js new file mode 100644 index 000000000..af51ec793 --- /dev/null +++ b/src/examples/table_example_02.js @@ -0,0 +1,38 @@ + +efl = require('efl'); +elm = require('elm'); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Table"); +win.setAutohide(true); + +table = new elm.Elm.Table(win); +win.resizeObjectAdd(table); +table.setVisible(true); +table.setHomogeneous(false); + +rect = new efl.Evas.Rectangle(win); +rect.setColor( 255, 0, 0, 255) +rect.setSizeHintMin( 100, 50); +rect.setVisible(true) +table.pack(rect, 0, 0, 2, 1); + +rect2 = new efl.Evas.Rectangle(win); +rect2.setColor( 0, 255, 0, 255) +rect2.setSizeHintMin( 50, 100); +rect2.setVisible(true) +table.pack(rect2, 0, 1, 1, 2); + +rect3 = new efl.Evas.Rectangle(win); +rect3.setColor( 0, 0, 255, 255) +rect3.setSizeHintMin( 50, 50); +rect3.setVisible(true) +table.pack(rect3, 1, 1, 1, 1); + +rect4 = new efl.Evas.Rectangle(win); +rect4.setColor( 255, 255, 0, 255) +rect4.setSizeHintMin( 50, 50); +rect4.setVisible(true) +table.pack(rect4, 1, 2, 1, 1); + +win.setVisible(true); diff --git a/src/examples/thumb_example_01.js b/src/examples/thumb_example_01.js new file mode 100644 index 000000000..c12a98829 --- /dev/null +++ b/src/examples/thumb_example_01.js @@ -0,0 +1,38 @@ +elm = require('elm'); + +_generation_started_cb = function(obj) +{ + console.log("thumbnail generation started."); +} + +_generation_finished_cb = function(obj) +{ + console.log("thumbnail generation finished."); +} + +_generation_error_cb = function(obj) +{ + console.log("thumbnail generation error."); +} + +win = new elm.Elm.WinStandard(null); +win.setTitle("Table"); +win.setAutohide(true); + +thumb = new elm.Elm.Thumb(win); + +thumb.on('generate_start', _generation_started_cb); +thumb.on('generate_stop', _generation_finished_cb); +thumb.on('generate_error', _generation_error_cb); + +thumb.setSize(160, 160); +thumb.setEditable(false); +thumb.setFile("../../data/images/plant_01.jpg", null); +thumb.reload(); + +thumb.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(thumb); + +thumb.setVisible(true); +win.setSize(320, 320); +win.setVisible(true); diff --git a/src/examples/twitter_example_01.edc b/src/examples/twitter_example_01.edc new file mode 100644 index 000000000..8a98930ff --- /dev/null +++ b/src/examples/twitter_example_01.edc @@ -0,0 +1,89 @@ +collections { + group { + name: "tweet"; + parts + { + part { + name: "user_icon"; + type: SWALLOW; + description { + rel1 { + relative: 0.0 0.0; + offset: 2 2; + } + rel2 { + relative: 0.0 0.0; + offset: 50 50 ; + } + } + } + part { + name: "user_name"; + type: TEXT; + effect: SOFT_SHADOW; + description { + color: 0 190 255 255; + rel1 { + relative: 1.0 0.0; + to_x: "user_icon"; + offset: 7 4; + } + rel2 { + relative: 1.0 0.0; + to_x: "user_icon"; + offset: 120 30; + } + text { + text: "User Name"; + size: 12; + font: "sans:style=Bold"; + min: 1 1; + ellipsis: -1; + align: 0.0 0.0; + } + } + } + part { + name: "screen_name"; + type: TEXT; + description { + rel1 { + relative: 1.0 0.0; + to: "user_name"; + offset: 15 4; + } + rel2 { + relative: 1.0 1.0; + to: "user_name"; + offset: 75 10; + } + text { + text: "scname"; + size: 10; + font: "sans"; + min: 1 1; + ellipsis: -1; + align: 0.0 0.0; + } + } + } + part { + name: "tweet_text"; + type: SWALLOW; + description { + rel1 { + relative: 0.0 1.0; + to: "user_name"; + offset: 0 0; + } + rel2 { + relative: 0.0 1.0; + to: "user_name"; + offset: 250 80; + } + } + } + } + } +} + diff --git a/src/examples/twitter_example_01.js b/src/examples/twitter_example_01.js new file mode 100644 index 000000000..84d1d7d76 --- /dev/null +++ b/src/examples/twitter_example_01.js @@ -0,0 +1,82 @@ + +efl = require('efl'); +elm = require('elm'); + +util = require('util'); +fs = require('fs'); + +user_acount = 'EnlightenmentKo' + +request = require('request'); //need "npm install request" +Twitter = require('twitter'); //need "npm install twitter" + +var twit = new Twitter({ + consumer_key: 'ZbSM93w5Sp2cyZ2SG0XuCvoHV', + consumer_secret: 'g8N7EEQLpdKPnAsS9hWuQV29FYjBkhH62jhZzXyYymDw87DKye', + access_token_key: '222611263-pPhKKjYh59uuNLP0b86sP7aAtLhdecjVQaEsCDCv', + access_token_secret: 'l7ccNKXTVv6cymfSD1gQH61tmfixkdna2QmOjPtpVxSHD' +}); + +win = new elm.Elm.WinStandard(null); +win.setTitle("Twitter App"); +win.setAutohide(true); + +box = new elm.Elm.Box(win); +box.setSizeHintWeight(1.0, 1.0); +win.resizeObjectAdd(box); +box.setVisible(true); + +list = new elm.Elm.List(win); +list.setSizeHintWeight(1.0, 1.0); +list.setSizeHintAlign(-1.0, -1.0); +box.packEnd(list); +list.setVisible(true); + +icon_array = new Array(); + +twit.get('statuses/user_timeline', {screen_name: user_acount, count:10}, function(error, tweets, response) { + if (!error){ + file = fs.createWriteStream('/tmp/twitter_pic.jpg'); + file.on('finish', function() { + console.log("finished"); + for (i=0; i < icon_array.length; i++) { + console.log(i); + icon_array[i].setFile("/tmp/twitter_pic.jpg", null); + } + }); + if (tweets.length > 0) { + request(tweets[0].user.profile_image_url).pipe(file); + } + + for(i=0; i < tweets.length; i++){ + var layout = new elm.Elm.Layout(win); + layout.setFile("twitter_example_01.edj", "tweet"); + + var user_name = tweets[i].user.name; + var screen_name = tweets[i].user.screen_name; + var user_icon_url = tweets[i].user.profile_image_url; + var text = tweets[i].text; + + layout.setText("user_name", screen_name); + layout.setText("screen_name", " - @"+screen_name); + var entry = new elm.Elm.Entry(win); + entry.setText("elm.text", text); + console.log(text); + layout.contentSet("tweet_text", entry); + + layout.setSizeHintMin(127, 96); + layout.setSizeHintWeight(1.0, 1.0); + layout.setSizeHintAlign(-1.0, -1.0); + + var icon = new elm.Elm.Image(win); + icon.setFillInside(true); + icon_array.push(icon); + layout.contentSet("user_icon", icon); + item = list.itemAppend("", layout, null, null, null); + } + list.go(); + } +}); + +win.setSize(380,400); +win.setVisible(true); |