On Sat, Jan 23, 2010 at 5:08 PM, Carsten Haitzler <ras...@rasterman.com> wrote:
> On Fri, 22 Jan 2010 10:27:09 +0800 Brian Wang <brian.wang.0...@gmail.com> 
> said:
>
> haahahahaha! un-lame now. and in svn - see svn commit log. also added the 
> thing
> i suggested - the time limit on idle calcs - i also had to move the calc into
> the ilder as opposed to being in the job.

Awesome!  I'll try the patch when I get my hand on my board tomorrow. :-)

It seems you also applied the elm_button autorepeat stuff for
Elementary.h.in but I didn't see the source get patched.  It's
probably because my autorepeat patch didn't go through (sigh,
again...).  I have the original autorepeat patch attached (now, I just
simply give the patch a txt extension...).  Please take a look and
correct it as you see fit. :-)


brian

>
>> This is lame...  Another try.
>>
>> On Fri, Jan 22, 2010 at 10:24 AM, Brian Wang <brian.wang.0...@gmail.com>
>> wrote:
>> > Hello all,
>> >
>> > The attached (hopefully, it's attached) is my try to implement the
>> > homogeneous mode for elm_genlist.  I know it's far from perfect (e.g.
>> > it still walks through the list to gather the width and height) and it
>> > might contain bugs.   It's ok with valgrind reports on x86 though.
>> >
>> > The patch is also contaminated with my elm_button autorepeat stuff in
>> > Elementary.h.in...
>> >
>> > I know it's far from being perfect, so please take a look and modify
>> > it to its correctness as it seems to be a nice-to-have feature.
>> >
>> > Cheers,
>> >
>> >
>> > brian
>> >
>> > --
>> > brian
>> > ------------------
>> >
>> > Cool-Karaoke - The smallest recording studio, in your palm, open-sourced
>> > http://cool-idea.com.tw/
>> >
>> > iMaGiNaTiOn iS mOrE iMpOrTaNt tHaN kNoWlEdGe
>> >
>>
>>
>>
>> --
>> brian
>> ------------------
>>
>> Cool-Karaoke - The smallest recording studio, in your palm, open-sourced
>> http://cool-idea.com.tw/
>>
>> iMaGiNaTiOn iS mOrE iMpOrTaNt tHaN kNoWlEdGe
>>
>
>
> --
> ------------- Codito, ergo sum - "I code, therefore I am" --------------
> The Rasterman (Carsten Haitzler)    ras...@rasterman.com
>
>



-- 
brian
------------------

Cool-Karaoke - The smallest recording studio, in your palm, open-sourced
http://cool-idea.com.tw/

iMaGiNaTiOn iS mOrE iMpOrTaNt tHaN kNoWlEdGe
Index: src/lib/elm_button.c
===================================================================
--- src/lib/elm_button.c        (revision 45349)
+++ src/lib/elm_button.c        (working copy)
@@ -1,3 +1,7 @@
+/*
+ *
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
 #include <Elementary.h>
 #include "elm_priv.h"
 
@@ -14,6 +18,12 @@
 {
    Evas_Object *btn, *icon;
    const char *label;
+
+   Eina_Bool autorepeat;
+   Eina_Bool repeating;
+   double ar_threshold;
+   double ar_interval;
+   Ecore_Timer *timer;
 };
 
 static void _del_hook(Evas_Object *obj);
@@ -23,6 +33,8 @@
 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void 
*event_info);
 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
 static void _signal_clicked(void *data, Evas_Object *obj, const char 
*emission, const char *source);
+static void _signal_pressed(void *data, Evas_Object *obj, const char 
*emission, const char *source);
+static void _signal_unpressed(void *data, Evas_Object *obj, const char 
*emission, const char *source);
 static void _on_focus_hook(void *data, Evas_Object *obj);
 
 static void
@@ -124,8 +136,63 @@
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
    evas_object_smart_callback_call(data, "clicked", NULL);
+   _signal_unpressed(data, obj, emission, source); /* safe guard when the 
theme does not emit the 'unpress' signal */
 }
 
+static int
+_autorepeat_send(void *data)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return ECORE_CALLBACK_CANCEL;
+
+   evas_object_smart_callback_call(data, "repeated", NULL);
+
+   return ECORE_CALLBACK_RENEW;
+}
+
+static int
+_autorepeat_initial_send(void *data)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return ECORE_CALLBACK_CANCEL;
+
+   _autorepeat_send(data);
+   wd->timer = ecore_timer_add(wd->ar_interval, _autorepeat_send, data);
+   wd->repeating = 1;
+
+   return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_signal_pressed(void *data, Evas_Object *obj, const char *emission, const char 
*source)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return;
+
+   if (wd->autorepeat)
+     {
+       if (wd->ar_threshold <= 0.0)
+         _autorepeat_initial_send(data); /* call immediately */
+       else
+         wd->timer = ecore_timer_add(wd->ar_threshold, 
_autorepeat_initial_send, data);
+     }
+}
+
+static void
+_signal_unpressed(void *data, Evas_Object *obj, const char *emission, const 
char *source)
+{
+   Widget_Data *wd = elm_widget_data_get(data);
+   if (!wd) return;
+   evas_object_smart_callback_call(data, "unpressed", NULL);
+
+   if (wd->timer)
+     {
+       ecore_timer_del(wd->timer);
+       wd->timer = NULL;
+     }
+   wd->repeating = 0;
+}
+
 /**
  * Add a new button to the parent
  * @param parent The parent object
@@ -156,6 +223,10 @@
    _elm_theme_set(wd->btn, "button", "base", "default");
    edje_object_signal_callback_add(wd->btn, "elm,action,click", "",
                                    _signal_clicked, obj);
+   edje_object_signal_callback_add(wd->btn, "elm,action,press", "",
+                                   _signal_pressed, obj);
+   edje_object_signal_callback_add(wd->btn, "elm,action,unpress", "",
+                                   _signal_unpressed, obj);
    elm_widget_resize_object_set(obj, wd->btn);
 
    evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
@@ -256,3 +327,81 @@
 {
    elm_widget_style_set(obj, style);
 }
+
+/**
+ * Turn on/off the autorepeat event generated when the user keeps pressing on 
the button
+ *
+ * @param obj The button object
+ * @param on  A bool to turn on/off the event
+ *
+ * @ingroup Button
+ */
+EAPI void
+elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   if (wd->timer) {
+          ecore_timer_del(wd->timer);
+          wd->timer = NULL;
+   }
+   wd->autorepeat = on;
+}
+
+/**
+ * Set the initial timeout before the autorepeat event is generated
+ *
+ * @param obj The button object
+ * @param t   Timeout
+ *
+ * @ingroup Button
+ */
+EAPI void
+elm_button_autorepeat_initital_timeout_set(Evas_Object *obj, double t)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   if (wd->ar_threshold == t)
+     return;
+
+   if (wd->timer)
+     {
+       ecore_timer_del(wd->timer);
+       wd->timer = NULL;
+     }
+
+   wd->ar_threshold = t;
+}
+
+/**
+ * Set the interval between each generated autorepeat event
+ *
+ * @param obj The button object
+ * @param t   Interval
+ *
+ * @ingroup Button
+ */
+EAPI void         
+elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, double t)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   if (wd->ar_interval == t)
+     return;
+
+   if (wd->timer)
+     {
+       ecore_timer_del(wd->timer);
+       wd->timer = NULL;
+     }
+
+   wd->ar_interval = t;
+   if (wd->repeating)
+     {
+       wd->timer = ecore_timer_add(t, _autorepeat_send, obj);
+     }
+}
+
Index: src/lib/Elementary.h.in
===================================================================
--- src/lib/Elementary.h.in     (revision 45349)
+++ src/lib/Elementary.h.in     (working copy)
@@ -374,6 +374,9 @@
    EAPI const char  *elm_button_label_get(Evas_Object *obj);
    EAPI void         elm_button_icon_set(Evas_Object *obj, Evas_Object *icon);
    EAPI Evas_Object *elm_button_icon_get(Evas_Object *obj);
+   EAPI void         elm_button_autorepeat_set(Evas_Object *obj, Eina_Bool on);
+   EAPI void         elm_button_autorepeat_initital_timeout_set(Evas_Object 
*obj, double t);
+   EAPI void         elm_button_autorepeat_gap_timeout_set(Evas_Object *obj, 
double t);
    EINA_DEPRECATED EAPI void elm_button_style_set(Evas_Object *obj, const char 
*style);
    /* available styles:
     * default
@@ -383,6 +386,7 @@
     */
    /* smart callbacks called:
     * "clicked" - the user clicked the button
+    * "repeated" - the user pressed the button without releasing it
     */
 
    typedef enum _Elm_Scroller_Policy
Index: src/bin/test_button.c
===================================================================
--- src/bin/test_button.c       (revision 45349)
+++ src/bin/test_button.c       (working copy)
@@ -1,5 +1,17 @@
 #include <Elementary.h>
 #ifndef ELM_LIB_QUICKLAUNCH
+static void
+_bt_repeated(void *data, Evas_Object *obj, void *event_info)
+{
+       static int count;
+       char buf[16];
+
+       snprintf(buf, sizeof(buf), "count=%d", count++);
+       if (count >= 10000)
+               count = 0;
+       elm_button_label_set(obj, buf);
+}
+
 void
 test_button(void *data, Evas_Object *obj, void *event_info)
 {
@@ -68,6 +80,10 @@
    bt = elm_button_add(win);
    elm_button_label_set(bt, "Label Only");
    elm_box_pack_end(bx, bt);
+   evas_object_smart_callback_add(bt, "repeated", _bt_repeated, NULL);
+   elm_button_autorepeat_set(bt, 1);
+   elm_button_autorepeat_initital_timeout_set(bt, 2.0);
+   elm_button_autorepeat_gap_timeout_set(bt, 0.5);
    evas_object_show(bt);
 
    ic = elm_icon_add(win);
Index: data/themes/default.edc
===================================================================
--- data/themes/default.edc     (revision 45349)
+++ data/themes/default.edc     (working copy)
@@ -737,6 +737,11 @@
            name:   "button_click";
            signal: "mouse,down,1";
            source: "over2";
+           action: SIGNAL_EMIT "elm,action,press" "";
+           after: "button_click_anim";
+        }
+        program {
+           name:   "button_click_anim";
            action: STATE_SET "clicked" 0.0;
            target: "button_image";
         }
@@ -744,6 +749,11 @@
            name:   "button_unclick";
            signal: "mouse,up,1";
            source: "over2";
+           action: SIGNAL_EMIT "elm,action,unpress" "";
+           after: "button_unclick_anim";
+        }
+        program {
+           name:   "button_unclick_anim";
            action: STATE_SET "default" 0.0;
            target: "button_image";
         }
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to