shadow: render icon-shadow for spinners
This commit is contained in:

committed by
Benjamin Otte

parent
aa37e7323f
commit
1208f2bde0
@ -445,6 +445,7 @@ gtk_private_h_sources = \
|
|||||||
gtktexttagprivate.h \
|
gtktexttagprivate.h \
|
||||||
gtktexttypes.h \
|
gtktexttypes.h \
|
||||||
gtktextutil.h \
|
gtktextutil.h \
|
||||||
|
gtkthemingengineprivate.h \
|
||||||
gtktimeline.h \
|
gtktimeline.h \
|
||||||
gtktoolpaletteprivate.h \
|
gtktoolpaletteprivate.h \
|
||||||
gtktreedatalist.h \
|
gtktreedatalist.h \
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "gtkshadowprivate.h"
|
#include "gtkshadowprivate.h"
|
||||||
#include "gtkstylecontext.h"
|
#include "gtkstylecontext.h"
|
||||||
#include "gtkpango.h"
|
#include "gtkpango.h"
|
||||||
|
#include "gtkthemingengineprivate.h"
|
||||||
|
|
||||||
typedef struct _GtkShadowElement GtkShadowElement;
|
typedef struct _GtkShadowElement GtkShadowElement;
|
||||||
|
|
||||||
@ -298,3 +299,27 @@ _gtk_icon_shadow_paint (GtkShadow *shadow,
|
|||||||
cairo_pattern_destroy (pattern);
|
cairo_pattern_destroy (pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gtk_icon_shadow_paint_spinner (GtkShadow *shadow,
|
||||||
|
cairo_t *cr,
|
||||||
|
gdouble radius,
|
||||||
|
gdouble progress)
|
||||||
|
{
|
||||||
|
GtkShadowElement *element;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = g_list_last (shadow->elements); l != NULL; l = l->prev)
|
||||||
|
{
|
||||||
|
element = l->data;
|
||||||
|
|
||||||
|
cairo_save (cr);
|
||||||
|
|
||||||
|
cairo_translate (cr, element->hoffset, element->voffset);
|
||||||
|
_gtk_theming_engine_paint_spinner (cr,
|
||||||
|
radius, progress,
|
||||||
|
&element->color);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -61,6 +61,11 @@ void _gtk_text_shadow_paint_layout (GtkShadow *shadow,
|
|||||||
void _gtk_icon_shadow_paint (GtkShadow *shadow,
|
void _gtk_icon_shadow_paint (GtkShadow *shadow,
|
||||||
cairo_t *cr);
|
cairo_t *cr);
|
||||||
|
|
||||||
|
void _gtk_icon_shadow_paint_spinner (GtkShadow *shadow,
|
||||||
|
cairo_t *cr,
|
||||||
|
gdouble radius,
|
||||||
|
gdouble progress);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_SHADOW_H__ */
|
#endif /* __GTK_SHADOW_H__ */
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "gtkpango.h"
|
#include "gtkpango.h"
|
||||||
#include "gtkshadowprivate.h"
|
#include "gtkshadowprivate.h"
|
||||||
#include "gtkcsstypesprivate.h"
|
#include "gtkcsstypesprivate.h"
|
||||||
|
#include "gtkthemingengineprivate.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkthemingengine
|
* SECTION:gtkthemingengine
|
||||||
@ -3031,30 +3032,19 @@ gtk_theming_engine_render_handle (GtkThemingEngine *engine,
|
|||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
gtk_theming_engine_render_activity (GtkThemingEngine *engine,
|
_gtk_theming_engine_paint_spinner (cairo_t *cr,
|
||||||
cairo_t *cr,
|
gdouble radius,
|
||||||
gdouble x,
|
gdouble progress,
|
||||||
gdouble y,
|
GdkRGBA *color)
|
||||||
gdouble width,
|
|
||||||
gdouble height)
|
|
||||||
{
|
{
|
||||||
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER))
|
|
||||||
{
|
|
||||||
GtkStateFlags state;
|
|
||||||
guint num_steps, step;
|
guint num_steps, step;
|
||||||
GdkRGBA color;
|
|
||||||
gdouble progress;
|
|
||||||
gdouble radius;
|
|
||||||
gdouble half;
|
gdouble half;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
num_steps = 12;
|
num_steps = 12;
|
||||||
|
|
||||||
state = gtk_theming_engine_get_state (engine);
|
if (progress >= 0)
|
||||||
gtk_theming_engine_get_color (engine, state, &color);
|
|
||||||
|
|
||||||
if (gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress))
|
|
||||||
step = (guint) (progress * num_steps);
|
step = (guint) (progress * num_steps);
|
||||||
else
|
else
|
||||||
step = 0;
|
step = 0;
|
||||||
@ -3063,9 +3053,7 @@ gtk_theming_engine_render_activity (GtkThemingEngine *engine,
|
|||||||
|
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||||
cairo_set_line_width (cr, 2.0);
|
cairo_set_line_width (cr, 2.0);
|
||||||
cairo_translate (cr, x + width / 2, y + height / 2);
|
|
||||||
|
|
||||||
radius = MIN (width / 2, height / 2);
|
|
||||||
half = num_steps / 2;
|
half = num_steps / 2;
|
||||||
|
|
||||||
for (i = 0; i < num_steps; i++)
|
for (i = 0; i < num_steps; i++)
|
||||||
@ -3078,10 +3066,10 @@ gtk_theming_engine_render_activity (GtkThemingEngine *engine,
|
|||||||
gdouble yscale = - cos (i * G_PI / half);
|
gdouble yscale = - cos (i * G_PI / half);
|
||||||
|
|
||||||
cairo_set_source_rgba (cr,
|
cairo_set_source_rgba (cr,
|
||||||
color.red,
|
color->red,
|
||||||
color.green,
|
color->green,
|
||||||
color.blue,
|
color->blue,
|
||||||
color.alpha * t);
|
color->alpha * t);
|
||||||
|
|
||||||
cairo_move_to (cr,
|
cairo_move_to (cr,
|
||||||
(radius - inset) * xscale,
|
(radius - inset) * xscale,
|
||||||
@ -3089,10 +3077,69 @@ gtk_theming_engine_render_activity (GtkThemingEngine *engine,
|
|||||||
cairo_line_to (cr,
|
cairo_line_to (cr,
|
||||||
radius * xscale,
|
radius * xscale,
|
||||||
radius * yscale);
|
radius * yscale);
|
||||||
|
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
render_spinner (GtkThemingEngine *engine,
|
||||||
|
cairo_t *cr,
|
||||||
|
gdouble x,
|
||||||
|
gdouble y,
|
||||||
|
gdouble width,
|
||||||
|
gdouble height)
|
||||||
|
{
|
||||||
|
GtkStateFlags state;
|
||||||
|
GtkShadow *shadow;
|
||||||
|
GdkRGBA color;
|
||||||
|
gdouble progress;
|
||||||
|
gdouble radius;
|
||||||
|
|
||||||
|
state = gtk_theming_engine_get_state (engine);
|
||||||
|
|
||||||
|
if (!gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress))
|
||||||
|
progress = -1;
|
||||||
|
|
||||||
|
radius = MIN (width / 2, height / 2);
|
||||||
|
|
||||||
|
gtk_theming_engine_get_color (engine, state, &color);
|
||||||
|
gtk_theming_engine_get (engine, state,
|
||||||
|
"icon-shadow", &shadow,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
cairo_save (cr);
|
||||||
|
cairo_translate (cr, x + width / 2, y + height / 2);
|
||||||
|
|
||||||
|
if (shadow != NULL)
|
||||||
|
{
|
||||||
|
_gtk_icon_shadow_paint_spinner (shadow, cr,
|
||||||
|
radius,
|
||||||
|
progress);
|
||||||
|
_gtk_shadow_unref (shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
_gtk_theming_engine_paint_spinner (cr,
|
||||||
|
radius,
|
||||||
|
progress,
|
||||||
|
&color);
|
||||||
|
|
||||||
|
cairo_restore (cr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_theming_engine_render_activity (GtkThemingEngine *engine,
|
||||||
|
cairo_t *cr,
|
||||||
|
gdouble x,
|
||||||
|
gdouble y,
|
||||||
|
gdouble width,
|
||||||
|
gdouble height)
|
||||||
|
{
|
||||||
|
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER))
|
||||||
|
{
|
||||||
|
render_spinner (engine, cr, x, y, width, height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
30
gtk/gtkthemingengineprivate.h
Normal file
30
gtk/gtkthemingengineprivate.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* GTK - The GIMP Toolkit
|
||||||
|
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GTK_THEMING_ENGINE_PRIVATE_H__
|
||||||
|
#define __GTK_THEMING_ENGINE_PRIVATE_H__
|
||||||
|
|
||||||
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
|
void _gtk_theming_engine_paint_spinner (cairo_t *cr,
|
||||||
|
gdouble radius,
|
||||||
|
gdouble progress,
|
||||||
|
GdkRGBA *color);
|
||||||
|
|
||||||
|
#endif /* __GTK_THEMING_ENGINE_PRIVATE_H__ */
|
Reference in New Issue
Block a user