Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
ewl_entry.c ewl_entry.h ewl_text.c
Log Message:
- make the cursor blink
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_entry.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- ewl_entry.c 2 Nov 2005 21:41:44 -0000 1.32
+++ ewl_entry.c 3 Nov 2005 01:05:56 -0000 1.33
@@ -3,6 +3,12 @@
#include "ewl_macros.h"
#include "ewl_private.h"
+#define EWL_ENTRY_CURSOR_ON_TIME 0.9
+#define EWL_ENTRY_CURSOR_OFF_TIME 0.25
+
+static int ewl_entry_cursor_cb_flash_timer(void *data);
+static void ewl_entry_cursor_timer_set(Ewl_Entry_Cursor *c, double time);
+
/**
* @param text: The text to set into the entry
* @return Returns a new Ewl_Widget on success or NULL on failure
@@ -246,7 +252,7 @@
DCHECK_TYPE("w", w, "widget");
entry = EWL_ENTRY(w);
- if (entry->editable)
+ if (entry->editable && !VISIBLE(entry->cursor))
ewl_widget_show(entry->cursor);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -263,7 +269,7 @@
DCHECK_TYPE("w", w, "widget");
entry = EWL_ENTRY(w);
- if (entry->editable)
+ if (entry->editable && VISIBLE(entry->cursor))
ewl_widget_hide(entry->cursor);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -283,6 +289,10 @@
event = ev;
e = EWL_ENTRY(w);
+ /* reset the cursor blink on key down */
+ ewl_entry_cursor_timer_set(EWL_ENTRY_CURSOR(e->cursor),
+ EWL_ENTRY_CURSOR_ON_TIME);
+
if (!strcmp(event->keyname, "Left"))
ewl_entry_cursor_move_left(e);
@@ -538,6 +548,11 @@
ewl_widget_inherit(EWL_WIDGET(c), "cursor");
c->parent = parent;
+ ewl_callback_append(EWL_WIDGET(c), EWL_CALLBACK_SHOW,
+ ewl_entry_cursor_cb_show, NULL);
+ ewl_callback_append(EWL_WIDGET(c), EWL_CALLBACK_HIDE,
+ ewl_entry_cursor_cb_hide, NULL);
+
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
@@ -564,3 +579,77 @@
DLEVEL_STABLE);
}
+void
+ewl_entry_cursor_cb_show(Ewl_Widget *w, void *ev __UNUSED__,
+ void *data __UNUSED__)
+{
+ Ewl_Entry_Cursor *c;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+
+ c = EWL_ENTRY_CURSOR(w);
+ ewl_entry_cursor_timer_set(c, EWL_ENTRY_CURSOR_ON_TIME);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void
+ewl_entry_cursor_cb_hide(Ewl_Widget *w, void *ev __UNUSED__,
+ void *data __UNUSED__)
+{
+ Ewl_Entry_Cursor *c;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+
+ c = EWL_ENTRY_CURSOR(w);
+ ewl_entry_cursor_timer_set(c, 0.0);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static int
+ewl_entry_cursor_cb_flash_timer(void *data)
+{
+ Ewl_Entry_Cursor *c;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("data", data, 0);
+
+ c = data;
+
+ if (VISIBLE(c))
+ {
+ ewl_widget_hide(EWL_WIDGET(c));
+ ewl_entry_cursor_timer_set(c, EWL_ENTRY_CURSOR_OFF_TIME);
+ }
+ else
+ ewl_widget_show(EWL_WIDGET(c));
+
+
+ DRETURN_INT(0, DLEVEL_STABLE);
+}
+
+/*
+ * This will setup the timer for the cursor blink. If you pass 0.0 it will
+ * just remove the timer
+ */
+static void
+ewl_entry_cursor_timer_set(Ewl_Entry_Cursor *c, double time)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("c", c);
+ DCHECK_TYPE("c", c, "cursor");
+
+ if (c->timer) ecore_timer_del(c->timer);
+ c->timer = NULL;
+
+ if (time > 0)
+ c->timer = ecore_timer_add(time,
ewl_entry_cursor_cb_flash_timer, c);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_entry.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- ewl_entry.h 18 Oct 2005 05:11:07 -0000 1.11
+++ ewl_entry.h 3 Nov 2005 01:05:56 -0000 1.12
@@ -53,6 +53,8 @@
{
Ewl_Widget widget;
Ewl_Entry *parent;
+
+ Ecore_Timer *timer; /**< The timer to control the cursor flash */
};
Ewl_Widget *ewl_entry_cursor_new(Ewl_Entry *parent);
@@ -60,5 +62,8 @@
void ewl_entry_cursor_position_set(Ewl_Entry_Cursor *c, unsigned
int pos);
unsigned int ewl_entry_cursor_position_get(Ewl_Entry_Cursor *c);
+void ewl_entry_cursor_cb_show(Ewl_Widget *w, void *ev, void *data);
+void ewl_entry_cursor_cb_hide(Ewl_Widget *w, void *ev, void *data);
+
#endif /* __EWL_ENTRY_H__ */
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_text.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- ewl_text.c 2 Nov 2005 21:41:44 -0000 1.42
+++ ewl_text.c 3 Nov 2005 01:05:56 -0000 1.43
@@ -2597,13 +2597,6 @@
evas_object_layer_set(t->textblock,
ewl_widget_layer_sum_get(w));
- /* This needs to be here to cause the scrollpane to update
- * as you scroll, tho I think Evas should be doing this
- * itself behind the scenes */
-//printf("THIS NEEDED?\n");
-// evas_damage_rectangle_add(evas_object_evas_get(t->textblock),
-// xx, yy, ww, hh);
-
ewl_text_triggers_configure(t);
}
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs