2010-03-13 10:23:23 +00:00
|
|
|
/* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-03-13 10:23:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2010-07-19 09:54:31 +00:00
|
|
|
#include <math.h>
|
2010-03-13 10:23:23 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <gtk/gtkthemingengine.h>
|
|
|
|
#include <gtk/gtkstylecontext.h>
|
|
|
|
#include <gtk/gtkintl.h>
|
|
|
|
|
2010-10-25 22:43:20 +00:00
|
|
|
#include "gtkprivate.h"
|
2011-10-22 06:48:13 +00:00
|
|
|
#include "gtkmodulesprivate.h"
|
2011-05-26 19:53:28 +00:00
|
|
|
#include "gtkborderimageprivate.h"
|
2010-08-20 12:58:54 +00:00
|
|
|
#include "gtkpango.h"
|
2012-04-03 09:49:46 +00:00
|
|
|
#include "gtkcssarrayvalueprivate.h"
|
2012-04-03 16:39:01 +00:00
|
|
|
#include "gtkcsscornervalueprivate.h"
|
2012-03-28 06:19:53 +00:00
|
|
|
#include "gtkcssenumvalueprivate.h"
|
2012-04-03 14:57:44 +00:00
|
|
|
#include "gtkcssnumbervalueprivate.h"
|
2012-03-28 04:28:13 +00:00
|
|
|
#include "gtkcssrgbavalueprivate.h"
|
2012-04-03 13:15:24 +00:00
|
|
|
#include "gtkcssshadowsvalueprivate.h"
|
2011-05-26 03:09:48 +00:00
|
|
|
#include "gtkcsstypesprivate.h"
|
2012-11-25 02:33:33 +00:00
|
|
|
#include "gtkhslaprivate.h"
|
2011-06-06 15:38:45 +00:00
|
|
|
#include "gtkthemingengineprivate.h"
|
2011-06-11 02:14:19 +00:00
|
|
|
#include "gtkroundedboxprivate.h"
|
2011-12-10 00:14:12 +00:00
|
|
|
#include "gtkthemingbackgroundprivate.h"
|
2010-08-20 12:58:54 +00:00
|
|
|
|
2012-02-21 04:43:57 +00:00
|
|
|
#include "fallback-c89.c"
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkthemingengine
|
|
|
|
* @Short_description: Theming renderers
|
|
|
|
* @Title: GtkThemingEngine
|
|
|
|
* @See_also: #GtkStyleContext
|
|
|
|
*
|
|
|
|
* #GtkThemingEngine is the object used for rendering themed content
|
|
|
|
* in GTK+ widgets. Even though GTK+ has a default implementation,
|
|
|
|
* it can be overridden in CSS files by enforcing a #GtkThemingEngine
|
|
|
|
* object to be loaded as a module.
|
|
|
|
*
|
|
|
|
* In order to implement a theming engine, a #GtkThemingEngine subclass
|
|
|
|
* must be created, alongside the CSS file that will reference it, the
|
|
|
|
* theming engine would be created as an .so library, and installed in
|
|
|
|
* $(gtk-modules-dir)/theming-engines/.
|
2010-10-29 18:17:03 +00:00
|
|
|
*
|
|
|
|
* #GtkThemingEngine<!-- -->s have limited access to the object they are
|
|
|
|
* rendering, the #GtkThemingEngine API has read-only accessors to the
|
|
|
|
* style information contained in the rendered object's #GtkStyleContext.
|
2010-10-19 08:59:46 +00:00
|
|
|
*/
|
|
|
|
|
2010-10-25 22:43:20 +00:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_NAME
|
|
|
|
};
|
|
|
|
|
2010-03-13 10:23:23 +00:00
|
|
|
struct GtkThemingEnginePrivate
|
|
|
|
{
|
|
|
|
GtkStyleContext *context;
|
2010-10-25 22:43:20 +00:00
|
|
|
gchar *name;
|
2010-03-13 10:23:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GTK_THEMING_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_THEMING_ENGINE, GtkThemingEnginePrivate))
|
|
|
|
|
2010-10-25 22:43:20 +00:00
|
|
|
static void gtk_theming_engine_finalize (GObject *object);
|
|
|
|
static void gtk_theming_engine_impl_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_theming_engine_impl_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
2010-03-20 13:17:40 +00:00
|
|
|
static void gtk_theming_engine_render_check (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height);
|
2010-03-20 16:37:34 +00:00
|
|
|
static void gtk_theming_engine_render_option (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height);
|
2010-03-27 17:50:39 +00:00
|
|
|
static void gtk_theming_engine_render_arrow (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble angle,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble size);
|
2010-03-27 19:06:44 +00:00
|
|
|
static void gtk_theming_engine_render_background (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height);
|
2010-03-27 19:11:31 +00:00
|
|
|
static void gtk_theming_engine_render_frame (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height);
|
2010-03-27 19:15:45 +00:00
|
|
|
static void gtk_theming_engine_render_expander (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height);
|
2010-03-27 19:18:38 +00:00
|
|
|
static void gtk_theming_engine_render_focus (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height);
|
2010-03-27 19:21:55 +00:00
|
|
|
static void gtk_theming_engine_render_layout (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
PangoLayout *layout);
|
2010-03-27 20:17:22 +00:00
|
|
|
static void gtk_theming_engine_render_line (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x0,
|
|
|
|
gdouble y0,
|
|
|
|
gdouble x1,
|
|
|
|
gdouble y1);
|
2010-03-27 20:20:21 +00:00
|
|
|
static void gtk_theming_engine_render_slider (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
GtkOrientation orientation);
|
2010-03-27 20:23:13 +00:00
|
|
|
static void gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
GtkPositionType gap_side,
|
|
|
|
gdouble xy0_gap,
|
|
|
|
gdouble xy1_gap);
|
2010-03-27 20:25:33 +00:00
|
|
|
static void gtk_theming_engine_render_extension (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
GtkPositionType gap_side);
|
2010-03-27 20:27:52 +00:00
|
|
|
static void gtk_theming_engine_render_handle (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
2010-10-12 22:52:50 +00:00
|
|
|
gdouble height);
|
2010-11-01 01:46:35 +00:00
|
|
|
static void gtk_theming_engine_render_activity (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height);
|
2010-11-03 20:14:08 +00:00
|
|
|
static GdkPixbuf * gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine,
|
|
|
|
const GtkIconSource *source,
|
|
|
|
GtkIconSize size);
|
2011-06-06 14:23:06 +00:00
|
|
|
static void gtk_theming_engine_render_icon (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
GdkPixbuf *pixbuf,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y);
|
2010-03-20 13:17:40 +00:00
|
|
|
|
2010-03-13 10:23:23 +00:00
|
|
|
G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
|
|
|
|
|
2010-03-13 17:35:35 +00:00
|
|
|
|
|
|
|
typedef struct GtkThemingModule GtkThemingModule;
|
|
|
|
typedef struct GtkThemingModuleClass GtkThemingModuleClass;
|
|
|
|
|
|
|
|
struct GtkThemingModule
|
|
|
|
{
|
|
|
|
GTypeModule parent_instance;
|
2010-10-20 11:26:27 +00:00
|
|
|
GModule *module;
|
2010-03-13 17:35:35 +00:00
|
|
|
gchar *name;
|
|
|
|
|
2010-10-20 11:26:27 +00:00
|
|
|
void (*init) (GTypeModule *module);
|
|
|
|
void (*exit) (void);
|
2010-03-13 17:35:35 +00:00
|
|
|
GtkThemingEngine * (*create_engine) (void);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GtkThemingModuleClass
|
|
|
|
{
|
|
|
|
GTypeModuleClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GTK_TYPE_THEMING_MODULE (gtk_theming_module_get_type ())
|
|
|
|
#define GTK_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_THEMING_MODULE, GtkThemingModule))
|
|
|
|
#define GTK_IS_THEMING_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_THEMING_MODULE))
|
|
|
|
|
2012-10-02 17:19:50 +00:00
|
|
|
GType gtk_theming_module_get_type (void);
|
|
|
|
|
2010-03-13 17:35:35 +00:00
|
|
|
G_DEFINE_TYPE (GtkThemingModule, gtk_theming_module, G_TYPE_TYPE_MODULE);
|
|
|
|
|
2010-03-13 10:23:23 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_class_init (GtkThemingEngineClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2010-10-25 22:43:20 +00:00
|
|
|
object_class->finalize = gtk_theming_engine_finalize;
|
|
|
|
object_class->set_property = gtk_theming_engine_impl_set_property;
|
|
|
|
object_class->get_property = gtk_theming_engine_impl_get_property;
|
|
|
|
|
2011-06-06 14:23:06 +00:00
|
|
|
klass->render_icon = gtk_theming_engine_render_icon;
|
2010-03-20 13:17:40 +00:00
|
|
|
klass->render_check = gtk_theming_engine_render_check;
|
2010-03-20 16:37:34 +00:00
|
|
|
klass->render_option = gtk_theming_engine_render_option;
|
2010-03-27 17:50:39 +00:00
|
|
|
klass->render_arrow = gtk_theming_engine_render_arrow;
|
2010-03-27 19:06:44 +00:00
|
|
|
klass->render_background = gtk_theming_engine_render_background;
|
2010-03-27 19:11:31 +00:00
|
|
|
klass->render_frame = gtk_theming_engine_render_frame;
|
2010-03-27 19:15:45 +00:00
|
|
|
klass->render_expander = gtk_theming_engine_render_expander;
|
2010-03-27 19:18:38 +00:00
|
|
|
klass->render_focus = gtk_theming_engine_render_focus;
|
2010-03-27 19:21:55 +00:00
|
|
|
klass->render_layout = gtk_theming_engine_render_layout;
|
2010-03-27 20:17:22 +00:00
|
|
|
klass->render_line = gtk_theming_engine_render_line;
|
2010-03-27 20:20:21 +00:00
|
|
|
klass->render_slider = gtk_theming_engine_render_slider;
|
2010-03-27 20:23:13 +00:00
|
|
|
klass->render_frame_gap = gtk_theming_engine_render_frame_gap;
|
2010-03-27 20:25:33 +00:00
|
|
|
klass->render_extension = gtk_theming_engine_render_extension;
|
2010-03-27 20:27:52 +00:00
|
|
|
klass->render_handle = gtk_theming_engine_render_handle;
|
2010-11-01 01:46:35 +00:00
|
|
|
klass->render_activity = gtk_theming_engine_render_activity;
|
2010-11-03 20:14:08 +00:00
|
|
|
klass->render_icon_pixbuf = gtk_theming_engine_render_icon_pixbuf;
|
2010-03-20 13:17:40 +00:00
|
|
|
|
2010-10-25 22:43:20 +00:00
|
|
|
/**
|
|
|
|
* GtkThemingEngine:name:
|
|
|
|
*
|
|
|
|
* The theming engine name, this name will be used when registering
|
|
|
|
* custom properties, for a theming engine named "Clearlooks" registering
|
|
|
|
* a "glossy" custom property, it could be referenced in the CSS file as
|
|
|
|
*
|
|
|
|
* <programlisting>
|
|
|
|
* -Clearlooks-glossy: true;
|
|
|
|
* </programlisting>
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_NAME,
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
P_("Name"),
|
|
|
|
P_("Theming engine name"),
|
|
|
|
NULL,
|
|
|
|
G_PARAM_CONSTRUCT_ONLY | GTK_PARAM_READWRITE));
|
|
|
|
|
2010-03-13 10:23:23 +00:00
|
|
|
g_type_class_add_private (object_class, sizeof (GtkThemingEnginePrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_init (GtkThemingEngine *engine)
|
|
|
|
{
|
|
|
|
engine->priv = GTK_THEMING_ENGINE_GET_PRIVATE (engine);
|
|
|
|
}
|
|
|
|
|
2010-10-25 22:43:20 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
priv = GTK_THEMING_ENGINE (object)->priv;
|
|
|
|
g_free (priv->name);
|
|
|
|
|
|
|
|
G_OBJECT_GET_CLASS (gtk_theming_engine_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_impl_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
priv = GTK_THEMING_ENGINE (object)->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_NAME:
|
|
|
|
if (priv->name)
|
|
|
|
g_free (priv->name);
|
|
|
|
|
|
|
|
priv->name = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_impl_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
priv = GTK_THEMING_ENGINE (object)->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_NAME:
|
|
|
|
g_value_set_string (value, priv->name);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-13 10:23:23 +00:00
|
|
|
void
|
|
|
|
_gtk_theming_engine_set_context (GtkThemingEngine *engine,
|
|
|
|
GtkStyleContext *context)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
priv->context = context;
|
|
|
|
}
|
|
|
|
|
2012-02-08 21:10:01 +00:00
|
|
|
GtkStyleContext *
|
|
|
|
_gtk_theming_engine_get_context (GtkThemingEngine *engine)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
|
|
|
|
|
|
|
|
return engine->priv->context;
|
|
|
|
}
|
|
|
|
|
2012-03-06 13:16:32 +00:00
|
|
|
GtkCssValue *
|
2012-01-03 01:35:56 +00:00
|
|
|
_gtk_theming_engine_peek_property (GtkThemingEngine *engine,
|
2012-03-31 03:42:28 +00:00
|
|
|
guint property_id)
|
2012-01-03 01:35:56 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
|
|
|
|
|
2012-03-31 03:42:28 +00:00
|
|
|
return _gtk_style_context_peek_property (engine->priv->context, property_id);
|
2012-01-03 01:35:56 +00:00
|
|
|
}
|
|
|
|
|
2012-01-15 04:29:02 +00:00
|
|
|
double
|
|
|
|
_gtk_theming_engine_get_number (GtkThemingEngine *engine,
|
2012-03-31 03:42:28 +00:00
|
|
|
guint property_id,
|
2012-01-15 04:29:02 +00:00
|
|
|
double one_hundred_percent)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0.0);
|
|
|
|
|
2012-03-31 03:42:28 +00:00
|
|
|
return _gtk_style_context_get_number (engine->priv->context, property_id, one_hundred_percent);
|
2012-01-15 04:29:02 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_property:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @property: the property name
|
|
|
|
* @state: state to retrieve the value for
|
|
|
|
* @value: (out) (transfer full): return location for the property value,
|
|
|
|
* you must free this memory using g_value_unset() once you are
|
|
|
|
* done with it.
|
|
|
|
*
|
|
|
|
* Gets a property value as retrieved from the style settings that apply
|
|
|
|
* to the currently rendered element.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-13 10:23:23 +00:00
|
|
|
void
|
|
|
|
gtk_theming_engine_get_property (GtkThemingEngine *engine,
|
|
|
|
const gchar *property,
|
2010-08-16 17:09:34 +00:00
|
|
|
GtkStateFlags state,
|
2010-03-13 10:23:23 +00:00
|
|
|
GValue *value)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
g_return_if_fail (property != NULL);
|
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_property (priv->context, property, state, value);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_valist:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @state: state to retrieve values for
|
|
|
|
* @args: va_list of property name/return location pairs, followed by %NULL
|
|
|
|
*
|
|
|
|
* Retrieves several style property values that apply to the currently
|
|
|
|
* rendered element.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-13 10:23:23 +00:00
|
|
|
void
|
|
|
|
gtk_theming_engine_get_valist (GtkThemingEngine *engine,
|
2010-08-16 17:09:34 +00:00
|
|
|
GtkStateFlags state,
|
2010-03-13 10:23:23 +00:00
|
|
|
va_list args)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_valist (priv->context, state, args);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @state: state to retrieve values for
|
|
|
|
* @...: property name /return value pairs, followed by %NULL
|
|
|
|
*
|
|
|
|
* Retrieves several style property values that apply to the currently
|
|
|
|
* rendered element.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-13 10:23:23 +00:00
|
|
|
void
|
|
|
|
gtk_theming_engine_get (GtkThemingEngine *engine,
|
2010-08-16 17:09:34 +00:00
|
|
|
GtkStateFlags state,
|
2010-03-13 10:23:23 +00:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
|
|
|
|
va_start (args, state);
|
|
|
|
gtk_style_context_get_valist (priv->context, state, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_style_property:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @property_name: the name of the widget style property
|
2011-01-18 09:14:33 +00:00
|
|
|
* @value: Return location for the property value, free with
|
2010-10-19 08:59:46 +00:00
|
|
|
* g_value_unset() after use.
|
|
|
|
*
|
|
|
|
* Gets the value for a widget style property.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-02 13:33:20 +00:00
|
|
|
void
|
|
|
|
gtk_theming_engine_get_style_property (GtkThemingEngine *engine,
|
|
|
|
const gchar *property_name,
|
|
|
|
GValue *value)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
g_return_if_fail (property_name != NULL);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_style_property (priv->context, property_name, value);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_style_valist:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @args: va_list of property name/return location pairs, followed by %NULL
|
|
|
|
*
|
|
|
|
* Retrieves several widget style properties from @engine according to the
|
|
|
|
* currently rendered content's style.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-02 13:33:20 +00:00
|
|
|
void
|
|
|
|
gtk_theming_engine_get_style_valist (GtkThemingEngine *engine,
|
|
|
|
va_list args)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_style_valist (priv->context, args);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_style:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @...: property name /return value pairs, followed by %NULL
|
|
|
|
*
|
|
|
|
* Retrieves several widget style properties from @engine according
|
|
|
|
* to the currently rendered content's style.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-02 13:33:20 +00:00
|
|
|
void
|
|
|
|
gtk_theming_engine_get_style (GtkThemingEngine *engine,
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
|
|
|
|
va_start (args, engine);
|
|
|
|
gtk_style_context_get_style_valist (priv->context, args);
|
|
|
|
va_end (args);
|
|
|
|
}
|
|
|
|
|
2010-12-01 18:19:26 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_lookup_color:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @color_name: color name to lookup
|
2010-12-04 14:08:35 +00:00
|
|
|
* @color: (out): Return location for the looked up color
|
2010-12-01 18:19:26 +00:00
|
|
|
*
|
|
|
|
* Looks up and resolves a color name in the current style's color map.
|
2010-12-09 22:55:33 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if @color_name was found and resolved, %FALSE otherwise
|
2010-12-01 18:19:26 +00:00
|
|
|
**/
|
2010-12-09 22:55:33 +00:00
|
|
|
gboolean
|
2010-12-04 14:08:35 +00:00
|
|
|
gtk_theming_engine_lookup_color (GtkThemingEngine *engine,
|
|
|
|
const gchar *color_name,
|
|
|
|
GdkRGBA *color)
|
2010-12-01 18:19:26 +00:00
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
2010-12-09 22:55:33 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
|
|
|
|
g_return_val_if_fail (color_name != NULL, FALSE);
|
2010-12-01 18:19:26 +00:00
|
|
|
|
|
|
|
priv = engine->priv;
|
2010-12-09 22:55:33 +00:00
|
|
|
return gtk_style_context_lookup_color (priv->context, color_name, color);
|
2010-12-01 18:19:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_state:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
*
|
|
|
|
* returns the state used when rendering.
|
|
|
|
*
|
|
|
|
* Returns: the state flags
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-13 10:23:23 +00:00
|
|
|
GtkStateFlags
|
|
|
|
gtk_theming_engine_get_state (GtkThemingEngine *engine)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
return gtk_style_context_get_state (priv->context);
|
|
|
|
}
|
|
|
|
|
2010-10-19 10:09:23 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_state_is_running:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @state: a widget state
|
|
|
|
* @progress: (out): return location for the transition progress
|
|
|
|
*
|
|
|
|
* Returns %TRUE if there is a transition animation running for the
|
|
|
|
* current region (see gtk_style_context_push_animatable_region()).
|
|
|
|
*
|
|
|
|
* If @progress is not %NULL, the animation progress will be returned
|
|
|
|
* there, 0.0 means the state is closest to being %FALSE, while 1.0 means
|
|
|
|
* it's closest to being %TRUE. This means transition animations will
|
|
|
|
* run from 0 to 1 when @state is being set to %TRUE and from 1 to 0 when
|
|
|
|
* it's being set to %FALSE.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if there is a running transition animation for @state.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2012-04-04 16:55:51 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.6: Always returns %FALSE
|
2010-10-19 10:09:23 +00:00
|
|
|
**/
|
2010-03-13 10:23:23 +00:00
|
|
|
gboolean
|
2010-10-19 10:09:23 +00:00
|
|
|
gtk_theming_engine_state_is_running (GtkThemingEngine *engine,
|
|
|
|
GtkStateType state,
|
|
|
|
gdouble *progress)
|
2010-03-13 10:23:23 +00:00
|
|
|
{
|
2010-10-19 10:09:23 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
|
2010-03-13 10:23:23 +00:00
|
|
|
|
2012-04-04 16:55:51 +00:00
|
|
|
return FALSE;
|
2010-03-13 10:23:23 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_path:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
*
|
|
|
|
* Returns the widget path used for style matching.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): A #GtkWidgetPath
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2011-06-06 18:13:44 +00:00
|
|
|
const GtkWidgetPath *
|
2010-03-13 10:23:23 +00:00
|
|
|
gtk_theming_engine_get_path (GtkThemingEngine *engine)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
return gtk_style_context_get_path (priv->context);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_has_class:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @style_class: class name to look up
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the currently rendered contents have
|
|
|
|
* defined the given class name.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @engine has @class_name defined
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-20 13:13:50 +00:00
|
|
|
gboolean
|
|
|
|
gtk_theming_engine_has_class (GtkThemingEngine *engine,
|
|
|
|
const gchar *style_class)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
return gtk_style_context_has_class (priv->context, style_class);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_has_region:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @style_region: a region name
|
|
|
|
* @flags: (out) (allow-none): return location for region flags
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the currently rendered contents have the
|
|
|
|
* region defined. If @flags_return is not %NULL, it is set
|
|
|
|
* to the flags affecting the region.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if region is defined
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-20 13:13:50 +00:00
|
|
|
gboolean
|
2010-08-05 09:08:51 +00:00
|
|
|
gtk_theming_engine_has_region (GtkThemingEngine *engine,
|
2010-10-19 08:59:46 +00:00
|
|
|
const gchar *style_region,
|
2010-08-05 09:08:51 +00:00
|
|
|
GtkRegionFlags *flags)
|
2010-03-20 13:13:50 +00:00
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
if (flags)
|
|
|
|
*flags = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), FALSE);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
2010-10-19 08:59:46 +00:00
|
|
|
return gtk_style_context_has_region (priv->context, style_region, flags);
|
2010-03-20 13:13:50 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_direction:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
*
|
|
|
|
* Returns the widget direction used for rendering.
|
|
|
|
*
|
|
|
|
* Returns: the widget direction
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-03 18:26:53 +00:00
|
|
|
GtkTextDirection
|
|
|
|
gtk_theming_engine_get_direction (GtkThemingEngine *engine)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), GTK_TEXT_DIR_LTR);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
return gtk_style_context_get_direction (priv->context);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_junction_sides:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
*
|
|
|
|
* Returns the widget direction used for rendering.
|
|
|
|
*
|
|
|
|
* Returns: the widget direction
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-03 18:36:09 +00:00
|
|
|
GtkJunctionSides
|
|
|
|
gtk_theming_engine_get_junction_sides (GtkThemingEngine *engine)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
return gtk_style_context_get_junction_sides (priv->context);
|
|
|
|
}
|
|
|
|
|
2010-12-02 22:41:24 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_color:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @state: state to retrieve the color for
|
|
|
|
* @color: (out): return value for the foreground color
|
|
|
|
*
|
|
|
|
* Gets the foreground color for a given state.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_theming_engine_get_color (GtkThemingEngine *engine,
|
|
|
|
GtkStateFlags state,
|
|
|
|
GdkRGBA *color)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_color (priv->context, state, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_background_color:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @state: state to retrieve the color for
|
|
|
|
* @color: (out): return value for the background color
|
|
|
|
*
|
|
|
|
* Gets the background color for a given state.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_theming_engine_get_background_color (GtkThemingEngine *engine,
|
|
|
|
GtkStateFlags state,
|
|
|
|
GdkRGBA *color)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_background_color (priv->context, state, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_border_color:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @state: state to retrieve the color for
|
|
|
|
* @color: (out): return value for the border color
|
|
|
|
*
|
|
|
|
* Gets the border color for a given state.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_theming_engine_get_border_color (GtkThemingEngine *engine,
|
|
|
|
GtkStateFlags state,
|
|
|
|
GdkRGBA *color)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_border_color (priv->context, state, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_border:
|
2012-07-02 06:19:06 +00:00
|
|
|
* @engine: a #GtkThemingEngine
|
2010-12-02 22:41:24 +00:00
|
|
|
* @state: state to retrieve the border for
|
2011-01-06 13:12:01 +00:00
|
|
|
* @border: (out): return value for the border settings
|
2010-12-02 22:41:24 +00:00
|
|
|
*
|
|
|
|
* Gets the border for a given state as a #GtkBorder.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_theming_engine_get_border (GtkThemingEngine *engine,
|
|
|
|
GtkStateFlags state,
|
|
|
|
GtkBorder *border)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_border (priv->context, state, border);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_padding:
|
2012-07-02 06:19:06 +00:00
|
|
|
* @engine: a #GtkThemingEngine
|
2010-12-02 22:41:24 +00:00
|
|
|
* @state: state to retrieve the padding for
|
2010-12-17 19:47:56 +00:00
|
|
|
* @padding: (out): return value for the padding settings
|
2010-12-02 22:41:24 +00:00
|
|
|
*
|
|
|
|
* Gets the padding for a given state as a #GtkBorder.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_theming_engine_get_padding (GtkThemingEngine *engine,
|
|
|
|
GtkStateFlags state,
|
|
|
|
GtkBorder *padding)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_padding (priv->context, state, padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_margin:
|
2010-12-17 19:47:56 +00:00
|
|
|
* @engine: a #GtkThemingEngine
|
2010-12-02 22:41:24 +00:00
|
|
|
* @state: state to retrieve the border for
|
2010-12-17 19:47:56 +00:00
|
|
|
* @margin: (out): return value for the margin settings
|
2010-12-02 22:41:24 +00:00
|
|
|
*
|
|
|
|
* Gets the margin for a given state as a #GtkBorder.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_theming_engine_get_margin (GtkThemingEngine *engine,
|
|
|
|
GtkStateFlags state,
|
|
|
|
GtkBorder *margin)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_THEMING_ENGINE (engine));
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
gtk_style_context_get_margin (priv->context, state, margin);
|
|
|
|
}
|
|
|
|
|
2010-12-13 20:36:49 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_font:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
* @state: state to retrieve the font for
|
|
|
|
*
|
|
|
|
* Returns the font description for a given state.
|
|
|
|
*
|
2011-01-18 09:01:17 +00:00
|
|
|
* Returns: (transfer none): the #PangoFontDescription for the given
|
|
|
|
* state. This object is owned by GTK+ and should not be
|
|
|
|
* freed.
|
2010-12-13 20:36:49 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
const PangoFontDescription *
|
|
|
|
gtk_theming_engine_get_font (GtkThemingEngine *engine,
|
|
|
|
GtkStateFlags state)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
return gtk_style_context_get_font (priv->context, state);
|
|
|
|
}
|
2010-12-02 22:41:24 +00:00
|
|
|
|
2010-03-13 17:35:35 +00:00
|
|
|
/* GtkThemingModule */
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_theming_module_load (GTypeModule *type_module)
|
|
|
|
{
|
|
|
|
GtkThemingModule *theming_module;
|
|
|
|
GModule *module;
|
|
|
|
gchar *name, *module_path;
|
|
|
|
|
|
|
|
theming_module = GTK_THEMING_MODULE (type_module);
|
|
|
|
name = theming_module->name;
|
|
|
|
module_path = _gtk_find_module (name, "theming-engines");
|
|
|
|
|
|
|
|
if (!module_path)
|
2010-12-06 05:44:01 +00:00
|
|
|
return FALSE;
|
2010-03-13 17:35:35 +00:00
|
|
|
|
|
|
|
module = g_module_open (module_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
|
|
|
|
g_free (module_path);
|
|
|
|
|
|
|
|
if (!module)
|
2010-12-06 05:44:01 +00:00
|
|
|
return FALSE;
|
2010-03-13 17:35:35 +00:00
|
|
|
|
2010-10-20 11:26:27 +00:00
|
|
|
if (!g_module_symbol (module, "theme_init",
|
|
|
|
(gpointer *) &theming_module->init) ||
|
|
|
|
!g_module_symbol (module, "theme_exit",
|
|
|
|
(gpointer *) &theming_module->exit) ||
|
|
|
|
!g_module_symbol (module, "create_engine",
|
2010-03-13 17:35:35 +00:00
|
|
|
(gpointer *) &theming_module->create_engine))
|
|
|
|
{
|
|
|
|
g_module_close (module);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-10-20 11:26:27 +00:00
|
|
|
theming_module->module = module;
|
|
|
|
|
2010-11-03 20:12:57 +00:00
|
|
|
theming_module->init (G_TYPE_MODULE (theming_module));
|
2010-03-13 17:35:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-10-20 11:26:27 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_module_unload (GTypeModule *type_module)
|
|
|
|
{
|
|
|
|
GtkThemingModule *theming_module;
|
|
|
|
|
|
|
|
theming_module = GTK_THEMING_MODULE (type_module);
|
|
|
|
|
|
|
|
theming_module->exit ();
|
|
|
|
|
|
|
|
g_module_close (theming_module->module);
|
|
|
|
|
|
|
|
theming_module->module = NULL;
|
|
|
|
theming_module->init = NULL;
|
|
|
|
theming_module->exit = NULL;
|
|
|
|
theming_module->create_engine = NULL;
|
|
|
|
}
|
|
|
|
|
2010-03-13 17:35:35 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_module_class_init (GtkThemingModuleClass *klass)
|
|
|
|
{
|
|
|
|
GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass);
|
|
|
|
|
|
|
|
module_class->load = gtk_theming_module_load;
|
2010-10-20 11:26:27 +00:00
|
|
|
module_class->unload = gtk_theming_module_unload;
|
2010-03-13 17:35:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_module_init (GtkThemingModule *module)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_load:
|
|
|
|
* @name: Theme engine name to load
|
|
|
|
*
|
|
|
|
* Loads and initializes a theming engine module from the
|
|
|
|
* standard directories.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): A theming engine, or %NULL if
|
|
|
|
* the engine @name doesn't exist.
|
|
|
|
**/
|
2010-10-08 16:13:14 +00:00
|
|
|
GtkThemingEngine *
|
2010-03-13 17:35:35 +00:00
|
|
|
gtk_theming_engine_load (const gchar *name)
|
|
|
|
{
|
|
|
|
static GHashTable *engines = NULL;
|
|
|
|
static GtkThemingEngine *default_engine;
|
|
|
|
GtkThemingEngine *engine = NULL;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
if (!engines)
|
|
|
|
engines = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
|
|
|
engine = g_hash_table_lookup (engines, name);
|
|
|
|
|
|
|
|
if (!engine)
|
|
|
|
{
|
|
|
|
GtkThemingModule *module;
|
|
|
|
|
|
|
|
module = g_object_new (GTK_TYPE_THEMING_MODULE, NULL);
|
|
|
|
g_type_module_set_name (G_TYPE_MODULE (module), name);
|
|
|
|
module->name = g_strdup (name);
|
|
|
|
|
|
|
|
if (module && g_type_module_use (G_TYPE_MODULE (module)))
|
|
|
|
{
|
|
|
|
engine = (module->create_engine) ();
|
|
|
|
|
|
|
|
if (engine)
|
|
|
|
g_hash_table_insert (engines, module->name, engine);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-21 00:41:10 +00:00
|
|
|
else
|
2010-03-13 17:35:35 +00:00
|
|
|
{
|
2010-06-13 15:31:22 +00:00
|
|
|
if (G_UNLIKELY (!default_engine))
|
2010-03-13 17:35:35 +00:00
|
|
|
default_engine = g_object_new (GTK_TYPE_THEMING_ENGINE, NULL);
|
|
|
|
|
|
|
|
engine = default_engine;
|
|
|
|
}
|
|
|
|
|
|
|
|
return engine;
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_theming_engine_get_screen:
|
|
|
|
* @engine: a #GtkThemingEngine
|
|
|
|
*
|
|
|
|
* Returns the #GdkScreen to which @engine currently rendering to.
|
|
|
|
*
|
2011-01-18 09:01:17 +00:00
|
|
|
* Returns: (transfer none): a #GdkScreen, or %NULL.
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-07-03 11:21:56 +00:00
|
|
|
GdkScreen *
|
|
|
|
gtk_theming_engine_get_screen (GtkThemingEngine *engine)
|
|
|
|
{
|
|
|
|
GtkThemingEnginePrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
|
|
|
|
|
|
|
|
priv = engine->priv;
|
|
|
|
return gtk_style_context_get_screen (priv->context);
|
|
|
|
}
|
|
|
|
|
2010-03-20 13:17:40 +00:00
|
|
|
/* Paint method implementations */
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_check (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA fg_color, bg_color;
|
2010-03-20 13:17:40 +00:00
|
|
|
GtkStateFlags flags;
|
2010-07-19 09:42:18 +00:00
|
|
|
gint exterior_size, interior_size, thickness, pad;
|
2010-11-19 18:18:20 +00:00
|
|
|
GtkBorderStyle border_style;
|
2011-03-28 17:34:40 +00:00
|
|
|
GtkBorder border;
|
2010-11-19 18:18:20 +00:00
|
|
|
gint border_width;
|
2011-12-10 00:14:12 +00:00
|
|
|
GtkThemingBackground bg;
|
|
|
|
|
|
|
|
_gtk_theming_background_init (&bg, engine,
|
|
|
|
x, y,
|
|
|
|
width, height,
|
|
|
|
gtk_theming_engine_get_junction_sides (engine));
|
|
|
|
|
|
|
|
if (_gtk_theming_background_has_background_image (&bg))
|
|
|
|
{
|
|
|
|
_gtk_theming_background_render (&bg, cr);
|
|
|
|
return;
|
|
|
|
}
|
2010-03-20 13:17:40 +00:00
|
|
|
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
|
|
|
cairo_save (cr);
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_color (engine, flags, &fg_color);
|
|
|
|
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
|
|
|
|
gtk_theming_engine_get_border (engine, flags, &border);
|
2012-05-16 22:27:21 +00:00
|
|
|
border_style = _gtk_css_border_style_value_get
|
|
|
|
(_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
|
2010-03-20 13:17:40 +00:00
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
border_width = MIN (MIN (border.top, border.bottom),
|
|
|
|
MIN (border.left, border.right));
|
2010-07-19 09:42:18 +00:00
|
|
|
exterior_size = MIN (width, height);
|
|
|
|
|
|
|
|
if (exterior_size % 2 == 0) /* Ensure odd */
|
|
|
|
exterior_size -= 1;
|
|
|
|
|
|
|
|
/* FIXME: thickness */
|
|
|
|
thickness = 1;
|
|
|
|
pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
|
|
|
|
interior_size = MAX (1, exterior_size - 2 * pad);
|
|
|
|
|
|
|
|
if (interior_size < 7)
|
2010-03-20 13:17:40 +00:00
|
|
|
{
|
2010-07-19 09:42:18 +00:00
|
|
|
interior_size = 7;
|
|
|
|
pad = MAX (0, (exterior_size - interior_size) / 2);
|
|
|
|
}
|
2010-03-20 13:17:40 +00:00
|
|
|
|
2010-07-19 09:42:18 +00:00
|
|
|
x -= (1 + exterior_size - (gint) width) / 2;
|
|
|
|
y -= (1 + exterior_size - (gint) height) / 2;
|
2010-03-20 13:17:40 +00:00
|
|
|
|
2010-11-19 18:18:20 +00:00
|
|
|
if (border_style == GTK_BORDER_STYLE_SOLID)
|
2010-07-19 09:42:18 +00:00
|
|
|
{
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA border_color;
|
|
|
|
|
2010-11-19 18:18:20 +00:00
|
|
|
cairo_set_line_width (cr, border_width);
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_border_color (engine, flags, &border_color);
|
2010-07-19 09:42:18 +00:00
|
|
|
|
|
|
|
cairo_rectangle (cr, x + 0.5, y + 0.5, exterior_size - 1, exterior_size - 1);
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &bg_color);
|
2010-03-20 13:17:40 +00:00
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &border_color);
|
2010-03-20 13:17:40 +00:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &fg_color);
|
2010-03-20 13:17:40 +00:00
|
|
|
|
2010-10-19 10:09:23 +00:00
|
|
|
if (flags & GTK_STATE_FLAG_INCONSISTENT)
|
2010-03-20 13:17:40 +00:00
|
|
|
{
|
2010-07-19 09:42:18 +00:00
|
|
|
int line_thickness = MAX (1, (3 + interior_size * 2) / 7);
|
|
|
|
|
|
|
|
cairo_rectangle (cr,
|
|
|
|
x + pad,
|
|
|
|
y + pad + (1 + interior_size - line_thickness) / 2,
|
|
|
|
interior_size,
|
|
|
|
line_thickness);
|
|
|
|
cairo_fill (cr);
|
2010-03-20 13:17:40 +00:00
|
|
|
}
|
2010-08-19 20:47:02 +00:00
|
|
|
else
|
2010-03-20 13:17:40 +00:00
|
|
|
{
|
2012-05-16 22:13:02 +00:00
|
|
|
if (flags & GTK_STATE_FLAG_ACTIVE)
|
2010-08-19 20:47:02 +00:00
|
|
|
{
|
|
|
|
cairo_translate (cr,
|
|
|
|
x + pad, y + pad);
|
|
|
|
|
|
|
|
cairo_scale (cr, interior_size / 7., interior_size / 7.);
|
|
|
|
|
2012-05-16 22:13:02 +00:00
|
|
|
cairo_rectangle (cr, 0, 0, 7, 7);
|
2010-08-19 20:47:02 +00:00
|
|
|
cairo_clip (cr);
|
|
|
|
|
|
|
|
cairo_move_to (cr, 7.0, 0.0);
|
|
|
|
cairo_line_to (cr, 7.5, 1.0);
|
|
|
|
cairo_curve_to (cr, 5.3, 2.0,
|
|
|
|
4.3, 4.0,
|
|
|
|
3.5, 7.0);
|
|
|
|
cairo_curve_to (cr, 3.0, 5.7,
|
|
|
|
1.3, 4.7,
|
|
|
|
0.0, 4.7);
|
|
|
|
cairo_line_to (cr, 0.2, 3.5);
|
|
|
|
cairo_curve_to (cr, 1.1, 3.5,
|
|
|
|
2.3, 4.3,
|
|
|
|
3.0, 5.0);
|
|
|
|
cairo_curve_to (cr, 1.0, 3.9,
|
|
|
|
2.4, 4.1,
|
|
|
|
3.2, 4.9);
|
|
|
|
cairo_curve_to (cr, 3.5, 3.1,
|
|
|
|
5.2, 2.0,
|
|
|
|
7.0, 0.0);
|
|
|
|
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
2010-03-20 13:17:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
2010-03-20 16:37:34 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_option (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
|
|
|
GtkStateFlags flags;
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA fg_color, bg_color;
|
2010-11-19 19:17:18 +00:00
|
|
|
gint exterior_size, interior_size, pad, thickness, border_width;
|
|
|
|
GtkBorderStyle border_style;
|
2011-03-28 17:34:40 +00:00
|
|
|
GtkBorder border;
|
2011-12-10 00:14:12 +00:00
|
|
|
GtkThemingBackground bg;
|
|
|
|
|
|
|
|
_gtk_theming_background_init (&bg, engine,
|
|
|
|
x, y,
|
|
|
|
width, height,
|
|
|
|
gtk_theming_engine_get_junction_sides (engine));
|
|
|
|
|
|
|
|
if (_gtk_theming_background_has_background_image (&bg))
|
|
|
|
{
|
|
|
|
_gtk_theming_background_render (&bg, cr);
|
|
|
|
return;
|
|
|
|
}
|
2010-03-20 16:37:34 +00:00
|
|
|
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_color (engine, flags, &fg_color);
|
|
|
|
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
|
|
|
|
gtk_theming_engine_get_border (engine, flags, &border);
|
2012-05-16 22:27:21 +00:00
|
|
|
border_style = _gtk_css_border_style_value_get
|
|
|
|
(_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
|
2010-03-20 16:37:34 +00:00
|
|
|
|
2010-07-19 09:45:35 +00:00
|
|
|
exterior_size = MIN (width, height);
|
2011-03-28 17:34:40 +00:00
|
|
|
border_width = MIN (MIN (border.top, border.bottom),
|
|
|
|
MIN (border.left, border.right));
|
2010-07-19 09:45:35 +00:00
|
|
|
|
|
|
|
if (exterior_size % 2 == 0) /* Ensure odd */
|
|
|
|
exterior_size -= 1;
|
|
|
|
|
|
|
|
x -= (1 + exterior_size - width) / 2;
|
|
|
|
y -= (1 + exterior_size - height) / 2;
|
|
|
|
|
2010-11-19 19:17:18 +00:00
|
|
|
if (border_style == GTK_BORDER_STYLE_SOLID)
|
2010-03-20 16:37:34 +00:00
|
|
|
{
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA border_color;
|
|
|
|
|
2010-11-19 19:17:18 +00:00
|
|
|
cairo_set_line_width (cr, border_width);
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_border_color (engine, flags, &border_color);
|
2011-01-12 19:29:08 +00:00
|
|
|
|
|
|
|
cairo_new_sub_path (cr);
|
2010-03-20 16:37:34 +00:00
|
|
|
cairo_arc (cr,
|
2011-01-24 02:50:39 +00:00
|
|
|
x + exterior_size / 2.,
|
|
|
|
y + exterior_size / 2.,
|
|
|
|
(exterior_size - 1) / 2.,
|
|
|
|
0, 2 * G_PI);
|
2010-03-20 16:37:34 +00:00
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &bg_color);
|
2010-03-20 16:37:34 +00:00
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &border_color);
|
2010-03-20 16:37:34 +00:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &fg_color);
|
2010-03-20 16:37:34 +00:00
|
|
|
|
2010-07-19 09:45:35 +00:00
|
|
|
/* FIXME: thickness */
|
|
|
|
thickness = 1;
|
|
|
|
|
2010-10-19 10:09:23 +00:00
|
|
|
if (flags & GTK_STATE_FLAG_INCONSISTENT)
|
2010-03-20 16:37:34 +00:00
|
|
|
{
|
2010-07-19 09:45:35 +00:00
|
|
|
gint line_thickness;
|
|
|
|
|
|
|
|
pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
|
|
|
|
interior_size = MAX (1, exterior_size - 2 * pad);
|
|
|
|
|
|
|
|
if (interior_size < 7)
|
|
|
|
{
|
|
|
|
interior_size = 7;
|
|
|
|
pad = MAX (0, (exterior_size - interior_size) / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
line_thickness = MAX (1, (3 + interior_size * 2) / 7);
|
|
|
|
|
|
|
|
cairo_rectangle (cr,
|
2011-01-24 02:50:39 +00:00
|
|
|
x + pad,
|
|
|
|
y + pad + (interior_size - line_thickness) / 2.,
|
|
|
|
interior_size,
|
|
|
|
line_thickness);
|
2010-07-19 09:45:35 +00:00
|
|
|
cairo_fill (cr);
|
2010-03-20 16:37:34 +00:00
|
|
|
}
|
2010-10-19 10:09:23 +00:00
|
|
|
if (flags & GTK_STATE_FLAG_ACTIVE)
|
2010-03-20 16:37:34 +00:00
|
|
|
{
|
2010-07-19 09:45:35 +00:00
|
|
|
pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9);
|
|
|
|
interior_size = MAX (1, exterior_size - 2 * pad);
|
2010-03-20 16:37:34 +00:00
|
|
|
|
2010-07-19 09:45:35 +00:00
|
|
|
if (interior_size < 5)
|
2011-01-24 02:50:39 +00:00
|
|
|
{
|
|
|
|
interior_size = 7;
|
|
|
|
pad = MAX (0, (exterior_size - interior_size) / 2);
|
|
|
|
}
|
2010-07-19 09:45:35 +00:00
|
|
|
|
2011-01-12 19:29:08 +00:00
|
|
|
cairo_new_sub_path (cr);
|
2010-07-19 09:45:35 +00:00
|
|
|
cairo_arc (cr,
|
2011-01-24 02:50:39 +00:00
|
|
|
x + pad + interior_size / 2.,
|
|
|
|
y + pad + interior_size / 2.,
|
|
|
|
interior_size / 2.,
|
|
|
|
0, 2 * G_PI);
|
2010-03-20 16:37:34 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
2010-03-27 17:50:39 +00:00
|
|
|
static void
|
|
|
|
add_path_arrow (cairo_t *cr,
|
|
|
|
gdouble angle,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble size)
|
|
|
|
{
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
|
|
cairo_translate (cr, x + (size / 2), y + (size / 2));
|
|
|
|
cairo_rotate (cr, angle);
|
|
|
|
|
2010-08-02 13:45:13 +00:00
|
|
|
cairo_move_to (cr, 0, - (size / 4));
|
|
|
|
cairo_line_to (cr, - (size / 2), (size / 4));
|
|
|
|
cairo_line_to (cr, (size / 2), (size / 4));
|
2010-03-27 17:50:39 +00:00
|
|
|
cairo_close_path (cr);
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_arrow (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble angle,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble size)
|
|
|
|
{
|
|
|
|
GtkStateFlags flags;
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA fg_color;
|
2010-03-27 17:50:39 +00:00
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_color (engine, flags, &fg_color);
|
2010-03-27 17:50:39 +00:00
|
|
|
|
|
|
|
if (flags & GTK_STATE_FLAG_INSENSITIVE)
|
|
|
|
{
|
|
|
|
add_path_arrow (cr, angle, x + 1, y + 1, size);
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
add_path_arrow (cr, angle, x, y, size);
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &fg_color);
|
2010-03-27 17:50:39 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
2010-03-27 19:06:44 +00:00
|
|
|
static void
|
2010-07-19 09:51:17 +00:00
|
|
|
add_path_line (cairo_t *cr,
|
|
|
|
gdouble x1,
|
|
|
|
gdouble y1,
|
|
|
|
gdouble x2,
|
|
|
|
gdouble y2)
|
2010-03-27 19:06:44 +00:00
|
|
|
{
|
2010-07-19 09:51:17 +00:00
|
|
|
/* Adjust endpoints */
|
|
|
|
if (y1 == y2)
|
|
|
|
{
|
|
|
|
y1 += 0.5;
|
|
|
|
y2 += 0.5;
|
|
|
|
x2 += 1;
|
|
|
|
}
|
|
|
|
else if (x1 == x2)
|
|
|
|
{
|
|
|
|
x1 += 0.5;
|
|
|
|
x2 += 0.5;
|
|
|
|
y2 += 1;
|
|
|
|
}
|
2010-03-27 19:06:44 +00:00
|
|
|
|
2010-07-19 09:51:17 +00:00
|
|
|
cairo_move_to (cr, x1, y1);
|
|
|
|
cairo_line_to (cr, x2, y2);
|
|
|
|
}
|
|
|
|
|
2010-03-27 19:11:31 +00:00
|
|
|
static void
|
2010-10-22 10:41:19 +00:00
|
|
|
color_shade (const GdkRGBA *color,
|
|
|
|
gdouble factor,
|
|
|
|
GdkRGBA *color_return)
|
2010-03-27 19:11:31 +00:00
|
|
|
{
|
2012-11-25 02:33:33 +00:00
|
|
|
GtkHSLA hsla;
|
2010-11-06 11:38:52 +00:00
|
|
|
|
2012-11-25 02:33:33 +00:00
|
|
|
_gtk_hsla_init_from_rgba (&hsla, color);
|
|
|
|
_gtk_hsla_shade (&hsla, &hsla, factor);
|
|
|
|
_gdk_rgba_init_from_hsla (color_return, &hsla);
|
2010-03-27 19:11:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 10:24:04 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_background (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
2011-12-10 00:14:12 +00:00
|
|
|
GtkThemingBackground bg;
|
2010-11-29 10:24:04 +00:00
|
|
|
|
2011-12-10 00:14:12 +00:00
|
|
|
_gtk_theming_background_init (&bg, engine,
|
|
|
|
x, y,
|
|
|
|
width, height,
|
|
|
|
gtk_theming_engine_get_junction_sides (engine));
|
2010-11-29 10:24:04 +00:00
|
|
|
|
2011-12-10 00:14:12 +00:00
|
|
|
_gtk_theming_background_render (&bg, cr);
|
2010-11-29 10:24:04 +00:00
|
|
|
}
|
|
|
|
|
2011-06-12 20:58:10 +00:00
|
|
|
static void
|
2012-10-27 01:16:35 +00:00
|
|
|
gtk_theming_engine_hide_border_sides (double border[4],
|
|
|
|
GtkBorderStyle border_style[4],
|
|
|
|
guint hidden_side)
|
2011-06-12 20:58:10 +00:00
|
|
|
{
|
2012-10-27 01:16:35 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if (hidden_side & (1 << i) ||
|
|
|
|
border_style[i] == GTK_BORDER_STYLE_NONE ||
|
|
|
|
border_style[i] == GTK_BORDER_STYLE_HIDDEN)
|
|
|
|
border[i] = 0;
|
|
|
|
}
|
2011-06-12 20:58:10 +00:00
|
|
|
}
|
|
|
|
|
2012-01-07 19:50:17 +00:00
|
|
|
static void
|
|
|
|
render_frame_fill (cairo_t *cr,
|
|
|
|
GtkRoundedBox *border_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
const double border_width[4],
|
2012-01-07 19:59:59 +00:00
|
|
|
GdkRGBA colors[4],
|
2012-01-07 19:50:17 +00:00
|
|
|
guint hidden_side)
|
|
|
|
{
|
|
|
|
GtkRoundedBox padding_box;
|
|
|
|
guint i, j;
|
|
|
|
|
|
|
|
padding_box = *border_box;
|
2012-10-27 01:16:35 +00:00
|
|
|
_gtk_rounded_box_shrink (&padding_box,
|
|
|
|
border_width[GTK_CSS_TOP],
|
|
|
|
border_width[GTK_CSS_RIGHT],
|
|
|
|
border_width[GTK_CSS_BOTTOM],
|
|
|
|
border_width[GTK_CSS_LEFT]);
|
2012-01-07 19:50:17 +00:00
|
|
|
|
|
|
|
if (hidden_side == 0 &&
|
2012-01-07 19:59:59 +00:00
|
|
|
gdk_rgba_equal (&colors[0], &colors[1]) &&
|
|
|
|
gdk_rgba_equal (&colors[0], &colors[2]) &&
|
|
|
|
gdk_rgba_equal (&colors[0], &colors[3]))
|
2012-01-07 19:50:17 +00:00
|
|
|
{
|
2012-01-07 19:59:59 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &colors[0]);
|
2012-01-07 19:50:17 +00:00
|
|
|
|
|
|
|
_gtk_rounded_box_path (border_box, cr);
|
|
|
|
_gtk_rounded_box_path (&padding_box, cr);
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2012-01-07 21:20:51 +00:00
|
|
|
if (hidden_side & (1 << i))
|
2012-01-07 19:50:17 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
{
|
2012-01-07 21:20:51 +00:00
|
|
|
if (hidden_side & (1 << j))
|
2012-01-07 19:50:17 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (i == j ||
|
2012-01-07 19:59:59 +00:00
|
|
|
(gdk_rgba_equal (&colors[i], &colors[j])))
|
2012-01-07 19:50:17 +00:00
|
|
|
{
|
|
|
|
/* We were already painted when i == j */
|
|
|
|
if (i > j)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (j == 0)
|
|
|
|
_gtk_rounded_box_path_top (border_box, &padding_box, cr);
|
|
|
|
else if (j == 1)
|
|
|
|
_gtk_rounded_box_path_right (border_box, &padding_box, cr);
|
|
|
|
else if (j == 2)
|
|
|
|
_gtk_rounded_box_path_bottom (border_box, &padding_box, cr);
|
|
|
|
else if (j == 3)
|
|
|
|
_gtk_rounded_box_path_left (border_box, &padding_box, cr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* We were already painted when i == j */
|
|
|
|
if (i > j)
|
|
|
|
continue;
|
|
|
|
|
2012-01-07 19:59:59 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &colors[i]);
|
2012-01-07 19:50:17 +00:00
|
|
|
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-08 00:17:48 +00:00
|
|
|
static void
|
|
|
|
set_stroke_style (cairo_t *cr,
|
|
|
|
double line_width,
|
|
|
|
GtkBorderStyle style,
|
|
|
|
double length)
|
|
|
|
{
|
|
|
|
double segments[2];
|
|
|
|
double n;
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, line_width);
|
|
|
|
|
|
|
|
if (style == GTK_BORDER_STYLE_DOTTED)
|
|
|
|
{
|
|
|
|
n = round (0.5 * length / line_width);
|
|
|
|
|
|
|
|
segments[0] = 0;
|
|
|
|
segments[1] = n ? length / n : 2;
|
|
|
|
cairo_set_dash (cr, segments, G_N_ELEMENTS (segments), 0);
|
|
|
|
|
|
|
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
|
|
|
|
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = length / line_width;
|
|
|
|
/* Optimize the common case of an integer-sized rectangle
|
|
|
|
* Again, we care about focus rectangles.
|
|
|
|
*/
|
|
|
|
if (n == nearbyint (n))
|
|
|
|
{
|
|
|
|
segments[0] = 1;
|
|
|
|
segments[1] = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = round ((1. / 3) * n);
|
|
|
|
|
|
|
|
segments[0] = n ? (1. / 3) * length / n : 1;
|
|
|
|
segments[1] = 2 * segments[1];
|
|
|
|
}
|
|
|
|
cairo_set_dash (cr, segments, G_N_ELEMENTS (segments), 0);
|
|
|
|
|
|
|
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
|
|
|
cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
render_frame_stroke (cairo_t *cr,
|
|
|
|
GtkRoundedBox *border_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
const double border_width[4],
|
2012-01-08 00:17:48 +00:00
|
|
|
GdkRGBA colors[4],
|
|
|
|
guint hidden_side,
|
|
|
|
GtkBorderStyle stroke_style)
|
|
|
|
{
|
|
|
|
gboolean different_colors, different_borders;
|
|
|
|
GtkRoundedBox stroke_box;
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
different_colors = !gdk_rgba_equal (&colors[0], &colors[1]) ||
|
|
|
|
!gdk_rgba_equal (&colors[0], &colors[2]) ||
|
|
|
|
!gdk_rgba_equal (&colors[0], &colors[3]);
|
2012-10-27 01:16:35 +00:00
|
|
|
different_borders = border_width[0] != border_width[1] ||
|
|
|
|
border_width[0] != border_width[2] ||
|
|
|
|
border_width[0] != border_width[3] ;
|
2012-01-08 00:17:48 +00:00
|
|
|
|
|
|
|
stroke_box = *border_box;
|
|
|
|
_gtk_rounded_box_shrink (&stroke_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
border_width[GTK_CSS_TOP] / 2.0,
|
|
|
|
border_width[GTK_CSS_RIGHT] / 2.0,
|
|
|
|
border_width[GTK_CSS_BOTTOM] / 2.0,
|
|
|
|
border_width[GTK_CSS_LEFT] / 2.0);
|
2012-01-08 00:17:48 +00:00
|
|
|
|
|
|
|
if (!different_colors && !different_borders && hidden_side == 0)
|
|
|
|
{
|
|
|
|
double length = 0;
|
|
|
|
|
|
|
|
/* FAST PATH:
|
|
|
|
* Mostly expected to trigger for focus rectangles */
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
length += _gtk_rounded_box_guess_length (&stroke_box, i);
|
|
|
|
_gtk_rounded_box_path_side (&stroke_box, cr, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &colors[0]);
|
2012-10-27 01:16:35 +00:00
|
|
|
set_stroke_style (cr, border_width[0], stroke_style, length);
|
2012-01-08 00:17:48 +00:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GtkRoundedBox padding_box;
|
|
|
|
|
|
|
|
padding_box = *border_box;
|
|
|
|
_gtk_rounded_box_path (&padding_box, cr);
|
|
|
|
_gtk_rounded_box_shrink (&padding_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
border_width[GTK_CSS_TOP],
|
|
|
|
border_width[GTK_CSS_RIGHT],
|
|
|
|
border_width[GTK_CSS_BOTTOM],
|
|
|
|
border_width[GTK_CSS_LEFT]);
|
2012-01-08 00:17:48 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
if (hidden_side & (1 << i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
_gtk_rounded_box_path_top (border_box, &padding_box, cr);
|
|
|
|
else if (i == 1)
|
|
|
|
_gtk_rounded_box_path_right (border_box, &padding_box, cr);
|
|
|
|
else if (i == 2)
|
|
|
|
_gtk_rounded_box_path_bottom (border_box, &padding_box, cr);
|
|
|
|
else if (i == 3)
|
|
|
|
_gtk_rounded_box_path_left (border_box, &padding_box, cr);
|
|
|
|
cairo_clip (cr);
|
|
|
|
|
|
|
|
_gtk_rounded_box_path_side (&stroke_box, cr, i);
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &colors[i]);
|
|
|
|
set_stroke_style (cr,
|
2012-10-27 01:16:35 +00:00
|
|
|
border_width[i],
|
2012-01-08 00:17:48 +00:00
|
|
|
stroke_style,
|
|
|
|
_gtk_rounded_box_guess_length (&stroke_box, i));
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-27 19:11:31 +00:00
|
|
|
static void
|
2012-01-08 01:41:30 +00:00
|
|
|
render_border (cairo_t *cr,
|
|
|
|
GtkRoundedBox *border_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
const double border_width[4],
|
2012-01-08 01:41:30 +00:00
|
|
|
guint hidden_side,
|
|
|
|
GdkRGBA colors[4],
|
|
|
|
GtkBorderStyle border_style[4])
|
2010-03-27 19:11:31 +00:00
|
|
|
{
|
2011-06-13 04:13:16 +00:00
|
|
|
guint i, j;
|
2010-03-27 19:11:31 +00:00
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
cairo_save (cr);
|
2010-03-27 19:11:31 +00:00
|
|
|
|
2011-06-11 04:13:00 +00:00
|
|
|
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
|
|
|
|
|
2012-01-07 19:50:17 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2012-01-06 19:58:19 +00:00
|
|
|
{
|
2012-01-07 21:20:51 +00:00
|
|
|
if (hidden_side & (1 << i))
|
2012-01-07 20:24:50 +00:00
|
|
|
continue;
|
|
|
|
|
2012-01-07 19:50:17 +00:00
|
|
|
switch (border_style[i])
|
2011-06-13 03:04:44 +00:00
|
|
|
{
|
2012-01-07 19:50:17 +00:00
|
|
|
case GTK_BORDER_STYLE_NONE:
|
|
|
|
case GTK_BORDER_STYLE_HIDDEN:
|
|
|
|
case GTK_BORDER_STYLE_SOLID:
|
|
|
|
break;
|
|
|
|
case GTK_BORDER_STYLE_INSET:
|
|
|
|
if (i == 1 || i == 2)
|
2012-01-07 19:59:59 +00:00
|
|
|
color_shade (&colors[i], 1.8, &colors[i]);
|
2012-01-07 19:50:17 +00:00
|
|
|
break;
|
|
|
|
case GTK_BORDER_STYLE_OUTSET:
|
|
|
|
if (i == 0 || i == 3)
|
2012-01-07 19:59:59 +00:00
|
|
|
color_shade (&colors[i], 1.8, &colors[i]);
|
2012-01-07 19:50:17 +00:00
|
|
|
break;
|
|
|
|
case GTK_BORDER_STYLE_DOTTED:
|
|
|
|
case GTK_BORDER_STYLE_DASHED:
|
2012-01-08 00:17:48 +00:00
|
|
|
{
|
|
|
|
guint dont_draw = hidden_side;
|
|
|
|
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
{
|
|
|
|
if (border_style[j] == border_style[i])
|
|
|
|
hidden_side |= (1 << j);
|
|
|
|
else
|
|
|
|
dont_draw |= (1 << j);
|
|
|
|
}
|
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
render_frame_stroke (cr, border_box, border_width, colors, dont_draw, border_style[i]);
|
2012-01-08 00:17:48 +00:00
|
|
|
}
|
2012-01-07 19:50:17 +00:00
|
|
|
break;
|
|
|
|
case GTK_BORDER_STYLE_DOUBLE:
|
|
|
|
{
|
2012-01-07 20:24:50 +00:00
|
|
|
GtkRoundedBox other_box;
|
2012-10-27 01:16:35 +00:00
|
|
|
double other_border[4];
|
2012-01-07 19:50:17 +00:00
|
|
|
guint dont_draw = hidden_side;
|
|
|
|
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
{
|
|
|
|
if (border_style[j] == GTK_BORDER_STYLE_DOUBLE)
|
2012-01-07 21:20:51 +00:00
|
|
|
hidden_side |= (1 << j);
|
2012-01-07 19:50:17 +00:00
|
|
|
else
|
2012-01-07 21:20:51 +00:00
|
|
|
dont_draw |= (1 << j);
|
2012-10-27 01:16:35 +00:00
|
|
|
|
|
|
|
other_border[i] = border_width[i] / 3;
|
2012-01-07 19:50:17 +00:00
|
|
|
}
|
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
render_frame_fill (cr, border_box, other_border, colors, dont_draw);
|
2012-01-07 19:50:17 +00:00
|
|
|
|
2012-01-08 01:41:30 +00:00
|
|
|
other_box = *border_box;
|
2012-01-07 20:24:50 +00:00
|
|
|
_gtk_rounded_box_shrink (&other_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
2 * other_border[GTK_CSS_TOP],
|
|
|
|
2 * other_border[GTK_CSS_RIGHT],
|
|
|
|
2 * other_border[GTK_CSS_BOTTOM],
|
|
|
|
2 * other_border[GTK_CSS_LEFT]);
|
|
|
|
render_frame_fill (cr, &other_box, other_border, colors, dont_draw);
|
2012-01-07 19:50:17 +00:00
|
|
|
}
|
2012-11-30 03:42:36 +00:00
|
|
|
break;
|
2012-01-07 19:50:17 +00:00
|
|
|
case GTK_BORDER_STYLE_GROOVE:
|
|
|
|
case GTK_BORDER_STYLE_RIDGE:
|
2012-01-07 20:24:50 +00:00
|
|
|
{
|
|
|
|
GtkRoundedBox other_box;
|
|
|
|
GdkRGBA other_colors[4];
|
|
|
|
guint dont_draw = hidden_side;
|
2012-10-27 01:16:35 +00:00
|
|
|
double other_border[4];
|
2012-01-07 20:24:50 +00:00
|
|
|
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
{
|
|
|
|
other_colors[j] = colors[j];
|
|
|
|
if ((j == 0 || j == 3) ^ (border_style[j] == GTK_BORDER_STYLE_RIDGE))
|
|
|
|
color_shade (&other_colors[j], 1.8, &other_colors[j]);
|
|
|
|
else
|
|
|
|
color_shade (&colors[j], 1.8, &colors[j]);
|
|
|
|
if (border_style[j] == GTK_BORDER_STYLE_GROOVE ||
|
|
|
|
border_style[j] == GTK_BORDER_STYLE_RIDGE)
|
2012-01-07 21:20:51 +00:00
|
|
|
hidden_side |= (1 << j);
|
2012-01-07 20:24:50 +00:00
|
|
|
else
|
2012-01-07 21:20:51 +00:00
|
|
|
dont_draw |= (1 << j);
|
2012-10-27 01:16:35 +00:00
|
|
|
other_border[i] = border_width[i] / 2;
|
2012-01-07 20:24:50 +00:00
|
|
|
}
|
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
render_frame_fill (cr, border_box, other_border, colors, dont_draw);
|
2012-01-07 20:24:50 +00:00
|
|
|
|
2012-01-08 01:41:30 +00:00
|
|
|
other_box = *border_box;
|
2012-01-07 20:24:50 +00:00
|
|
|
_gtk_rounded_box_shrink (&other_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
other_border[GTK_CSS_TOP],
|
|
|
|
other_border[GTK_CSS_RIGHT],
|
|
|
|
other_border[GTK_CSS_BOTTOM],
|
|
|
|
other_border[GTK_CSS_LEFT]);
|
|
|
|
render_frame_fill (cr, &other_box, other_border, other_colors, dont_draw);
|
2012-01-07 20:24:50 +00:00
|
|
|
}
|
2012-01-07 19:50:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
2011-06-13 03:04:44 +00:00
|
|
|
}
|
2010-10-22 08:38:21 +00:00
|
|
|
}
|
2012-01-07 19:50:17 +00:00
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
render_frame_fill (cr, border_box, border_width, colors, hidden_side);
|
2010-07-19 09:59:27 +00:00
|
|
|
|
2012-01-07 19:50:17 +00:00
|
|
|
cairo_restore (cr);
|
2010-03-27 19:11:31 +00:00
|
|
|
}
|
|
|
|
|
2012-01-08 01:41:30 +00:00
|
|
|
static void
|
|
|
|
render_frame_internal (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
guint hidden_side,
|
|
|
|
GtkJunctionSides junction)
|
|
|
|
{
|
2012-01-08 04:38:10 +00:00
|
|
|
GtkBorderImage border_image;
|
2012-01-08 01:41:30 +00:00
|
|
|
GtkBorderStyle border_style[4];
|
|
|
|
GtkRoundedBox border_box;
|
2012-10-27 01:16:35 +00:00
|
|
|
double border_width[4];
|
2012-01-08 01:41:30 +00:00
|
|
|
GdkRGBA colors[4];
|
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
border_width[0] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100);
|
|
|
|
border_width[1] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100);
|
|
|
|
border_width[2] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH), 100);
|
|
|
|
border_width[3] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH), 100);
|
|
|
|
|
|
|
|
border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
|
|
|
|
border_style[1] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
|
|
|
|
border_style[2] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
|
|
|
|
border_style[3] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
|
2012-01-08 01:41:30 +00:00
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
gtk_theming_engine_hide_border_sides (border_width, border_style, hidden_side);
|
2012-01-08 01:41:30 +00:00
|
|
|
|
2012-01-08 04:38:10 +00:00
|
|
|
if (_gtk_border_image_init (&border_image, engine))
|
2012-10-27 01:16:35 +00:00
|
|
|
_gtk_border_image_render (&border_image, border_width, cr, x, y, width, height);
|
2012-01-08 04:38:10 +00:00
|
|
|
else
|
2012-01-08 01:41:30 +00:00
|
|
|
{
|
2012-05-16 22:27:21 +00:00
|
|
|
colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_COLOR));
|
|
|
|
colors[1] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR));
|
|
|
|
colors[2] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR));
|
|
|
|
colors[3] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_LEFT_COLOR));
|
2012-01-08 01:41:30 +00:00
|
|
|
|
2012-01-08 04:38:10 +00:00
|
|
|
_gtk_rounded_box_init_rect (&border_box, x, y, width, height);
|
2012-04-03 16:39:01 +00:00
|
|
|
_gtk_rounded_box_apply_border_radius_for_engine (&border_box, engine, junction);
|
2012-01-08 01:41:30 +00:00
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
render_border (cr, &border_box, border_width, hidden_side, colors, border_style);
|
2012-01-08 04:38:10 +00:00
|
|
|
}
|
2012-01-08 01:55:34 +00:00
|
|
|
|
2012-03-31 03:42:28 +00:00
|
|
|
border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_STYLE));
|
2012-01-08 01:55:34 +00:00
|
|
|
if (border_style[0] != GTK_BORDER_STYLE_NONE)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
border_style[1] = border_style[2] = border_style[3] = border_style[0];
|
2012-10-27 01:16:35 +00:00
|
|
|
border_width[0] = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_WIDTH), 100);
|
|
|
|
border_width[3] = border_width[2] = border_width[1] = border_width[0];
|
2012-03-31 03:42:28 +00:00
|
|
|
colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_COLOR));
|
2012-01-08 01:55:34 +00:00
|
|
|
colors[3] = colors[2] = colors[1] = colors[0];
|
2012-04-03 14:57:44 +00:00
|
|
|
offset = _gtk_css_number_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_OFFSET), 100);
|
2012-01-08 01:55:34 +00:00
|
|
|
|
|
|
|
/* reinit box here - outlines don't have a border radius */
|
|
|
|
_gtk_rounded_box_init_rect (&border_box, x, y, width, height);
|
|
|
|
_gtk_rounded_box_shrink (&border_box,
|
2012-10-27 01:16:35 +00:00
|
|
|
- border_width[GTK_CSS_TOP] - offset,
|
|
|
|
- border_width[GTK_CSS_RIGHT] - offset,
|
|
|
|
- border_width[GTK_CSS_LEFT] - offset,
|
|
|
|
- border_width[GTK_CSS_BOTTOM] - offset);
|
2012-01-08 01:55:34 +00:00
|
|
|
|
2012-10-27 01:16:35 +00:00
|
|
|
render_border (cr, &border_box, border_width, hidden_side, colors, border_style);
|
2012-01-08 01:55:34 +00:00
|
|
|
}
|
2012-01-08 01:41:30 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_frame (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
|
|
|
GtkJunctionSides junction;
|
|
|
|
|
|
|
|
junction = gtk_theming_engine_get_junction_sides (engine);
|
|
|
|
|
2012-01-08 04:38:10 +00:00
|
|
|
render_frame_internal (engine, cr,
|
|
|
|
x, y, width, height,
|
|
|
|
0, junction);
|
2010-11-15 22:28:06 +00:00
|
|
|
}
|
|
|
|
|
2010-03-27 19:15:45 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_expander (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
|
|
|
GtkStateFlags flags;
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA outline_color, fg_color;
|
2010-08-02 13:49:45 +00:00
|
|
|
double vertical_overshoot;
|
|
|
|
int diameter;
|
|
|
|
double radius;
|
|
|
|
double interp; /* interpolation factor for center position */
|
|
|
|
double x_double_horz, y_double_horz;
|
|
|
|
double x_double_vert, y_double_vert;
|
|
|
|
double x_double, y_double;
|
2010-03-27 19:15:45 +00:00
|
|
|
gdouble angle;
|
2010-08-02 13:49:45 +00:00
|
|
|
gint line_width;
|
2012-05-16 22:13:02 +00:00
|
|
|
gboolean is_rtl;
|
2010-12-13 11:37:40 +00:00
|
|
|
gdouble progress;
|
2010-03-27 19:15:45 +00:00
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_color (engine, flags, &fg_color);
|
|
|
|
gtk_theming_engine_get_border_color (engine, flags, &outline_color);
|
2010-03-27 19:15:45 +00:00
|
|
|
|
2010-12-13 11:37:40 +00:00
|
|
|
is_rtl = (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL);
|
2010-08-02 13:49:45 +00:00
|
|
|
line_width = 1;
|
2012-05-16 22:13:02 +00:00
|
|
|
progress = (flags & GTK_STATE_FLAG_ACTIVE) ? 1 : 0;
|
2010-12-13 11:37:40 +00:00
|
|
|
|
2011-01-12 21:07:34 +00:00
|
|
|
if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_HORIZONTAL))
|
2011-01-12 01:35:19 +00:00
|
|
|
{
|
|
|
|
if (is_rtl)
|
|
|
|
angle = (G_PI) - ((G_PI / 2) * progress);
|
|
|
|
else
|
|
|
|
angle = (G_PI / 2) * progress;
|
|
|
|
}
|
2010-08-02 13:49:45 +00:00
|
|
|
else
|
2011-01-12 01:35:19 +00:00
|
|
|
{
|
|
|
|
if (is_rtl)
|
|
|
|
angle = (G_PI / 2) + ((G_PI / 2) * progress);
|
|
|
|
else
|
|
|
|
angle = (G_PI / 2) - ((G_PI / 2) * progress);
|
|
|
|
}
|
2010-12-13 11:37:40 +00:00
|
|
|
|
|
|
|
interp = progress;
|
2010-08-02 13:49:45 +00:00
|
|
|
|
|
|
|
/* Compute distance that the stroke extends beyonds the end
|
|
|
|
* of the triangle we draw.
|
|
|
|
*/
|
|
|
|
vertical_overshoot = line_width / 2.0 * (1. / tan (G_PI / 8));
|
|
|
|
|
|
|
|
/* For odd line widths, we end the vertical line of the triangle
|
|
|
|
* at a half pixel, so we round differently.
|
|
|
|
*/
|
|
|
|
if (line_width % 2 == 1)
|
|
|
|
vertical_overshoot = ceil (0.5 + vertical_overshoot) - 0.5;
|
2010-03-27 19:15:45 +00:00
|
|
|
else
|
2010-08-02 13:49:45 +00:00
|
|
|
vertical_overshoot = ceil (vertical_overshoot);
|
2010-03-27 19:15:45 +00:00
|
|
|
|
2010-08-02 13:49:45 +00:00
|
|
|
/* Adjust the size of the triangle we draw so that the entire stroke fits
|
|
|
|
*/
|
|
|
|
diameter = (gint) MAX (3, width - 2 * vertical_overshoot);
|
|
|
|
|
|
|
|
/* If the line width is odd, we want the diameter to be even,
|
|
|
|
* and vice versa, so force the sum to be odd. This relationship
|
|
|
|
* makes the point of the triangle look right.
|
|
|
|
*/
|
|
|
|
diameter -= (1 - (diameter + line_width) % 2);
|
|
|
|
|
|
|
|
radius = diameter / 2.;
|
|
|
|
|
|
|
|
/* Adjust the center so that the stroke is properly aligned with
|
|
|
|
* the pixel grid. The center adjustment is different for the
|
|
|
|
* horizontal and vertical orientations. For intermediate positions
|
|
|
|
* we interpolate between the two.
|
|
|
|
*/
|
|
|
|
x_double_vert = floor ((x + width / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
|
|
|
|
y_double_vert = (y + height / 2) - 0.5;
|
|
|
|
|
|
|
|
x_double_horz = (x + width / 2) - 0.5;
|
|
|
|
y_double_horz = floor ((y + height / 2) - (radius + line_width) / 2.) + (radius + line_width) / 2.;
|
|
|
|
|
|
|
|
x_double = x_double_vert * (1 - interp) + x_double_horz * interp;
|
|
|
|
y_double = y_double_vert * (1 - interp) + y_double_horz * interp;
|
|
|
|
|
|
|
|
cairo_translate (cr, x_double, y_double);
|
|
|
|
cairo_rotate (cr, angle);
|
|
|
|
|
|
|
|
cairo_move_to (cr, - radius / 2., - radius);
|
|
|
|
cairo_line_to (cr, radius / 2., 0);
|
|
|
|
cairo_line_to (cr, - radius / 2., radius);
|
|
|
|
cairo_close_path (cr);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, line_width);
|
2010-03-27 19:15:45 +00:00
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &fg_color);
|
2010-03-27 19:15:45 +00:00
|
|
|
|
|
|
|
cairo_fill_preserve (cr);
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &outline_color);
|
2010-03-27 19:15:45 +00:00
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
2010-03-27 19:18:38 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_focus (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
|
|
|
GtkStateFlags flags;
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA color;
|
2010-08-02 13:50:37 +00:00
|
|
|
gint line_width;
|
|
|
|
gint8 *dash_list;
|
2010-03-27 19:18:38 +00:00
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_color (engine, flags, &color);
|
2010-03-27 19:18:38 +00:00
|
|
|
|
2010-08-02 13:50:37 +00:00
|
|
|
gtk_theming_engine_get_style (engine,
|
|
|
|
"focus-line-width", &line_width,
|
|
|
|
"focus-line-pattern", (gchar *) &dash_list,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
cairo_set_line_width (cr, (gdouble) line_width);
|
|
|
|
|
|
|
|
if (dash_list[0])
|
|
|
|
{
|
|
|
|
gint n_dashes = strlen ((const gchar *) dash_list);
|
|
|
|
gdouble *dashes = g_new (gdouble, n_dashes);
|
|
|
|
gdouble total_length = 0;
|
|
|
|
gdouble dash_offset;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < n_dashes; i++)
|
|
|
|
{
|
|
|
|
dashes[i] = dash_list[i];
|
|
|
|
total_length += dash_list[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The dash offset here aligns the pattern to integer pixels
|
|
|
|
* by starting the dash at the right side of the left border
|
|
|
|
* Negative dash offsets in cairo don't work
|
|
|
|
* (https://bugs.freedesktop.org/show_bug.cgi?id=2729)
|
|
|
|
*/
|
|
|
|
dash_offset = - line_width / 2.;
|
|
|
|
|
|
|
|
while (dash_offset < 0)
|
|
|
|
dash_offset += total_length;
|
|
|
|
|
|
|
|
cairo_set_dash (cr, dashes, n_dashes, dash_offset);
|
|
|
|
g_free (dashes);
|
|
|
|
}
|
2010-03-27 19:18:38 +00:00
|
|
|
|
|
|
|
cairo_rectangle (cr,
|
2010-08-02 13:50:37 +00:00
|
|
|
x + line_width / 2.,
|
|
|
|
y + line_width / 2.,
|
|
|
|
width - line_width,
|
|
|
|
height - line_width);
|
2010-03-27 19:18:38 +00:00
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
2010-03-27 19:18:38 +00:00
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
|
2010-08-02 13:50:37 +00:00
|
|
|
g_free (dash_list);
|
2010-03-27 19:18:38 +00:00
|
|
|
}
|
|
|
|
|
2010-03-27 20:17:22 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_line (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x0,
|
|
|
|
gdouble y0,
|
|
|
|
gdouble x1,
|
|
|
|
gdouble y1)
|
|
|
|
{
|
2011-09-01 16:43:08 +00:00
|
|
|
GdkRGBA color;
|
2010-03-27 20:17:22 +00:00
|
|
|
GtkStateFlags flags;
|
|
|
|
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
|
|
|
cairo_save (cr);
|
|
|
|
|
2011-09-01 16:43:08 +00:00
|
|
|
gtk_theming_engine_get_color (engine, flags, &color);
|
2010-03-27 20:17:22 +00:00
|
|
|
|
|
|
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
|
|
|
|
cairo_set_line_width (cr, 1);
|
|
|
|
|
2011-09-01 16:43:08 +00:00
|
|
|
cairo_move_to (cr, x0 + 0.5, y0 + 0.5);
|
|
|
|
cairo_line_to (cr, x1 + 0.5, y1 + 0.5);
|
2010-03-27 20:17:22 +00:00
|
|
|
|
2011-09-01 16:43:08 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
|
|
|
cairo_stroke (cr);
|
2010-03-27 20:17:22 +00:00
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
2011-05-03 16:45:08 +00:00
|
|
|
static void
|
|
|
|
prepare_context_for_layout (cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
PangoLayout *layout)
|
|
|
|
{
|
|
|
|
const PangoMatrix *matrix;
|
|
|
|
|
|
|
|
matrix = pango_context_get_matrix (pango_layout_get_context (layout));
|
|
|
|
|
2011-05-22 01:53:21 +00:00
|
|
|
cairo_move_to (cr, x, y);
|
|
|
|
|
2011-05-03 16:45:08 +00:00
|
|
|
if (matrix)
|
|
|
|
{
|
|
|
|
cairo_matrix_t cairo_matrix;
|
|
|
|
|
|
|
|
cairo_matrix_init (&cairo_matrix,
|
|
|
|
matrix->xx, matrix->yx,
|
|
|
|
matrix->xy, matrix->yy,
|
|
|
|
matrix->x0, matrix->y0);
|
|
|
|
|
2011-05-22 01:53:21 +00:00
|
|
|
cairo_transform (cr, &cairo_matrix);
|
2011-05-03 16:45:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-27 19:21:55 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_layout (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
PangoLayout *layout)
|
|
|
|
{
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA fg_color;
|
2010-03-27 19:21:55 +00:00
|
|
|
GtkStateFlags flags;
|
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_color (engine, flags, &fg_color);
|
2010-03-27 19:21:55 +00:00
|
|
|
|
2011-05-22 02:24:23 +00:00
|
|
|
prepare_context_for_layout (cr, x, y, layout);
|
|
|
|
|
2012-04-03 13:15:24 +00:00
|
|
|
_gtk_css_shadows_value_paint_layout (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_TEXT_SHADOW),
|
|
|
|
cr, layout);
|
2010-08-20 12:58:54 +00:00
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, &fg_color);
|
2010-08-20 12:58:54 +00:00
|
|
|
pango_cairo_show_layout (cr, layout);
|
2010-03-27 19:21:55 +00:00
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
2010-03-27 20:20:21 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_slider (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
GtkOrientation orientation)
|
|
|
|
{
|
|
|
|
gtk_theming_engine_render_background (engine, cr, x, y, width, height);
|
|
|
|
gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2010-03-27 20:23:13 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_frame_gap (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
GtkPositionType gap_side,
|
|
|
|
gdouble xy0_gap,
|
|
|
|
gdouble xy1_gap)
|
|
|
|
{
|
2010-11-24 15:23:37 +00:00
|
|
|
GtkJunctionSides junction;
|
2010-11-15 22:28:06 +00:00
|
|
|
GtkStateFlags state;
|
2011-05-26 03:09:48 +00:00
|
|
|
gint border_width;
|
2012-04-03 16:39:01 +00:00
|
|
|
GtkCssValue *corner[4];
|
2010-11-24 03:51:40 +00:00
|
|
|
gdouble x0, y0, x1, y1, xc, yc, wc, hc;
|
2011-03-28 17:34:40 +00:00
|
|
|
GtkBorder border;
|
2010-03-27 20:23:13 +00:00
|
|
|
|
2010-12-01 00:26:03 +00:00
|
|
|
xc = yc = wc = hc = 0;
|
2010-11-15 22:28:06 +00:00
|
|
|
state = gtk_theming_engine_get_state (engine);
|
2010-11-24 15:23:37 +00:00
|
|
|
junction = gtk_theming_engine_get_junction_sides (engine);
|
2011-03-28 17:34:40 +00:00
|
|
|
|
|
|
|
gtk_theming_engine_get_border (engine, state, &border);
|
2012-04-03 16:39:01 +00:00
|
|
|
corner[GTK_CSS_TOP_LEFT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS);
|
|
|
|
corner[GTK_CSS_TOP_RIGHT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS);
|
|
|
|
corner[GTK_CSS_BOTTOM_LEFT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS);
|
|
|
|
corner[GTK_CSS_BOTTOM_RIGHT] = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS);
|
2010-08-02 13:52:26 +00:00
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
border_width = MIN (MIN (border.top, border.bottom),
|
|
|
|
MIN (border.left, border.right));
|
2010-11-30 23:55:14 +00:00
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
cairo_save (cr);
|
2010-08-02 13:52:26 +00:00
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
switch (gap_side)
|
2010-07-19 09:58:13 +00:00
|
|
|
{
|
2010-11-15 22:28:06 +00:00
|
|
|
case GTK_POS_TOP:
|
2010-11-24 03:51:40 +00:00
|
|
|
xc = x + xy0_gap + border_width;
|
|
|
|
yc = y;
|
|
|
|
wc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
|
|
|
|
hc = border_width;
|
2010-11-24 15:23:37 +00:00
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy0_gap < _gtk_css_corner_value_get_x (corner[GTK_CSS_TOP_LEFT], width))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_TOPLEFT;
|
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy1_gap > width - _gtk_css_corner_value_get_x (corner[GTK_CSS_TOP_RIGHT], width))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_TOPRIGHT;
|
2010-11-15 22:28:06 +00:00
|
|
|
break;
|
|
|
|
case GTK_POS_BOTTOM:
|
2010-11-24 03:51:40 +00:00
|
|
|
xc = x + xy0_gap + border_width;
|
|
|
|
yc = y + height - border_width;
|
|
|
|
wc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
|
|
|
|
hc = border_width;
|
2010-11-24 15:23:37 +00:00
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy0_gap < _gtk_css_corner_value_get_x (corner[GTK_CSS_BOTTOM_LEFT], width))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;
|
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy1_gap > width - _gtk_css_corner_value_get_x (corner[GTK_CSS_BOTTOM_RIGHT], width))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;
|
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
break;
|
|
|
|
case GTK_POS_LEFT:
|
2010-11-24 03:51:40 +00:00
|
|
|
xc = x;
|
|
|
|
yc = y + xy0_gap + border_width;
|
|
|
|
wc = border_width;
|
|
|
|
hc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
|
2010-11-24 15:23:37 +00:00
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy0_gap < _gtk_css_corner_value_get_y (corner[GTK_CSS_TOP_LEFT], height))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_TOPLEFT;
|
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy1_gap > height - _gtk_css_corner_value_get_y (corner[GTK_CSS_BOTTOM_LEFT], height))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT;
|
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
break;
|
|
|
|
case GTK_POS_RIGHT:
|
2010-11-24 03:51:40 +00:00
|
|
|
xc = x + width - border_width;
|
|
|
|
yc = y + xy0_gap + border_width;
|
|
|
|
wc = border_width;
|
|
|
|
hc = MAX (xy1_gap - xy0_gap - 2 * border_width, 0);
|
2010-11-24 15:23:37 +00:00
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy0_gap < _gtk_css_corner_value_get_y (corner[GTK_CSS_TOP_RIGHT], height))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_TOPRIGHT;
|
|
|
|
|
2012-04-03 16:39:01 +00:00
|
|
|
if (xy1_gap > height - _gtk_css_corner_value_get_y (corner[GTK_CSS_BOTTOM_RIGHT], height))
|
2010-11-24 15:23:37 +00:00
|
|
|
junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT;
|
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-08-02 13:52:26 +00:00
|
|
|
|
2010-11-24 03:51:40 +00:00
|
|
|
cairo_clip_extents (cr, &x0, &y0, &x1, &y1);
|
|
|
|
cairo_rectangle (cr, x0, y0, x1 - x0, yc - y0);
|
|
|
|
cairo_rectangle (cr, x0, yc, xc - x0, hc);
|
|
|
|
cairo_rectangle (cr, xc + wc, yc, x1 - (xc + wc), hc);
|
|
|
|
cairo_rectangle (cr, x0, yc + hc, x1 - x0, y1 - (yc + hc));
|
|
|
|
cairo_clip (cr);
|
|
|
|
|
2012-01-08 04:38:10 +00:00
|
|
|
render_frame_internal (engine, cr,
|
|
|
|
x, y, width, height,
|
|
|
|
0, junction);
|
2010-11-15 22:28:06 +00:00
|
|
|
|
2010-03-27 20:23:13 +00:00
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
2010-03-27 20:25:33 +00:00
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_extension (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height,
|
|
|
|
GtkPositionType gap_side)
|
|
|
|
{
|
2011-12-10 00:14:12 +00:00
|
|
|
GtkThemingBackground bg;
|
2010-11-17 01:56:49 +00:00
|
|
|
GtkJunctionSides junction = 0;
|
|
|
|
guint hidden_side = 0;
|
2010-03-27 20:25:33 +00:00
|
|
|
|
2010-07-19 09:57:25 +00:00
|
|
|
switch (gap_side)
|
|
|
|
{
|
2010-11-15 22:28:06 +00:00
|
|
|
case GTK_POS_LEFT:
|
|
|
|
junction = GTK_JUNCTION_LEFT;
|
2012-01-07 21:20:51 +00:00
|
|
|
hidden_side = (1 << GTK_CSS_LEFT);
|
2010-11-15 22:28:06 +00:00
|
|
|
break;
|
|
|
|
case GTK_POS_RIGHT:
|
|
|
|
junction = GTK_JUNCTION_RIGHT;
|
2012-01-07 21:20:51 +00:00
|
|
|
hidden_side = (1 << GTK_CSS_RIGHT);
|
2010-11-15 22:28:06 +00:00
|
|
|
break;
|
2010-07-19 09:57:25 +00:00
|
|
|
case GTK_POS_TOP:
|
2010-11-15 22:28:06 +00:00
|
|
|
junction = GTK_JUNCTION_TOP;
|
2012-01-07 21:20:51 +00:00
|
|
|
hidden_side = (1 << GTK_CSS_TOP);
|
2010-07-19 09:57:25 +00:00
|
|
|
break;
|
|
|
|
case GTK_POS_BOTTOM:
|
2010-11-15 22:28:06 +00:00
|
|
|
junction = GTK_JUNCTION_BOTTOM;
|
2012-01-07 21:20:51 +00:00
|
|
|
hidden_side = (1 << GTK_CSS_BOTTOM);
|
2010-07-19 09:57:25 +00:00
|
|
|
break;
|
2010-11-15 22:28:06 +00:00
|
|
|
}
|
2010-07-19 09:57:25 +00:00
|
|
|
|
2012-04-25 00:22:24 +00:00
|
|
|
_gtk_theming_background_init (&bg, engine,
|
|
|
|
x, y,
|
|
|
|
width, height,
|
|
|
|
junction);
|
2011-12-10 00:14:12 +00:00
|
|
|
_gtk_theming_background_render (&bg, cr);
|
|
|
|
|
2010-11-15 22:28:06 +00:00
|
|
|
render_frame_internal (engine, cr,
|
|
|
|
x, y, width, height,
|
|
|
|
hidden_side, junction);
|
2010-03-27 20:25:33 +00:00
|
|
|
}
|
|
|
|
|
2010-03-27 20:27:52 +00:00
|
|
|
static void
|
2010-10-22 10:41:19 +00:00
|
|
|
render_dot (cairo_t *cr,
|
|
|
|
const GdkRGBA *lighter,
|
|
|
|
const GdkRGBA *darker,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble size)
|
2010-03-27 20:27:52 +00:00
|
|
|
{
|
2010-07-19 09:47:37 +00:00
|
|
|
size = CLAMP ((gint) size, 2, 3);
|
2010-03-27 20:27:52 +00:00
|
|
|
|
2010-07-19 09:47:37 +00:00
|
|
|
if (size == 2)
|
|
|
|
{
|
2010-10-22 10:41:19 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, lighter);
|
2010-07-19 09:47:37 +00:00
|
|
|
cairo_rectangle (cr, x, y, 1, 1);
|
|
|
|
cairo_rectangle (cr, x + 1, y + 1, 1, 1);
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
else if (size == 3)
|
|
|
|
{
|
2010-10-22 10:41:19 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, lighter);
|
2010-07-19 09:47:37 +00:00
|
|
|
cairo_rectangle (cr, x, y, 2, 1);
|
|
|
|
cairo_rectangle (cr, x, y, 1, 2);
|
|
|
|
cairo_fill (cr);
|
|
|
|
|
2010-10-22 10:41:19 +00:00
|
|
|
gdk_cairo_set_source_rgba (cr, darker);
|
2010-07-19 09:47:37 +00:00
|
|
|
cairo_rectangle (cr, x + 1, y + 1, 2, 1);
|
|
|
|
cairo_rectangle (cr, x + 2, y, 1, 2);
|
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
2010-03-27 20:27:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_handle (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
2010-10-12 22:52:50 +00:00
|
|
|
gdouble height)
|
2010-03-27 20:27:52 +00:00
|
|
|
{
|
|
|
|
GtkStateFlags flags;
|
2011-03-28 17:34:40 +00:00
|
|
|
GdkRGBA bg_color, lighter, darker;
|
2011-03-12 16:02:49 +00:00
|
|
|
GtkJunctionSides sides;
|
2011-12-10 00:14:12 +00:00
|
|
|
GtkThemingBackground bg;
|
2010-03-27 20:27:52 +00:00
|
|
|
gint xx, yy;
|
2012-05-14 13:20:56 +00:00
|
|
|
gboolean has_image;
|
2010-03-27 20:27:52 +00:00
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
flags = gtk_theming_engine_get_state (engine);
|
|
|
|
|
2011-03-12 16:02:49 +00:00
|
|
|
cairo_set_line_width (cr, 1.0);
|
|
|
|
sides = gtk_theming_engine_get_junction_sides (engine);
|
2011-03-28 17:34:40 +00:00
|
|
|
gtk_theming_engine_get_background_color (engine, flags, &bg_color);
|
2010-03-27 20:27:52 +00:00
|
|
|
|
2011-03-28 17:34:40 +00:00
|
|
|
color_shade (&bg_color, 0.7, &darker);
|
|
|
|
color_shade (&bg_color, 1.3, &lighter);
|
2010-03-27 20:27:52 +00:00
|
|
|
|
2011-12-10 00:14:12 +00:00
|
|
|
_gtk_theming_background_init (&bg, engine, x, y, width, height, sides);
|
2012-05-14 13:20:56 +00:00
|
|
|
has_image = _gtk_theming_background_has_background_image (&bg);
|
2011-12-10 00:14:12 +00:00
|
|
|
_gtk_theming_background_render (&bg, cr);
|
2010-03-27 20:27:52 +00:00
|
|
|
|
2012-04-25 01:47:45 +00:00
|
|
|
gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
|
|
|
|
|
2011-01-10 22:23:54 +00:00
|
|
|
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_GRIP))
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
/* reduce confusing values to a meaningful state */
|
2010-11-23 03:37:19 +00:00
|
|
|
if ((sides & (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT)) == (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT))
|
|
|
|
sides &= ~GTK_JUNCTION_CORNER_TOPLEFT;
|
2010-11-01 01:42:08 +00:00
|
|
|
|
2010-11-23 03:37:19 +00:00
|
|
|
if ((sides & (GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMLEFT)) == (GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMLEFT))
|
|
|
|
sides &= ~GTK_JUNCTION_CORNER_TOPRIGHT;
|
2010-11-01 01:42:08 +00:00
|
|
|
|
|
|
|
if (sides == 0)
|
2010-11-23 03:37:19 +00:00
|
|
|
sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT;
|
2010-11-01 01:42:08 +00:00
|
|
|
|
|
|
|
/* align drawing area to the connected side */
|
|
|
|
if (sides == GTK_JUNCTION_LEFT)
|
|
|
|
{
|
|
|
|
if (height < width)
|
|
|
|
width = height;
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_TOPLEFT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
if (width < height)
|
|
|
|
height = width;
|
|
|
|
else if (height < width)
|
|
|
|
width = height;
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_BOTTOMLEFT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
/* make it square, aligning to bottom left */
|
|
|
|
if (width < height)
|
|
|
|
{
|
|
|
|
y += (height - width);
|
|
|
|
height = width;
|
|
|
|
}
|
|
|
|
else if (height < width)
|
|
|
|
width = height;
|
|
|
|
}
|
2010-11-17 05:44:36 +00:00
|
|
|
else if (sides == GTK_JUNCTION_RIGHT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
/* aligning to right */
|
|
|
|
if (height < width)
|
|
|
|
{
|
|
|
|
x += (width - height);
|
|
|
|
width = height;
|
|
|
|
}
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_TOPRIGHT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
if (width < height)
|
|
|
|
height = width;
|
|
|
|
else if (height < width)
|
|
|
|
{
|
|
|
|
x += (width - height);
|
|
|
|
width = height;
|
|
|
|
}
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_BOTTOMRIGHT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
/* make it square, aligning to bottom right */
|
|
|
|
if (width < height)
|
|
|
|
{
|
|
|
|
y += (height - width);
|
|
|
|
height = width;
|
|
|
|
}
|
|
|
|
else if (height < width)
|
|
|
|
{
|
|
|
|
x += (width - height);
|
|
|
|
width = height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sides == GTK_JUNCTION_TOP)
|
|
|
|
{
|
|
|
|
if (width < height)
|
|
|
|
height = width;
|
|
|
|
}
|
|
|
|
else if (sides == GTK_JUNCTION_BOTTOM)
|
|
|
|
{
|
|
|
|
/* align to bottom */
|
|
|
|
if (width < height)
|
|
|
|
{
|
|
|
|
y += (height - width);
|
|
|
|
height = width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
if (sides == GTK_JUNCTION_LEFT ||
|
|
|
|
sides == GTK_JUNCTION_RIGHT)
|
|
|
|
{
|
|
|
|
gint xi;
|
|
|
|
|
|
|
|
xi = x;
|
|
|
|
|
|
|
|
while (xi < x + width)
|
|
|
|
{
|
|
|
|
gdk_cairo_set_source_rgba (cr, &lighter);
|
|
|
|
add_path_line (cr, x, y, x, y + height);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
xi++;
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &darker);
|
|
|
|
add_path_line (cr, xi, y, xi, y + height);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
xi += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sides == GTK_JUNCTION_TOP ||
|
|
|
|
sides == GTK_JUNCTION_BOTTOM)
|
|
|
|
{
|
|
|
|
gint yi;
|
|
|
|
|
|
|
|
yi = y;
|
|
|
|
|
|
|
|
while (yi < y + height)
|
|
|
|
{
|
|
|
|
gdk_cairo_set_source_rgba (cr, &lighter);
|
|
|
|
add_path_line (cr, x, yi, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
yi++;
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &darker);
|
|
|
|
add_path_line (cr, x, yi, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
2011-01-24 02:50:39 +00:00
|
|
|
yi += 2;
|
2010-11-01 01:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_TOPLEFT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
gint xi, yi;
|
|
|
|
|
|
|
|
xi = x + width;
|
|
|
|
yi = y + height;
|
|
|
|
|
|
|
|
while (xi > x + 3)
|
|
|
|
{
|
|
|
|
gdk_cairo_set_source_rgba (cr, &darker);
|
|
|
|
add_path_line (cr, xi, y, x, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
--xi;
|
|
|
|
--yi;
|
|
|
|
|
|
|
|
add_path_line (cr, xi, y, x, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
--xi;
|
|
|
|
--yi;
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &lighter);
|
|
|
|
add_path_line (cr, xi, y, x, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
xi -= 3;
|
|
|
|
yi -= 3;
|
|
|
|
}
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_TOPRIGHT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
gint xi, yi;
|
|
|
|
|
|
|
|
xi = x;
|
|
|
|
yi = y + height;
|
|
|
|
|
|
|
|
while (xi < (x + width - 3))
|
|
|
|
{
|
|
|
|
gdk_cairo_set_source_rgba (cr, &lighter);
|
|
|
|
add_path_line (cr, xi, y, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
++xi;
|
|
|
|
--yi;
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &darker);
|
|
|
|
add_path_line (cr, xi, y, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
++xi;
|
|
|
|
--yi;
|
|
|
|
|
|
|
|
add_path_line (cr, xi, y, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
xi += 3;
|
|
|
|
yi -= 3;
|
|
|
|
}
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_BOTTOMLEFT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
gint xi, yi;
|
|
|
|
|
|
|
|
xi = x + width;
|
|
|
|
yi = y;
|
|
|
|
|
|
|
|
while (xi > x + 3)
|
|
|
|
{
|
|
|
|
gdk_cairo_set_source_rgba (cr, &darker);
|
|
|
|
add_path_line (cr, x, yi, xi, y + height);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
--xi;
|
|
|
|
++yi;
|
|
|
|
|
|
|
|
add_path_line (cr, x, yi, xi, y + height);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
--xi;
|
|
|
|
++yi;
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &lighter);
|
|
|
|
add_path_line (cr, x, yi, xi, y + height);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
xi -= 3;
|
|
|
|
yi += 3;
|
|
|
|
}
|
|
|
|
}
|
2010-11-23 03:37:19 +00:00
|
|
|
else if (sides == GTK_JUNCTION_CORNER_BOTTOMRIGHT)
|
2010-11-01 01:42:08 +00:00
|
|
|
{
|
|
|
|
gint xi, yi;
|
|
|
|
|
|
|
|
xi = x;
|
|
|
|
yi = y;
|
|
|
|
|
|
|
|
while (xi < (x + width - 3))
|
|
|
|
{
|
|
|
|
gdk_cairo_set_source_rgba (cr, &lighter);
|
|
|
|
add_path_line (cr, xi, y + height, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
++xi;
|
|
|
|
++yi;
|
|
|
|
|
|
|
|
gdk_cairo_set_source_rgba (cr, &darker);
|
|
|
|
add_path_line (cr, xi, y + height, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
++xi;
|
|
|
|
++yi;
|
|
|
|
|
|
|
|
add_path_line (cr, xi, y + height, x + width, yi);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
|
|
|
|
xi += 3;
|
|
|
|
yi += 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-10 22:23:54 +00:00
|
|
|
else if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PANE_SEPARATOR))
|
2010-07-19 09:47:37 +00:00
|
|
|
{
|
2012-05-14 13:20:56 +00:00
|
|
|
if (!has_image)
|
|
|
|
{
|
|
|
|
if (width > height)
|
|
|
|
for (xx = x + width / 2 - 15; xx <= x + width / 2 + 15; xx += 5)
|
|
|
|
render_dot (cr, &lighter, &darker, xx, y + height / 2 - 1, 3);
|
|
|
|
else
|
|
|
|
for (yy = y + height / 2 - 15; yy <= y + height / 2 + 15; yy += 5)
|
|
|
|
render_dot (cr, &lighter, &darker, x + width / 2 - 1, yy, 3);
|
|
|
|
}
|
2010-07-19 09:47:37 +00:00
|
|
|
}
|
2010-03-27 20:27:52 +00:00
|
|
|
else
|
2010-07-19 09:47:37 +00:00
|
|
|
{
|
|
|
|
for (yy = y; yy < y + height; yy += 3)
|
2011-01-24 02:50:39 +00:00
|
|
|
for (xx = x; xx < x + width; xx += 6)
|
|
|
|
{
|
|
|
|
render_dot (cr, &lighter, &darker, xx, yy, 2);
|
|
|
|
render_dot (cr, &lighter, &darker, xx + 3, yy + 1, 2);
|
|
|
|
}
|
2010-07-19 09:47:37 +00:00
|
|
|
}
|
2010-03-27 20:27:52 +00:00
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
2010-11-01 01:46:35 +00:00
|
|
|
|
2011-06-06 15:38:45 +00:00
|
|
|
void
|
2012-04-03 09:49:22 +00:00
|
|
|
_gtk_theming_engine_paint_spinner (cairo_t *cr,
|
|
|
|
gdouble radius,
|
|
|
|
gdouble progress,
|
|
|
|
const GdkRGBA *color)
|
2010-11-01 01:46:35 +00:00
|
|
|
{
|
2011-06-06 15:38:45 +00:00
|
|
|
guint num_steps, step;
|
|
|
|
gdouble half;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
num_steps = 12;
|
|
|
|
|
|
|
|
if (progress >= 0)
|
|
|
|
step = (guint) (progress * num_steps);
|
|
|
|
else
|
|
|
|
step = 0;
|
|
|
|
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
|
|
|
cairo_set_line_width (cr, 2.0);
|
|
|
|
|
|
|
|
half = num_steps / 2;
|
|
|
|
|
|
|
|
for (i = 0; i < num_steps; i++)
|
2010-11-01 01:46:35 +00:00
|
|
|
{
|
2011-06-06 15:38:45 +00:00
|
|
|
gint inset = 0.7 * radius;
|
|
|
|
|
|
|
|
/* transparency is a function of time and intial value */
|
|
|
|
gdouble t = 1.0 - (gdouble) ((i + step) % num_steps) / num_steps;
|
|
|
|
gdouble xscale = - sin (i * G_PI / half);
|
|
|
|
gdouble yscale = - cos (i * G_PI / half);
|
|
|
|
|
|
|
|
cairo_set_source_rgba (cr,
|
|
|
|
color->red,
|
|
|
|
color->green,
|
|
|
|
color->blue,
|
|
|
|
color->alpha * t);
|
|
|
|
|
|
|
|
cairo_move_to (cr,
|
|
|
|
(radius - inset) * xscale,
|
|
|
|
(radius - inset) * yscale);
|
|
|
|
cairo_line_to (cr,
|
|
|
|
radius * xscale,
|
|
|
|
radius * yscale);
|
2010-11-01 01:46:35 +00:00
|
|
|
|
2011-06-06 15:38:45 +00:00
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
2010-11-01 01:46:35 +00:00
|
|
|
|
2011-06-06 15:38:45 +00:00
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
2010-11-01 01:46:35 +00:00
|
|
|
|
2011-06-06 15:38:45 +00:00
|
|
|
static void
|
|
|
|
render_spinner (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
|
|
|
GtkStateFlags state;
|
|
|
|
GdkRGBA color;
|
|
|
|
gdouble radius;
|
2010-11-01 01:46:35 +00:00
|
|
|
|
2011-06-06 15:38:45 +00:00
|
|
|
state = gtk_theming_engine_get_state (engine);
|
|
|
|
radius = MIN (width / 2, height / 2);
|
2010-11-01 01:46:35 +00:00
|
|
|
|
2011-06-06 15:38:45 +00:00
|
|
|
gtk_theming_engine_get_color (engine, state, &color);
|
2010-11-01 01:46:35 +00:00
|
|
|
|
2011-06-06 15:38:45 +00:00
|
|
|
cairo_save (cr);
|
|
|
|
cairo_translate (cr, x + width / 2, y + height / 2);
|
|
|
|
|
2012-04-03 13:15:24 +00:00
|
|
|
_gtk_css_shadows_value_paint_spinner (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW),
|
|
|
|
cr,
|
|
|
|
radius,
|
2012-05-16 22:13:02 +00:00
|
|
|
-1);
|
2011-06-06 15:38:45 +00:00
|
|
|
|
|
|
|
_gtk_theming_engine_paint_spinner (cr,
|
|
|
|
radius,
|
2012-05-16 22:13:02 +00:00
|
|
|
-1,
|
2011-06-06 15:38:45 +00:00
|
|
|
&color);
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_activity (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
gdouble width,
|
|
|
|
gdouble height)
|
|
|
|
{
|
2012-09-10 17:15:25 +00:00
|
|
|
GtkThemingBackground bg;
|
|
|
|
|
|
|
|
_gtk_theming_background_init (&bg, engine, x, y, width, height, 0);
|
|
|
|
|
|
|
|
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_SPINNER) &&
|
|
|
|
!_gtk_theming_background_has_background_image (&bg))
|
2011-06-06 15:38:45 +00:00
|
|
|
{
|
|
|
|
render_spinner (engine, cr, x, y, width, height);
|
2010-11-01 01:46:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-10 17:15:25 +00:00
|
|
|
_gtk_theming_background_render (&bg, cr);
|
2010-11-01 01:46:35 +00:00
|
|
|
gtk_theming_engine_render_frame (engine, cr, x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
2010-11-03 20:14:08 +00:00
|
|
|
|
|
|
|
static GdkPixbuf *
|
|
|
|
scale_or_ref (GdkPixbuf *src,
|
|
|
|
gint width,
|
|
|
|
gint height)
|
|
|
|
{
|
|
|
|
if (width == gdk_pixbuf_get_width (src) &&
|
|
|
|
height == gdk_pixbuf_get_height (src))
|
|
|
|
return g_object_ref (src);
|
|
|
|
else
|
|
|
|
return gdk_pixbuf_scale_simple (src,
|
|
|
|
width, height,
|
|
|
|
GDK_INTERP_BILINEAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
lookup_icon_size (GtkThemingEngine *engine,
|
|
|
|
GtkIconSize size,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
|
|
|
GdkScreen *screen;
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
|
|
screen = gtk_theming_engine_get_screen (engine);
|
|
|
|
settings = gtk_settings_get_for_screen (screen);
|
|
|
|
|
|
|
|
return gtk_icon_size_lookup_for_settings (settings, size, width, height);
|
|
|
|
}
|
|
|
|
|
2011-01-15 04:51:41 +00:00
|
|
|
static void
|
2011-06-06 14:23:44 +00:00
|
|
|
colorshift_source (cairo_t *cr,
|
|
|
|
gdouble shift)
|
|
|
|
{
|
|
|
|
cairo_pattern_t *source;
|
2011-01-15 04:51:41 +00:00
|
|
|
|
2011-06-06 14:23:44 +00:00
|
|
|
cairo_save (cr);
|
|
|
|
cairo_paint (cr);
|
2011-01-15 04:51:41 +00:00
|
|
|
|
2011-06-06 14:23:44 +00:00
|
|
|
source = cairo_pattern_reference (cairo_get_source (cr));
|
2011-01-15 04:51:41 +00:00
|
|
|
|
2011-06-06 14:23:44 +00:00
|
|
|
cairo_set_source_rgb (cr, shift, shift, shift);
|
|
|
|
cairo_set_operator (cr, CAIRO_OPERATOR_COLOR_DODGE);
|
2011-01-15 04:51:41 +00:00
|
|
|
|
2011-06-06 14:23:44 +00:00
|
|
|
cairo_mask (cr, source);
|
2011-01-15 04:51:41 +00:00
|
|
|
|
2011-06-06 14:23:44 +00:00
|
|
|
cairo_pattern_destroy (source);
|
|
|
|
cairo_restore (cr);
|
2011-01-15 04:51:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-03 20:14:08 +00:00
|
|
|
static GdkPixbuf *
|
|
|
|
gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine *engine,
|
|
|
|
const GtkIconSource *source,
|
|
|
|
GtkIconSize size)
|
|
|
|
{
|
|
|
|
GdkPixbuf *scaled;
|
|
|
|
GdkPixbuf *stated;
|
|
|
|
GdkPixbuf *base_pixbuf;
|
|
|
|
GtkStateFlags state;
|
|
|
|
gint width = 1;
|
|
|
|
gint height = 1;
|
2011-06-06 14:23:44 +00:00
|
|
|
cairo_t *cr;
|
|
|
|
cairo_surface_t *surface;
|
2010-11-03 20:14:08 +00:00
|
|
|
|
|
|
|
base_pixbuf = gtk_icon_source_get_pixbuf (source);
|
|
|
|
state = gtk_theming_engine_get_state (engine);
|
|
|
|
|
|
|
|
g_return_val_if_fail (base_pixbuf != NULL, NULL);
|
|
|
|
|
|
|
|
if (size != (GtkIconSize) -1 &&
|
|
|
|
!lookup_icon_size (engine, size, &width, &height))
|
|
|
|
{
|
|
|
|
g_warning (G_STRLOC ": invalid icon size '%d'", size);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the size was wildcarded, and we're allowed to scale, then scale; otherwise,
|
|
|
|
* leave it alone.
|
|
|
|
*/
|
|
|
|
if (size != (GtkIconSize) -1 &&
|
|
|
|
gtk_icon_source_get_size_wildcarded (source))
|
|
|
|
scaled = scale_or_ref (base_pixbuf, width, height);
|
|
|
|
else
|
|
|
|
scaled = g_object_ref (base_pixbuf);
|
|
|
|
|
|
|
|
/* If the state was wildcarded, then generate a state. */
|
|
|
|
if (gtk_icon_source_get_state_wildcarded (source))
|
|
|
|
{
|
|
|
|
if (state & GTK_STATE_FLAG_INSENSITIVE)
|
|
|
|
{
|
2011-06-06 14:23:44 +00:00
|
|
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
gdk_pixbuf_get_width (scaled),
|
|
|
|
gdk_pixbuf_get_height (scaled));
|
|
|
|
cr = cairo_create (surface);
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
|
|
|
|
cairo_paint_with_alpha (cr, 0.5);
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
g_object_unref (scaled);
|
|
|
|
stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
|
|
|
|
cairo_image_surface_get_width (surface),
|
|
|
|
cairo_image_surface_get_height (surface));
|
2011-06-15 12:13:20 +00:00
|
|
|
cairo_surface_destroy (surface);
|
2010-11-03 20:14:08 +00:00
|
|
|
}
|
|
|
|
else if (state & GTK_STATE_FLAG_PRELIGHT)
|
|
|
|
{
|
2011-06-06 14:23:44 +00:00
|
|
|
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
|
|
|
gdk_pixbuf_get_width (scaled),
|
|
|
|
gdk_pixbuf_get_height (scaled));
|
|
|
|
|
|
|
|
cr = cairo_create (surface);
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, scaled, 0, 0);
|
|
|
|
colorshift_source (cr, 0.10);
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
|
|
|
|
g_object_unref (scaled);
|
|
|
|
stated = gdk_pixbuf_get_from_surface (surface, 0, 0,
|
|
|
|
cairo_image_surface_get_width (surface),
|
|
|
|
cairo_image_surface_get_height (surface));
|
2011-06-15 12:13:20 +00:00
|
|
|
cairo_surface_destroy (surface);
|
2010-11-03 20:14:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
stated = scaled;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
stated = scaled;
|
|
|
|
|
|
|
|
return stated;
|
|
|
|
}
|
2011-06-06 14:23:06 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_theming_engine_render_icon (GtkThemingEngine *engine,
|
|
|
|
cairo_t *cr,
|
|
|
|
GdkPixbuf *pixbuf,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y)
|
|
|
|
{
|
|
|
|
cairo_save (cr);
|
|
|
|
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
|
|
|
|
|
2012-04-03 13:15:24 +00:00
|
|
|
_gtk_css_shadows_value_paint_icon (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW), cr);
|
2011-06-06 14:23:06 +00:00
|
|
|
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
|
|
|
}
|
|
|
|
|