Enlightenment CVS committal
Author : pfritz
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
ewl_spinner.c ewl_spinner.h
Log Message:
the spinner will now respect the user set steps
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_spinner.c 11 Aug 2006 04:00:57 -0000 1.19
+++ ewl_spinner.c 16 Aug 2006 16:00:31 -0000 1.20
@@ -416,6 +416,7 @@
if (ev_data) {
s->direction = (!r->invert) ? 1 : -1;
s->start_time = ecore_time_get();
+ s->last_value = 0.0;
s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s);
}
@@ -484,6 +485,7 @@
if (ev_data) {
s->direction = (!r->invert) ? -1 : 1;
s->start_time = ecore_time_get();
+ s->last_value = 0.0;
s->timer = ecore_timer_add(0.02, ewl_spinner_timer, s);
}
@@ -522,9 +524,9 @@
{
Ewl_Spinner *s;
Ewl_Range *r;
- double dt;
- double value, range, tmpt;
- int velocity, delay;
+ double dt, dv;
+ double step;
+ int velocity;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR_RET("data", data, FALSE);
@@ -533,8 +535,7 @@
r = EWL_RANGE(s);
dt = ecore_time_get() - s->start_time;
- value = r->value;
- range = r->max_val - r->min_val;
+ step = 0;
/*
* Check the theme for a velocity setting and bring it within normal
@@ -545,27 +546,26 @@
velocity = 1;
else if (velocity > 10)
velocity = 10;
-
- /*
- * Check the theme for a delay setting and bring it within normal
- * useable bounds.
- */
- delay = ewl_theme_data_int_get(EWL_WIDGET(s), "delay");
- if (delay < 1)
- delay = 1;
- else if (delay > 10)
- delay = 10;
+
/*
* Move the value of the spinner based on the direction of it's motion
* and the velocity setting.
*/
- tmpt = (dt > (double)delay ? dt - (double)delay : 0.0);
- tmpt = ((1 - exp(-tmpt)) * ((double)(velocity) / 100.0)) * range;
- value += (double)(s->direction) * ((1 - exp(-dt)) + tmpt);
-
- ewl_range_value_set(r, value);
+ dv = velocity * s->direction
+ * (r->max_val - r->min_val) / r->step / 10 * dt * dt;
+
+ while (r->step < abs(dv - s->last_value - step)) {
+ if (s->direction == 1)
+ step += r->step;
+ else
+ step -= r->step;
+ }
+
+ ewl_range_value_set(r, r->value + step);
+ s->last_value += step;
+
DRETURN_INT(TRUE, DLEVEL_STABLE);
}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_spinner.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- ewl_spinner.h 11 Aug 2006 04:00:57 -0000 1.11
+++ ewl_spinner.h 16 Aug 2006 16:00:31 -0000 1.12
@@ -45,6 +45,7 @@
Ewl_Widget *increment; /**< Ewl_Button to add value */
Ewl_Widget *decrement; /**< Ewl_Button to subtract value */
double start_time; /**< Time the spinner was pressed */
+ double last_value; /**< The last value while spinning */
int direction; /**< Indicate increasing/decreasing value */
Ecore_Timer *timer; /**< Timer for tracking mouse button held down */
};
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs