This just got in Elementary, support it here as well.
Signed-off-by: Daniel Willmann <d.willm...@samsung.com>
---
trunk/PROTO/elev8/data/javascript/progressbar.js | 29 +++++++++++++--
.../PROTO/elev8/src/modules/elm/CElmProgressBar.cc | 38 ++++++++++++++++++++
.../PROTO/elev8/src/modules/elm/CElmProgressBar.h | 10 ++++++
3 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/trunk/PROTO/elev8/data/javascript/progressbar.js b/trunk/PROTO/elev8/data/javascript/progressbar.js
index 77ee657..a8de8bc 100644
--- a/trunk/PROTO/elev8/data/javascript/progressbar.js
+++ b/trunk/PROTO/elev8/data/javascript/progressbar.js
@@ -16,6 +16,7 @@ var logo_icon_unscaled = elm.Icon ({
var bars = new Array(4);
var bouncers = new Array(3);
var start_time;
+var changed_label;
function set_animator(on) {
start_time = elm.loop_time();
@@ -38,6 +39,17 @@ function bouncing(on) {
}
}
+function changed_cb(obj) {
+ t = elm.loop_time() - start_time;
+ progress = obj.value;
+ if (progress == 0)
+ changed_label.label = "Not started";
+ else {
+ sec = (t/progress)*(1-progress);
+ changed_label.label = "Finished in " + sec.toFixed(0) + " seconds";
+ }
+}
+
var desc = elm.Window({
title : "Progressbar",
elements : {
@@ -68,6 +80,17 @@ var desc = elm.Window({
align : { x : -1.0, y : 0.5 },
weight : EXPAND_BOTH,
}),
+ changed_progress : elm.ProgressBar ({
+ label : "",
+ units : "%1.1f units",
+ on_changed : changed_cb,
+ align : { x : -1.0, y : 0.5 },
+ weight : EXPAND_BOTH,
+ }),
+ changed_label : elm.Label ({
+ label : "Not started",
+ align : { x : 0, y: 0.5},
+ }),
hbox : elm.Box ({
align : FILL_BOTH,
weight : EXPAND_BOTH,
@@ -143,10 +166,12 @@ var el = win.elements.the_box.elements;
bars[0] = el.progress_plain;
bars[1] = el.icon_progress;
-bars[2] = el.hbox.elements.vertical_pb;
-bars[3] = el.hbox.elements.vert_icon;
+bars[2] = el.changed_progress;
+bars[3] = el.hbox.elements.vertical_pb;
+bars[4] = el.hbox.elements.vert_icon;
bouncers[0] = el.infinite_bounce;
bouncers[1] = el.hbox.elements.vert_infinite;
bouncers[2] = el.wheel;
+changed_label = el.changed_label;
diff --git a/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.cc b/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.cc
index 9a73ff1..ff75acb 100644
--- a/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.cc
+++ b/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.cc
@@ -11,6 +11,7 @@ GENERATE_PROPERTY_CALLBACKS(CElmProgressBar, units);
GENERATE_PROPERTY_CALLBACKS(CElmProgressBar, span);
GENERATE_PROPERTY_CALLBACKS(CElmProgressBar, pulser);
GENERATE_PROPERTY_CALLBACKS(CElmProgressBar, value);
+GENERATE_PROPERTY_CALLBACKS(CElmProgressBar, on_changed);
GENERATE_METHOD_CALLBACKS(CElmProgressBar, pulse);
GENERATE_TEMPLATE(CElmProgressBar,
@@ -21,6 +22,7 @@ GENERATE_TEMPLATE(CElmProgressBar,
PROPERTY(span),
PROPERTY(pulser),
PROPERTY(value),
+ PROPERTY(on_changed),
METHOD(pulse));
Handle<Value> CElmProgressBar::pulse(const Arguments& args)
@@ -43,6 +45,7 @@ void CElmProgressBar::Initialize(Handle<Object> target)
CElmProgressBar::~CElmProgressBar()
{
cached.icon.Dispose();
+ on_changed_set(Undefined());
}
Handle<Value> CElmProgressBar::icon_get() const
@@ -123,4 +126,39 @@ void CElmProgressBar::value_set(Handle<Value> value)
elm_progressbar_value_set(eo, value->NumberValue());
}
+void CElmProgressBar::OnChanged(void *)
+{
+ Handle<Function> callback(Function::Cast(*cb.changed));
+ Handle<Value> args[1] = { jsObject };
+
+ callback->Call(jsObject, 1, args);
+}
+
+void CElmProgressBar::OnChangedWrapper(void *data, Evas_Object *, void *event_info)
+{
+ static_cast<CElmProgressBar*>(data)->OnChanged(event_info);
+}
+
+Handle<Value> CElmProgressBar::on_changed_get() const
+{
+ return cb.changed;
+}
+
+
+void CElmProgressBar::on_changed_set(Handle<Value> val)
+{
+ if (!cb.changed.IsEmpty())
+ {
+ evas_object_smart_callback_del(eo, "changed", &OnChangedWrapper);
+ cb.changed.Dispose();
+ cb.changed.Clear();
+ }
+
+ if (!val->IsFunction())
+ return;
+
+ cb.changed = Persistent<Value>::New(val);
+ evas_object_smart_callback_add(eo, "changed", &OnChangedWrapper, this);
+}
+
}
diff --git a/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.h b/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.h
index a68ad5c..46e3dbf 100644
--- a/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.h
+++ b/trunk/PROTO/elev8/src/modules/elm/CElmProgressBar.h
@@ -21,6 +21,10 @@ protected:
Persistent<Value> icon;
} cached;
+ struct {
+ Persistent<Value> changed;
+ } cb;
+
public:
static void Initialize(Handle<Object> target);
@@ -47,6 +51,12 @@ public:
Handle<Value> value_get() const;
void value_set(Handle<Value> value);
+ void OnChanged(void *event_info);
+ static void OnChangedWrapper(void *data, Evas_Object *, void *event_info);
+
+ Handle<Value> on_changed_get() const;
+ void on_changed_set(Handle<Value> val);
+
friend Handle<Value> CElmObject::New<CElmProgressBar>(const Arguments& args);
};
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel