Commit 5445cbc7 authored by Søren Sandmann's avatar Søren Sandmann Committed by Søren Sandmann Pedersen
Browse files

Accelerate the animation when it has been running for a while. (#143647).

Sat Sep  4 02:38:57 2004  Søren Sandmann  <sandmann@redhat.com>

	* gtk/gtktoolbar.c (position): Accelerate the animation when it
	has been running for a while. (#143647).
parent f8ef369e
Sat Sep 4 02:38:57 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtktoolbar.c (position): Accelerate the animation when it
has been running for a while. (#143647).
2004-09-03 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: List the three theme gtkrc files separately, zip
......
Sat Sep 4 02:38:57 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtktoolbar.c (position): Accelerate the animation when it
has been running for a while. (#143647).
2004-09-03 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: List the three theme gtkrc files separately, zip
......
Sat Sep 4 02:38:57 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtktoolbar.c (position): Accelerate the animation when it
has been running for a while. (#143647).
2004-09-03 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: List the three theme gtkrc files separately, zip
......
Sat Sep 4 02:38:57 2004 Søren Sandmann <sandmann@redhat.com>
* gtk/gtktoolbar.c (position): Accelerate the animation when it
has been running for a while. (#143647).
2004-09-03 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: List the three theme gtkrc files separately, zip
......
......@@ -53,6 +53,7 @@
#include "gtkvbox.h"
#include "gtkimage.h"
#include "gtkseparatormenuitem.h"
#include <math.h>
typedef struct _ToolbarContent ToolbarContent;
......@@ -71,7 +72,8 @@ typedef struct _ToolbarContent ToolbarContent;
* in the homogeneous game. In units of
* pango_font_get_estimated_char_width().
*/
#define SLIDE_SPEED 600 /* How fast the items slide, in pixels per second */
#define SLIDE_SPEED 600.0 /* How fast the items slide, in pixels per second */
#define ACCEL_THRESHOLD 0.18 /* After how much time in seconds will items start speeding up */
#define MIXED_API_WARNING \
"Mixing deprecated and non-deprecated GtkToolbar API is not allowed"
......@@ -959,10 +961,27 @@ gtk_toolbar_size_request (GtkWidget *widget,
static gint
position (gint from, gint to, gdouble elapsed)
{
gint n_pixels;
if (elapsed <= ACCEL_THRESHOLD)
{
n_pixels = SLIDE_SPEED * elapsed;
}
else
{
/* The formula is a second degree polynomial in
* @elapsed that has the line SLIDE_SPEED * @elapsed
* as tangent for @elapsed == ACCEL_THRESHOLD.
* This makes @n_pixels a smooth function of elapsed time.
*/
n_pixels = (SLIDE_SPEED / ACCEL_THRESHOLD) * elapsed * elapsed -
SLIDE_SPEED * elapsed + SLIDE_SPEED * ACCEL_THRESHOLD;
}
if (to > from)
return MIN (from + SLIDE_SPEED * elapsed, to);
return MIN (from + n_pixels, to);
else
return MAX (from - SLIDE_SPEED * elapsed, to);
return MAX (from - n_pixels, to);
}
static void
......@@ -1459,7 +1478,7 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
else
size = available_size;
/* calculate widths of items */
/* calculate widths and states of items */
overflowing = FALSE;
for (list = priv->content, i = 0; list != NULL; list = list->next, ++i)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment