diff options
author | Gustavo Lima Chaves <glima@profusion.mobi> | 2012-11-30 14:41:39 +0000 |
---|---|---|
committer | Gustavo Lima Chaves <glima@profusion.mobi> | 2012-11-30 14:41:39 +0000 |
commit | e966637e9fe77e3d52187726859a8de42eae6a22 (patch) | |
tree | a7a4f2417187c09ef3ffdf6720d5273d4daa2529 /data/objects | |
parent | f3aa3078161e4f5fe846bb4338e7e5c49bda94ea (diff) | |
download | elementary-e966637e9fe77e3d52187726859a8de42eae6a22.tar.gz |
[elm] Introducing a new widget, along with its infrastructure -- prefs.
The prefs widgets aims to aid with the implementation of
preference/configuration windows/UI elements in Elementary-based
applications (think of Enlightenment configuration dialogs,
elementary_config, etc).
Prefs is a widget that populates its view with widgets
bound to data types (following the instructions of a ".epb" file that
describes a set of items) and handles the storage/restoration of such
data on a configuration file automatically.
There's also the prefs_data handle, which is the one dealing with
user saved data for a given epb defaults set.
The documentation on the new widget is rich (we have examples and even
an EPC reference) and there's a new test entry for it.
I'm blogging about it soon, with screeshots and more details.
Enjoy.
ps.: This is a team work by Murilo Belluzzo, Ricardo de Almeida and me.
SVN revision: 79909
Diffstat (limited to 'data/objects')
-rw-r--r-- | data/objects/Makefile.am | 18 | ||||
-rw-r--r-- | data/objects/test_prefs.edc | 150 | ||||
-rw-r--r-- | data/objects/test_prefs.epc | 113 |
3 files changed, 279 insertions, 2 deletions
diff --git a/data/objects/Makefile.am b/data/objects/Makefile.am index f87759855..a1ad1ac71 100644 --- a/data/objects/Makefile.am +++ b/data/objects/Makefile.am @@ -9,11 +9,15 @@ EDJE_FLAGS = $(EDJE_FLAGS_$(V)) -id $(top_srcdir)/data/objects -fd $(top_srcdir) filesdir = $(datadir)/elementary/objects -files_DATA = test.edj test_external.edj multip.edj cursors.edj font_preview.edj postit_ent.edj multibuttonentry.edj +files_DATA = test.edj test_external.edj multip.edj cursors.edj font_preview.edj postit_ent.edj multibuttonentry.edj test_prefs.edj test_prefs.epb + +ELM_PREFS_CC = @elm_prefs_cc@ EXTRA_DIST = \ test.edc \ test_external.edc \ +test_prefs.edc \ +test_prefs.epc \ multip.edc \ cursors.edc \ font_preview.edc \ @@ -63,6 +67,16 @@ multibuttonentry.edj: Makefile $(EXTRA_DIST) $(EDJE_CC) $(EDJE_FLAGS) \ $(top_srcdir)/data/objects/multibuttonentry.edc \ $(top_builddir)/data/objects/multibuttonentry.edj - + +test_prefs.edj: Makefile test_prefs.edc + $(EDJE_CC) $(EDJE_FLAGS) \ + $(top_srcdir)/data/objects/test_prefs.edc \ + $(top_builddir)/data/objects/test_prefs.edj + +test_prefs.epb: Makefile test_prefs.epc + $(ELM_PREFS_CC) $(ELM_PREFS_FLAGS) \ + $(top_srcdir)/data/objects/test_prefs.epc \ + $(top_builddir)/data/objects/test_prefs.epb + clean-local: rm -f *.edj diff --git a/data/objects/test_prefs.edc b/data/objects/test_prefs.edc new file mode 100644 index 000000000..836856c67 --- /dev/null +++ b/data/objects/test_prefs.edc @@ -0,0 +1,150 @@ +#define MSG_ID_VEL (1) + +collections { + group { + name: "prefs_edje"; + max: 450 450; + min: 50 50; + + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 450 450; + max: 450 450; + color: 255 255 255 0; + align: 0.0 0.0; + } + } + + part { + name: "square1"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 50 50; + max: 50 50; + color: 0 0 255 255; + align: 0.0 0.5; + } + description { + state: "invert" 0.0; + inherit: "default" 0.0; + color: 0 255 0 255; + align: 1 0.5; + } + } + + part { + name: "square2"; + type: RECT; + description { + state: "default" 0.0; + min: 50 50; + max: 50 50; + color: 0 255 0 255; + align: 0.5 0.0; + } + description { + state: "invert" 0.0; + inherit: "default" 0.0; + color: 0 0 255 255; + align: 0.5 1.0; + } + } + } + + program { + name: "animation_start"; + signal: "start"; + source: "animation"; + after: "animation,clear"; + } + + program { + name: "call_animation,state1"; + script { + cancel_anim(anim_id); + set_int(anim_id, anim(get_float(global_speed), "animation_1", 0)); + set_int(anim_n, 1); + } + } + + program { + name: "call_animation,state2"; + script { + cancel_anim(anim_id); + set_int(anim_id, anim(get_float(global_speed), "animation_2", 0)); + set_int(anim_n, 2); + } + } + + program { + name: "animation,stop"; + signal: "stop"; + source: "animation"; + script { + cancel_anim(get_int(anim_id)); + } + } + + program { + name: "animation,clear"; + script { + cancel_anim(get_int(anim_id)); + if (get_int(anim_n) == 2) + set_float(anim_pos, (get_float(anim_pos) - 1) * ( -1)); + } + after: "call_animation,state1"; + } + + script { + public global_speed; + public anim_id; + public anim_pos; + public anim_n; + + public message(Msg_Type:type, id, ...) { + if ((type == MSG_FLOAT) && (id == MSG_ID_VEL)) + set_float(global_speed, Float:getarg(2)); + } + + public animation_1(val, Float:pos) { + if (pos >= get_float(anim_pos) && get_int(anim_n) == 1) + { + set_tween_state(PART:"square1", pos, "default", 0.0, + "invert", 0.0); + set_tween_state(PART:"square2", pos, "default", 0.0, + "invert", 0.0); + set_float(anim_pos, pos); + } + if (pos >= 1) + { + run_program(PROGRAM:"call_animation,state2"); + set_float(anim_pos, 0.0); + } + } + + public animation_2(val, Float:pos) { + if (pos >= get_float(anim_pos) && get_int(anim_n) == 2) + { + set_tween_state(PART:"square1", pos, "invert", 0.0, + "default", 0.0); + set_tween_state(PART:"square2", pos, "invert", 0.0, + "default", 0.0); + set_float(anim_pos, pos); + } + if (pos >= 1) + { + run_program(PROGRAM:"call_animation,state1"); + set_float(anim_pos, 0.0); + } + } + } +} + +#undef MSG_ID_VEL diff --git a/data/objects/test_prefs.epc b/data/objects/test_prefs.epc new file mode 100644 index 000000000..3eb2efa4c --- /dev/null +++ b/data/objects/test_prefs.epc @@ -0,0 +1,113 @@ +collection +{ + page + { + name: "main"; + version: 1; + title: "Preferences Widget"; + subtitle: "Prefs"; + widget: "elm/vertical_frame"; + + items { + item { + name: "universe"; + type: INT; + label: "Ultimate Answer of Life, the Universe and Everything"; + editable: 1; + + int { + default: 42; + min: 0; + max: 150; + } + } + + item { + name: "label"; + type: LABEL; + label: "Just a label..."; + } + + item { + name: "text"; + type: TEXT; + editable: 1; + + text { + placeholder: "This is a text field (:"; + default: "default str."; + deny: "^[0-9]*$"; + } + } + + item { + name: "date"; + type: DATE; + label: "First EFL Developer Day"; + + date { + default: 2012 11 05; + min: 1980 11 1; + max: 2200 12 2; + } + } + + item { + name: "animation"; + type: BOOL; + persistent: 1; + label: "Animation"; + + bool { + default: true; + } + } + + item { + name: "animation_time"; + type: FLOAT; + persistent: 1; + label: "Animation Time"; + + float { + default: 0.6; + min: 0.0; + max: 1.0; + } + } + + item { + name: "sep"; + type: SEPARATOR; + } + + item { + name: "swal"; + type: SWALLOW; + } + + item { + name: "sep2"; + type: SEPARATOR; + } + + item { + name: "save"; + type: SAVE; + label: "Save"; + } + + item { + name: "reset"; + type: RESET; + label: "Reset"; + } + + item { + name: "action"; + type: ACTION; + label: "Action!"; + } + } + } +} |