2014-12-09 10:41:16 -08:00
|
|
|
|
|
|
|
efl = require('efl');
|
|
|
|
|
2017-05-18 17:23:58 -07:00
|
|
|
win = new efl.Efl.Ui.Win(null, "Efl JS Example", efl.Efl.Ui.Win.Type.BASIC, "hw");
|
2016-07-26 14:21:02 -07:00
|
|
|
win.setText("Slider Example");
|
2014-12-09 10:41:16 -08:00
|
|
|
win.setAutohide(true);
|
|
|
|
|
2016-07-26 14:21:02 -07:00
|
|
|
bx = new efl.Efl.Ui.Box(win);
|
2017-08-22 21:39:10 -07:00
|
|
|
bx.cast("Efl.Ui.Direction").setDirection(efl.Efl.Ui.Dir.HORIZONTAL);
|
2016-07-26 14:21:02 -07:00
|
|
|
bx.setHintWeight(1.0, 1.0);
|
2016-12-07 09:49:43 -08:00
|
|
|
win.setContent(bx);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.setVisible(true);
|
|
|
|
|
2016-07-26 14:21:02 -07:00
|
|
|
sl = new efl.Elm.Slider(win);
|
|
|
|
sl.setHintAlign(-1.0, 0.5);
|
|
|
|
sl.setHintWeight(1.0, 1.0);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.packEnd(sl);
|
|
|
|
sl.setVisible(true);
|
|
|
|
|
|
|
|
/* with icon, end and label */
|
2016-07-26 14:21:02 -07:00
|
|
|
sl = new efl.Elm.Slider(win);
|
2017-05-18 17:23:58 -07:00
|
|
|
sl.setPartText("elm.text", "Counter");
|
2014-12-09 10:41:16 -08:00
|
|
|
|
2016-12-07 09:49:43 -08:00
|
|
|
ic = new efl.Efl.Ui.Image(win);
|
2016-07-26 14:21:02 -07:00
|
|
|
ic.setIcon("home");
|
|
|
|
// ic.setResizable(false, false);
|
2017-11-19 22:41:07 -08:00
|
|
|
sl.part("icon").cast("Efl.Content").setContent(ic);
|
2014-12-09 10:41:16 -08:00
|
|
|
|
2016-12-07 09:49:43 -08:00
|
|
|
ic = new efl.Efl.Ui.Image(win);
|
2016-07-26 14:21:02 -07:00
|
|
|
ic.setIcon("folder");
|
|
|
|
// ic.setResizable(false, false);
|
2017-11-19 22:41:07 -08:00
|
|
|
sl.part("end").cast("Efl.Content").setContent(ic);
|
2014-12-09 10:41:16 -08:00
|
|
|
|
2016-07-26 14:21:02 -07:00
|
|
|
sl.setHintAlign(-1.0, 0.5);
|
|
|
|
sl.setHintWeight(1.0, 1.0);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.packEnd(sl);
|
|
|
|
sl.setVisible(true);
|
|
|
|
|
|
|
|
/* value set and span size */
|
2016-07-26 14:21:02 -07:00
|
|
|
sl = new efl.Elm.Slider(win);
|
|
|
|
sl.setProgressValue(1);
|
2014-12-09 10:41:16 -08:00
|
|
|
sl.setSpanSize(200);
|
2016-07-26 14:21:02 -07:00
|
|
|
sl.setHintAlign(-1.0, 0.5);
|
|
|
|
sl.setHintWeight(1.0, 1.0);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.packEnd(sl);
|
|
|
|
sl.setVisible(true);
|
|
|
|
|
|
|
|
/* with unit label and min - max */
|
2016-07-26 14:21:02 -07:00
|
|
|
sl = new efl.Elm.Slider(win);
|
2014-12-09 10:41:16 -08:00
|
|
|
sl.setUnitFormat("%1.0f units");
|
|
|
|
sl.setMinMax(0, 100);
|
2016-07-26 14:21:02 -07:00
|
|
|
sl.setHintAlign(-1.0, 0.5);
|
|
|
|
sl.setHintWeight(1.0, 1.0);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.packEnd(sl);
|
|
|
|
sl.setVisible(true);
|
|
|
|
|
|
|
|
/* with indicator label and inverted */
|
2016-07-26 14:21:02 -07:00
|
|
|
sl = new efl.Elm.Slider(win);
|
2014-12-09 10:41:16 -08:00
|
|
|
sl.setIndicatorFormat("%1.2f");
|
2016-07-26 14:21:02 -07:00
|
|
|
// legacy function, not supported.
|
|
|
|
// sl.setInverted(true);
|
|
|
|
sl.setHintAlign(-1.0, 0.5);
|
|
|
|
sl.setHintWeight(1.0, 1.0);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.packEnd(sl);
|
|
|
|
sl.setVisible(true);
|
|
|
|
|
|
|
|
/* vertical with indicator format func */
|
2016-07-26 14:21:02 -07:00
|
|
|
sl = new efl.Elm.Slider(win);
|
2017-08-22 21:39:10 -07:00
|
|
|
sl.cast("Efl.Ui.Direction").setDirection(efl.Efl.Ui.Dir.VERTICAL);
|
2014-12-09 10:41:16 -08:00
|
|
|
//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);
|
|
|
|
|
2016-07-26 14:21:02 -07:00
|
|
|
sl.setHintAlign(0.5, -1.0);
|
|
|
|
sl.setHintWeight(0.0, 1.0);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.packEnd(sl);
|
|
|
|
sl.setVisible(true);
|
|
|
|
|
|
|
|
/* callbacks */
|
2016-07-26 14:21:02 -07:00
|
|
|
sl = new efl.Elm.Slider(win);
|
2014-12-09 10:41:16 -08:00
|
|
|
sl.setUnitFormat("%1.3f units");
|
2016-07-26 14:21:02 -07:00
|
|
|
sl.setHintAlign(-1.0, 0.5);
|
|
|
|
sl.setHintWeight(1.0, 1.0);
|
2014-12-09 10:41:16 -08:00
|
|
|
bx.packEnd(sl);
|
|
|
|
sl.setVisible(true);
|
|
|
|
|
|
|
|
sl.on('changed', function(obj)
|
|
|
|
{
|
2016-07-26 14:21:02 -07:00
|
|
|
val = obj.getProgressValue();
|
2014-12-09 10:41:16 -08:00
|
|
|
console.log("Changed to " + val);
|
|
|
|
});
|
|
|
|
|
|
|
|
sl.on('delay_changed', function(obj)
|
|
|
|
{
|
2016-07-26 14:21:02 -07:00
|
|
|
val = obj.getProgressValue();
|
2016-01-08 15:31:26 -08:00
|
|
|
console.log("Delay changed to " + val);
|
2014-12-09 10:41:16 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
win.setVisible(true);
|